From jboss/java1.6 to wildfly20/java1.8 - java

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 ?

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?

Integrating Spring boot war inside ear along with other war's

I have created zuul proxy application using spring boot and I am able to deploy it as a spring boot and war in Wildfly server by making some changes in pom and SpringApplication class file.
Structure of my ear :
MyEE.ear
|
|__gatewayzull.war
|_WEB-INF/lib/all jar for spring boot application
|
|__EJB.jar
|
|__XX.war
|
|lib/all jar (which also includes spring jars)
I have done some changes in pom.xml to deploy spring application war in WildFly server and It is working as expected.
When I tried to add gatewayzull.war in MyEE.ear and deploy it in Wildfly server, I am getting this exception
10:08:47,108 INFO [com.hummingbird.gateway.HbgatewayApplication] (MSC service thread 1-4) No active profile set, falling back to default profiles: default
10:08:47,119 INFO [org.springframework.boot.context.embedded.AnnotationConfigEmbeddedWebApplicationContext] (MSC service thread 1-4) Refreshing org.springframework.boot.context.embedded.AnnotationConfigEmbeddedWebApplicationContext#51640e39: startup date [Thu Jun 01 10:08:47 UTC 2017]; parent: org.springframework.context.annotation.AnnotationConfigApplicationContext#50b75933
....
....
....
....
10:08:56,635 WARN [org.springframework.boot.context.embedded.AnnotationConfigEmbeddedWebApplicationContext] (MSC service thread 1-4) Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.BeanDefinitionStoreException: Failed to process import candidates for configuration class [org.springframework.boot.autoconfigure.jdbc.DataSourceTransactionManagerAutoConfiguration$TransactionManagementConfiguration]; nested exception is java.lang.IllegalArgumentException: class org.springframework.transaction.annotation.TransactionManagementConfigurationSelector is not assignable to interface org.springframework.context.annotation.ImportSelector
10:08:56,711 ERROR [org.springframework.boot.SpringApplication] (MSC service thread 1-4) Application startup failed: org.springframework.beans.factory.BeanDefinitionStoreException: Failed to process import candidates for configuration class [org.springframework.boot.autoconfigure.jdbc.DataSourceTransactionManagerAutoConfiguration$TransactionManagementConfiguration]; nested exception is java.lang.IllegalArgumentException: class org.springframework.transaction.annotation.TransactionManagementConfigurationSelector is not assignable to interface org.springframework.context.annotation.ImportSelector
at org.springframework.context.annotation.ConfigurationClassParser.processImports(ConfigurationClassParser.java:546) [spring-context-4.3.2.RELEASE.jar:4.3.2.RELEASE]
at org.springframework.context.annotation.ConfigurationClassParser.doProcessConfigurationClass(ConfigurationClassParser.java:286) [spring-context-4.3.2.RELEASE.jar:4.3.2.RELEASE]
.....
.....
.....
Caused by: java.lang.IllegalArgumentException: class org.springframework.transaction.annotation.TransactionManagementConfigurationSelector is not assignable to interface org.springframework.context.annotation.ImportSelector
at org.springframework.util.Assert.isAssignable(Assert.java:376) [spring-core-4.3.2.RELEASE.jar:4.3.2.RELEASE]
at org.springframework.util.Assert.isAssignable(Assert.java:359) [spring-core-4.3.2.RELEASE.jar:4.3.2.RELEASE]
at org.springframework.beans.BeanUtils.instantiateClass(BeanUtils.java:124) [spring-beans-4.3.2.RELEASE.jar:4.3.2.RELEASE]
at org.springframework.context.annotation.ConfigurationClassParser.processImports(ConfigurationClassParser.java:511) [spring-context-4.3.2.RELEASE.jar:4.3.2.RELEASE]
... 30 more
WildFly was trying to start Gatewayapplication but failed to start it.
jar inside gatewayzull.war.WEB-INF.lib not loaded.
deployment.MyEE.ear.lib also has spring related jar. I have added exclusion tag in jboss-deplyment-structure.xml inorder to exclude while loading but this also did not helps.
Snipper of jboss.xml :
<?xml version="1.0" encoding="UTF-8"?>
<jboss-deployment-structure>
..
..
<sub-deployment name="gateway.war">
<exclusions>
<module name="deployment.MyEE.ear.XX.war" />
<module name="deployment.MyEE.ear.EJB.jar" />
<module name="deployment.MyEE.ear.lib" />
<module name="javax.ws.rs.api" />
</exclusions>
<exclude-subsystems>
<subsystem name="jaxrs" />
</exclude-subsystems>
</sub-deployment>
</jboss-deployment-structure>
I am assuming that core issue would be due to application server not able to load jar inside war/web-inf/lib and in turn server not intializing SpringBootServeletIntializer.
Any idea to resolve this ?

