JBPM6 project connect to mysql failed - jboss

i installed jbpm6 and mysql,i used PoolingDataSource to start BD,but always unable to find'squenses' tables,i kown it's hibernate'dialect problem,and i want to use persistence.xml to start .
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<persistence
version="2.0"
xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_2_0.xsd http://java.sun.com/xml/ns/persistence/orm http://java.sun.com/xml/ns/persistence/orm_2_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="com.test.test" transaction-type="JTA">
<provider>org.hibernate.ejb.HibernatePersistence</provider>
<jta-data-source>jdbc/jbpm-ds</jta-data-source>
<mapping-file>META-INF/JBPMorm.xml</mapping-file>
<mapping-file>META-INF/Taskorm.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>
<class>org.jbpm.persistence.correlation.CorrelationKeyInfo</class>
<class>org.jbpm.persistence.correlation.CorrelationPropertyInfo</class>
<!-- manager -->
<class>org.jbpm.runtime.manager.impl.jpa.ContextMappingInfo</class>
<class>org.jbpm.services.task.impl.model.AttachmentImpl</class>
<class>org.jbpm.services.task.impl.model.ContentImpl</class>
<class>org.jbpm.services.task.impl.model.BooleanExpressionImpl</class>
<class>org.jbpm.services.task.impl.model.CommentImpl</class>
<class>org.jbpm.services.task.impl.model.DeadlineImpl</class>
<class>org.jbpm.services.task.impl.model.CommentImpl</class>
<class>org.jbpm.services.task.impl.model.DeadlineImpl</class>
<class>org.jbpm.services.task.impl.model.DelegationImpl</class>
<class>org.jbpm.services.task.impl.model.EscalationImpl</class>
<class>org.jbpm.services.task.impl.model.GroupImpl</class>
<class>org.jbpm.services.task.impl.model.I18NTextImpl</class>
<class>org.jbpm.services.task.impl.model.NotificationImpl</class>
<class>org.jbpm.services.task.impl.model.EmailNotificationImpl</class>
<class>org.jbpm.services.task.impl.model.EmailNotificationHeaderImpl</class>
<class>org.jbpm.services.task.impl.model.PeopleAssignmentsImpl</class>
<class>org.jbpm.services.task.impl.model.ReassignmentImpl</class>
<class>org.jbpm.services.task.impl.model.TaskImpl</class>
<class>org.jbpm.services.task.impl.model.TaskDataImpl</class>
<class>org.jbpm.services.task.impl.model.UserImpl</class>
<!--BAM for task service -->
<class>org.jbpm.services.task.impl.model.BAMTaskSummaryImpl</class>
<properties>
<property name="hibernate.max_fetch_depth" value="3"/>
<property name="hibernate.hbm2ddl.auto" value="update" />
<property name="hibernate.show_sql" value="true" />
<property name="hibernate.dialect" value="org.hibernate.dialect.MySQLDialect"/>
<!-- BZ 841786: AS7/EAP 6/Hib 4 uses new (sequence) generators which seem to cause problems -->
<property name="hibernate.id.new_generator_mappings" value="false" />
<property name="hibernate.connection.driver_class" value="com.mysql.jdbc.Driver"/>
<property name="hibernate.connection.username" value="jbpm"/>
<property name="hibernate.connection.password" value="jbpm"/>
<property name="hibernate.connection.url" value="jdbc:mysql://localhost:3306/jbpm"/>
<property name="hibernate.cglib.use_reflection_optimizer" value="true"/>
<property name="hibernate.transaction.jta.platform" value="org.hibernate.service.jta.platform.internal.BitronixJtaPlatform" />
</properties>
</persistence-unit>
</persistence>
but the error is that:
​Exception in thread "main" javax.persistence.PersistenceException: [PersistenceUnit: org.jbpm.persistence.jpa] Unable to build EntityManagerFactory
at org.hibernate.ejb.Ejb3Configuration.buildEntityManagerFactory(Ejb3Configuration.java:925)
at org.hibernate.ejb.Ejb3Configuration.buildEntityManagerFactory(Ejb3Configuration.java:900)
at org.hibernate.ejb.HibernatePersistence.createEntityManagerFactory(HibernatePersistence.java:59)
at javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:63)
at javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:47)
at test.test.createRuntimeManager(test.java:71)
at test.test.main(test.java:37)
Caused by: org.hibernate.service.jndi.JndiException: Unable to lookup JNDI name [jdbc/jbpm-ds]
at org.hibernate.service.jndi.internal.JndiServiceImpl.locate(JndiServiceImpl.java:68)
at org.hibernate.service.jdbc.connections.internal.DatasourceConnectionProviderImpl.configure(DatasourceConnectionProviderImpl.java:116)
at org.hibernate.service.internal.StandardServiceRegistryImpl.configureService(StandardServiceRegistryImpl.java:85)
at org.hibernate.service.internal.AbstractServiceRegistryImpl.initializeService(AbstractServiceRegistryImpl.java:184)
at org.hibernate.service.internal.AbstractServiceRegistryImpl.getService(AbstractServiceRegistryImpl.java:156)
at org.hibernate.engine.jdbc.internal.JdbcServicesImpl.buildJdbcConnectionAccess(JdbcServicesImpl.java:223)
at org.hibernate.engine.jdbc.internal.JdbcServicesImpl.configure(JdbcServicesImpl.java:89)
at org.hibernate.service.internal.StandardServiceRegistryImpl.configureService(StandardServiceRegistryImpl.java:85)
at org.hibernate.service.internal.AbstractServiceRegistryImpl.initializeService(AbstractServiceRegistryImpl.java:184)
at org.hibernate.service.internal.AbstractServiceRegistryImpl.getService(AbstractServiceRegistryImpl.java:156)
at org.hibernate.cfg.Configuration.buildTypeRegistrations(Configuration.java:1827)
at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1785)
at org.hibernate.ejb.EntityManagerFactoryImpl.<init>(EntityManagerFactoryImpl.java:96)
at org.hibernate.ejb.Ejb3Configuration.buildEntityManagerFactory(Ejb3Configuration.java:915)
... 6 more
Caused by: javax.naming.NameNotFoundException: unable to find a bound object at name 'jdbc/jbpm-ds'
at bitronix.tm.jndi.BitronixContext.lookup(BitronixContext.java:83)
at bitronix.tm.jndi.BitronixContext.lookup(BitronixContext.java:67)
at javax.naming.InitialContext.lookup(Unknown Source)
at org.hibernate.service.jndi.internal.JndiServiceImpl.locate(JndiServiceImpl.java:65)
... 19 more
i don't kown what i lose

