[EJB3] - @Stateless bean is not initialized when using Spring
by Kirill Linnik
Kirill Linnik [https://community.jboss.org/people/kirillica] created the discussion
"@Stateless bean is not initialized when using Spring"
To view the discussion, visit: https://community.jboss.org/message/723788#723788
--------------------------------------------------------------
Hi there,
One module of our application is made by third party company and it's Spring-based. That's should be OK, since Spring has enabled EJB injection and vice-versa. Injecting EJBs in Spring works fine, but if I follow manual ( http://refcardz.dzone.com/refcardz/dependency-injection-in-ejb3 http://refcardz.dzone.com/refcardz/dependency-injection-in-ejb3) and do like this:@Local
public interface MyDAO {
public void test();
}
and:
@Stateless
public class MyDAOImpl extends AbstractStatelessSessionBean implements
MyDAO {
private static final long serialVersionUID = 4738436066552146052L;
private MySpringService mySpringServiceService;
@Override
protected void onEjbCreate() throws CreateException {
mySpringServiceService = (MySpringService) getBeanFactory()
.getBean("mySpringService");
}
@Override
public void test() {
...
}
}
where:
@Service("mySpringService")
and inject this EJB in another EJB like:
@EJB
private MyDAO myDAO;
On server startup I see:
Caused by: java.lang.RuntimeException:
Could not resolve @EJB reference:
[EJB Reference: beanInterface 'MyDAO', beanName 'null', mappedName 'null', lookupName 'null', owning unit 'ComponentDeploymentContext@726473212
{org.jboss.metadata.ejb.jboss.JBossEnterpriseBeanMetaData.AnotherDAOImpl}']
for environment entry: env/AnotherDAOImpl/myDAO
in unit ComponentDeploymentContext(a)726473212{org.jboss.metadata.ejb.jboss.JBossEnterpriseBeanMetaData.AnotherDAOImpl}
It means, AFAIK, MyDAO is not an EJB and cannot be injected.
Well, where I am wrong?
--------------------------------------------------------------
Reply to this message by going to Community
[https://community.jboss.org/message/723788#723788]
Start a new discussion in EJB3 at Community
[https://community.jboss.org/choose-container!input.jspa?contentType=1&con...]
14 years
[jBPM] - JBPM Console Process List Error
by Timothy Charman
Timothy Charman [https://community.jboss.org/people/tcharman] created the discussion
"JBPM Console Process List Error"
To view the discussion, visit: https://community.jboss.org/message/723692#723692
--------------------------------------------------------------
Hi
I've tried installing JBPM console 5.2 (downloaded war) and 5.3 (compiled myself with maven) at separate times. I am running in JBoss AS 7.0.2.
In both cases I changed the login provider to be JAAS filesystem based/container managed. I also changed the persistence to use MySQL through a JNDI datasource.
If anyone has any ideas it would be much, much appreciated. I just want to see my process in the web UI console. Please :) .
h4. Dom4j Error
In both versions I get:
Caused by: org.dom4j.DocumentException: org.dom4j.DocumentFactory cannot be cast to org.dom4j.DocumentFactory Nested exception: org.dom4j.DocumentFactory cannot be cast to org.dom4j.DocumentFactory
when deploying jbpm-gwt-console-server. To remedy this, I removed both dom4j jars (1.6 and 1.6.1) from WEB-INF/lib in the jbpm-gwt-console-server. This lets me get past deployment.
I can log in to JBPM console server with no errors. I get an error in rendering the task pane, but that seems to go away after the first time it renders. I would paste it here, but the error has not occurred since I set the process pane to be default on login.
h4. Errors in Console Server Process Pane
I navigate to the process pane, hit refresh, and in both versions (5.2 and 5.3) I get an error.
*5.2 gives this error:*
19:03:49,119 ERROR [org.apache.catalina.core.ContainerBase.[jboss.web].[default-host].[/gwt-console-server].[Resteasy]] (http--0.0.0.0-8080-7) Servlet.service() for servlet Resteasy threw exception: org.jboss.resteasy.spi.UnhandledException: java.lang.RuntimeException: Could not initialize stateful knowledge session: No Persistence provider for EntityManager named org.jbpm.persistence.jpa
*5.3 gives this error:*
21:51:50,067 ERROR [org.apache.catalina.core.ContainerBase.[jboss.web].[default-host].[/gwt-console-server].[Resteasy]] (http--0.0.0.0-8080-4) Servlet.service() for servlet Resteasy threw exception: org.jboss.resteasy.spi.UnhandledException: java.lang.NoClassDefFoundError: Could not initialize class org.jbpm.integration.console.StatefulKnowledgeSessionUtil$SessionHolder
h4. Persistence Config
In both cases Hibernate is set to create the database, and the tables do get created. I also set showsql to true, and I can see the database being created.
h5. hibernate.cfg.xml
In the jbpm-gwt-console-server jar my WEB-INF/classes/META-INF/hibernate.cfg.xml looks like this:
<?xml version='1.0' encoding='utf-8'?>
<!DOCTYPE hibernate-configuration PUBLIC
"-//Hibernate/Hibernate Configuration DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd">
<hibernate-configuration>
<session-factory>
<!-- Database connection settings -->
<property name="connection.datasource">java:jboss/datasources/jbpm</property>
<!-- JDBC connection pool (use the built-in) -->
<property name="connection.pool_size">1</property>
<!-- SQL dialect -->
<property name="dialect">org.hibernate.dialect.MySQLDialect</property>
<!-- Enable Hibernate's automatic session context management -->
<property name="current_session_context_class">thread</property>
<!-- Disable the second-level cache -->
<property name="cache.provider_class">org.hibernate.cache.NoCacheProvider</property>
<!-- Echo all executed SQL to stdout -->
<property name="show_sql">true</property>
<!-- Drop and re-create the database schema on startup -->
<property name="hbm2ddl.auto">create</property>
<mapping resource="AuditLog.hbm.xml"/>
</session-factory>
</hibernate-configuration>
h5. persistence.xml
and my WEB-INF/classes/META-INF/persistence.xml looks like this (5.2):
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<persistence version="1.0"
xsi:schemaLocation="http://java.sun.com/xml/ns/persistence
http://java.sun.com/xml/ns/persistence/persistence_1_0.xsd
http://java.sun.com/xml/ns/persistence/orm
http://java.sun.com/xml/ns/persistence/orm_1_0.xsd"
xmlns:orm="http://java.sun.com/xml/ns/persistence/orm"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://java.sun.com/xml/ns/persistence">
<persistence-unit name="org.jbpm.persistence.jpa" transaction-type="JTA">
<provider>org.hibernate.ejb.HibernatePersistence</provider>
<jta-data-source>java:jboss/datasources/jbpm</jta-data-source>
<mapping-file>META-INF/JBPMorm.xml</mapping-file>
<class>org.jbpm.persistence.processinstance.ProcessInstanceInfo</class>
<class>org.drools.persistence.info.SessionInfo</class>
<class>org.drools.persistence.info.WorkItemInfo</class>
<properties>
<property name="hibernate.dialect" value="org.hibernate.dialect.MySQLDialect"/>
<property name="hibernate.max_fetch_depth" value="3"/>
<property name="hibernate.hbm2ddl.auto" value="create" />
<property name="hibernate.show_sql" value="true" />
<property name="hibernate.transaction.manager_lookup_class" value="org.jbpm.integration.console.JBPMTransactionManager" />
</properties>
</persistence-unit>
</persistence>
and like this in 5.3:
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<persistence
version="1.0"
xsi:schemaLocation=
"http://java.sun.com/xml/ns/persistence
http://java.sun.com/xml/ns/persistence/persistence_1_0.xsd
http://java.sun.com/xml/ns/persistence/orm
http://java.sun.com/xml/ns/persistence/orm_1_0.xsd"
xmlns:orm="http://java.sun.com/xml/ns/persistence/orm"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://java.sun.com/xml/ns/persistence">
<persistence-unit name="org.jbpm.persistence.jpa" transaction-type="JTA">
<provider>org.hibernate.ejb.HibernatePersistence</provider>
<jta-data-source>java:jboss/datasources/jbpm</jta-data-source>
<mapping-file>META-INF/JBPMorm.xml</mapping-file>
<class>org.jbpm.persistence.processinstance.ProcessInstanceInfo</class>
<class>org.drools.persistence.info.SessionInfo</class>
<class>org.drools.persistence.info.WorkItemInfo</class>
<class>org.jbpm.process.audit.ProcessInstanceLog</class>
<class>org.jbpm.process.audit.NodeInstanceLog</class>
<class>org.jbpm.process.audit.VariableInstanceLog</class>
<properties>
<property name="hibernate.dialect" value="org.hibernate.dialect.MySQLDialect"/>
<property name="hibernate.max_fetch_depth" value="3"/>
<property name="hibernate.hbm2ddl.auto" value="create" />
<property name="hibernate.show_sql" value="true" />
<property name="hibernate.transaction.manager_lookup_class" value="org.hibernate.transaction.JBossTransactionManagerLookup" />
</properties>
</persistence-unit>
</persistence>
h5. JBPMorm.xml
and finally my WEB-INF/classes/META-INF/JBPMorm.xml looks like this:
<?xml version="1.0" encoding="UTF-8"?>
<entity-mappings xmlns="http://java.sun.com/xml/ns/persistence/orm"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/persistence/orm orm_1_0.xsd"
version="2.0">
<named-query name="ProcessInstancesWaitingForEvent">
<query>
select
processInstanceInfo.processInstanceId
from
ProcessInstanceInfo processInstanceInfo join processInstanceInfo.eventTypes eventTypes
where
eventTypes = :type
</query>
</named-query>
<sql-result-set-mapping name="ProcessInstancesWaitingForEvent.mapping">
<column-result name="InstanceId" />
</sql-result-set-mapping>
<entity class="org.jbpm.persistence.processinstance.ProcessInstanceInfo">
<attributes>
<element-collection name="eventTypes">
<collection-table name="EventTypes">
<join-column name="InstanceId" />
</collection-table>
</element-collection>
</attributes>
</entity>
</entity-mappings>
h5. JBPMorm.xml error
Here you will see that I followed someone's (I forget whose) note that suggests changing JBPMorm.xml following getting this error:
Caused by: org.hibernate.MappingException: Could not determine type for: java.util.Set, at table: ProcessInstanceInfo, for columns: [org.hibernate.mapping.Column(eventTypes)]
--------------------------------------------------------------
Reply to this message by going to Community
[https://community.jboss.org/message/723692#723692]
Start a new discussion in jBPM at Community
[https://community.jboss.org/choose-container!input.jspa?contentType=1&con...]
14 years
[jBPM] - Could not delete execution when flow end?
by hob wang
hob wang [https://community.jboss.org/people/hob007] created the discussion
"Could not delete execution when flow end?"
To view the discussion, visit: https://community.jboss.org/message/723401#723401
--------------------------------------------------------------
I tested a jbpm 4.4 flow connected to MySql integrated with spring and hibernate. The flow deployment and execution were fine, but when the flow end, it was wrong.
Cannot delete or update a parent row: a foreign key constraint fails.
Test environment:
jbpm 4.4 version, mySql 5.0.12, hibernate 3.2, spring 2.5.6
mySql engine: InnoDB
hibernate dialect: org.hibernate.dialect.MySQLInnoDBDialect
The error stack under this:
Hibernate: delete from jbpm4_execution where dbid_=? and dbversion_=?
14:54:57 [http-8080-6] ERROR org.hibernate.util.JDBCExceptionReporter.logExceptions(101) - Cannot delete or update a parent row: a foreign key constraint fails
14:54:57 [http-8080-6] ERROR org.hibernate.event.def.AbstractFlushingEventListener.performExecutions(324) - Could not synchronize database state with session
org.hibernate.exception.ConstraintViolationException: could not delete: [org.jbpm.pvm.internal.model.ExecutionImpl#130009]
at org.hibernate.exception.SQLStateConverter.convert(SQLStateConverter.java:94)
at org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:66)
at org.hibernate.persister.entity.AbstractEntityPersister.delete(AbstractEntityPersister.java:2569)
at org.hibernate.persister.entity.AbstractEntityPersister.delete(AbstractEntityPersister.java:2725)
at org.hibernate.action.EntityDeleteAction.execute(EntityDeleteAction.java:97)
at org.hibernate.engine.ActionQueue.execute(ActionQueue.java:279)
at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:263)
at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:172)
at org.hibernate.event.def.AbstractFlushingEventListener.performExecutions(AbstractFlushingEventListener.java:321)
at org.hibernate.event.def.DefaultFlushEventListener.onFlush(DefaultFlushEventListener.java:50)
at org.hibernate.impl.SessionImpl.flush(SessionImpl.java:1027)
at org.hibernate.impl.SessionImpl.managedFlush(SessionImpl.java:365)
at org.hibernate.transaction.JDBCTransaction.commit(JDBCTransaction.java:137)
at org.springframework.orm.hibernate3.HibernateTransactionManager.doCommit(HibernateTransactionManager.java:655)
at org.springframework.transaction.support.AbstractPlatformTransactionManager.processCommit(AbstractPlatformTransactionManager.java:732)
at org.springframework.transaction.support.AbstractPlatformTransactionManager.commit(AbstractPlatformTransactionManager.java:701)
at org.springframework.transaction.support.TransactionTemplate.execute(TransactionTemplate.java:140)
at org.jbpm.pvm.internal.tx.SpringTransactionInterceptor.execute(SpringTransactionInterceptor.java:49)
at org.jbpm.pvm.internal.svc.EnvironmentInterceptor.executeInNewEnvironment(EnvironmentInterceptor.java:53)
at org.jbpm.pvm.internal.svc.EnvironmentInterceptor.execute(EnvironmentInterceptor.java:40)
at org.jbpm.pvm.internal.svc.RetryInterceptor.execute(RetryInterceptor.java:56)
at org.jbpm.pvm.internal.svc.TaskServiceImpl.completeTask(TaskServiceImpl.java:96)
at com.founder.nmcms.mamc.controller.MamcProgramController.check(MamcProgramController.java:734)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at com.founder.e5.web.BaseUpgradeController.handleRequest(BaseUpgradeController.java:158)
at org.springframework.web.servlet.mvc.SimpleControllerHandlerAdapter.handle(SimpleControllerHandlerAdapter.java:48)
at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:875)
at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:807)
at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:571)
at org.springframework.web.servlet.FrameworkServlet.doPost(FrameworkServlet.java:511)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:637)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.springframework.orm.hibernate3.support.OpenSessionInViewFilter.doFilterInternal(OpenSessionInViewFilter.java:198)
at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:76)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at filters.SetCharacterEncodingFilter.doFilter(SetCharacterEncodingFilter.java:38)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:175)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:128)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
at org.apache.catalina.authenticator.SingleSignOn.invoke(SingleSignOn.java:394)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:286)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:844)
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:583)
at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:447)
at java.lang.Thread.run(Thread.java:619)
Caused by: com.mysql.jdbc.exceptions.jdbc4.MySQLIntegrityConstraintViolationException: Cannot delete or update a parent row: a foreign key constraint fails
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)
at java.lang.reflect.Constructor.newInstance(Constructor.java:513)
at com.mysql.jdbc.Util.handleNewInstance(Util.java:407)
at com.mysql.jdbc.Util.getInstance(Util.java:382)
at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:1039)
at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:3603)
at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:3535)
at com.mysql.jdbc.MysqlIO.sendCommand(MysqlIO.java:1989)
at com.mysql.jdbc.MysqlIO.sqlQueryDirect(MysqlIO.java:2150)
at com.mysql.jdbc.ConnectionImpl.execSQL(ConnectionImpl.java:2626)
at com.mysql.jdbc.PreparedStatement.executeInternal(PreparedStatement.java:2119)
at com.mysql.jdbc.PreparedStatement.executeUpdate(PreparedStatement.java:2415)
at com.mysql.jdbc.PreparedStatement.executeUpdate(PreparedStatement.java:2333)
at com.mysql.jdbc.PreparedStatement.executeUpdate(PreparedStatement.java:2318)
at org.apache.tomcat.dbcp.dbcp.DelegatingPreparedStatement.executeUpdate(DelegatingPreparedStatement.java:102)
at org.hibernate.persister.entity.AbstractEntityPersister.delete(AbstractEntityPersister.java:2551)
... 52 more
Someone said It seems with problem with hiberante dialect, MySql should use MySQLInnoDBDialect. And my MySql DB engine is "InnoDB".
I try MySQLInnoDBDialect and MySQLDialect, and the error stack is the same.
I wonder is there something wrong with my configuration, how could I do to complete flow test?
Sincerely looking for you advice.
--------------------------------------------------------------
Reply to this message by going to Community
[https://community.jboss.org/message/723401#723401]
Start a new discussion in jBPM at Community
[https://community.jboss.org/choose-container!input.jspa?contentType=1&con...]
14 years