Failed to process phase STRUCTURE of deployment

I read in other topics, but I can't quite figure this out. I have an EJB module that uses log4j. I want to package that EJB into a JAR file and put in the WEB-INF/lib path of a web project. The web project has a servlet that executes a function from the EJB, and that's it. But seems that the appender doesn't work, for the file is created but not written.
I read that a deployment descriptor for JBoss, so I created one based on one of the previous posts. But i get a "Failed to process phase STRUCTURE of deployment" error.
12:04:44,905 ERROR [org.jboss.msc.service.fail] (MSC service thread 1-2) MSC00001: Failed to start service jboss.deployment.unit."SampleWeb.war".STRUCTURE: org.jboss.msc.service.StartException in service jboss.deployment.unit."SampleWeb.war".STRUCTURE: Failed to process phase STRUCTURE of deployment "SampleWeb.war"
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_21]
at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source) [rt.jar:1.7.0_21]
at java.lang.Thread.run(Unknown Source) [rt.jar:1.7.0_21]
Caused by: org.jboss.as.server.deployment.DeploymentUnitProcessingException: Sub deployment SampleEJB.jar in jboss-structure.xml was not found. Available sub deployments:
at org.jboss.as.server.deployment.module.descriptor.DeploymentStructureDescriptorParser.subDeploymentNotFound(DeploymentStructureDescriptorParser.java:233) [jboss-as-server-7.1.1.Final.jar:7.1.1.Final]
at org.jboss.as.server.deployment.module.descriptor.DeploymentStructureDescriptorParser.deploy(DeploymentStructureDescriptorParser.java:159) [jboss-as-server-7.1.1.Final.jar:7.1.1.Final]
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
Here's the jboss-deployment-structure.xml I created. Because the web project only uses the EJB jar file I created I assumed that the deployment tag is not used.
<?xml version="1.0" encoding="UTF-8"?>
<jboss-deployment-structure>
<sub-deployment name="SampleEJB.jar">
<exclusions>
<module name="org.apache.log4j"/>
<module name="org.slf4j" />
<module name="org.apache.commons.logging"/>
<module name="org.log4j"/>
<module name="org.jboss.logging"/>
</exclusions>
</sub-deployment>
</jboss-deployment-structure>
I'm using JBoss 7.1.1, by the way.
It seems like eclipse issue, may happen when dependant project of an ear not built properly.
In my case I was getting the same error with reason that ear was unable to find one included dependency jar.
Just check that dependent project and check it's target directory where maven creates jar after building the project. It would be empty if maven does not build that project properly.
Build that dependent project separately by "mvn install" and then try deploying ear on your server.
It worked for me.
org.jboss.as.server.deployment.DeploymentUnitProcessingException: Sub deployment SampleEJB.jar in jboss-structure.xml was not found.
It seems SampleEJB.jar is not deployed yet. Create deployment structure file to deploy components in order.

Creating module in jBoss AS

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>

JBOSS 7 - Spring ContextLoaderListener ClassNotFoundException