Related

How to share Entity classes across multiple Persistence Unit?

How to share Entity classes across multiple Persistence Unit?
I have 2 MySql databases (dbOne, dbTWO) with the same table "users"
I would like to have an Entity class like this :
#Entity
public class User {
...
...
}
shared between the 2 PU (of dbONE and dbTWO).. (eclipse.persistence)
i tried with :
<persistence-unit name="one_PU" transaction-type="RESOURCE_LOCAL">
<provider>org.eclipse.persistence.jpa.PersistenceProvider</provider>
<class>com.model.User</class>
<validation-mode>NONE</validation-mode>
<exclude-unlisted-classes>true</exclude-unlisted-classes>
<shared-cache-mode>NONE</shared-cache-mode>
<properties>
<property name="javax.persistence.jdbc.url" value="jdbc:mysql://localhost/dbONE"/>
<property name="javax.persistence.jdbc.driver" value="com.mysql.jdbc.Driver"/>
<property name="javax.persistence.jdbc.user" value="*****"/>
<property name="javax.persistence.jdbc.password" value="******"/>
<property name="eclipselink.jdbc.batch-writing" value="JDBC"/>
<property name="eclipselink.jdbc.batch-writing.size" value="1000"/>
<property name="eclipselink.jdbc.cache-statements" value="false"/>
<property name="eclipselink.cache.shared.default" value="false"/>
</properties>
</persistence-unit>
<persistence-unit name="two_PU" transaction-type="RESOURCE_LOCAL">
<provider>org.eclipse.persistence.jpa.PersistenceProvider</provider>
<class>com.model.User</class>
<validation-mode>NONE</validation-mode>
<exclude-unlisted-classes>true</exclude-unlisted-classes>
<shared-cache-mode>NONE</shared-cache-mode>
<properties>
<property name="javax.persistence.jdbc.url" value="jdbc:mysql://localhost/dbTWO"/>
<property name="javax.persistence.jdbc.driver" value="com.mysql.jdbc.Driver"/>
<property name="javax.persistence.jdbc.user" value="*****"/>
<property name="javax.persistence.jdbc.password" value="*****"/>
<property name="eclipselink.jdbc.batch-writing" value="JDBC"/>
<property name="eclipselink.jdbc.batch-writing.size" value="1000"/>
<property name="eclipselink.jdbc.cache-statements" value="false"/>
<property name="eclipselink.cache.shared.default" value="false"/>
</properties>
</persistence-unit>
without success..
Is it possible?..how can i do that?

