jbpm audit log always looking for jta transaction - jta

Am trying to pull records from JBPM AuditLog but am getting
SEVERE: Servlet.service() for servlet [dispatcher] in context with path [/dms] threw exception [Request processing failed; nested exception is java.lang.IllegalStateException: Unable to find JTA transaction.] with root cause
java.lang.IllegalStateException: Unable to find JTA transaction.
at org.jbpm.process.audit.strategy.StandaloneJtaStrategy.joinTransaction(StandaloneJtaStrategy.java:45)
at org.jbpm.process.audit.JPAAuditLogService.joinTransaction(JPAAuditLogService.java:319)
at org.jbpm.process.audit.JPAAuditLogService.executeQuery(JPAAuditLogService.java:327)
at org.jbpm.process.audit.JPAAuditLogService.findVariableInstancesByNameAndValue(JPAAuditLogService.java:280)
at com.softech.dms.workflow.WorkflowUtil.getAuditLog(WorkflowUtil.java:237)
at com.softech.dms.workflow.WorkflowUtil$$FastClassBySpringCGLIB$$73d95f1.invoke(<generated>)
at org.springframework.cglib.proxy.MethodProxy.invoke(MethodProxy.java:204)
looking at trace it is still using the JTA strategy instead of local transaction strategy
am using jbpm v6.2.0.CR2 and my persistence.xml is as follows
<persistence-unit name="dms-jbpm" transaction-type="RESOURCE_LOCAL">
<provider>org.hibernate.ejb.HibernatePersistence</provider>
<mapping-file>META-INF/JBPMorm.xml</mapping-file>
<mapping-file>META-INF/Taskorm.xml</mapping-file>
<mapping-file>META-INF/TaskAuditorm.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>
<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.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>
<class>org.jbpm.services.task.audit.impl.model.BAMTaskSummaryImpl</class>
<class>org.jbpm.services.task.audit.impl.model.TaskEventImpl</class>
<class>org.jbpm.services.task.audit.impl.model.AuditTaskImpl</class>
<properties>
<property name="hibernate.transaction.jta.platform" value="org.hibernate.service.jta.platform.internal.BitronixJtaPlatform" />
</properties>
</persistence-unit>

jBPM persistence is using JTA to manage the transaction. As a result, you should use JTA as transaction type in your persistence.xml and use a JTA data source. The only exception is Spring, where we also integrate with the Spring transaction manager to support local transactions as well.

Related

EclipseLink internal logging statements go through Log4j2

I want the internal logging statements from EclipseLink (version 2.7.x) to be logged through my Log4j2 setup.
I know there's a bug report on this (https://issues.apache.org/jira/browse/LOG4J2-444) which never got solved. I also know, there is a wiki how to implement an own logger (https://wiki.eclipse.org/EclipseLink/Examples/Foundation/Logging).
Since I think someone must have already addressed this problem (since there should be thousands of EclipseLink + log4j2 setups out there) and come out with a reliable solution, my question would be:
Where can i find it?
I am not sure this solution is the best, but
The library contain EclipseLink logger impelementation for slf4j:
https://search.maven.org/artifact/org.eclipse.persistence/org.eclipse.persistence.extension
You can set it to use in persistence.xml:
<property name="eclipselink.logging.logger" value="org.eclipse.persistence.logging.slf4j.SLF4JLogger" />
Now you need bridge slf4j -> log4j2:
https://search.maven.org/artifact/org.apache.logging.log4j/log4j-slf4j-impl
And finally log4j2.xml: <Logger name="eclipselink.logging" level="ALL"> ... </Logger>
level="ALL" because what exatly will be logged is configured in persistence.xml e.g. eclipselink.logging.level property an so on:
https://wiki.eclipse.org/EclipseLink/Examples/JPA/Logging

jpa-store and hibernate OGM

