Jboss 7 not Creating Persistence Unit - java

I use Jboss 7 , hibernate 4.1.5 FINAL and Spring 3.1.2 for my application
Caused by: javax.persistence.PersistenceException: [PersistenceUnit: Virtuoso] Unable to build EntityManagerFactory
at org.hibernate.ejb.Ejb3Configuration.buildEntityManagerFactory(Ejb3Configuration.java:915)
at org.hibernate.ejb.Ejb3Configuration.buildEntityManagerFactory(Ejb3Configuration.java:890)
at org.hibernate.ejb.HibernatePersistence.createContainerEntityManagerFactory(HibernatePersistence.java:74)
at org.jboss.as.jpa.service.PersistenceUnitServiceImpl.createContainerEntityManagerFactory(PersistenceUnitServiceImpl.java:162)
at org.jboss.as.jpa.service.PersistenceUnitServiceImpl.start(PersistenceUnitServiceImpl.java:85)
at org.jboss.msc.service.ServiceControllerImpl$StartTask.startService(ServiceControllerImpl.java:1811) [jboss-msc-1.0.2.GA.jar:1.0.2.GA]
at org.jboss.msc.service.ServiceControllerImpl$StartTask.run(ServiceControllerImpl.java:1746) [jboss-msc-1.0.2.GA.jar:1.0.2.GA]
... 3 more
Caused by: org.hibernate.service.spi.ServiceException: Unable to create requested service [org.hibernate.service.jdbc.connections.spi.ConnectionProvider]
at org.hibernate.service.internal.AbstractServiceRegistryImpl.createService(AbstractServiceRegistryImpl.java:186)
at org.hibernate.service.internal.AbstractServiceRegistryImpl.initializeService(AbstractServiceRegistryImpl.java:150)
at org.hibernate.service.internal.AbstractServiceRegistryImpl.getService(AbstractServiceRegistryImpl.java:131)
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:75)
at org.hibernate.service.internal.AbstractServiceRegistryImpl.initializeService(AbstractServiceRegistryImpl.java:159)
at org.hibernate.service.internal.AbstractServiceRegistryImpl.getService(AbstractServiceRegistryImpl.java:131)
at org.hibernate.cfg.SettingsFactory.buildSettings(SettingsFactory.java:71)
at org.hibernate.cfg.Configuration.buildSettingsInternal(Configuration.java:2277)
at org.hibernate.cfg.Configuration.buildSettings(Configuration.java:2273)
at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1742)
at org.hibernate.ejb.EntityManagerFactoryImpl.<init>(EntityManagerFactoryImpl.java:94)
at org.hibernate.ejb.Ejb3Configuration.buildEntityManagerFactory(Ejb3Configuration.java:905)
... 9 more
Caused by: org.hibernate.HibernateException: Could not instantiate connection provider [org.hibernate.ejb.connection.InjectedDataSourceConnectionProvider]
at org.hibernate.service.jdbc.connections.internal.ConnectionProviderInitiator.instantiateExplicitConnectionProvider(ConnectionProviderInitiator.java:192)
at org.hibernate.service.jdbc.connections.internal.ConnectionProviderInitiator.initiateService(ConnectionProviderInitiator.java:114)
at org.hibernate.service.jdbc.connections.internal.ConnectionProviderInitiator.initiateService(ConnectionProviderInitiator.java:54)
at org.hibernate.service.internal.StandardServiceRegistryImpl.initiateService(StandardServiceRegistryImpl.java:69)
at org.hibernate.service.internal.AbstractServiceRegistryImpl.createService(AbstractServiceRegistryImpl.java:176)
... 22 more
Caused by: java.lang.ClassCastException: org.hibernate.ejb.connection.InjectedDataSourceConnectionProvider cannot be cast to org.hibernate.service.jdbc.connections.spi.ConnectionProvider
at org.hibernate.service.jdbc.connections.internal.ConnectionProviderInitiator.instantiateExplicitConnectionProvider(ConnectionProviderInitiator.java:189)
... 26 more
jboss-deployment-structure.xml
<jboss-deployment-structure>
<deployment>
<exclusions>
<module name="org.hibernate"></module>
</exclusions>
</deployment>
</jboss-deployment-structure>
persistence.xml
<?xml version="1.0" encoding="UTF-8"?>
<persistence version="1.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 http://java.sun.com/xml/ns/persistence/persistence_1_0.xsd">
<persistence-unit name="Virtuoso" transaction-type="RESOURCE_LOCAL" >
<provider>org.hibernate.ejb.HibernatePersistence</provider>
<non-jta-data-source>java:jboss/datasources/MySqlDS</non-jta-data-source>
</persistence-unit>
</persistence>
i am not knowing where i am going wrong..My Persistent unit not getting started.