openJPA configured not persisting

I have a very minimal test that properly configures openJPA, JTA, database connectivity, enhancement and emits no exceptions however it does not persist with the simple code below. What more do I need to show or what is necessary beyond the simple statements to actually write records to the db?
public class Manipulation00 {
public Manipulation00(){}
public void startUp(ServletContext sc){
EntityManagerFactory emf =
(EntityManagerFactory)sc.getAttribute("emf");
EntityManager em = emf.createEntityManager();
Exemptions00 exempt00 = new Exemptions00();
exempt00.setUpc("722430001166");
exempt00.setDesc("KOMBUCHA,OG2,SEASONAL");
em.persist(exempt00);
}
}
the persistence.xml
<?xml version="1.0" encoding="UTF-8"?>
<persistence version="2.1" xmlns="http://xmlns.jcp.org/xml/ns/persistence" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/persistence http://xmlns.jcp.org/xml/ns/persistence/persistence_2_1.xsd">
<persistence-unit name="ediExemptions" transaction-type="JTA">
<provider>org.apache.openjpa.persistence.PersistenceProviderImpl</provider>
<jta-data-source>java:app/ediExemptions</jta-data-source>
<class>tng.db02.Exemptions00</class>
<properties>
<property name="javax.persistence.schema-generation.database.action" value="drop-and-create"/>
<property name="openjpa.Log" value="DefaultLevel=WARN, Tool=INFO"/>
<property name="openjpa.jdbc.SynchronizeMappings"
value="buildSchema"/>
<property name="openjpa.ConnectionURL"
value="jdbc:derby://localhost:1527/ediExemptions"/>
<property name="openjpa.ConnectionDriverName"
value="org.apache.derby.jdbc.ClientDriver"/>
<property name="openjpa.ConnectionUserName"
value="root"/>
<property name="openjpa.ConnectionPassword"
value="admin"/>
</properties>
</persistence-unit>
</persistence>
I'd guess that your transaction isn't being committed.

Exception in thread "main" org.spring....beans.factory.BeanCreationException: Error creating bean with name 'FirstStep': Instantiation of bean failed

