Known Issues
When you define a persistence unit with com.logitags.cibet.sensor.jpa.Provider as PersistenceProvider with Hibernate as native PersistenceProvider in JBoss 7 you may get a NullPointerException when using an EntityManager from this unit:
java.lang.NullPointerException at org.hibernate.engine.transaction.internal.jta.JtaStatusHelper.getStatus(JtaStatusHelper.java:73)This can be avoided by setting property <property name="hibernate.transaction.jta.platform" value="org.hibernate.service.jta.platform.internal.JBossAppServerJtaPlatform" /> in the persistence unit
When you define a persistence unit with com.logitags.cibet.sensor.jpa.Provider as PersistenceProvider in JBoss-as 7.1.1 you may get the following exception during deployment:
javax.persistence.PersistenceException: JBAS011466: PersistenceProvider 'com.logitags.cibet.sensor.jpa.Provider' not found at org.jboss.as.jpa.processor.PersistenceUnitDeploymentProcessor.lookupProvider(PersistenceUnitDeploymentProcessor.java:555) at org.jboss.as.jpa.processor.PersistenceUnitDeploymentProcessor.deployPersistenceUnit(PersistenceUnitDeploymentProcessor.java:295) at org.jboss.as.jpa.processor.PersistenceUnitDeploymentProcessor.addPuService(PersistenceUnitDeploymentProcessor.java:258) at org.jboss.as.jpa.processor.PersistenceUnitDeploymentProcessor.handleWarDeployment(PersistenceUnitDeploymentProcessor.java:194) at org.jboss.as.jpa.processor.PersistenceUnitDeploymentProcessor.deploy(PersistenceUnitDeploymentProcessor.java:118) at org.jboss.as.server.deployment.DeploymentUnitPhaseService.start(DeploymentUnitPhaseService.java:113) [jboss-as-server-7.1.1.Final.jar:7.1.1.Final]This seems to be a bug in JBoss-as 7.1.1. Change to JBoss-eap 6.3
Failed to start service jboss.persistenceunit."cibetArq1.war#Cibet": org.jboss.msc.service.StartException in service jboss.persistenceunit."cibetArq1.war#Cibet": java.lang.NoClassDefFoundError: org/apache/shiro/mgt/DefaultSecurityManager
The Hibernate/JBoss PersistenceUnitService scans the cibet.jar file for JPA annotations and the JBoss classloader loads all classes that it finds in the jar. Sometimes you don't need these classes, for example the Shiro classes if you don't use Shiro.
To avoid these errors use the <class> tags instead of the <jar-file> tag:
<class>com.logitags.cibet.actuator.archive.Archive</class> <class>com.logitags.cibet.actuator.archive.IntegrityCheck</class> <class>com.logitags.cibet.actuator.archive.IntegrityCheckResult</class> <class>com.logitags.cibet.actuator.dc.DcControllable</class> <class>com.logitags.cibet.actuator.lock.LockedObject</class> <class>com.logitags.cibet.resource.Resource</class> <class>com.logitags.cibet.resource.ResourceParameter</class> <class>com.logitags.cibet.core.EventResult</class>
This is a bug we observed in Glassfish 3.1.2.2. See Glassfish issue 15888 and Google for more explanations. There are two workarounds:
Both workarounds may lead to ClassNotFoundExceptions because now all Cibet classes are loaded and scanned for CDI annotations. If you do not use Apache Shiro for example, there will be some Exceptions about Shiro classes not being found. These ClassNotFoundExceptions can be ignored.
You have to add <mapping-file>orm-openjpa.xml</mapping-file> to the cibet persistence unit in your persistence.xml. See my post in the OpenJPA mailing list for more explanations about this problem.
If EJB service requests are denied a DeniedEjbException is thrown which is a subclass of DeniedException. Some EJB containers do not correctly recognize this exception as an ApplicationException and roll back the transaction. To prevent this, add an ejb-jar.xml file into the META-INF directory with the following content:
<?xml version="1.0" encoding="UTF-8"?> <ejb-jar xmlns = "http://java.sun.com/xml/ns/javaee" version = "3.1" xmlns:xsi = "http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation = "http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/ejb-jar_3_1.xsd"> <assembly-descriptor> <application-exception> <exception-class> com.logitags.cibet.actuator.common.DeniedEjbException </exception-class> <rollback>false</rollback> </application-exception> </assembly-descriptor> </ejb-jar>
If EJB service requests are postponed by a dual control actuator a PostponedEjbException is thrown which is a subclass of PostponedException. Some EJB containers do not correctly recognize this exception as an ApplicationException and roll back the transaction. To prevent this, add an ejb-jar.xml file into the META-INF directory with the following content:
<?xml version="1.0" encoding="UTF-8"?> <ejb-jar xmlns = "http://java.sun.com/xml/ns/javaee" version = "3.1" xmlns:xsi = "http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation = "http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/ejb-jar_3_1.xsd"> <assembly-descriptor> <application-exception> <exception-class> com.logitags.cibet.actuator.common.PostponedEjbException </exception-class> <rollback>false</rollback> </application-exception> </assembly-descriptor> </ejb-jar>
This is a rare error observed with Glassfish but it is not excluded that it could occur also with other application servers. The situation is as follows: A Spring application that uses Cibet with custom aspects defined in an aop.xml is deployed. The Spring ContextLoaderListener is defined in web.xml as listener:
<listener> <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class> </listener>
The custom aspect defines a pointcut for a managed object, for example an EJB. The pointcut uses wildcards to intercept all methods of that object:
<aspectj> <aspects> <concrete-aspect name="com.xyz.tracing.EJBAspectTest" extends="com.logitags.cibet.sensor.pojo.CustomAspect"> <pointcut name="cibetIntercept" expression="target(com.logitags.cibet.helper.arquillian.EjbService) && execution(public * *(..))"/> </concrete-aspect> </aspects> <weaver options="-verbose"> </weaver> </aspectj>
Now Glassfish uses byte code instrumentation on EJBs to add additional methods and during deployment such methods may be called. The custom aspect will be applied for the object already during registering of the managed object in the application server. Applying a Cibet custom aspect leads to initialisation of Cibet and the exception
java.lang.NullPointerException at com.logitags.cibet.actuator.springsecurity.SpringSecurityActuator.checkUrlAccessExpression(SpringSecurityActuator.java:654)The reason is that at this point in time Spring has not been initialised and the Spring context has not been injected in SpringSecurityActuator. In Glassfish, the sequence of initialisation during startup is like this:
1. registering of aspects
2. registering of managed objects like EJBs
3. Initialisation of Spring context
It is therefore necessary to define custom aspects in a way that they are not executed before Spring has been initialised. This can be done for example by declaring more concrete methods that shall be intercepted:
<aspectj> <aspects> <concrete-aspect name="com.xyz.tracing.EJBAspectTest" extends="com.logitags.cibet.sensor.pojo.CustomAspect"> <pointcut name="cibetIntercept" expression="target(com.logitags.cibet.helper.arquillian.EjbService) && execution(public String logThis*(String))"/> </concrete-aspect> </aspects> <weaver options="-verbose"> </weaver> </aspectj>
OpenEjb auto-detects some known persistence providers like Eclipselink and provisions it with information about the application server platform. The Cibet persistence provider is not automatically detected, therefore this information is not provided and the Eclipselink provider assumes it were running on a resource-local platform
This can be avoided by setting property <property name="eclipselink.target-server" value="org.apache.openejb.jpa.integration.eclipselink.OpenEJBServerPlatform" /> in the persistence unit