How to deploy a JDBC Driver to Wildfly that can be used by WebApp - jdbc

We are currently migrating from Tomcat to Wildfly 10 server. We like to take advantages of a Java EE Server. Currently we have some issues with the DataSource. We have deployed the JDBC Driver on Wildfly and set up the DataSource.
That works mainly good, but we like to use DatabaseQueryNotification (Oracle) for database-side events.
Now the problem I run into:
When I package the Driver with my war (additionally), I get an ClassCastException because of mismatch of T4Connection and OracleConnection. Therefore I removed the JDBC-Driver from my War (maven -> scope: provided). But now my Application failed on Deployment, because of NoClassDefFound (see Stacktrace bellow).
How can I make sure that the JDBC Driver can be found by the application?
Java Snippet:
public class DBListener implements IDBListener, Runnable, DatabaseChangeListener, IPropertyListener, Serializable {
#Resource(lookup = "java:/PlsDS")
private DataSource dataSource;
...
public void connectToDB(){
Connection tmpCon = dataSource.getConnection();
connection = (OracleConnection) tmpCon.getMetaData().getConnection();
...
}
}
Stacktrace:
14:32:59,869 WARN [org.jboss.modules] (MSC service thread 1-7) Failed to define class de.istec.pls.client.db.listener.DBListener in Module "deployment.client.pls-sc-1.0.0-SNAPSHOT.war:main" from Service Module Loader: java.lang.NoClassDefFoundError: Failed to link de/istec/pls/client/db/listener/DBListener (Module "deployment.client.pls-sc-1.0.0-SNAPSHOT.war:main" from Service Module Loader): oracle/jdbc/dcn/DatabaseChangeListener
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.lang.reflect.Constructor.newInstance(Constructor.java:422)
at org.jboss.modules.ModuleClassLoader.defineClass(ModuleClassLoader.java:446)
at org.jboss.modules.ModuleClassLoader.loadClassLocal(ModuleClassLoader.java:274)
at org.jboss.modules.ModuleClassLoader$1.loadClassLocal(ModuleClassLoader.java:78)
at org.jboss.modules.Module.loadModuleClass(Module.java:606)
at org.jboss.modules.ModuleClassLoader.findClass(ModuleClassLoader.java:190)
at org.jboss.modules.ConcurrentClassLoader.performLoadClassUnchecked(ConcurrentClassLoader.java:363)
at org.jboss.modules.ConcurrentClassLoader.performLoadClass(ConcurrentClassLoader.java:351)
at org.jboss.modules.ConcurrentClassLoader.loadClass(ConcurrentClassLoader.java:93)
at org.wildfly.extension.undertow.deployment.ServletContainerInitializerDeploymentProcessor.loadClassInfoSet(ServletContainerInitializerDeploymentProcessor.java:259)
at org.wildfly.extension.undertow.deployment.ServletContainerInitializerDeploymentProcessor.deploy(ServletContainerInitializerDeploymentProcessor.java:169)
at org.jboss.as.server.deployment.DeploymentUnitPhaseService.start(DeploymentUnitPhaseService.java:147)
at org.jboss.msc.service.ServiceControllerImpl$StartTask.startService(ServiceControllerImpl.java:1948)
at org.jboss.msc.service.ServiceControllerImpl$StartTask.run(ServiceControllerImpl.java:1881)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at java.lang.Thread.run(Thread.java:745)
14:32:59,871 ERROR [org.jboss.msc.service.fail] (MSC service thread 1-7) MSC000001: Failed to start service jboss.deployment.unit."client.pls-sc-1.0.0-SNAPSHOT.war".INSTALL: org.jboss.msc.service.StartException in service jboss.deployment.unit."client.pls-sc-1.0.0-SNAPSHOT.war".INSTALL: WFLYSRV0153: Failed to process phase INSTALL of deployment "client.pls-sc-1.0.0-SNAPSHOT.war"
at org.jboss.as.server.deployment.DeploymentUnitPhaseService.start(DeploymentUnitPhaseService.java:154)
at org.jboss.msc.service.ServiceControllerImpl$StartTask.startService(ServiceControllerImpl.java:1948)
at org.jboss.msc.service.ServiceControllerImpl$StartTask.run(ServiceControllerImpl.java:1881)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at java.lang.Thread.run(Thread.java:745)
Caused by: java.lang.NoClassDefFoundError: Failed to link de/istec/pls/client/db/listener/DBListener (Module "deployment.client.pls-sc-1.0.0-SNAPSHOT.war:main" from Service Module Loader): oracle/jdbc/dcn/DatabaseChangeListener
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.lang.reflect.Constructor.newInstance(Constructor.java:422)
at org.jboss.modules.ModuleClassLoader.defineClass(ModuleClassLoader.java:446)
at org.jboss.modules.ModuleClassLoader.loadClassLocal(ModuleClassLoader.java:274)
at org.jboss.modules.ModuleClassLoader$1.loadClassLocal(ModuleClassLoader.java:78)
at org.jboss.modules.Module.loadModuleClass(Module.java:606)
at org.jboss.modules.ModuleClassLoader.findClass(ModuleClassLoader.java:190)
at org.jboss.modules.ConcurrentClassLoader.performLoadClassUnchecked(ConcurrentClassLoader.java:363)
at org.jboss.modules.ConcurrentClassLoader.performLoadClass(ConcurrentClassLoader.java:351)
at org.jboss.modules.ConcurrentClassLoader.loadClass(ConcurrentClassLoader.java:93)
at org.wildfly.extension.undertow.deployment.ServletContainerInitializerDeploymentProcessor.loadClassInfoSet(ServletContainerInitializerDeploymentProcessor.java:259)
at org.wildfly.extension.undertow.deployment.ServletContainerInitializerDeploymentProcessor.deploy(ServletContainerInitializerDeploymentProcessor.java:169)
at org.jboss.as.server.deployment.DeploymentUnitPhaseService.start(DeploymentUnitPhaseService.java:147)