am trying to run my application am getting error.I am using spring batch patitioning to run multiple threads of job.Here am getting exception is step name is Instantiation of bean failed; nested exception is java.lang.IllegalStateException: No bean class specified on bean definition.please suggest me any one.
Exception in thread "main" org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'Step': Instantiation of bean failed; nested exception is java.lang.IllegalStateException: No bean class specified on bean definition
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantiateBean(AbstractAutowireCapableBeanFactory.java:1071)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:1016)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:504)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:475)
at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:300)
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:228)
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:296)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:195)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:660)
at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:760)
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:482)
at org.springframework.context.support.ClassPathXmlApplicationContext.<init>(ClassPathXmlApplicationContext.java:139)
at org.springframework.context.support.ClassPathXmlApplicationContext.<init>(ClassPathXmlApplicationContext.java:83)
at john.deere.com.PartApp.runTest(PartApp.java:18)
at john.deere.com.PartApp.main(PartApp.java:13)
Caused by: java.lang.IllegalStateException: No bean class specified on bean definition
at org.springframework.beans.factory.support.AbstractBeanDefinition.getBeanClass(AbstractBeanDefinition.java:354)
at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:66)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantiateBean(AbstractAutowireCapableBeanFactory.java:1064)
... 14 more
in my configuration file is
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:batch="http://www.springframework.org/schema/batch"
xmlns:util="http://www.springframework.org/schema/util"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:context="http://www.springframework.org/schema/context"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.2.xsd
http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util-3.2.xsd
http://www.springframework.org/schema/batch http://www.springframework.org/schema/batch/spring-batch-2.2.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-4.0.xsd">
<context:component-scan base-package="john.deere.com" />
<import resource="applicationContext.xml"/>
<import resource="ApplicationDB.xml"/>
<job id="partitionJob" xmlns="http://www.springframework.org/schema/batch">
<!-- master step, 10 threads (grid-size) -->
<step id="Step">
<partition step="slave" partitioner="rangePart">
<handler grid-size="10" task-executor="taskExecutor" />
</partition>
</step>
<step id="slave" xmlns="http://www.springframework.org/schema/batch">
<tasklet>
<chunk reader="itemReader" processor="itemProcessor" writer="itemWriter" commit-interval="1" />
</tasklet>
</step>
</job>
<bean id="rangePart" class="john.deere.com.PartitionerEx" />
<bean id="taskExecutor" class="org.springframework.core.task.SimpleAsyncTaskExecutor" />
<bean id="itemProcessor" class="john.deere.com.EmpProcessor"
scope="step">
<property name="threadName" value="#{stepExecutionContext[name]}" />
</bean>
<!-- csv file writer -->
<bean id="itemWriter" class="org.springframework.batch.item.file.FlatFileItemWriter"
scope="step" >
<property name="resource"
value="file:csv/outputs/employee.processed#{stepExecutionContext[fromId]}-#{stepExecutionContext[toId]}.csv" />
<!-- <property name="appendAllowed" value="false" /> -->
<property name="lineAggregator">
<bean
class="org.springframework.batch.item.file.transform.DelimitedLineAggregator">
<property name="delimiter" value="," />
<property name="fieldExtractor">
<bean
class="org.springframework.batch.item.file.transform.BeanWrapperFieldExtractor">
<property name="names" value="id, name, age, salarey, address" />
</bean>
</property>
</bean>
</property>
</bean>
<bean id="itemReader"
class="org.springframework.batch.item.database.JdbcPagingItemReader"
scope="step">
<property name="dataSource" ref="dataSource" />
<property name="queryProvider">
<bean
class="org.springframework.batch.item.database.support.SqlPagingQueryProviderFactoryBean">
<property name="dataSource" ref="dataSource" />
<property name="selectClause" value="select id, name, age, salary, address" />
<property name="fromClause" value="from employee" />
<property name="whereClause">
<value>
<![CDATA[
where id >= :fromId and id <= :toId
]]>
</value>
</property>
<property name="sortKey" value="id" />
</bean>
</property>
<!-- Inject via the ExecutionContext in rangePartitioner -->
<property name="parameterValues">
<map>
<entry key="fromId" value="#{stepExecutionContext[fromId]}" />
<entry key="toId" value="#{stepExecutionContext[toId]}" />
</map>
</property>
<property name="pageSize" value="10" />
<property name="rowMapper">
<bean class="john.deere.com.EmpRowMapper" />
</property>
</bean>
</beans>
You step slave is defined outside of the job tag. That does not look correct
....
</step>
</job>
<step id="slave" xmlns="http://www.springframework.org/schema/batch">
<tasklet>
....

EntityTransaction rollback