Since you're attempting to use Hibernate 4.x packaged in your application, you should instead be setting the jboss.as.jpa.providerModule property to application in your persistence.xml configuration file.
You're better off replacing the Hibernate 4.0 module in AS7, with a newer version though. That way, you dont need to package a JPA provider in your application.

ejb3 - persistence jar was present in my lib folder which was conflicting with mu hibernate jpa 2.0 jar . so i added scope provided in my pom.xml . after that class cast exception went away.

Related

JBOSS/Wildfly 21 org.jboss.msc.service.StartException in service jboss.persistenceunit

We are migrating up to Wildfly 21 from 8 & 9 and I am having some issues getting the persistence unit working. Here is the full error:
13:47:29,524 ERROR [org.jboss.msc.service.fail] (ServerService Thread Pool -- 78) MSC000001: Failed to start service jboss.persistenceunit.”projectName.war#ertDatasource": org.jboss.msc.service.StartException in service jboss.persistenceunit."projectName.war#ertDatasource": java.lang.AbstractMethodError
at org.jboss.as.jpa.service.PersistenceUnitServiceImpl$1$1.run(PersistenceUnitServiceImpl.java:198)
at org.jboss.as.jpa.service.PersistenceUnitServiceImpl$1$1.run(PersistenceUnitServiceImpl.java:128)
at java.security.AccessController.doPrivileged(Native Method)
at org.wildfly.security.manager.WildFlySecurityManager.doChecked(WildFlySecurityManager.java:659)
at org.jboss.as.jpa.service.PersistenceUnitServiceImpl$1.run(PersistenceUnitServiceImpl.java:213)
at org.jboss.threads.ContextClassLoaderSavingRunnable.run(ContextClassLoaderSavingRunnable.java:35)
at org.jboss.threads.EnhancedQueueExecutor.safeRun(EnhancedQueueExecutor.java:1990)
at org.jboss.threads.EnhancedQueueExecutor$ThreadBody.doRunTask(EnhancedQueueExecutor.java:1486)
at org.jboss.threads.EnhancedQueueExecutor$ThreadBody.run(EnhancedQueueExecutor.java:1377)
at java.lang.Thread.run(Thread.java:748)
at org.jboss.threads.JBossThread.run(JBossThread.java:513)
Caused by: java.lang.AbstractMethodError
at org.hibernate.internal.SessionFactoryImpl.<init>(SessionFactoryImpl.java:276)
at org.hibernate.boot.internal.SessionFactoryBuilderImpl.build(SessionFactoryBuilderImpl.java:467)
at org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl.build(EntityManagerFactoryBuilderImpl.java:1250)
at org.jboss.as.jpa.hibernate5.TwoPhaseBootstrapImpl.build(TwoPhaseBootstrapImpl.java:44)
at org.jboss.as.jpa.service.PersistenceUnitServiceImpl$1$1.run(PersistenceUnitServiceImpl.java:170)
... 10 more
13:47:29,587 ERROR [org.jboss.as.controller.management-operation] (Controller Boot Thread) WFLYCTL0013: Operation ("deploy") failed - address: ([("deployment" => "projectName.war")]) - failure description: {"WFLYCTL0080: Failed services" => {"jboss.persistenceunit.\"projectName.war#ertDatasource\"" => "java.lang.AbstractMethodError
Caused by: java.lang.AbstractMethodError"}}
So, some issue starting the persistence unit.
Here is my persistence.xml
<persistence 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 http://java.sun.com/xml/ns/persistence/persistence_2_0.xsd"
version="2.0">
<persistence-unit name="ertDatasource">
<provider>org.hibernate.jpa.HibernatePersistenceProvider</provider>
<jta-data-source>java:jboss/datasources/ERT</jta-data-source>
<properties>
<property name="hibernate.ejb.naming_strategy" value="org.hibernate.cfg.ImprovedNamingStrategy"/>
<property name="hibernate.enable_lazy_load_no_trans" value="true"/>
</properties>
</persistence-unit>
</persistence>
I forget which version of Wildfly started this trend, but they are shipping with the Jakarta Persistence libs now. As is default I have the jakarta.persistence-api-2.2.3.jar as well as the module.xml files located in the wildfly/modules/system/layers/base/javax/persistence/api/main folder
Here is the content of the module.xml:
<?xml version="1.0" encoding="UTF-8"?>
<module name="javax.persistence.api" xmlns="urn:jboss:module:1.7">
<dependencies>
<!-- PersistenceUnitInfo needs javax.sql.DataSource -->
<module name="javax.api" export="true"/>
</dependencies>
<resources>
<resource-root path="jakarta.persistence-api-2.2.3.jar"/>
</resources>
</module>
Here is all the pom.xml's data on hibernate.
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-jpamodelgen</artifactId>
<version>4.3.9.Final</version>
<scope>compile</scope>
</dependency>
So, that is likely where things went wrong, am I missing some dependencies, or should I just change the hibernate-jpamodelgen's scope to provided?
In the WEB-INF/lib i have:
hibernate-commons-annotations-4.0.4.Final, hibernate-jpamodelgen-4.3.9.Final, and hibernate-validator-5.0.1.Final
Wondering what might be misconfigured here?

Jboss-as7 can't find oracle driver despite it being deployed

I'm using hibernate to connect to a database from a web application in jboss-as7. This is my persistence.xml:
<?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 http://java.sun.com/xml/ns/persistence/persistence_2_0.xsd">
<persistence-unit name="HBOService">
<exclude-unlisted-classes>false</exclude-unlisted-classes>
<properties>
<property name="hibernate.connection.driver_class" value="oracle.jdbc.OracleDriver"/>
<property name="hibernate.connection.url" value="jdbc:oracle:thin:#localhost:1521:XE"/>
<property name="hibernate.connection.username" value="hboweb"/>
<property name="hibernate.connection.password" value="****"/>
</properties>
I also deployed ojdb6.jar in my jboss server, as a matter of fact I can see it's listed in the Manage Deployements tab of the admin console.
Still I get this message when trying to start the application:
Caused by: javax.persistence.PersistenceException: [PersistenceUnit: HBOService] Unable to build EntityManagerFactory
at org.hibernate.ejb.Ejb3Configuration.buildEntityManagerFactory(Ejb3Configuration.java:914)
at org.hibernate.ejb.Ejb3Configuration.buildEntityManagerFactory(Ejb3Configuration.java:889)
at org.hibernate.ejb.HibernatePersistence.createContainerEntityManagerFactory(HibernatePersistence.java:73)
at org.jboss.as.jpa.service.PersistenceUnitServiceImpl.createContainerEntityManagerFactory(PersistenceUnitServiceImpl.java:162)
at org.jboss.as.jpa.service.PersistenceUnitServiceImpl.start(PersistenceUnitServiceImpl.java:85)
at org.jboss.msc.service.ServiceControllerImpl$StartTask.startService(ServiceControllerImpl.java:1811) [jboss-msc-1.0.2.GA.jar:1.0.2.GA]
at org.jboss.msc.service.ServiceControllerImpl$StartTask.run(ServiceControllerImpl.java:1746) [jboss-msc-1.0.2.GA.jar:1.0.2.GA]
... 3 more
Caused by: org.hibernate.HibernateException: Specified JDBC Driver oracle.jdbc.OracleDriver class not found
at org.hibernate.service.jdbc.connections.internal.DriverManagerConnectionProviderImpl.configure(DriverManagerConnectionProviderImpl.java:104)
at org.hibernate.service.internal.StandardServiceRegistryImpl.configureService(StandardServiceRegistryImpl.java:75)
at org.hibernate.service.internal.AbstractServiceRegistryImpl.initializeService(AbstractServiceRegistryImpl.java:159)
at org.hibernate.service.internal.AbstractServiceRegistryImpl.getService(AbstractServiceRegistryImpl.java:131)
at org.hibernate.engine.jdbc.internal.JdbcServicesImpl.buildJdbcConnectionAccess(JdbcServicesImpl.java:234)
at org.hibernate.engine.jdbc.internal.JdbcServicesImpl.configure(JdbcServicesImpl.java:91)
at org.hibernate.service.internal.StandardServiceRegistryImpl.configureService(StandardServiceRegistryImpl.java:75)
at org.hibernate.service.internal.AbstractServiceRegistryImpl.initializeService(AbstractServiceRegistryImpl.java:159)
at org.hibernate.service.internal.AbstractServiceRegistryImpl.getService(AbstractServiceRegistryImpl.java:131)
at org.hibernate.cfg.SettingsFactory.buildSettings(SettingsFactory.java:71)
at org.hibernate.cfg.Configuration.buildSettingsInternal(Configuration.java:2270)
at org.hibernate.cfg.Configuration.buildSettings(Configuration.java:2266)
at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1735)
at org.hibernate.ejb.EntityManagerFactoryImpl.<init>(EntityManagerFactoryImpl.java:84)
at org.hibernate.ejb.Ejb3Configuration.buildEntityManagerFactory(Ejb3Configuration.java:904)
... 9 more
Caused by: java.lang.ClassNotFoundException: oracle.jdbc.OracleDriver from [Module "org.hibernate:main" from local module loader #778f9ba9 (roots: C:\Users\Developer1\Desktop\Development\Servers\jboss-as-7.1.1.Final\modules)]
at org.jboss.modules.ModuleClassLoader.findClass(ModuleClassLoader.java:190)
at org.jboss.modules.ConcurrentClassLoader.performLoadClassUnchecked(ConcurrentClassLoader.java:468)
at org.jboss.modules.ConcurrentClassLoader.performLoadClassChecked(ConcurrentClassLoader.java:456)
at org.jboss.modules.ConcurrentClassLoader.performLoadClass(ConcurrentClassLoader.java:398)
at org.jboss.modules.ConcurrentClassLoader.loadClass(ConcurrentClassLoader.java:120)
at java.lang.Class.forName0(Native Method) [rt.jar:1.7.0_79]
at java.lang.Class.forName(Class.java:191) [rt.jar:1.7.0_79]
at org.hibernate.internal.util.ReflectHelper.classForName(ReflectHelper.java:192)
at org.hibernate.service.jdbc.connections.internal.DriverManagerConnectionProviderImpl.configure(DriverManagerConnectionProviderImpl.java:101)
... 23 more
Is oracle.jdb.driver actually in the classpath? How can I know?
With Jboss-server the jdbc driver will be loaded from its module class loader, in your case it will scan and load class from the path
C:\Users\Developer1\Desktop\Development\Servers\jboss-as-7.1.1.Final\modules
Becaused oracle.jdb.driver is included in the jar file jdbc-oracle.jar or ojdbc6.jar so you can try to do a file search inside above module folder. If you can not find the file, you can add new module to your server according to below guide
1)Downloaded ojdbc6-11.jar and placed it inside the folder $JBOSS_HOME/modules/com/oracle/ojdbc6/main
2)Created the file module.xml under $JBOSS_HOME/modules/com/oracle/ojdbc6/main and this is the content of the file
<module xmlns="urn:jboss:module:1.0" name="com.oracle.ojdbc6">
<resources>
<resource-root path="ojdbc6.jar"/>
</resources>
<dependencies>
<module name="javax.api"/>
</dependencies>
</module>
3) Add a dependency on the com.oracle.ojdbc6 module using a MANIFEST.MF file in the WEB-INF lib dir with contents:
Dependencies: com.oracle.ojdbc6
This can be created using the following Maven plugin configuration:
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<configuration>
<archive>
<manifestEntries>
<Dependencies>com.oracle.ojdbc6
</Dependencies>
</manifestEntries>
</archive>
</configuration>
</plugin>
</plugins>

