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>
Related
sorry for long post
i have a web application made in java 1.6.0, jsf, richfaces3.3.3 and hibernate 3 ( DB oracle )
hibernate mapping made through *.hbm.xml files, and datasource configured on hibernate-service.xml
<?xml version="1.0" encoding="UTF-8"?>
<server>
<mbean code="org.jboss.hibernate.jmx.Hibernate"
name="jboss.har:service=HibernateFlowManager">
<!-- Datasource settings -->
<attribute name="SessionFactoryName">java:/hibernate/HibernateFlowManagerFactory</attribute>
<attribute name="DatasourceName">java:OracleDS</attribute>
<attribute name="Dialect">org.hibernate.dialect.Oracle9iDialect</attribute>
<!-- Second-level caching -->
<attribute name="SecondLevelCacheEnabled">false</attribute>
<attribute name="QueryCacheEnabled">false</attribute>
<attribute name="ReflectionOptimizationEnabled">true</attribute>
<!-- Batching -->
<attribute name="JdbcBatchSize">50</attribute>
<!-- Logging -->
<attribute name="ShowSqlEnabled">false</attribute>
</mbean>
</server>
i have an HibernateUtils class with sessionFactory
sessionFactory = (SessionFactory)new InitialContext().lookup("java:/hibernate/HibernateFlowManagerFactory");
all packed in app.ear and deployed into jboss 4.2.3.GA
the goal is use the app with java 1.8.0 and use wildfly 20
i installed wildfly 20 and configured a oracle datasource OracleDS and test is ok
i tried to deploy app.ear but i have the exception
20:26:18,094 ERROR [org.jboss.as.server] (management-handler-thread Caused by: java.lang.RuntimeException: WFLYSRV0177: Error getting reflective information for class myapp.appl.beans.MgrValidatorBean with ClassLoader ModuleClassLoader for Module \"deployment.app.ear.app.jar\" from Service Module Loader
Caused by: java.lang.NoClassDefFoundError: org/hibernate/Query
Caused by: java.lang.ClassNotFoundException: org.hibernate.Query from [Module \"deployment.app.ear.app.jar\" from Service Module Loader]",
"jboss.deployment.subunit.\"app.ear\".\"app.war\".POST_MODULE" => "WFLYSRV0153: Failed to process phase POST_MODULE of subdeployment \"app.war\" of deployment \"app.ear\"
Caused by: java.lang.NoClassDefFoundError: org/hibernate/Session
i don't want to change hibernate in the app so i builded app.ear and in META-INF folder i put file jboss-deployment-structure.xml like this
<jboss-deployment-structure xmlns="urn:jboss:deployment-structure:1.2">
<!-- Make sub deployments isolated by default, so they cannot see each others classes without a Class-Path entry -->
<ear-subdeployments-isolated>true</ear-subdeployments-isolated>
<!-- This corresponds to the top level deployment. For a war this is the war's module, for an ear -->
<!-- This is the top level ear module, which contains all the classes in the EAR's lib folder -->
<deployment>
<!-- exclude-subsystem prevents a subsystems deployment unit processors running on a deployment -->
<!-- which gives basically the same effect as removing the subsystem, but it only affects single deployment -->
<exclude-subsystems>
<subsystem name="org.hibernate" />
<subsystem name="org.hibernate.validator" />
</exclude-subsystems>
<!-- Exclusions allow you to prevent the server from automatically adding some dependencies -->
<exclusions>
<module name="org.hibernate" />
<module name="org.hibernate.validator" />
</exclusions>
</deployment>
</jboss-deployment-structure>
deploy and different exception
20:29:20,671 ERROR [org.jboss.as.controller.management-operation] (management-handler-thread - 1) WFLYCTL0013: Operation ("deploy") failed - address: ({"deployment" => "app.ear"}) - failure description: {
"WFLYCTL0080: Failed services" => {
"jboss.deployment.subunit.\"app.ear\".\"app.jar\".POST_MODULE" => "WFLYSRV0153: Failed to process phase POST_MODULE of subdeployment \"app.jar\" of deployment \"app.ear\"
Caused by: java.lang.RuntimeException: WFLYSRV0177: Error getting reflective information for class myapp.appl.beans.MgrValidatorBean with ClassLoader ModuleClassLoader for Module \"deployment.app.ear.app.jar\" from Service Module Loader
Caused by: java.lang.NoClassDefFoundError: org/hibernate/Query
Caused by: java.lang.ClassNotFoundException: org.hibernate.Query from [Module \"deployment.app.ear.app.jar\" from Service Module Loader]",
what approach i can use to achieve my goal ?
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?
My goal is to do CRUD operation using datanucleus, h2 database in java. but getting stuck in connecting PersistenceManagerFactory and persistence.xml
I have tried with different versions of datanucleus-core,h2database,datanucleus-api-jdo. I am currently referring to the official document: http://www.datanucleus.org/products/accessplatform/jdo/getting_started.html
Main code file
import javax.jdo.JDOHelper;
import javax.jdo.PersistenceManager;
import javax.jdo.PersistenceManagerFactory;
public class Main {
public static void main(String[] args)
{
PersistenceManagerFactory pmf = JDOHelper.getPersistenceManagerFactory("Tutorial");
PersistenceManager pm = pmf.getPersistenceManager();
pm.currentTransaction().begin();
try {
Users user = new Users();
user.setId(1);
user.setUser("himmat");
user.setEmail("xyz#gmail.com");
user.setMobileNo("7896585687");
pm.currentTransaction().commit();
}finally {
if(pm.currentTransaction().isActive())
{
pm.currentTransaction().rollback();
}
pm.close();
}
}
}
persistence.xml
<?xml version="1.0" encoding="UTF-8" ?>
<persistence 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" version="2.1">
<!-- JDO tutorial "unit" -->
<persistence-unit name="Tutorial">
<class>Users</class>
<exclude-unlisted-classes/>
<properties>
<property name="javax.jdo.option.ConnectionURL" value="jdbc:h2:mem:nucleus1"/>
<property name="javax.jdo.option.ConnectionUserName" value="sa"/>
<property name="javax.jdo.option.ConnectionPassword" value=""/>
<property name="datanucleus.schema.autoCreateAll" value="true"/>
</properties>
</persistence-unit>
</persistence>
error code
"C:\Program Files\Java\jdk1.8.0_211\bin\java.exe" "-javaagent:C:\Users\shyam\AppData\Local\JetBrains\IntelliJ IDEA 2019.1.3\lib\idea_rt.jar=56680:C:\Users\shyam\AppData\Local\JetBrains\IntelliJ IDEA 2019.1.3\bin" -Dfile.encoding=UTF-8 -classpath "C:\Program Files\Java\jdk1.8.0_211\jre\lib\charsets.jar;C:\Program Files\Java\jdk1.8.0_211\jre\lib\deploy.jar;C:\Program Files\Java\jdk1.8.0_211\jre\lib\ext\access-bridge-64.jar;C:\Program Files\Java\jdk1.8.0_211\jre\lib\ext\cldrdata.jar;C:\Program Files\Java\jdk1.8.0_211\jre\lib\ext\dnsns.jar;C:\Program Files\Java\jdk1.8.0_211\jre\lib\ext\jaccess.jar;C:\Program Files\Java\jdk1.8.0_211\jre\lib\ext\jfxrt.jar;C:\Program Files\Java\jdk1.8.0_211\jre\lib\ext\localedata.jar;C:\Program Files\Java\jdk1.8.0_211\jre\lib\ext\nashorn.jar;C:\Program Files\Java\jdk1.8.0_211\jre\lib\ext\sunec.jar;C:\Program Files\Java\jdk1.8.0_211\jre\lib\ext\sunjce_provider.jar;C:\Program Files\Java\jdk1.8.0_211\jre\lib\ext\sunmscapi.jar;C:\Program Files\Java\jdk1.8.0_211\jre\lib\ext\sunpkcs11.jar;C:\Program Files\Java\jdk1.8.0_211\jre\lib\ext\zipfs.jar;C:\Program Files\Java\jdk1.8.0_211\jre\lib\javaws.jar;C:\Program Files\Java\jdk1.8.0_211\jre\lib\jce.jar;C:\Program Files\Java\jdk1.8.0_211\jre\lib\jfr.jar;C:\Program Files\Java\jdk1.8.0_211\jre\lib\jfxswt.jar;C:\Program Files\Java\jdk1.8.0_211\jre\lib\jsse.jar;C:\Program Files\Java\jdk1.8.0_211\jre\lib\management-agent.jar;C:\Program Files\Java\jdk1.8.0_211\jre\lib\plugin.jar;C:\Program Files\Java\jdk1.8.0_211\jre\lib\resources.jar;C:\Program Files\Java\jdk1.8.0_211\jre\lib\rt.jar;C:\Users\shyam\eclipse-workspace\DemoJDO\target\classes;C:\Users\shyam\.m2\repository\org\datanucleus\datanucleus-api-jdo\5.2.1\datanucleus-api-jdo-5.2.1.jar;C:\Users\shyam\.m2\repository\org\datanucleus\datanucleus-core\5.2.1\datanucleus-core-5.2.1.jar;C:\Users\shyam\.m2\repository\org\datanucleus\datanucleus-rdbms\5.2.1\datanucleus-rdbms-5.2.1.jar;C:\Users\shyam\.m2\repository\javax\jdo\jdo-api\3.0.1\jdo-api-3.0.1.jar;C:\Users\shyam\.m2\repository\javax\transaction\jta\1.1\jta-1.1.jar" Main
Exception in thread "main" javax.jdo.JDOFatalUserException: A property named javax.jdo.PersistenceManagerFactoryClass must be specified, or a jar file with a META-INF/services/javax.jdo.PersistenceManagerFactory entry must be in the classpath, or a property named javax.jdo.option.PersistenceUnitName must be specified.
at javax.jdo.JDOHelper.getPersistenceManagerFactory(JDOHelper.java:861)
at javax.jdo.JDOHelper.getPersistenceManagerFactory(JDOHelper.java:1099)
at javax.jdo.JDOHelper.getPersistenceManagerFactory(JDOHelper.java:919)
at Main.main(Main.java:8)
NestedThrowablesStackTrace:
javax.jdo.JDOException: Errors were encountered when loading the MetaData for the persistence-unit "Tutorial". See the nested exceptions for details
at org.datanucleus.api.jdo.JDOPersistenceManagerFactory.initialiseMetaData(JDOPersistenceManagerFactory.java:807)
at org.datanucleus.api.jdo.JDOPersistenceManagerFactory.<init>(JDOPersistenceManagerFactory.java:600)
at org.datanucleus.api.jdo.JDOPersistenceManagerFactory.createPersistenceManagerFactory(JDOPersistenceManagerFactory.java:316)
at org.datanucleus.api.jdo.JDOPersistenceManagerFactory.getPersistenceManagerFactory(JDOPersistenceManagerFactory.java:225)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at javax.jdo.JDOHelper$16.run(JDOHelper.java:1965)
at java.security.AccessController.doPrivileged(Native Method)
at javax.jdo.JDOHelper.invoke(JDOHelper.java:1960)
at javax.jdo.JDOHelper.invokeGetPersistenceManagerFactoryOnImplementation(JDOHelper.java:1166)
at javax.jdo.JDOHelper.getPersistenceManagerFactory(JDOHelper.java:844)
at javax.jdo.JDOHelper.getPersistenceManagerFactory(JDOHelper.java:1099)
at javax.jdo.JDOHelper.getPersistenceManagerFactory(JDOHelper.java:919)
at Main.main(Main.java:8)
NestedThrowablesStackTrace:
Errors were encountered when loading the MetaData for the persistence-unit "Tutorial". See the nested exceptions for details
org.datanucleus.exceptions.NucleusUserException: Errors were encountered when loading the MetaData for the persistence-unit "Tutorial". See the nested exceptions for details
at org.datanucleus.metadata.MetaDataManagerImpl.loadPersistenceUnit(MetaDataManagerImpl.java:1124)
at org.datanucleus.api.jdo.JDOPersistenceManagerFactory.initialiseMetaData(JDOPersistenceManagerFactory.java:797)
at org.datanucleus.api.jdo.JDOPersistenceManagerFactory.<init>(JDOPersistenceManagerFactory.java:600)
at org.datanucleus.api.jdo.JDOPersistenceManagerFactory.createPersistenceManagerFactory(JDOPersistenceManagerFactory.java:316)
at org.datanucleus.api.jdo.JDOPersistenceManagerFactory.getPersistenceManagerFactory(JDOPersistenceManagerFactory.java:225)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at javax.jdo.JDOHelper$16.run(JDOHelper.java:1965)
at java.security.AccessController.doPrivileged(Native Method)
at javax.jdo.JDOHelper.invoke(JDOHelper.java:1960)
at javax.jdo.JDOHelper.invokeGetPersistenceManagerFactoryOnImplementation(JDOHelper.java:1166)
at javax.jdo.JDOHelper.getPersistenceManagerFactory(JDOHelper.java:844)
at javax.jdo.JDOHelper.getPersistenceManagerFactory(JDOHelper.java:1099)
at javax.jdo.JDOHelper.getPersistenceManagerFactory(JDOHelper.java:919)
at Main.main(Main.java:8)
Caused by: java.lang.NoClassDefFoundError: javax/jdo/AttributeConverter$UseDefault
at org.datanucleus.api.jdo.metadata.JDOAnnotationReader.processMemberAnnotations(JDOAnnotationReader.java:955)
at org.datanucleus.metadata.annotations.AbstractAnnotationReader.getMetaDataForClass(AbstractAnnotationReader.java:251)
at org.datanucleus.metadata.annotations.AnnotationManagerImpl.getMetaDataForClass(AnnotationManagerImpl.java:190)
at org.datanucleus.metadata.MetaDataManagerImpl.loadAnnotationsForClass(MetaDataManagerImpl.java:2818)
at org.datanucleus.metadata.MetaDataManagerImpl.loadPersistenceUnit(MetaDataManagerImpl.java:1095)
... 16 more
Caused by: java.lang.ClassNotFoundException: javax.jdo.AttributeConverter$UseDefault
at java.net.URLClassLoader.findClass(URLClassLoader.java:382)
at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:349)
at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
... 21 more
Nested Throwables StackTrace:
java.lang.NoClassDefFoundError: javax/jdo/AttributeConverter$UseDefault
at org.datanucleus.api.jdo.metadata.JDOAnnotationReader.processMemberAnnotations(JDOAnnotationReader.java:955)
at org.datanucleus.metadata.annotations.AbstractAnnotationReader.getMetaDataForClass(AbstractAnnotationReader.java:251)
at org.datanucleus.metadata.annotations.AnnotationManagerImpl.getMetaDataForClass(AnnotationManagerImpl.java:190)
at org.datanucleus.metadata.MetaDataManagerImpl.loadAnnotationsForClass(MetaDataManagerImpl.java:2818)
at org.datanucleus.metadata.MetaDataManagerImpl.loadPersistenceUnit(MetaDataManagerImpl.java:1095)
at org.datanucleus.api.jdo.JDOPersistenceManagerFactory.initialiseMetaData(JDOPersistenceManagerFactory.java:797)
at org.datanucleus.api.jdo.JDOPersistenceManagerFactory.<init>(JDOPersistenceManagerFactory.java:600)
at org.datanucleus.api.jdo.JDOPersistenceManagerFactory.createPersistenceManagerFactory(JDOPersistenceManagerFactory.java:316)
at org.datanucleus.api.jdo.JDOPersistenceManagerFactory.getPersistenceManagerFactory(JDOPersistenceManagerFactory.java:225)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at javax.jdo.JDOHelper$16.run(JDOHelper.java:1965)
at java.security.AccessController.doPrivileged(Native Method)
at javax.jdo.JDOHelper.invoke(JDOHelper.java:1960)
at javax.jdo.JDOHelper.invokeGetPersistenceManagerFactoryOnImplementation(JDOHelper.java:1166)
at javax.jdo.JDOHelper.getPersistenceManagerFactory(JDOHelper.java:844)
at javax.jdo.JDOHelper.getPersistenceManagerFactory(JDOHelper.java:1099)
at javax.jdo.JDOHelper.getPersistenceManagerFactory(JDOHelper.java:919)
at Main.main(Main.java:8)
Caused by: java.lang.ClassNotFoundException: javax.jdo.AttributeConverter$UseDefault
at java.net.URLClassLoader.findClass(URLClassLoader.java:382)
at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:349)
at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
... 21 more
Process finished with exit code 1
You can use properties instead of persistence.xml
Actually, I have done a similar example using properties. Another issue is maybe you are missing some dependencies, I am sharing pom.xml. try using that you maybe get the results. It is easy to do if you are using Maven. You also need to do enhance for that as displaying in official docs.
http://www.datanucleus.org/products/accessplatform/jdo/getting_started.html
For that, you need to follow
http://www.datanucleus.org/products/accessplatform_3_2/jdo/enhancer.html
POM.xml
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.automated</groupId>
<artifactId>DemoJDO</artifactId>
<version>1.0-SNAPSHOT</version>
<dependencies>
<dependency>
<groupId>org.datanucleus</groupId>
<artifactId>datanucleus-api-jdo</artifactId>
<version>5.2.1</version>
</dependency>
<dependency>
<groupId>com.h2database</groupId>
<artifactId>h2</artifactId>
<version>1.4.199</version>
</dependency>
<dependency>
<groupId>org.datanucleus</groupId>
<artifactId>datanucleus-rdbms</artifactId>
<version>5.2.1</version>
</dependency>
<dependency>
<groupId>javax.jdo</groupId>
<artifactId>jdo-api</artifactId>
<version>3.1</version>
</dependency>
<dependency>
<groupId>org.datanucleus</groupId>
<artifactId>datanucleus-core</artifactId>
<version>5.2.1</version>
</dependency>
<dependency>
<groupId>org.datanucleus</groupId>
<artifactId>javax.jdo</artifactId>
<version>3.2.0-m3</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.datanucleus</groupId>
<artifactId>datanucleus-maven-plugin</artifactId>
<version>3.2.0-m3</version>
<configuration>
<log4jConfiguration>${basedir}/log4j.properties</log4jConfiguration>
<verbose>true</verbose>
</configuration>
<executions>
<execution>
<phase>process-classes</phase>
<goals>
<goal>enhance</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
Code of the main file
public static void main(String[] args)
{
Properties properties = new Properties();
properties.setProperty("javax.jdo.PersistenceManagerFactoryClass",
"org.datanucleus.api.jdo.JDOPersistenceManagerFactory");
properties.setProperty("javax.jdo.option.ConnectionDriverName","org.h2.Driver");
properties.setProperty("javax.jdo.option.ConnectionURL","jdbc:h2:~/test");
properties.setProperty("javax.jdo.option.ConnectionUserName","sa");
properties.setProperty("javax.jdo.option.ConnectionPassword","");
properties.setProperty("datanucleus.schema.autoCreateAll","true");
PersistenceManagerFactory pmf = JDOHelper.getPersistenceManagerFactory(properties);
PersistenceManager pm = pmf.getPersistenceManager();
pm.currentTransaction().begin();
try {
//...
//You can use your logic here
//...
pm.currentTransaction().commit();
}finally {
if(pm.currentTransaction().isActive())
{
pm.currentTransaction().rollback();
}
pm.close();
}
}
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.
I’m using jBoss AS 7 to publish my various projects, and all of them use the Jersey API, so instead of deploying it in every project I wanted to create a module for it. For that, I created the folder JBOSS_HOME\modules\com\sun\Jersey\main and in this folder I placed the Jersey jar’s and the file module.xml:
<?xml version="1.0" encoding="UTF-8"?>
<module xmlns="urn:jboss:module:1.1" name="com.sun.jersey">
<properties>
<property name="jboss.api" value="private"/>
</properties>
<resources>
<resource-root path="jersey-bundle-1.12.jar"/>
<resource-root path="asm-3.1.jar"/>
<resource-root path="jackson-core-asl-1.9.2.jar"/>
<resource-root path="jackson-jaxrs-1.9.2.jar"/>
<resource-root path="jackson-mapper-asl-1.9.2.jar"/>
<resource-root path="jackson-xc-1.9.2.jar"/>
<resource-root path="jersey-client-1.12.jar"/>
<resource-root path="jersey-core-1.12.jar"/>
<resource-root path="jersey-json-1.12.jar"/>
<resource-root path="jersey-server-1.12.jar"/>
<resource-root path="jersey-servlet-1.12.jar"/>
<resource-root path="jettison-1.1.jar"/>
<resource-root path="jsr311-api-1.1.1.jar"/>
</resources>
<dependencies>
<module name="javax.api"/>
<module name="org.jboss.staxmapper"/>
<module name="org.jboss.as.controller"/>
<module name="org.jboss.as.server"/>
<module name="org.jboss.modules"/>
<module name="org.jboss.msc"/>
<module name="org.jboss.logging"/>
<module name="org.jboss.vfs"/>
</dependencies>
</module>
To prevent the use of the jBoss JAX-RS I removed from the file JBOSS_HOME\standalone\standalone.xml the following lines:
<subsystem xmlns="urn:jboss:domain:jaxrs:1.0"/>
<extension module="org.jboss.as.jaxrs"/>
In MyProjectEAR\META-INF folder I created the jboss-deployment-structure.xml file with the following structure:
<?xml version="1.0" encoding="UTF-8"?>
<jboss-deployment-structure xmlns="urn:jboss:deployment-structure:1.0">
<deployment>
<dependencies>
<module name="com.sun.jersey" slot="main" >
<imports>
<include path="META-INF/**"/>
<include path="**"/>
</imports>
</module>
</dependencies>
</deployment>
</jboss-deployment-structure>
My MyProject\webContent\web.xml file is this:
<?xml version="1.0" encoding="UTF-8"?>
<web-app id="WebApp_ID" version="2.5" xmlns="http://java.sun.com/xml/ns/javaee" 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/web-app_2_5.xsd">
<display-name> MyProject </display-name>
<servlet>
<description>
</description>
<servlet-name>Jersey Servlet</servlet-name>
<servlet-class>com.sun.jersey.spi.container.servlet.ServletContainer</servlet-class>
<init-param>
<description></description>
<param-name>javax.ws.rs.Application</param-name>
<param-value>com.MyProject.service.REST_Application</param-value>
</init-param>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>Jersey Servlet</servlet-name>
<url-pattern>/jaxrs/*</url-pattern>
</servlet-mapping>
</web-app>
My manifest file present at MyProject\webContent\META-INF\ MANIFEST.MF is this:
Manifest-Version: 1.0
Class-Path:
When i tried to deploy the project I got the following error:
12:12:11,804 INFO [org.jboss.as.server.deployment] (MSC service thread 1-5) JBAS015876: Starting deployment of "MyProjectEAR.ear"
12:12:11,852 INFO [org.jboss.as.server.deployment] (MSC service thread 1-7) JBAS015876: Starting deployment of "MyProject.war"
12:12:12,052 WARN [org.jboss.as.dependency.private] (MSC service thread 1-3) JBAS018567: Deployment "deployment.MyProjectEAR.ear" is using a private module ("com.sun.jersey:main") which may be changed or removed in future versions without notice.
12:12:12,054 WARN [org.jboss.as.dependency.private] (MSC service thread 1-3) JBAS018567: Deployment "deployment.MyProjectEAR.ear" is using a private module ("com.sun.jersey:main") which may be changed or removed in future versions without notice.
12:12:12,055 WARN [org.jboss.as.dependency.private] (MSC service thread 1-3) JBAS018567: Deployment "deployment.MyProjectEAR.ear" is using a private module ("com.sun.misc:main") which may be changed or removed in future versions without notice.
12:12:12,057 WARN [org.jboss.as.dependency.private] (MSC service thread 1-3) JBAS018567: Deployment "deployment.MyProjectEAR.ear" is using a private module ("com.sun.misc:main") which may be changed or removed in future versions without notice.
12:12:12,117 ERROR [org.jboss.msc.service.fail] (MSC service thread 1-7) MSC00001: Failed to start service jboss.deployment.subunit."MyProjectEAR.ear"."MyProject.war".POST_MODULE: org.jboss.msc.service.StartException in service jboss.deployment.subunit."MyProjectEAR.ear"."MyProject.war".POST_MODULE: Failed to process phase POST_MODULE of subdeployment "MyProject.war" of deployment "MyProjectEAR.ear"
at org.jboss.as.server.deployment.DeploymentUnitPhaseService.start(DeploymentUnitPhaseService.java:119) [jboss-as-server-7.1.0.Final.jar:7.1.0.Final]
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]
at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(Unknown Source) [rt.jar:1.6.0_30]
at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source) [rt.jar:1.6.0_30]
at java.lang.Thread.run(Unknown Source) [rt.jar:1.6.0_30]
Caused by: org.jboss.as.server.deployment.DeploymentUnitProcessingException: JBAS011093: Could not load component class com.sun.jersey.spi.container.servlet.ServletContainer
at org.jboss.as.ee.component.deployers.InterceptorAnnotationProcessor.processComponentConfig(InterceptorAnnotationProcessor.java:113)
at org.jboss.as.ee.component.deployers.InterceptorAnnotationProcessor.deploy(InterceptorAnnotationProcessor.java:54)
at org.jboss.as.server.deployment.DeploymentUnitPhaseService.start(DeploymentUnitPhaseService.java:113) [jboss-as-server-7.1.0.Final.jar:7.1.0.Final]
... 5 more
Caused by: java.lang.ClassNotFoundException: com.sun.jersey.spi.container.servlet.ServletContainer from [Module "deployment.MyProjectEAR.ear.MyProject.war:main" from Service Module Loader]
at org.jboss.modules.ModuleClassLoader.findClass(ModuleClassLoader.java:190) [jboss-modules.jar:1.1.1.GA]
at org.jboss.modules.ConcurrentClassLoader.performLoadClassUnchecked(ConcurrentClassLoader.java:468) [jboss-modules.jar:1.1.1.GA]
at org.jboss.modules.ConcurrentClassLoader.performLoadClassChecked(ConcurrentClassLoader.java:456) [jboss-modules.jar:1.1.1.GA]
at org.jboss.modules.ConcurrentClassLoader.performLoadClass(ConcurrentClassLoader.java:398) [jboss-modules.jar:1.1.1.GA]
at org.jboss.modules.ConcurrentClassLoader.loadClass(ConcurrentClassLoader.java:120) [jboss-modules.jar:1.1.1.GA]
at org.jboss.as.ee.component.deployers.InterceptorAnnotationProcessor.processComponentConfig(InterceptorAnnotationProcessor.java:111)
... 7 more
12:12:12,340 INFO [org.jboss.as.server] (DeploymentScanner-threads - 2) JBAS015870: Deploy of deployment "MyProjectEAR.ear" was rolled back with failure message {"JBAS014671: Failed services" => {"jboss.deployment.subunit.\"MyProjectEAR.ear\".\"MyProject.war\".POST_MODULE" => "org.jboss.msc.service.StartException in service jboss.deployment.subunit.\"MyProjectEAR.ear\".\"MyProject.war\".POST_MODULE: Failed to process phase POST_MODULE of subdeployment \"MyProject.war\" of deployment \"MyProjectEAR.ear\""}}
12:12:12,351 INFO [org.jboss.as.server.deployment] (MSC service thread 1-5) JBAS015877: Stopped deployment MyProject.war in 9ms
12:12:12,353 INFO [org.jboss.as.server.deployment] (MSC service thread 1-5) JBAS015877: Stopped deployment MyProjectEAR.ear in 12ms
12:12:12,355 INFO [org.jboss.as.controller] (DeploymentScanner-threads - 2) JBAS014774: Service status report
JBAS014777: Services which failed to start: service jboss.deployment.subunit."MyProjectEAR.ear"."MyProject.war".POST_MODULE: org.jboss.msc.service.StartException in service jboss.deployment.subunit."MyProjectEAR.ear"."MyProject.war".POST_MODULE: Failed to process phase POST_MODULE of subdeployment "MyProject.war" of deployment "MyProjectEAR.ear"
12:12:12,359 ERROR [org.jboss.as.server.deployment.scanner] (DeploymentScanner-threads - 1) {"JBAS014653: Composite operation failed and was rolled back. Steps that failed:" => {"Operation step-2" => {"JBAS014671: Failed services" => {"jboss.deployment.subunit.\"MyProjectEAR.ear\".\"MyProject.war\".POST_MODULE" => "org.jboss.msc.service.StartException in service jboss.deployment.subunit.\"MyProjectEAR.ear\".\"MyProject.war\".POST_MODULE: Failed to process phase POST_MODULE of subdeployment \"MyProject.war\" of deployment \"MyProjectEAR.ear\""}}}}
* EDIT : * If I place the Jersey API in JBOSS_HOME\modules\com\sun\jsf-impl\main and change the corresponding module.xml everything works ok. What does this location have different?
You need to specify a dependency on your module in the deployment.
META-INF\ MANIFEST.MF
Dependencies: com.sun.jersey
See also https://docs.jboss.org/author/display/AS71/Class+Loading+in+AS7
I needed to add
<subsystem xmlns="urn:jboss:domain:ee:1.0">
<global-modules>
<module name="com.sun.jersey" slot="main"/>
</global-modules>
</subsystem>
into the JBOSS_HOME\standalone\configuration\standalone.xml configuration file
There is already an answer, but I'd like to clarify the topic a little bit for future readers.
There are three places where to declare a JBoss module as a dependency of other deployments in JBoss 7 (EAP 6):
Global modules
MANIFEST.MF
jboss-deployment-structure.xml
In most cases, they are alternative.
1. Global modules
A global module is a module that JBoss Enterprise Application Platform 6 provides as a dependency to every application. Any module can be made global by adding it to the application server's list of global modules.
You can easily add global modules from the management console (see sources), or by editing the standalone.xml:
<subsystem xmlns="urn:jboss:domain:ee:1.0" >
<global-modules>
<!-- Add global modules here -->
<module name="org.javassist" slot="main" />
</global-modules>
</subsystem>
2. MANIFEST.MF
Add a Dependencies entry to the MANIFEST.MF file with a comma-separated list of dependency module names.
Dependencies: org.javassist, org.apache.velocity
If you are using Maven, you just need to configure some plugins.
e.g for ear.
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-ear-plugin</artifactId>
<configuration>
<version>6</version>
...
<defaultLibBundleDir>lib</defaultLibBundleDir>
<archive>
<manifestEntries>
<Dependencies>
com.foo.bar.test-module export optional
<!-- Beware of new lines! They can quietly break the conf -->
</Dependencies>
</manifestEntries>
</archive>
<modules>
...
</modules>
</configuration>
</plugin>
NOTE: using export makes the com.foo.bar.test-module visible for all the modules bundled in the ear.
3. jboss-deployment-structure.xml
jboss-deployment-structure.xml is a JBoss specific deployment descriptor that can be used to control class loading in a fine grained manner. It should be placed in the top level deployment, in META-INF (or WEB-INF for web deployments)
You can see from docs below how powerful it is compared to MANIFEST.MF.
For the simplest case, here's an example:
<?xml version="1.0" encoding="UTF-8"?>
<jboss-deployment-structure>
<ear-subdeployments-isolated>false</ear-subdeployments-isolated>
<deployment>
<dependencies>
<!-- Add modules here -->
<module name="com.foo.bar.test-module" export="true"/>
<module name="org.apache.axis.axis-jaxrpc" export="true"/>
</dependencies>
</deployment>
</jboss-deployment-structure>
NOTE 1: just like with MANIFEST.MF, setting export=true makes the com.foo.bar.test-module visible for all the modules bundled in the ear.
NOTE 2:The attribute optional=true/false is also available in jboss-deployment-structure.xml, but not working properly for specific versions (probably < EAP 6.4.7). Check it out, if you need it.
Hope it helps.
Sources:
RedHat docs - Add an Explicit Module Dependency to a Deployment
RedHat docs - Configuring Modules
RedHat docs - Add a module to all deployments
JBoss AS 7 Developer Guide
If using Maven, you can add a reference to a module in JBoss AS like this:
<plugin>
<artifactId>maven-war-plugin</artifactId>
<version>2.2</version>
<configuration>
<archive>
<manifestEntries>
<!-- List your dependencies here -->
<Dependencies>com.sun.jersey</Dependencies>
</manifestEntries>
</archive>
</configuration>
</plugin>
Which will automatically generate the manifest entries for you.
I personally have to use this approach to avoid the "Native Library xxxxxxx already loaded in another classloader" error while loading com.microsoft.jdbc.sqlserver.SQLServerDriver that I have defined as a module in JBoss AS - That way JNDI defined connections can connect to MSSQL, and at the same time I can reuse that dependency to connect to the DB directly (this time trough DriverManager instead of JNDI).
I'm not a jboss-modules expert, but there a couple things you could try.
You said you put all the JAR's and module.xml in JBOSS_HOME\modules\com\sun\Jersey\main. Notice the capital J. I don't know that it matters, but you for consistency at least you might want to make it lower case.
Also I don't think you want the <include path="**"/> in the jboss-deployment-structure.xml.
Again, I could be wrong since I'm definitely not a jboss-modules expert, but I would try those two things first.
Global modules can also be added through the CLI interface.
This makes it easy to make changes as you can create a batch file and run it ./jboss-cli.sh --file {path to file}
Comment out the init param in web.xml that really worked...
<?xml version="1.0" encoding="UTF-8"?>
<web-app id="WebApp_ID" version="2.5" xmlns="http://java.sun.com/xml/ns/javaee" 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/web-app_2_5.xsd">
<display-name> MyProject </display-name>
<servlet>
<description>
</description>
<servlet-name>Jersey Servlet</servlet-name>
<servlet-class>com.sun.jersey.spi.container.servlet.ServletContainer</servlet-class>
<!-- <init-param>
<description></description>
<param-name>javax.ws.rs.Application</param-name>
<param-value>com.MyProject.service.REST_Application</param-value>
</init-param>-->
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>Jersey Servlet</servlet-name>
<url-pattern>/jaxrs/*</url-pattern>
</servlet-mapping>
</web-app>