I use EJB to insert/update data to the database and I have this problem. My commit only works with updating(merge), but doesn't rollback inserts(persist). Even more, my inserts(persist) happen before transaction commit.
my persistence unit:
<persistence-unit name="bpmBeans_RESOURCE_LOCAL" transaction-type="RESOURCE_LOCAL">
<jta-data-source>java:jboss/datasources/java_orgstruct</jta-data-source>
<properties>
<property name="hibernate.hbm2ddl.auto" value="update" />
<property name="hibernate.show_sql" value="true" />
<property name="hibernate.connection.useUnicode" value="true"/>
<property name="hibernate.connection.characterEncoding" value="UTF-8"/>
<property name="hibernate.connection.CharSet" value="utf8"/>
<property name="hibernate.cache.use_second_level_cache" value="true" />
<property name="hibernate.cache.use_query_cache" value="true" />
<property name="hibernate.transaction.factory_class" value="org.hibernate.transaction.JTATransactionFactory" />
<property name="hibernate.transaction.manager_lookup_class" value="org.hibernate.transaction.JBossTransactionManagerLookup"/>
<property name="hibernate.connection.autocommit" value="false"/>
</properties>
</persistence-unit>
how i inject entity manager factory
#PersistenceUnit(unitName="bpmBeans_RESOURCE_LOCAL")
public EntityManagerFactory emf;
what happens with the code
EntityManager em = emf.createEntityManager();
EntityTransaction ets = em.getTransaction();
ets.begin();
Process newObj = new Process();
em.persist(newObj); //data gets inserted at this moment, not at commit
...
...
if(allgood){
ets.commit();// now update(merge, setters on managed entities) would happend.
} else {
ets.rollback(); // this would rollback the updates, but not the insert
}
Any ideas what to try? I guess I'm just understanding some JPA concepts badly.
EDIT:
Datasource code. Datasource is described in WEB-INF/mysql-ds.xml file . Driver .jar is in JBoss deployments.
<?xml version="1.0" encoding="UTF-8"?>
<datasources xmlns="http://www.jboss.org/ironjacamar/schema">
<datasource jndi-name="java:jboss/datasources/java_orgstruct" pool-name="MySQLPool">
<connection-url>jdbc:mysql://192.168.150.141/organisation_model</connection-url>
<connection-property name="zeroDateTimeBehavior">convertToNull</connection-property>
<connection-property name="characterEncoding">utf8</connection-property>
<driver>mysql-connector-java-5.1.28-bin.jar</driver>
<security>
<user-name></user-name>
<password></password>
</security>
</datasource>
</datasources>

join table between two persistance unit

join 2 table between 2 persistance unit
<persistence-unit name="oltpJPA">
<class>entity.timetable</class>
<class>entity.facultyleave</class>
<properties>
<property name="openjpa.jdbc.Schema" value="OLTP" />
<property name="openjpa.ConnectionDriverName"value="com.ibm.db2.jcc.DB2Driver"/>
<property name="openjpa.ConnectionURL" value="jdbc:db2://172.16.1.7:50000/OLTPDB:retrieveMessagesFromServerOnGetMessage=true;"/>
<property name="openjpa.ConnectionUserName" value="administrator"/>
<property name="openjpa.ConnectionPassword" value="server"/>
</properties>
</persistence-unit>
<persistence-unit name="oltpJPAabs">
<class>property.Properties</class>
<class>entity.StudentAbsenteseDate</class>
<class>entity.StudentAbsenteseLecture</class>
<properties>
<property name="openjpa.jdbc.Schema" value="OLTP" />
<property name="openjpa.ConnectionDriverName" value="com.ibm.db2.jcc.DB2Driver"/>
<property name="openjpa.ConnectionURL" value="jdbc:db2://172.16.1.9:50000/OLTPDB:retrieveMessagesFromServerOnGetMessage=true;"/>
<property name="openjpa.ConnectionUserName" value="administrator"/>
<property name="openjpa.ConnectionPassword" value="lenovo"/>
</properties>
</persistence-unit></persistence>
not able to manage the foreign key between studentabsenteselecture and timetable