Issue:
Try to configure infinspan cache with jpa-store and hibernate OGM. I can able to access the infinispan server cache through hotrod client with simple cache store, the configuration is follows,
I have configured following in ..\infinispan-server-8.1.0.CR1\standalone\configuration\standalone.xml and run the server by command ../bin>standalone.bat
<subsystem xmlns="urn:infinispan:server:core:8.1">
<cache-container name="local" default-cache="default" statistics="true">
...
<local-cache name="testCache">
<compatibility/>
</local-cache>
</<cache-container>
<subsystem>
In client side, accessing the cache sucessfully using hotrod client like below code.
Configuration config = new ConfigurationBuilder().addServer().host("127.0.0.1").port(11222).build();
RemoteCacheManager cacheManager = new RemoteCacheManager(config);
RemoteCache<Integer, TestEntity> cache = cacheManager.getCache("testCache");
1. How to configure jpa-store (with load from database and write into database) in standalone.xml?
I have tried with below code in standalone.xml.
<persistence passivation="false">
<jpa-store xmlns="urn:infinispan:config:store:jpa:8.0"
shared="true" preload="true"
persistence-unit="CachePersistenceUnit"
entity-class="TestEntity"
singleton="false"
batch-size="1">
</jpa-store>
</persistence>
Caused by: javax.xml.stream.XMLStreamException: WFLYCTL0198: Unexpected element '{urn:infinispan:server:core:8.1}persistence' encountered
at org.jboss.as.controller.parsing.ParseUtils.unexpectedElement(ParseUtils.java:89)
at org.jboss.as.clustering.infinispan.subsystem.InfinispanSubsystemXMLReader.parseCacheElement(InfinispanSubsystemXMLReader.java:971)
at org.jboss.as.clustering.infinispan.subsystem.InfinispanSubsystemXMLReader.parseLocalCache(InfinispanSubsystemXMLReader.java:706)
at org.jboss.as.clustering.infinispan.subsystem.InfinispanSubsystemXMLReader.parseContainer(InfinispanSubsystemXMLReader.java:247)
at org.jboss.as.clustering.infinispan.subsystem.InfinispanSubsystemXMLReader.readElement(InfinispanSubsystemXMLReader.java:97)
at org.jboss.as.clustering.infinispan.subsystem.InfinispanSubsystemXMLReader.readElement(InfinispanSubsystemXMLReader.java:70)
at org.jboss.staxmapper.XMLMapperImpl.processNested(XMLMapperImpl.java:110)
at org.jboss.staxmapper.XMLExtendedStreamReaderImpl.handleAny(XMLExtendedStreamReaderImpl.java:69)
at org.jboss.as.server.parsing.StandaloneXml_4.parseServerProfile(StandaloneXml_4.java:547)
at org.jboss.as.server.parsing.StandaloneXml_4.readServerElement(StandaloneXml_4.java:244)
at org.jboss.as.server.parsing.StandaloneXml_4.readElement(StandaloneXml_4.java:143)
at org.jboss.as.server.parsing.StandaloneXml.readElement(StandaloneXml.java:69)
at org.jboss.as.server.parsing.StandaloneXml.readElement(StandaloneXml.java:47)
at org.jboss.staxmapper.XMLMapperImpl.processNested(XMLMapperImpl.java:110)
at org.jboss.staxmapper.XMLMapperImpl.parseDocument(XMLMapperImpl.java:69)
at org.jboss.as.controller.persistence.XmlConfigurationPersister.load(XmlConfigurationPersister.java:123)
... 3 more
How to auto deploy project (customized infinispan manager class(java class), persistence.xml and infinispan-config.xml) in infinispan server(Jboss)?
The two questions are actually related:
Infinispan Server is designed as a backend data store and hence it's not designed to have applications deployed on it.
With that in mind, since you can't deployed applications onto it, you can't deploy JPA entities and hence it does not make sense to be able to configure a JPA cache store in Server mode.
You are able to deploy JPA entities on Wildfly/EAP or similar environments, where it is possible to deploy an Infinispan based application (see tutorials here) and configure a JPA store.
Cheers,
Galder

What does this mean commit():Illegal for a non-transacted Session:sessionId

I am using a glassfish server and using the JMS functionality of that glassfish server.
Keep on getting this error message :
MQJMSRA_DS4001: commit():Illegal for a non-transacted Session:sessionId
What is the reason I am getting this error message ?
The reason you get that error is that your Session is not transacted . This means than commit/ rollback methods are meaningless. Try setting the session as transacted when you create it (E.g. connection.createSession(true, Session.AUTO_ACKNOWLEDGE)).
If you don't want your session to be transacted you should remove Commit / rollbacks from code, or cheching a global variable before executing.
You can use TransactionAwareConnectionFactoryProxy .
Instead of using the raw vendor-provided ConnectionFactory, the configuration wraps ConnectionFactory in a decorator that handles the transaction synchronization. This happens in the jms-context.xml as follows :-
<bean id="connectionFactory" class="org.springframework.jms.connection.TransactionAwareConnectionFactoryProxy">
<property name="targetConnectionFactory" ref="myCamelConnectionFactory"/>
</bean>
<jee:jndi-lookup id="myconnectionFactory" jndi-name="SoDConflictConnFactory"/>
This will remove the Warning message :-MQJMSRA_DS4001

derby persistence.xml

