AnsweredAssumed Answered

Initialize Activiti in Glassfish 3 from JNDI resource

Question asked by andrewnomoire on Jul 5, 2017

Please help with initialization Activiti in Glassfish 3.1.

 

Error stacktrace is:

 

[#|2017-07-05T16:21:43.583+0300|SEVERE|oracle-glassfish3.1.2|javax.enterprise.system.tools.admin.org.glassfish.deployment.admin|_ThreadID=378;_ThreadName=Thread-2;|Exception while invoking class org.glassfish.ejb.startup.EjbApplication start method
javax.ejb.EJBException: javax.ejb.CreateException: Initialization failed for Singleton ActivitiService
   at com.sun.ejb.containers.AbstractSingletonContainer$SingletonContextFactory.create(AbstractSingletonContainer.java:721)
   <...>
   at java.lang.Thread.run(Thread.java:745)
Caused by: javax.ejb.CreateException: Initialization failed for Singleton ActivitiService
   at com.sun.ejb.containers.AbstractSingletonContainer.createSingletonEJB(AbstractSingletonContainer.java:547)
   at com.sun.ejb.containers.AbstractSingletonContainer.access$100(AbstractSingletonContainer.java:79)
   at com.sun.ejb.containers.AbstractSingletonContainer$SingletonContextFactory.create(AbstractSingletonContainer.java:719)
   ... 60 more
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'processEngineConfiguration' defined in class path resource [activiti.cfg.xml]: Cannot resolve reference to bean 'workflowHelper' while setting bean property 'beans' with key [TypedStringValue: value [workflowHelper], target type [null]]; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'workflowHelper': Invocation of init method failed; nested exception is javax.naming.NamingException: Lookup failed for 'java:global/csms-portlet/WorkflowHelperImpl' in SerialContext[myEnv={java.naming.factory.initial=com.sun.enterprise.naming.impl.SerialInitContextFactory, java.naming.factory.state=com.sun.corba.ee.impl.presentation.rmi.JNDIStateFactoryImpl, java.naming.factory.url.pkgs=com.sun.enterprise.naming} [Root exception is javax.naming.NameNotFoundException: csms-portlet]
   at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveReference(BeanDefinitionValueResolver.java:336)
   <...>
   at org.activiti.engine.ProcessEngineConfiguration.createProcessEngineConfigurationFromResourceDefault(ProcessEngineConfiguration.java:224)
   at com.example.csms.service.ActivitiService.init(ActivitiService.java:47)
   <...>
   at com.sun.ejb.containers.AbstractSingletonContainer.createSingletonEJB(AbstractSingletonContainer.java:538)
   ... 62 more
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'workflowHelper': Invocation of init method failed; nested exception is javax.naming.NamingException: Lookup failed for 'java:global/csms-portlet/WorkflowHelperImpl' in SerialContext[myEnv={java.naming.factory.initial=com.sun.enterprise.naming.impl.SerialInitContextFactory, java.naming.factory.state=com.sun.corba.ee.impl.presentation.rmi.JNDIStateFactoryImpl, java.naming.factory.url.pkgs=com.sun.enterprise.naming} [Root exception is javax.naming.NameNotFoundException: csms-portlet]
   at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1553)
   <...>
   at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveReference(BeanDefinitionValueResolver.java:328)
   ... 96 more
Caused by: javax.naming.NamingException: Lookup failed for 'java:global/csms-portlet/WorkflowHelperImpl' in SerialContext[myEnv={java.naming.factory.initial=com.sun.enterprise.naming.impl.SerialInitContextFactory, java.naming.factory.state=com.sun.corba.ee.impl.presentation.rmi.JNDIStateFactoryImpl, java.naming.factory.url.pkgs=com.sun.enterprise.naming} [Root exception is javax.naming.NameNotFoundException: csms-portlet]
   at com.sun.enterprise.naming.impl.SerialContext.lookup(SerialContext.java:518)
   at com.sun.enterprise.naming.impl.SerialContext.lookup(SerialContext.java:455)
   at javax.naming.InitialContext.lookup(InitialContext.java:411)
   at javax.naming.InitialContext.lookup(InitialContext.java:411)
   at org.springframework.jndi.JndiTemplate$1.doInContext(JndiTemplate.java:155)
   at org.springframework.jndi.JndiTemplate.execute(JndiTemplate.java:87)
   at org.springframework.jndi.JndiTemplate.lookup(JndiTemplate.java:152)
   at org.springframework.jndi.JndiTemplate.lookup(JndiTemplate.java:179)
   at org.springframework.jndi.JndiLocatorSupport.lookup(JndiLocatorSupport.java:95)
   at org.springframework.jndi.JndiObjectLocator.lookup(JndiObjectLocator.java:106)
   at org.springframework.ejb.access.AbstractSlsbInvokerInterceptor.refreshHome(AbstractSlsbInvokerInterceptor.java:122)
   at org.springframework.ejb.access.AbstractSlsbInvokerInterceptor.afterPropertiesSet(AbstractSlsbInvokerInterceptor.java:109)
   at org.springframework.ejb.access.LocalStatelessSessionProxyFactoryBean.afterPropertiesSet(LocalStatelessSessionProxyFactoryBean.java:87)
   at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1612)
   at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1549)
   ... 103 more
Caused by: javax.naming.NameNotFoundException: csms-portlet
   at com.sun.enterprise.naming.impl.TransientContext.resolveContext(TransientContext.java:310)
   at com.sun.enterprise.naming.impl.TransientContext.lookup(TransientContext.java:218)
   at com.sun.enterprise.naming.impl.TransientContext.lookup(TransientContext.java:219)
   at com.sun.enterprise.naming.impl.SerialContextProviderImpl.lookup(SerialContextProviderImpl.java:77)
   at com.sun.enterprise.naming.impl.LocalSerialContextProviderImpl.lookup(LocalSerialContextProviderImpl.java:119)
   at com.sun.enterprise.naming.impl.SerialContext.lookup(SerialContext.java:505)
   ... 117 more
|#]
And portlet deployment is failed!


That class...
// singleton service that loads and holds Activiti Process Engine
// used to access internal services provided by Activiti.

@Singleton
@Startup
@LocalBean
public class ActivitiService {

<...>
// initializes activiti engine configuration from activiti.cfg.xml, deploys process from xml
@PostConstruct
public void init() {
   ProcessEngineConfiguration pec = ProcessEngineConfiguration.createProcessEngineConfigurationFromResourceDefault();
<...>
That class created with ProcessEngineConfiguration.
ProcessEngineConfiguration from activiti-engine-5.17.0.jar. Looks like some standard way to initialize engine.
package org.activiti.engine;
<...>
public abstract class ProcessEngineConfiguration implements EngineServices {
<...>

public static ProcessEngineConfiguration createProcessEngineConfigurationFromResourceDefault() {
return createProcessEngineConfigurationFromResource("activiti.cfg.xml", "processEngineConfiguration");
}

 

I guess required step is

 

1. Add config to glassfish.

Copy file activiti.cfg.xml to directory C:\glassfish3\glassfish\domains\domain1\config ?

Or copy content of activiti.cfg.xml to file C:\glassfish3\glassfish\domains\domain1\config\domain.xml ?

Or something else.

 

2. Register JNDI resource in glassfish 3.

 

Something like 

bin\asadmin create-jndi-resource

--restype com.example.csms.bpm.WorkflowHelper

--factoryclass some_implementaion_of_javax.naming.spi.ObjectFactory

--jndilookupname java:global

--description "whatever" csms-portlet/WorkflowHelperImpl

Tried many variations. Via shell and from glassfish GUI. With no luck.

Attachments

Outcomes