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 ?
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 ?
I am trying to deploy same web application with different context on jboss EAP 7.2
Like testOne.war and testTwo.war. My urls will be like
1)http://127.0.0.1:8080/testOne/get.
2)http://127.0.0.1:8080/testTwo/get.
Both wars are deployed properly, but only one url is working fine and other is throwing error by overriding the default server.
[org.wildfly.extension.undertow] (ServerService Thread Pool -- 84) WFLYUT0021: Registered web context: '/testOne' for server 'default-server'
it's over ridden by
[org.wildfly.extension.undertow] (ServerService Thread Pool -- 84) WFLYUT0021: Registered web context: '/testTwo' for server 'default-server'
In the above senario http://127.0.0.1:8080/testTwo/get. will work fine and http://127.0.0.1:8080/testOne/get will throw exception
UT005023: Exception handling request to testOne/get: java.lang.LinkageError: loader constraint violation in interface itable initialization: when resolving method "org.glassfish.jersey.message.internal.InboundMessageContext.getHeaders()Ljavax/ws/rs/core/MultivaluedMap;" the class loader (instance of org/jboss/modules/ModuleClassLoader) of the current class, org/glassfish/jersey/server/ContainerRequest, and the class loader (instance of org/jboss/modules/ModuleClassLoader) for interface javax/ws/rs/container/ContainerRequestContext have different Class objects for the type javax/ws/rs/core/MultivaluedMap used in the signature
The same is working fine in tomcat 8.5.35
Add below snippet in "jboss-deployment-structure.xml"
<?xml version="1.0" encoding="UTF-8"?>
<jboss-deployment-structure>
<deployment>
<dependencies>
<module name="org.jboss.remote-naming" />
</dependencies>
</deployment>
</jboss-deployment-structure>
I'm deploying my EAR on JBoss EAP 7.0.0, which has the following structure:
app.ear
|-- ejb.jar
|-- app.war
|-- lib
|-- hibernate-core-5.2.10.Final.jar
|-- hibernate-hibernate-spatial-5.2.10.Final.jar
|-- hibernate-commons-annotations-5.0.1.Final.jar
|-- META-INF
|-- application.xml
|-- jboss-app.xml
I added a small piece of code in one of my EJB bean that prints org.hibernate.Version.getVersionString() to know which version of Hibernate my application is using and it gives me 5.0.9.Final-readhat-1 instead of something like 5.2.10.Final.
I've read a lot about classloading issues (especially here and here), but after many different trials, I couldn't find a way to make JBoss use the packaged version of Hibernate in my EAR.
It looks like the tag is ignored in EAP 7 ? It seems that the classloading has changed in JBoss AS 7.
Here is the content of my jboss-app.xml:
<?xml version="1.0" encoding="UTF-8"?>
<jboss-app>
<loader-repository>
my.package:archive=app.ear
<loader-repository-config>
java2ParentDelegation=false
</loader-repository-config>
</loader-repository>
</jboss-app>
Is there a way to force JBoss EAP 7 to load the classes from my EAR prior to the bootstrap classloader ?
Note: I also posted this question here.
======================================================= EDIT
I tried with this jboss-deployment-structure.xml:
<jboss-deployment-structure>
<deployment>
<exclude-subsystems>
<subsystem name="org.hibernate" />
</exclude-subsystems>
<exclusions>
<module name="org.hibernate" />
</exclusions>
</deployment>
</jboss-deployment-structure>
During the deployment, I get the following error:
{"WFLYCTL0062: Composite operation failed and was rolled back. Steps that failed:" => {"Operation step-2" => {"WFLYCTL0080: Failed services" => {"jboss.persistenceunit.\"app.ear/ejb.jar#app-ejbPU\"" => "org.jboss.msc.service.StartException in service jboss.persistenceunit.\"app.ear/ejb.jar#app-ejbPU\": java.util.ServiceConfigurationError: org.hibernate.integrator.spi.Integrator: Provider org.hibernate.envers.boot.internal.EnversIntegrator not a subtype
Caused by: java.util.ServiceConfigurationError: org.hibernate.integrator.spi.Integrator: Provider org.hibernate.envers.boot.internal.EnversIntegrator not a subtype"}}}}
JBoss 7 (and WildFly) is using a modules system instead of class loaders to separate different apps and libraries.
Try to disable hibernate in your app: Place a jboss-deployment-stucture.xml file in your EAR's META-INF folder:
<jboss-deployment-structure>
<deployment>
<exclusions>
<module name="org.hibernate" />
</exclusions>
</deployment>
</jboss-deployment-structure>
See: https://docs.jboss.org/author/display/WFLY10/Class+Loading+in+WildFly
I have a fresh installed Wildfly 10 application server running in standalone mode. I need to deploy a project requiring the MySQL JDBC driver.
I installed the driver following the tutorial found at JDBC Driver Setup (I have chosen the module installation). After restarting WildFly, in console.log I read:
INFO [org.jboss.as.connector.subsystems.datasources] (ServerService
Thread Pool -- 33) WFLYJCA0005: Deploying non-JDBC-compliant driver
class com.mysql.jdbc.Driver (version 5.1)
INFO [org.jboss.as.connector.deployers.jdbc] (MSC service thread 1-6)
WFLYJCA0018: Started Driver service with driver-name = mysql
It seems all good, but I can't get a connection for the database.
I'm using this piece of code:
Class.forName("com.mysql.jdbc.Driver");
Connection conn=DriverManager.getConnection("jdbc:mysql://localhost:3306/dbName?user=someUser&password=somePass");
The first line throws the exception:
com.mysql.jdbc.Driver from [Module
"deployment.someProject-1.0.0.war:main
from Service Module Loader]"
If I comment out the first line, I get No suitable driver exception.
Do you have any idea? Thanks in advice
You need to add a dependency for your WAR on the MySQL module you just created.
There are two ways, use a MANIFEST.MF file in the WAR with a line Dependencies: com.mysql
Or use a jboss-dependencies XML file like:
<jboss-deployment-structure>
<deployment>
<dependencies>
<module name="com.mysql" />
</dependencies>
</deployment>
</jboss-deployment-structure>
Both should be placed in the META-INF directory of the WAR file. There should be Maven plugins available to create both for you.
I have an idea.
As far as I know in WildFly modules are not seen to the apps by default.
And I suppose that you need to make your app know about the MySql module.
If you have WAR than need to create file jboss-deployment-structure.xml in WEB-INF folder with content like this:
<?xml version="1.0" encoding="UTF-8"?>
<jboss-deployment-structure>
<deployment>
<dependencies>
<module name="mysql" />
</dependencies>
</deployment>
</jboss-deployment-structure>
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.