I have solved the Problem:
I had to deploy the JDBC-Driver as a Module (see:
http://hpehl.info/jdbc-driver-setup.html)
I have to Export the needed oracle.jdbc.dcn* files, from module
Insert the Dependency in the Manifest.MF file. (can be done by Maven, see below)
module.xml
<module xmlns="urn:jboss:module:1.1" name="com.oracle">
<resources>
<resource-root path="ojdbc7-12.1.0.2.jar"/>
</resources>
<dependencies>
<system export="true">
<paths>
<path name="oracle/jdbc/OracleStatement"/>
<path name="oracle/jdbc/dcn/DatabaseChangeEvent"/>
<path name="oracle/jdbc/dcn/DatabaseChangeListener"/>
<path name="oracle/jdbc/dcn/DatabaseChangeRegistration"/>
<path name="oracle/jdbc/dcn/QueryChangeDescription"/>
<path name="oracle/jdbc/dcn/RowChangeDescription"/>
</paths>
</system>
<module name="javax.api"/>
<module name="javax.transaction.api"/>
</dependencies>
</module>
pom.xml
<plugin>
<artifactId>maven-war-plugin</artifactId>
<version>3.1.0</version>
<configuration>
<archive>
<manifestEntries>
<Dependencies>com.oracle</Dependencies>
</manifestEntries>
</archive>
</configuration>
</plugin>

You should get an instance of a datasource through JNDI or inject through CDI.

Related

How to fix ear deployement error in JBoss7.1 when there is a clash for org.apache.commons.logging.LogFactory

I am trying to deploy an ear file in JBoss.
My project structure is jar>war>ear.
In the war file I have webapp>WEB-INF>jboss-deployment-structure.xml where I have mentioned
<?xml version="1.0" encoding="UTF-8"?>
<jboss-deployment-structure>
<deployment>
<exclusions>
<module name="org.apache.commons.logging" />
</exclusions>
</deployment>
</jboss-deployment-structure>
when I deploy the war file in the JBOSS, it deploys it fine.
But when I try to deploy the ear file having the war file inside.
It is giving the following error:
Caused by: org.apache.commons.discovery.DiscoveryException: Unable to instantiate implementation class for org.apache.commons.logging.LogFactory
at org.apache.commons.discovery.tools.DiscoverSingleton.find(DiscoverSingleton.java:378)
at org.apache.commons.discovery.tools.DiscoverSingleton.find(DiscoverSingleton.java:328)
at org.apache.axis.components.logger.LogFactory$1.run(LogFactory.java:45)
at java.security.AccessController.doPrivileged(Native Method)
at org.apache.axis.components.logger.LogFactory.getLogFactory(LogFactory.java:41)
at org.apache.axis.components.logger.LogFactory.<clinit>(LogFactory.java:33)
... 49 more
Caused by: java.lang.UnsupportedOperationException
at org.apache.commons.logging.LogFactory.getClassLoader(LogFactory.java:401)
at org.apache.commons.logging.impl.LogFactoryImpl.getClassLoader(LogFactoryImpl.java:392)
at org.apache.commons.logging.impl.LogFactoryImpl.initDiagnostics(LogFactoryImpl.java:420)
at org.apache.commons.logging.impl.LogFactoryImpl.<init>(LogFactoryImpl.java:87)
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
at java.lang.Class.newInstance(Class.java:442)
at org.apache.commons.discovery.tools.ClassUtils.newInstance(ClassUtils.java:153)
I used to get the same error when deploying the war file, which was fixed by the xml file. But now while deploying the ear file I am getting the same error. Any pointers will help

JBoss WildFly 11, Hibernate ORM 5.2, OGM 5.3 and MongoDB - OgmIntegrator not found

Progressing slowly through trying to get Hibernate ORM 5.2 working with OGM 5.3 so I can use JPA with MongoDB.
To remove the JNDI look-up error, referenced in the OGM FAQs:
When using Hibernate OGM on top of WildFly, I’m getting a
JndiException. What’s wrong? In case you’re are seeing a JndiException
saying "Unable to lookup JNDI name [---PlaceHolderDSForOGM---]", your
application likely cannot access the application server module(s) of
Hibernate OGM.
To change this, add the following line to the META-INF/MANIFEST.MF
file of your archive (adapt it to match your chosen datastore):
Dependencies: org.hibernate:ogm services, org.hibernate.ogm.mongodb
services Alternatively, you can configure this via the descriptor
jboss-deployment-structure.xml. See the reference guide to learn more.
I created: jboss-deployment-structure.xml
containing:
<jboss-deployment-structure>
<deployment>
<dependencies>
<module name="org.hibernate.ogm" slot="5.3" services="export" />
<module name="org.hibernate.ogm.mongodb" slot="5.3" services="export" />
</dependencies>
</deployment>
</jboss-deployment-structure>
Now when I try to deploy my EAR through the WildFly 11 console I get:
17:58:42,921 ERROR [org.jboss.msc.service.fail] (ServerService Thread
Pool -- 65) MSC000001: Failed to start service
jboss.persistenceunit."NOTiFYwell.ear/NOTiFYwellJAR.jar#NOTiFYwellMongoDBPersistenceUnit".FIRST_PHASE:
org.jboss.msc.service.StartException in service
jboss.persistenceunit."NOTiFYwell.ear/NOTiFYwellJAR.jar#NOTiFYwellMongoDBPersistenceUnit".FIRST_PHASE:
java.util.ServiceConfigurationError:
org.hibernate.integrator.spi.Integrator: Provider
org.hibernate.ogm.service.impl.OgmIntegrator not found at
org.jboss.as.jpa.service.PhaseOnePersistenceUnitServiceImpl$1$1.run(PhaseOnePersistenceUnitServiceImpl.java:128)
at
org.jboss.as.jpa.service.PhaseOnePersistenceUnitServiceImpl$1$1.run(PhaseOnePersistenceUnitServiceImpl.java:104)
at
org.wildfly.security.manager.WildFlySecurityManager.doChecked(WildFlySecurityManager.java:640)
at
org.jboss.as.jpa.service.PhaseOnePersistenceUnitServiceImpl$1.run(PhaseOnePersistenceUnitServiceImpl.java:137)
at
java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
at
java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at java.lang.Thread.run(Thread.java:745) at
org.jboss.threads.JBossThread.run(JBossThread.java:320) Caused by:
java.util.ServiceConfigurationError:
org.hibernate.integrator.spi.Integrator: Provider
org.hibernate.ogm.service.impl.OgmIntegrator not found at
java.util.ServiceLoader.fail(ServiceLoader.java:239) at
java.util.ServiceLoader.access$300(ServiceLoader.java:185) at
java.util.ServiceLoader$LazyIterator.nextService(ServiceLoader.java:372)
at java.util.ServiceLoader$LazyIterator.next(ServiceLoader.java:404)
at java.util.ServiceLoader$1.next(ServiceLoader.java:480) at
org.hibernate.boot.registry.classloading.internal.ClassLoaderServiceImpl.loadJavaServices(ClassLoaderServiceImpl.java:459)
at
org.hibernate.integrator.internal.IntegratorServiceImpl.(IntegratorServiceImpl.java:40)
at
org.hibernate.boot.registry.BootstrapServiceRegistryBuilder.build(BootstrapServiceRegistryBuilder.java:224)
at
org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl.buildBootstrapServiceRegistry(EntityManagerFactoryBuilderImpl.java:406)
at
org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl.(EntityManagerFactoryBuilderImpl.java:196)
at
org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl.(EntityManagerFactoryBuilderImpl.java:164)
at
org.hibernate.jpa.boot.spi.Bootstrap.getEntityManagerFactoryBuilder(Bootstrap.java:32)
at
org.hibernate.jpa.boot.spi.Bootstrap.getEntityManagerFactoryBuilder(Bootstrap.java:89)
at
org.jboss.as.jpa.hibernate5.TwoPhaseBootstrapImpl.(TwoPhaseBootstrapImpl.java:39)
at
org.jboss.as.jpa.hibernate5.HibernatePersistenceProviderAdaptor.getBootstrap(HibernatePersistenceProviderAdaptor.java:199)
at
org.wildfly.jpa.hibernateogm5.HibernateOGMPersistenceProviderAdaptor.getBootstrap(HibernateOGMPersistenceProviderAdaptor.java:87)
at
org.jboss.as.jpa.service.PhaseOnePersistenceUnitServiceImpl.createContainerEntityManagerFactoryBuilder(PhaseOnePersistenceUnitServiceImpl.java:254)
at
org.jboss.as.jpa.service.PhaseOnePersistenceUnitServiceImpl.access$900(PhaseOnePersistenceUnitServiceImpl.java:59)
at
org.jboss.as.jpa.service.PhaseOnePersistenceUnitServiceImpl$1$1.run(PhaseOnePersistenceUnitServiceImpl.java:125)
... 7 more
17:58:42,926 ERROR [org.jboss.as.controller.management-operation]
(External Management Request Threads -- 1) WFLYCTL0013: Operation
("add") failed - address: ([("deployment" => "NOTiFYwell.ear")]) -
failure description: {"WFLYCTL0080: Failed services" =>
{"jboss.persistenceunit.\"NOTiFYwell.ear/NOTiFYwellJAR.jar#NOTiFYwellMongoDBPersistenceUnit\".FIRST_PHASE"
=> "java.util.ServiceConfigurationError: org.hibernate.integrator.spi.Integrator: Provider
org.hibernate.ogm.service.impl.OgmIntegrator not found
Caused by: java.util.ServiceConfigurationError: org.hibernate.integrator.spi.Integrator: Provider
org.hibernate.ogm.service.impl.OgmIntegrator not found"}} 17:58:42,927
ERROR [org.jboss.as.server] (External Management Request Threads -- 1)
WFLYSRV0021: Deploy of deployment "NOTiFYwell.ear" was rolled back
with the following failure message: {"WFLYCTL0080: Failed services"
=> {"jboss.persistenceunit.\"NOTiFYwell.ear/NOTiFYwellJAR.jar#NOTiFYwellMongoDBPersistenceUnit\".FIRST_PHASE"
=> "java.util.ServiceConfigurationError: org.hibernate.integrator.spi.Integrator: Provider
org.hibernate.ogm.service.impl.OgmIntegrator not found
Caused by: java.util.ServiceConfigurationError: org.hibernate.integrator.spi.Integrator: Provider
org.hibernate.ogm.service.impl.OgmIntegrator not found"}} 17:58:42,939
INFO [org.jboss.as.server.deployment] (MSC service thread 1-7)
WFLYSRV0208: Stopped subdeployment (runtime-name: NOTiFYwellJAR.jar)
in 10ms 17:58:42,942 INFO [org.jboss.as.server.deployment] (MSC
service thread 1-8) WFLYSRV0208: Stopped subdeployment (runtime-name:
NOTiFYwellWAR.war) in 13ms 17:58:42,952 INFO
[org.jboss.as.server.deployment] (MSC service thread 1-8) WFLYSRV0028:
Stopped deployment NOTiFYwell.ear (runtime-name: NOTiFYwell.ear) in
25ms
The error:
Provider org.hibernate.ogm.service.impl.OgmIntegrator not found
Refers to class OgmIntegrator found in:
org/hibernate/ogm/service/impl/OgmIntegrator.class under /usr/local/Cellar/wildfly-as/11.0.0.Final/libexec/modules/system/layers/base/org/hibernate/ogm/5.3/hibernate-ogm-core-5.3.0.Final.jar
Any ideas why this isn't being loaded? TIA
I think I figure out the problem, you need to use this:
<jboss-deployment-structure>
<deployment>
<dependencies>
<module name="org.hibernate.ogm" slot="5.3" services="export" />
<module name="org.hibernate.ogm.mongodb" slot="5.3" services="export" />
</dependencies>
</deployment>
</jboss-deployment-structure>
This exception
org.jboss.modules.ModuleNotFoundException: org.hibernate:5.3
means that you are using org.hibernate:5.3 instead of org.hibernate.ogm:5.3
The error might be in the jboss-deployment descriptor or in the MANIFEST.MF. Just make sure you are only using one or the other.
UPDATE: There was an error in the Hibernate website FAQ session, I updated it. Thanks for the feedback.
Finally got the EAR deployed.
It only deploys the EAR if I include a MANIFEST.MF in EAR's META-INF:
Manifest-Version: 1.0
Dependencies: org.hibernate.ogm:5.3 services, org.hibernate.ogm.mongodb:5.3 services
and remove 'jboss-deployment-structure.xml'.
If I try and use a 'jboss-deployment-structure.xml' (empty MANIFEST):
<jboss-deployment-structure>
<deployment>
<dependencies>
<module name="org.hibernate.ogm" slot="5.3" services="export" />
<module name="org.hibernate.ogm.mongodb" slot="5.3" services="export" />
</dependencies>
</deployment>
</jboss-deployment-structure>
It fails to deploy with the error I've had before:
17:31:53,892 ERROR [org.jboss.msc.service.fail] (ServerService Thread
Pool -- 30) MSC000001: Failed to start service
jboss.persistenceunit."NOTiFYwell.ear/NOTiFYwellJAR.jar#NOTiFYwellMongoDBPersistenceUnit".FIRST_PHASE:
org.jboss.msc.service.StartException in service
jboss.persistenceunit."NOTiFYwell.ear/NOTiFYwellJAR.jar#NOTiFYwellMongoDBPersistenceUnit".FIRST_PHASE:
java.util.ServiceConfigurationError:
org.hibernate.integrator.spi.Integrator: Provider
org.hibernate.ogm.service.impl.OgmIntegrator not found at
org.jboss.as.jpa.service.PhaseOnePersistenceUnitServiceImpl$1$1.run(PhaseOnePersistenceUnitServiceImpl.java:128)
at
org.jboss.as.jpa.service.PhaseOnePersistenceUnitServiceImpl$1$1.run(PhaseOnePersistenceUnitServiceImpl.java:104)
at
org.wildfly.security.manager.WildFlySecurityManager.doChecked(WildFlySecurityManager.java:640)
at
org.jboss.as.jpa.service.PhaseOnePersistenceUnitServiceImpl$1.run(PhaseOnePersistenceUnitServiceImpl.java:137)
at
java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
at
java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at java.lang.Thread.run(Thread.java:745) at
org.jboss.threads.JBossThread.run(JBossThread.java:320) Caused by:
java.util.ServiceConfigurationError:
org.hibernate.integrator.spi.Integrator: Provider
org.hibernate.ogm.service.impl.OgmIntegrator not found at
java.util.ServiceLoader.fail(ServiceLoader.java:239) at
java.util.ServiceLoader.access$300(ServiceLoader.java:185) at
java.util.ServiceLoader$LazyIterator.nextService(ServiceLoader.java:372)
at java.util.ServiceLoader$LazyIterator.next(ServiceLoader.java:404)
at java.util.ServiceLoader$1.next(ServiceLoader.java:480) at
org.hibernate.boot.registry.classloading.internal.ClassLoaderServiceImpl.loadJavaServices(ClassLoaderServiceImpl.java:459)
at
org.hibernate.integrator.internal.IntegratorServiceImpl.(IntegratorServiceImpl.java:40)
at
org.hibernate.boot.registry.BootstrapServiceRegistryBuilder.build(BootstrapServiceRegistryBuilder.java:224)
at
org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl.buildBootstrapServiceRegistry(EntityManagerFactoryBuilderImpl.java:406)
at
org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl.(EntityManagerFactoryBuilderImpl.java:196)
at
org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl.(EntityManagerFactoryBuilderImpl.java:164)
at
org.hibernate.jpa.boot.spi.Bootstrap.getEntityManagerFactoryBuilder(Bootstrap.java:32)
at
org.hibernate.jpa.boot.spi.Bootstrap.getEntityManagerFactoryBuilder(Bootstrap.java:89)
at
org.jboss.as.jpa.hibernate5.TwoPhaseBootstrapImpl.(TwoPhaseBootstrapImpl.java:39)
at
org.jboss.as.jpa.hibernate5.HibernatePersistenceProviderAdaptor.getBootstrap(HibernatePersistenceProviderAdaptor.java:199)
at
org.wildfly.jpa.hibernateogm5.HibernateOGMPersistenceProviderAdaptor.getBootstrap(HibernateOGMPersistenceProviderAdaptor.java:87)
at
org.jboss.as.jpa.service.PhaseOnePersistenceUnitServiceImpl.createContainerEntityManagerFactoryBuilder(PhaseOnePersistenceUnitServiceImpl.java:254)
at
org.jboss.as.jpa.service.PhaseOnePersistenceUnitServiceImpl.access$900(PhaseOnePersistenceUnitServiceImpl.java:59)
at
org.jboss.as.jpa.service.PhaseOnePersistenceUnitServiceImpl$1$1.run(PhaseOnePersistenceUnitServiceImpl.java:125)
... 7 more
17:31:53,908 ERROR [org.jboss.as.controller.management-operation]
(External Management Request Threads -- 3) WFLYCTL0013: Operation
("add") failed - address: ([("deployment" => "NOTiFYwell.ear")]) -
failure description: {"WFLYCTL0080: Failed services" =>
{"jboss.persistenceunit.\"NOTiFYwell.ear/NOTiFYwellJAR.jar#NOTiFYwellMongoDBPersistenceUnit\".FIRST_PHASE"
=> "java.util.ServiceConfigurationError: org.hibernate.integrator.spi.Integrator: Provider
org.hibernate.ogm.service.impl.OgmIntegrator not found
Caused by: java.util.ServiceConfigurationError: org.hibernate.integrator.spi.Integrator: Provider
org.hibernate.ogm.service.impl.OgmIntegrator not found"}} 17:31:53,909
ERROR [org.jboss.as.server] (External Management Request Threads -- 3)
WFLYSRV0021: Deploy of deployment "NOTiFYwell.ear" was rolled back
with the following failure message: {"WFLYCTL0080: Failed services"
=> {"jboss.persistenceunit.\"NOTiFYwell.ear/NOTiFYwellJAR.jar#NOTiFYwellMongoDBPersistenceUnit\".FIRST_PHASE"
=> "java.util.ServiceConfigurationError: org.hibernate.integrator.spi.Integrator: Provider
org.hibernate.ogm.service.impl.OgmIntegrator not found
Caused by: java.util.ServiceConfigurationError: org.hibernate.integrator.spi.Integrator: Provider
org.hibernate.ogm.service.impl.OgmIntegrator not found"}}
Mapped an enity to my MongoDB table and was able to return a 'List' of Entities.
Had to ensure Collection's id type was mapped as:
#Id
#Type(type = "objectid")
private String id;

JBoss AS 7 not using WEB-INF hibernate lib and throwing "Unknown service requested [org.hibernate.boot.registry.classloading.spi.ClassLoaderService]"

I'm migrating a Spring+Hibernate application from Weblogic 12c to JBoss AS 7, and I'm getting the following error:
20:07:47,395 ERROR [org.jboss.msc.service.fail] (MSC service thread 1-1) MSC00001: Failed to start service jboss.persistenceunit."connecta-presenter-2.2.1.war#ConnectaPresenterPU": org.jboss.msc.service.StartException in service jboss.persistenceunit."connecta-presenter-2.2.1.war#ConnectaPresenterPU": 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_95]
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615) [rt.jar:1.7.0_95]
at java.lang.Thread.run(Thread.java:745) [rt.jar:1.7.0_95]
Caused by: javax.persistence.PersistenceException: [PersistenceUnit: ConnectaPresenterPU] 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.service.UnknownServiceException: Unknown service requested [org.hibernate.boot.registry.classloading.spi.ClassLoaderService]
at org.hibernate.service.internal.AbstractServiceRegistryImpl.getService(AbstractServiceRegistryImpl.java:126)
at org.hibernate.search.hcore.impl.HibernateSearchIntegrator.integrate(HibernateSearchIntegrator.java:49)
at org.hibernate.internal.SessionFactoryImpl.<init>(SessionFactoryImpl.java:294)
at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1737)
at org.hibernate.ejb.EntityManagerFactoryImpl.<init>(EntityManagerFactoryImpl.java:84)
at org.hibernate.ejb.Ejb3Configuration.buildEntityManagerFactory(Ejb3Configuration.java:904)
... 9 more
The Unknown service requested [org.hibernate.boot.registry.classloading.spi.ClassLoaderService] message thrown by line 126 of org.hibernate.service.internal.AbstractServiceRegistryImpl is an exception thrown only in version 4.0.1 of Hibernate Core, which is the version that is in my JBoss AS 7 modules folder.
The thing is that my application uses Hibernate 4.3.10, and this specific line doesn't exist more in this version (I could see comparing the source code on Github).
The following documentation on JBoss AS 7 site states that when you migrate from Weblogic to JBoss:
https://docs.jboss.org/author/display/AS72/How+do+I+migrate+my+application+from+WebLogic+to+AS+7#HowdoImigratemyapplicationfromWebLogictoAS7-Migrateweblogic.xmlDescriptorFileConfigurations
So there's no such code as the following in jboss-web.xml file:
<prefer-application-packages>
<package-name>javassist.*</package-name>
</prefer-application-packages>
It says that JBoss always uses WEB-INF/classes and WEB-INF/lib before the internal modules.
Any idea of what's happening?
If you want to use your own specific version of Hibernate (or any other service/software for that matter), you can do that instead of depending on JBoss AS 7 modules.
Create a new folder structure, say org/myhibernate/main in your $JBOSS_HOME\modules\system\layers\base\ directory. Put the needed jar (say my.jar) in the main folder and create a module.xml file like this:
<?xml version="1.0" encoding="UTF-8"?>
<module xmlns="urn:jboss:module:1.1" name="org.myhibernate">
<resources>
<!-- Modules -->
<resource-root path="my.jar" />
</resources>
<dependencies>
<module name="javax.api"/>
<module name="sun.jdk"/>
</dependencies>
</module>
Now create a jboss-deployment-structure.xml in your EAR/web folder in your workspace and include this dependency -
<?xml version="1.0" encoding="UTF-8"?>
<jboss-deployment-structure>
<sub-deployment name="yourfile.war">
<dependencies>
<module name="org.myhibernate" />
</dependencies>
</sub-deployment>
</jboss-deployment-structure>

two ejb jar files with same name in different EAR projects conflict with each other on jboss 7.1

I'm migrating projects from Jboss 5.1 to jboss 7.1
I have two EARs, which run on the same Jboss. They contain ejb project inside and both ejb jar files are called services.jar due to finalname tag in EJB_PROJECT/pom.xml
<build>
<finalName>services</finalName>
.....
</build>
On Jboss 5.1 it worked fine, but now i get error :
18:07:16,858 ERROR [org.jboss.msc.service.fail] (MSC service thread 1-7) MSC00001: Failed to start service jboss.deployment.subunit."my1.ear"."services.jar".INSTALL: org.jboss.msc.service.StartException in service jboss.deployment.subunit."my1.ear"."services.jar".INSTALL: Failed to process phase INSTALL of subdeployment "services.jar" of deployment "my1.ear"
at org.jboss.as.server.deployment.DeploymentUnitPhaseService.start(DeploymentUnitPhaseService.java:119) [jboss-as-server-7.1.1.Final.jar:7.1.1.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.runWorker(Unknown Source) [rt.jar:1.7.0_45]
at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source) [rt.jar:1.7.0_45]
at java.lang.Thread.run(Unknown Source) [rt.jar:1.7.0_45]
Caused by: org.jboss.as.server.deployment.DeploymentUnitProcessingException: JBAS018027: Failed to add JBoss Web deployment service
at org.jboss.as.web.deployment.WarDeploymentProcessor.processDeployment(WarDeploymentProcessor.java:320)
at org.jboss.as.web.deployment.WarDeploymentProcessor.deploy(WarDeploymentProcessor.java:114)
at org.jboss.as.server.deployment.DeploymentUnitPhaseService.start(DeploymentUnitPhaseService.java:113) [jboss-as-server-7.1.1.Final.jar:7.1.1.Final]
... 5 more
Caused by: org.jboss.msc.service.DuplicateServiceException: Service jboss.web.deployment.default-host./services.realm is already registered
at org.jboss.msc.service.ServiceRegistrationImpl.setInstance(ServiceRegistrationImpl.java:154) [jboss-msc-1.0.2.GA.jar:1.0.2.GA]
at org.jboss.msc.service.ServiceControllerImpl.startInstallation(ServiceControllerImpl.java:227) [jboss-msc-1.0.2.GA.jar:1.0.2.GA]
at org.jboss.msc.service.ServiceContainerImpl.install(ServiceContainerImpl.java:560) [jboss-msc-1.0.2.GA.jar:1.0.2.GA]
at org.jboss.msc.service.ServiceTargetImpl.install(ServiceTargetImpl.java:201) [jboss-msc-1.0.2.GA.jar:1.0.2.GA]
at org.jboss.msc.service.ServiceControllerImpl$ChildServiceTarget.install(ServiceControllerImpl.java:2228) [jboss-msc-1.0.2.GA.jar:1.0.2.GA]
at org.jboss.msc.service.ServiceTargetImpl.install(ServiceTargetImpl.java:201) [jboss-msc-1.0.2.GA.jar:1.0.2.GA]
at org.jboss.msc.service.ServiceControllerImpl$ChildServiceTarget.install(ServiceControllerImpl.java:2228) [jboss-msc-1.0.2.GA.jar:1.0.2.GA]
at org.jboss.msc.service.ServiceBuilderImpl.install(ServiceBuilderImpl.java:307) [jboss-msc-1.0.2.GA.jar:1.0.2.GA]
at org.jboss.as.web.deployment.WarDeploymentProcessor.processDeployment(WarDeploymentProcessor.java:269)
... 7 more
Is there a way to make this work without changing finalname tag's value? If I change it, then url to my application changes and i don't want that.
Try having this in your META-INF/ejb-jar.xml of your EJB:
<?xml version="1.0" encoding="UTF-8"?>
<javaee:ejb-jar version="3.1"
xmlns:javaee="http://java.sun.com/xml/ns/javaee"
xmlns:xml="http://www.w3.org/XML/1998/namespace"
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">
<javaee:module-name>some-name-you-want-for-your-ejb</javaee:module-name>
</javaee:ejb-jar>
As per EJB specification, that should override the file name for JNDI. This is clarified for example in EJB FAQ:
<module-name> defaults to the unqualified name of the ejb-jar file or
.war file in which the EJB component is defined, minus the file
extension. The <module-name> can be explicitly specified using the
<module-name> element of the ejb-jar.xml (for ejb-jars) or web.xml(for
EJB components defined in .wars).

Running tomcat7 maven plugin with custom classpath using VirtualWebappLoader

I have a maven war project, that I'm trying to run with tomcat7-maven-plugin. The problem I'm having is that the configuration for each of the environments is in custom folder (it's not inside /resources), as we have a different set of configuration files for each environments (local, test, uat or production).
I'm trying to figure out how can I run the plugin, while specifying a custom classpath that includes the local configuration directory. I've read on this improvement ticket that the way to do it, is to provide a context.xml with a Loader element, but if I do this, the webapp fails to start.
The configuration I have in the pom is
<plugin>
<groupId>org.apache.tomcat.maven</groupId>
<artifactId>tomcat7-maven-plugin</artifactId>
<version>2.0</version>
<configuration>
<path>/${project.build.finalName}</path>
<contextFile>${basedir}/src/env/local/context.xml</contextFile>
<contextReloadable>true</contextReloadable>
</configuration>
</plugin>
the context.xml file (the tomcat plugin does the filtering on this file automatically)
<?xml version="1.0" encoding="UTF-8"?>
<Context>
<Loader className="org.apache.catalina.loader.VirtualWebappLoader"
virtualClasspath="${basedir}/src/env/local/" />
<JarScanner scanAllDirectories="true" />
</Context>
And the error I get is
[INFO] create webapp with contextPath: /webapp
Handler error
java.lang.ClassNotFoundException: org.apache.juli.FileHandler
at java.net.URLClassLoader$1.run(URLClassLoader.java:202)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:190)
at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
at java.lang.ClassLoader.loadClass(ClassLoader.java:247)
at org.apache.juli.ClassLoaderLogManager.readConfiguration(ClassLoaderLogManager.java:521)
at org.apache.juli.ClassLoaderLogManager.readConfiguration(ClassLoaderLogManager.java:464)
at org.apache.juli.ClassLoaderLogManager$2.run(ClassLoaderLogManager.java:377)
at org.apache.juli.ClassLoaderLogManager$2.run(ClassLoaderLogManager.java:373)
at java.security.AccessController.doPrivileged(Native Method)
at org.apache.juli.ClassLoaderLogManager.getClassLoaderInfo(ClassLoaderLogManager.java:373)
at org.apache.juli.ClassLoaderLogManager.readConfiguration(ClassLoaderLogManager.java:452)
at org.apache.juli.ClassLoaderLogManager$2.run(ClassLoaderLogManager.java:377)
at org.apache.juli.ClassLoaderLogManager$2.run(ClassLoaderLogManager.java:373)
at java.security.AccessController.doPrivileged(Native Method)
at org.apache.juli.ClassLoaderLogManager.getClassLoaderInfo(ClassLoaderLogManager.java:373)
at org.apache.juli.ClassLoaderLogManager.getLogger(ClassLoaderLogManager.java:223)
at java.util.logging.LogManager.demandLogger(LogManager.java:389)
at java.util.logging.Logger.getLogger(Logger.java:288)
at org.apache.juli.logging.DirectJDKLog.<init>(DirectJDKLog.java:71)
at org.apache.juli.logging.DirectJDKLog.getInstance(DirectJDKLog.java:196)
at org.apache.juli.logging.LogFactory.getInstance(LogFactory.java:170)
at org.apache.juli.logging.LogFactory.getLog(LogFactory.java:311)
at org.apache.catalina.core.ContainerBase.getLogger(ContainerBase.java:452)
at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5162)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1559)
at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1549)
at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:303)
at java.util.concurrent.FutureTask.run(FutureTask.java:138)
at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
at java.lang.Thread.run(Thread.java:662)
Does anyone have any suggestion about how to fix this or achieve the same in a different way?
I've been able to do this with the cargo plugin, but the tomcat plugin has some features that I like :).

Resources