javax.persistence.PersistenceException: [PersistenceUnit: sapo] class or package not found

I know there are other questions about this topic in StackOverflow, I read them but I can't get rid off this error.
I'm deploying my web app in JBoss-as-7.1.1 Final. It's a Maven proyect.
When I go to sapo-ear, rigth click, run as, maven install, it says "build succesfull". Then I try to full publish it in JBoss and then it says:
23:59:26,009 ERROR [org.jboss.msc.service.fail] (MSC service thread 1-1) MSC00001: Failed to start service jboss.persistenceunit."SAPo-ear.ear/SAPo-ejb.jar#sapo": org.jboss.msc.service.StartException in service jboss.persistenceunit."SAPo-ear.ear/SAPo-ejb.jar#sapo": Failed to start service
at org.jboss.msc.service.ServiceControllerImpl$StartTask.run(ServiceControllerImpl.java:1767) [jboss-msc-1.0.2.GA.jar:1.0.2.GA]
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145) [rt.jar:1.7.0_80-ea]
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615) [rt.jar:1.7.0_80-ea]
at java.lang.Thread.run(Thread.java:745) [rt.jar:1.7.0_80-ea]
Caused by: javax.persistence.PersistenceException: [PersistenceUnit: sapo] class or package not found
at org.hibernate.ejb.Ejb3Configuration.addNamedAnnotatedClasses(Ejb3Configuration.java:1400)
at org.hibernate.ejb.Ejb3Configuration.addClassesToSessionFactory(Ejb3Configuration.java:1183)
at org.hibernate.ejb.Ejb3Configuration.configure(Ejb3Configuration.java:1047)
at org.hibernate.ejb.Ejb3Configuration.configure(Ejb3Configuration.java:692)
at org.hibernate.ejb.HibernatePersistence.createContainerEntityManagerFactory(HibernatePersistence.java:72)
at org.jboss.as.jpa.service.PersistenceUnitServiceImpl.createContainerEntityManagerFactory(PersistenceUnitServiceImpl.java:162)
at org.jboss.as.jpa.service.PersistenceUnitServiceImpl.start(PersistenceUnitServiceImpl.java:85)
at org.jboss.msc.service.ServiceControllerImpl$StartTask.startService(ServiceControllerImpl.java:1811) [jboss-msc-1.0.2.GA.jar:1.0.2.GA]
at org.jboss.msc.service.ServiceControllerImpl$StartTask.run(ServiceControllerImpl.java:1746) [jboss-msc-1.0.2.GA.jar:1.0.2.GA]
... 3 more
Caused by: java.lang.ClassNotFoundException: uy.edu.fing.tsi2.sapo.entities.Administrador from [Module "org.hibernate:main" from local module loader #beaed3 (roots: C:\Program Files\jboss-as-7.1.1.Final\modules)]
at org.jboss.modules.ModuleClassLoader.findClass(ModuleClassLoader.java:190)
at org.jboss.modules.ConcurrentClassLoader.performLoadClassUnchecked(ConcurrentClassLoader.java:468)
at org.jboss.modules.ConcurrentClassLoader.performLoadClassChecked(ConcurrentClassLoader.java:456)
at org.jboss.modules.ConcurrentClassLoader.performLoadClass(ConcurrentClassLoader.java:398)
at org.jboss.modules.ConcurrentClassLoader.loadClass(ConcurrentClassLoader.java:120)
at java.lang.Class.forName0(Native Method) [rt.jar:1.7.0_80-ea]
at java.lang.Class.forName(Class.java:278) [rt.jar:1.7.0_80-ea]
at org.hibernate.internal.util.ReflectHelper.classForName(ReflectHelper.java:170)
at org.hibernate.ejb.Ejb3Configuration.classForName(Ejb3Configuration.java:1317)
at org.hibernate.ejb.Ejb3Configuration.addNamedAnnotatedClasses(Ejb3Configuration.java:1389)
... 11 more
As far as I know, this could be caused by an inconsistence between persistence.xml and Adminstrador class.
Here is my persistence.xml
<?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
http://java.sun.com/xml/ns/persistence/persistence_2_0.xsd">
<persistence-unit name="sapo">
<jta-data-source>java:jboss/datasources/sapo</jta-data-source>
<class>sapo.entities.Administrador</class>
<class>sapo.entities.Almacen</class>
<class>sapo.entities.AtributoValor</class>
<class>sapo.entities.Comentario</class>
<class>sapo.entities.Estandar</class>
<class>sapo.entities.Mensaje</class>
<class>sapo.entities.Producto</class>
<class>sapo.entities.RolEnAlmacen</class>
<class>sapo.entities.CatCompleja</class>
<class>sapo.entities.ProductoGenerico</class>
<class>sapo.entities.TransaccionInterna</class>
<class>sapo.entities.TransaccionExterna</class>
<properties>
<!-- Properties for Hibernate -->
<property name="hibernate.hbm2ddl.auto" value="update" />
<property name="hibernate.show_sql" value="false" />
<property name="hibernate.dialect" value="org.hibernate.dialect.MySQLDialect" />
</properties>
</persistence-unit>
And this is my Administrador class
#Entity
public class Administrador extends Usuario {
public Administrador(){
}
public Administrador(String nick, String password, String nombre,
String mail, String direccion, Date fechaNacimiento,
String linkImagen) {
super(nick, password, nombre, mail, direccion, fechaNacimiento, linkImagen);
// TODO Auto-generated constructor stub
}
}
Usuario is an abstrac class
#Entity
#Inheritance(strategy=InheritanceType.TABLE_PER_CLASS)
public abstract class Usuario {
#Id
#GeneratedValue(strategy=GenerationType.TABLE)
#Basic(optional = false)
private Long id;
//attribs, Getters setters and other methods
}
The most strange is this line from jboss stack trace
java.lang.ClassNotFoundException: uy.edu.fing.tsi2.sapo.entities.Administrador
This directory was all changed to just sapo.entities.Administrador, the long path was from an old version. I deleted this old project and cloned it again from git, I also deleted all files from C:\Program Files\jboss-as-7.1.1.Final\standalone\deployments but stack trace keep throwing this old path.
My team mates are using the same configuration, cloned from the same git repository without any problem while I'm stacked with this.
Finally I solved it, it was a problem in maven project configuration in one of the pom.xml, we had some problems with group ids from artefact and parents.
I don't have the exact answer because my team mate was who solved it, I'll ask her and update this answer with more detail later.
If you have entries in your xml file as well as annotation for the corresponding class then sometime it cause problems. Try to remove one of both either annotation or xml entry for the corresponding class and then run again. Hope this helps.

Hibernate Weblogic 10.3.4 java.lang.NoSuchMethodError: javax/persistence/spi/PersistenceUnitInfo.getValidationMode()Ljavax/persistence/ValidationMode;

I'm running a weblogic 10.3.4 (Yes I know it a legacy version, but I'm not the one dictating the version...) on a Ubuntu 12.04 LTS.
When deploying a JPA (hibernate) webapp on the server I get
java.lang.NoSuchMethodError: javax/persistence/spi/PersistenceUnitInfo.getValidationMode()Ljavax/persistence/ValidationMode;
at org.hibernate.ejb.Ejb3Configuration.configure(Ejb3Configuration.java:629)
at org.hibernate.ejb.HibernatePersistence.createContainerEntityManagerFactory(HibernatePersistence.java:73)
at weblogic.deployment.BasePersistenceUnitInfoImpl.initializeEntityManagerFactory(BasePersistenceUnitInfoImpl.java:393)
at weblogic.deployment.BasePersistenceUnitInfoImpl.initializeEntityManagerFactory(BasePersistenceUnitInfoImpl.java:386)
at weblogic.deployment.BasePersistenceUnitInfoImpl.<init>(BasePersistenceUnitInfoImpl.java:158)
Truncated. see log file for complete stacktrace
Caused By: java.lang.NoSuchMethodError: javax/persistence/spi/PersistenceUnitInfo.getValidationMode()Ljavax/persistence/ValidationMode;
at org.hibernate.ejb.Ejb3Configuration.configure(Ejb3Configuration.java:629)
at org.hibernate.ejb.HibernatePersistence.createContainerEntityManagerFactory(HibernatePersistence.java:73)
at weblogic.deployment.BasePersistenceUnitInfoImpl.initializeEntityManagerFactory(BasePersistenceUnitInfoImpl.java:393)
at weblogic.deployment.BasePersistenceUnitInfoImpl.initializeEntityManagerFactory(BasePersistenceUnitInfoImpl.java:386)
at weblogic.deployment.BasePersistenceUnitInfoImpl.<init>(BasePersistenceUnitInfoImpl.java:158)
Truncated. see log file for complete stacktrace
I can see that MANY people have the same issue.
The official solution is found at http://docs.oracle.com/cd/E17904_01/web.1111/e13720/using_toplink.htm#EJBAD1309
Which tells me to add:
#Enable JPA 2.0 functionality on WebLogic Server 10.3.4
export PRE_CLASSPATH=%BEA_HOME%\modules\javax.persistence_1.0.0.0_2-0-0.jar;%BEA_HOME%\modules\com.oracle.jpa2support_1.0.0.0_2-0.jar
to WL_HOME/common/bin/commEnv.sh
This didn't work
My weblogic.xml is a following
<?xml version="1.0" encoding="UTF-8"?>
<weblogic-web-app xmlns="http://www.bea.com/ns/weblogic/90"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<container-descriptor>
<prefer-web-inf-classes>true</prefer-web-inf-classes>
</container-descriptor>
</weblogic-web-app>
I also tried many other versions there as, some have add issues with the above of e.g. java.lang.NoSuchMethodError: javax/persistence/spi/PersistenceUnitInfo.getValidationMode()Ljavax/persistence/ValidationMode
<?xml version="1.0" encoding="UTF-8"?>
<weblogic-web-app xmlns="http://www.bea.com/ns/weblogic/90" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<container-descriptor>
<prefer-application-packages>
<package-name>antlr.*</package-name>
<package-name>org.hibernate.*</package-name>
<package-name>javax.persistence.*</package-name>
</prefer-application-packages>
</container-descriptor>
That instead gives me:
weblogic.application.ModuleException: Failed to load webapp: 'administration-gui.war'
at weblogic.servlet.internal.WebAppModule.prepare(WebAppModule.java:393)
at weblogic.application.internal.flow.ScopedModuleDriver.prepare(ScopedModuleDriver.java:180)
at weblogic.application.internal.flow.ModuleListenerInvoker.prepare(ModuleListenerInvoker.java:199)
at weblogic.application.internal.flow.DeploymentCallbackFlow$1.next(DeploymentCallbackFlow.java:518)
at weblogic.application.utils.StateMachineDriver.nextState(StateMachineDriver.java:52)
Truncated. see log file for complete stacktrace
Caused By: weblogic.deployment.EnvironmentException: Error processing persistence unit Offer of module administration-gui.war: Error instantiating the Persistence Provider class org.hibernate.ejb.HibernatePersistence of the PersistenceUnit Offer: java.lang.ClassCastException: org.hibernate.ejb.HibernatePersistence
at weblogic.deployment.BasePersistenceUnitInfoImpl.getPersistenceProvider(BasePersistenceUnitInfoImpl.java:375)
at weblogic.deployment.BasePersistenceUnitInfoImpl.initializeEntityManagerFactory(BasePersistenceUnitInfoImpl.java:393)
at weblogic.deployment.BasePersistenceUnitInfoImpl.initializeEntityManagerFactory(BasePersistenceUnitInfoImpl.java:386)
at weblogic.deployment.BasePersistenceUnitInfoImpl.<init>(BasePersistenceUnitInfoImpl.java:158)
at weblogic.deployment.PersistenceUnitInfoImpl.<init>(PersistenceUnitInfoImpl.java:39)
Truncated. see log file for complete stacktrace
In my opinion, you have to remove:
<dependency>
<groupId>javax.persistence</groupId>
<artifactId>persistence-api</artifactId>
<version>1.0.2</version>
</dependency>
becouse probably you imported ibernate-jpa-2.0-api or ibernate-jpa-2.1-api, indirectly too.
This needs to be set as false:
<prefer-web-inf-classes>**false**</prefer-web-inf-classes>
if you're using:
<container-descriptor>
<prefer-application-packages>
<package-name>antlr.*</package-name>
<package-name>org.hibernate.*</package-name>
<package-name>javax.persistence.*</package-name>
</prefer-application-packages>
</container-descriptor>