What should be the property statement regarding the derby client driver in the persistence.xml e.g :
<property name="javax.persistence.jdbc.driver" value=" ? " />
When tyring to update the DB from Java I keep getting the exception below.
Actually I need the client driver instead the EmbeddedDriver . Don't know how to name it.
The project has in its java Build path/libraries the Derby Client JDBC driver ( eclipse plugin has the derby plugin).
The program instruction causing the exception is :
factory = Persistence.createEntityManagerFactory(PERSISTENCE_UNIT_NAME);
EntityManager em = factory.createEntityManager();
[EL Info]: 2012-02-02 10:48:44.805--ServerSession(1434473856)--EclipseLink, version: Eclipse Persistence Services - 2.3.2.v20111125-r10461
[EL Severe]: 2012-02-02 10:48:44.93--ServerSession(1434473856)--Exception [EclipseLink-4003] (Eclipse Persistence Services - 2.3.2.v20111125-r10461): org.eclipse.persistence.exceptions.DatabaseException
Exception Description: Configuration error. Class [org.apache.derby.jdbc.EmbeddedDriver] not found.
Exception [EclipseLink-4003] (Eclipse Persistence Services - 2.3.2.v20111125-r10461): org.eclipse.persistence.exceptions.DatabaseException
Exception Description: Configuration error. Class [org.apache.derby.jdbc.EmbeddedDriver] not found.
javax.persistence.jdbc.driver defines the protocol that shall be used to access the database.
You need to set it like this, if you want to access a remote/local derby network server:
<property name="javax.persistence.jdbc.driver" value="jdbc:derby://localhost:1527/my_schema " />
Where 1527 is the port of your NetworkServer.
And my_schema is your database schema.
If you don't have schema yet, use ;create=true to create it:
jdbc:derby://localhost:1527/my_schema;create=true
You may want to take a look at the Getting Started Guide.
Side note:
Class [org.apache.derby.jdbc.EmbeddedDriver] not found.
This tells you that not all jars needed by derby are present in the classpath(in your comment you state, that this is the case). If you get any such exception, make sure that all jars are actually in the classpath.

JBoss7 and Eclipselink, No Persistence provider for EntityManager

I'm having a problem with JBoss 7.02.Final. I'm porting a project from JBoss5.1GA and (outside a fair amount of rewrites in the lookups to support EE6) I'm having a problem registering Eclipselink on the classpath. I've searched around and I see several posts saying this issue is fixed but I can't seem to find a working example.
There's a very high chance I'm doing something wrong as I'm new to EE6 development.
The ear is built as the following
- ProductionEE6
./lib/eclipselink2.*.jar
./lib/javax.persistence.jar
. . .
ProductionEJB.jar
. . .
Production.war
My persistence.xml is:
<?xml version="1.0" encoding="UTF-8"?>
<persistence version="2.0" xmlns="http://java.sun.com/xml/ns/persistence" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/persistence persistence_2_0.xsd">
<persistence-unit name="production" transaction-type="RESOURCE_LOCAL">
<provider>org.eclipse.persistence.jpa.PersistenceProvider</provider>
<non-jta-data-source>java:/ProductionDS</non-jta-data-source>
<class><!-- entities --></class>
<properties>
<property name="javax.persistence.jdbc.driver" value="org.h2.Driver"/>
<property name="eclipselink.target-server" value="JBoss"/>
<!-- A few other properties here -->
</properties>
</persistence-unit>
</persistence>
Everything boots up fine, I see the datasources, I get through security (through a custom DatabaseModule so my data-sources are definitely fine) and when I finally make a call to an EJB I see the following errors:
Caused by: javax.persistence.PersistenceException: No Persistence provider for EntityManager named production
at javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:69) [hibernate-jpa-2.0-api-1.0.1.Final.jar:1.0.1.Final]
at javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:47) [hibernate-jpa-2.0-api-1.0.1.Final.jar:1.0.1.Final]
at com.danielbchapman.production.entity.DelegateInstance.getEm(DelegateInstance.java:67) [ProductionEJB.jar:]
at com.danielbchapman.production.entity.EntityInstance.getEm(EntityInstance.java:39) [ProductionEJB.jar:]
at com.danielbchapman.production.beans.OptionsDao.<init>(OptionsDao.java:20) [ProductionEJB.jar:]
... 94 more
In regards to that, I'm not using a JTA DataSource so I've been handling the transactions manually. This call is the "DelegateInstance" above with the following code: (where persistenceUnitId is "production" in this case.)
/**
* #return an instance of the entity manager if it isn't there.
*/
public EntityManager getEm()
{
if(manager == null)
{
manager = Persistence.createEntityManagerFactory(getPersistenceUnitId())
.createEntityManager();
}
return manager;
}
What worries me the most is seeing this on the stack:
[hibernate-jpa-2.0-api-1.0.1.Final.jar:1.0.1.Final] Obviously I'm not loading EclipseLink properly. I'm running out of ideas here so if anyone can help I'd be very grateful.
EclipseLink 2.4 will now work with JBoss AS 7.1.1 - tested and working - hth
According to http://dev.dzhokanov.com/?p=8:
Furthermore, this forum thread came to support my hypothesis – http://community.jboss.org/message/623759#623759
In the thread Scott Marlow (JBoss 7/JPA lead developer) admits:
“You are not the only one that wants to use EclipseLink but that is not ready yet. “
As far as I understand, there are some incompatibilities in the EclipseLink JPA implementation that need to be adjusted in order to be compatible with JBoss 7. So, I don’t expect Jboss 7-EclipseLink support soon.
So it might be the case that this is currently not possible at all. But if you find a way, I'd be very interested in it.