im trying to migrate my JBOSS 5.1 application to JBOSS 7.0.2. In admin console i select deployments -> add content and my .war and try to enable it.
I already resolved some problems, but cant figure out this one: (in short, in long at the end)
Caused by: java.lang.ClassNotFoundException: org.springframework.web.context.ContextLoaderListener from [Module "deployment.ZaprogsProject.war:main" from Servic
e Module Loader]
I copied to JBOSS7\standalone\lib\ the following files:
spring-aop-3.0.5.RELEASE.jar
spring-asm-3.0.5.RELEASE.jar
spring-beans-3.0.5.RELEASE.jar
spring-context-3.0.5.RELEASE.jar
spring-context-support-3.0.5.RELEASE.jar
spring-core-3.0.5.RELEASE.jar
spring-expression-3.0.5.RELEASE.jar
spring-jdbc-3.0.5.RELEASE.jar
spring-orm-3.0.5.RELEASE.jar
spring-test-3.0.5.RELEASE.jar
spring-tx-3.0.5.RELEASE.jar
spring-web-3.0.5.RELEASE.jar
spring-webmvc-3.0.5.RELEASE.jar
I have read this: https://docs.jboss.org/author/display/AS7/How+do+I+migrate+my+application+from+AS5+or+AS6+to+AS7 (Debug and resolve ClassNotFoundExceptions and NoClassDefFoundErrors) but cant find a solution for me and still getting the same error. Can anyone help?
22:19:12,091 ERROR [org.jboss.msc.service.fail] (MSC service thread 1-1) MSC00001: Failed to start service jboss.deployment.unit."ZaprogsProject.war".INSTALL: o
rg.jboss.msc.service.StartException in service jboss.deployment.unit."ZaprogsProject.war".INSTALL: Failed to process phase INSTALL of deployment "ZaprogsProject
.war"
at org.jboss.as.server.deployment.DeploymentUnitPhaseService.start(DeploymentUnitPhaseService.java:121) [jboss-as-server-7.0.2.Final.jar:7.0.2.Final]
at org.jboss.msc.service.ServiceControllerImpl$StartTask.startService(ServiceControllerImpl.java:1824) [jboss-msc-1.0.1.GA.jar:1.0.1.GA]
at org.jboss.msc.service.ServiceControllerImpl$StartTask.run(ServiceControllerImpl.java:1759) [jboss-msc-1.0.1.GA.jar:1.0.1.GA]
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1110) [:1.7.0]
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:603) [:1.7.0]
at java.lang.Thread.run(Thread.java:722) [:1.7.0]
Caused by: java.lang.RuntimeException: Failed to load class org.springframework.web.context.ContextLoaderListener
at org.jboss.as.ee.component.deployers.EEClassConfigurationProcessor$1.compute(EEClassConfigurationProcessor.java:141)
at org.jboss.as.ee.component.deployers.EEClassConfigurationProcessor$1.compute(EEClassConfigurationProcessor.java:122)
at org.jboss.as.ee.component.LazyValue.get(LazyValue.java:40)
at org.jboss.as.ee.component.EEApplicationDescription.getClassConfiguration(EEApplicationDescription.java:183)
at org.jboss.as.ee.component.ComponentDescription.createConfiguration(ComponentDescription.java:153)
at org.jboss.as.ee.component.deployers.EEModuleConfigurationProcessor.deploy(EEModuleConfigurationProcessor.java:70)
at org.jboss.as.server.deployment.DeploymentUnitPhaseService.start(DeploymentUnitPhaseService.java:115) [jboss-as-server-7.0.2.Final.jar:7.0.2.Final]
... 5 more
Caused by: java.lang.ClassNotFoundException: org.springframework.web.context.ContextLoaderListener from [Module "deployment.ZaprogsProject.war:main" from Servic
e Module Loader]
at org.jboss.modules.ModuleClassLoader.findClass(ModuleClassLoader.java:191)
at org.jboss.modules.ConcurrentClassLoader.performLoadClassChecked(ConcurrentClassLoader.java:361)
at org.jboss.modules.ConcurrentClassLoader.performLoadClassChecked(ConcurrentClassLoader.java:333)
at org.jboss.modules.ConcurrentClassLoader.performLoadClass(ConcurrentClassLoader.java:310)
at org.jboss.modules.ConcurrentClassLoader.loadClass(ConcurrentClassLoader.java:103)
at java.lang.Class.forName0(Native Method) [:1.7.0]
at java.lang.Class.forName(Class.java:264) [:1.7.0]
at org.jboss.as.ee.component.deployers.EEClassConfigurationProcessor$1.compute(EEClassConfigurationProcessor.java:139)
... 11 more
JBoss AS 7 does class-loading in a diff way.
All classes in the WAR are loaded with the same class loader. This means classes packaged in the WEB-INF/lib are treated the same as classes in WEB-INF/classes.
Hence it works for you.
But as you have said correctly your WEB-INF/lib is bloated.This would not be the correct way.
You would need to make a module :
Goto modules folder, make folder structure with main folder and put your jar and modules.xml with entries in it.
Something like :
<main-class name="org.jboss.msc.Version"/>
<resources>
<resource-root path="jboss-msc-1.0.1.GA.jar"/>
</resources>
<dependencies>
<module name="javax.api"/>
<module name="org.jboss.logging"/>
<module name="org.jboss.modules"/>
<!-- Optional deps -->
<module name="javax.inject.api" optional="true"/>
<module name="org.jboss.threads" optional="true"/>
<module name="org.jboss.vfs" optional="true"/>
</dependencies>
You would also need to update MANIFEST as well.
Details are here :
https://docs.jboss.org/author/display/MODULES/Module+descriptors
I would not put those JARs in that directory. Try them in your WAR file's WEB-INF/lib. The class loader will find them there.
You need to understand that all Java EE app servers use a hierarchy of class loaders: bootstrap, server, application. JBoss wasn't finding that class when it needed to.
There is a major change Jboss 7 when compared to previous versions.If you want to access any libraries outside your war file, it should be installed as module.
Check https://docs.jboss.org/author/display/MODULES/Introduction
In this case you should install Spring as module and specify the name of the module as dependency in your application's manifest file(check Manifest module information)
In case the issue started occurring all of a sudden(just like in my case), deleting the application (MyApp) physically from #JBOSS_HOME#\standalone\deployments\ MyApp.war worked for me.

Categories