Migrate EJB 2.1 from WebSphere 6.1 to JBoss EAP 6.1

I'm trying to migrate from WS 6.1 to JBoss EAP 6.1. I'm having a hard time trying to make the EJB 2.1 working in JBoss 6.1.
(Note : #GatewayEjbJndiName# is replaced at compile time by ant.)
This was the original ejb-jar.xml :
<?xml version="1.0" encoding="UTF-8"?>
<ejb-jar id="ejb-jar_ID" version="2.1" xmlns="http://java.sun.com/xml/ns/j2ee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/ejb-jar_2_1.xsd">
<display-name>ServerGateway</display-name>
<enterprise-beans>
<session id="Session_gateway">
<display-name>GatewayEJBSB</display-name>
<ejb-name>#GatewayEjbJndiName#</ejb-name>
<home>ca.company.qc.project.server.gateway.ejb.GatewayEJBRemoteHome</home>
<remote>ca.company.qc.project.server.gateway.ejb.GatewayEJBRemote</remote>
<ejb-class>ca.company.qc.project.server.gateway.ejb.GatewayEJBBean</ejb-class>
<session-type>Stateless</session-type>
<transaction-type>Container</transaction-type>
</session>
</enterprise-beans>
<assembly-descriptor>
<container-transaction>
<method>
<ejb-name>#GatewayEjbJndiName#</ejb-name>
<method-name>*</method-name>
</method>
<trans-attribute>Required</trans-attribute>
</container-transaction>
</assembly-descriptor>
</ejb-jar>
This is (after many hours of research) what i came up for JBoss EAP 6.1 (ejb-jar.xml) :
<?xml version="1.0" encoding="UTF-8"?>
<ejb-jar id="ejb-jar_ID" version="2.1" xmlns="http://java.sun.com/xml/ns/j2ee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/ejb-jar_2_1.xsd">
<display-name>ServerGateway</display-name>
<enterprise-beans>
<session id="Session_gateway">
<display-name>GatewayEJBSB</display-name>
<ejb-name>#GatewayEjbJndiName#</ejb-name>
<home>ca.company.qc.project.server.gateway.ejb.GatewayEJBRemoteHome</home>
<remote>ca.company.qc.project.server.gateway.ejb.GatewayEJBRemote</remote>
<ejb-class>ca.company.qc.project.server.gateway.ejb.GatewayEJBBean</ejb-class>
<session-type>Stateless</session-type>
<transaction-type>Container</transaction-type>
<ejb-ref>
<ejb-ref-name>ejb/projectGatewayEJB</ejb-ref-name>
<ejb-ref-type>Session</ejb-ref-type>
<home>ca.company.qc.project.server.gateway.ejb.GatewayEJBRemoteHome</home>
<remote>ca.company.qc.project.server.gateway.ejb.GatewayEJBRemote</remote>
</ejb-ref>
</session>
</enterprise-beans>
<assembly-descriptor>
<container-transaction>
<method>
<ejb-name>#GatewayEjbJndiName#</ejb-name>
<method-name>*</method-name>
</method>
<trans-attribute>Required</trans-attribute>
</container-transaction>
</assembly-descriptor>
</ejb-jar>
But every time is tried to start the JBoss server i have this error :
[org.jboss.as.ejb3.deployment.processors.EjbJndiBindingsDeploymentUnitProcessor] (MSC service thread 1-3) JNDI bindings for session bean named ProjectGatewayEJB in deployment unit subdeployment "GatewayEJBClientProject.jar" of deployment "Project.ear" are as follows:
java:global/Project/GatewayEJBClientProject/ProjectGatewayEJB!ca.company.qc.project.server.gateway.ejb.GatewayEJBRemote
java:app/GatewayEJBClientProject/ProjectGatewayEJB!ca.company.qc.project.server.gateway.ejb.GatewayEJBRemote
java:module/ProjectGatewayEJB!ca.company.qc.project.server.gateway.ejb.GatewayEJBRemote
java:jboss/exported/Project/GatewayEJBClientProject/ProjectGatewayEJB!ca.company.qc.project.server.gateway.ejb.GatewayEJBRemote
java:global/Project/GatewayEJBClientProject/ProjectGatewayEJB!ca.company.qc.project.server.gateway.ejb.GatewayEJBRemoteHome
java:app/GatewayEJBClientProject/ProjectGatewayEJB!ca.company.qc.project.server.gateway.ejb.GatewayEJBRemoteHome
java:module/ProjectGatewayEJB!ca.company.qc.project.server.gateway.ejb.GatewayEJBRemoteHome
java:jboss/exported/Project/GatewayEJBClientProject/ProjectGatewayEJB!ca.company.qc.project.server.gateway.ejb.GatewayEJBRemoteHome
10:54:41,858 ERROR [org.jboss.msc.service.fail] (MSC service thread 1-1) MSC00001: Failed to start service jboss.deployment.subunit."Project.ear"."ProjectWebApp.war".INSTALL: org.jboss.msc.service.StartException in service jboss.deployment.subunit."Project.ear"."ProjectWebApp.war".INSTALL: JBAS018733: Failed to process phase INSTALL of subdeployment "ProjectWebApp.war" of deployment "Project.ear"
at org.jboss.as.server.deployment.DeploymentUnitPhaseService.start(DeploymentUnitPhaseService.java:127) [jboss-as-server-7.2.0.Alpha1-redhat-4.jar:7.2.0.Alpha1-redhat-4]
at org.jboss.msc.service.ServiceControllerImpl$StartTask.startService(ServiceControllerImpl.java:1811) [jboss-msc-1.0.4.GA.jar:1.0.4.GA]
at org.jboss.msc.service.ServiceControllerImpl$StartTask.run(ServiceControllerImpl.java:1746) [jboss-msc-1.0.4.GA.jar:1.0.4.GA]
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145) [rt.jar:1.7.0_40]
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615) [rt.jar:1.7.0_40]
at java.lang.Thread.run(Thread.java:724) [rt.jar:1.7.0_40]
Caused by: org.jboss.as.server.deployment.DeploymentUnitProcessingException: JBAS014543: No EJB found with interface of type 'ca.company.qc.project.server.gateway.ejb.GatewayEJBRemoteHome' and name 'ServerGateway.jar#GatewayEJB' for binding java:module/env/ProjectGatewayEJBBean
at org.jboss.as.ejb3.deployment.processors.EjbInjectionSource.getResourceValue(EjbInjectionSource.java:97)
at org.jboss.as.ee.component.deployers.ModuleJndiBindingProcessor.addJndiBinding(ModuleJndiBindingProcessor.java:229)
at org.jboss.as.ee.component.deployers.ModuleJndiBindingProcessor.deploy(ModuleJndiBindingProcessor.java:120)
at org.jboss.as.server.deployment.DeploymentUnitPhaseService.start(DeploymentUnitPhaseService.java:120) [jboss-as-server-7.2.0.Alpha1-redhat-4.jar:7.2.0.Alpha1-redhat-4]
... 5 more
There is NO annotation anywhere in the EJBBean/EJBRemote/EJBRemoteBusiness/EJBRemoteHome classes. Because it's not supported in EJB 2.1 (for what i know).
I run the server using the "standalone-full.xml" config file. I also tried standalone-ha.xml with no success.
I really don't know what to do next..
There is topic on the JBoss community forum, I hope it'll help you to resolve problems.
Check the automated pluggable rule-based migration tool JBoss Windup. It covers EJB 2.1 to EJB 3 migration to some extent.
If you find something that is not covered, the Windup team will be happy to accept requests for enhancements at http://issues.jboss.org/WINDUPRULE.
To your question:
EJB 3 is available with standalone.xml, no need for standalone-ha which stands for High Availability, i.e. clustered solutions. full means full profile, as opposed to web profile, which is specified in Java EE 6 specification. See Java EE 6 Web profile vs Java EE 6 Full Platform .
I suggest to migrate to EJB 3 since Java EE 7 is here for some time and support for EJB 2.x will be dropped by most app servers.

Categories