CXF 2.7.0 web service deployment in Wildfly 10 - deployment

Goal - Migrating EAR application from JBoss EAP 5 to Wildfly 10
Issue : Code has CXF 2.7.0 web service client code (to call third party web service) and its added to the EAR/lib folder. But during deployment, I am getting below exception
log:
2016-02-26 12:17:48,075 ERROR [org.jboss.msc.service.fail] (MSC service thread 1-6) MSC000001: Failed to start service jboss.deployment.unit."rts-comcast-01.01.75.ear".WeldStartService: org.jboss.msc.service.StartException in service jboss.deployment.unit."rts-comcast-01.01.75.ear".WeldStartService: Failed to start service
at org.jboss.msc.service.ServiceControllerImpl$StartTask.run(ServiceControllerImpl.java:1904)
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: org.jboss.weld.exceptions.DefinitionException: WELD-000071: Managed bean with a parameterized bean class must be #Dependent: class org.apache.cxf.jaxrs.provider.DataBindingProvider
at org.jboss.weld.bean.ManagedBean.checkType(ManagedBean.java:208)
at org.jboss.weld.bean.AbstractBean.initializeAfterBeanDiscovery(AbstractBean.java:107)
at org.jboss.weld.bean.ManagedBean.initializeAfterBeanDiscovery(ManagedBean.java:122)
at org.jboss.weld.bootstrap.ConcurrentBeanDeployer$AfterBeanDiscoveryInitializerFactory.doWork(ConcurrentBeanDeployer.java:136)
at org.jboss.weld.bootstrap.ConcurrentBeanDeployer$AfterBeanDiscoveryInitializerFactory.doWork(ConcurrentBeanDeployer.java:127)
at org.jboss.weld.executor.IterativeWorkerTaskFactory$1.call(IterativeWorkerTaskFactory.java:63)
at org.jboss.weld.executor.IterativeWorkerTaskFactory$1.call(IterativeWorkerTaskFactory.java:56)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
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)
beans-xml
I have added below beans-xml to the META-INF and WEB-INF as well
<?xml version="1.0" encoding="UTF-8"?> <beans xmlns="http://xmlns.jcp.org/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/beans_1_1.xsd"
bean-discovery-mode="annotated">
Alternate try
I was in a doubt whether the given libs are getting loaded to the application and want confirm my dependencies are good. so made a sample web application and loaded all the CXF jar files this time to WEB-INF/lib folder itself and deployed this time also the same issue as mentioned above
CXF version in Wildfly 10
Wildfly 10 comes with CXF 3.1.4, but i have given my needed jars in my lib folder and did not mention any container provided CXF modules, to ensure CXF version in libs to load.
Could some provide an insight where I am doing wrong? Thanks for your help
After searching for a while i added the below config changes in jboss-deployment-strucutre.xml and still having issues. Please use this link for detailed information
https://developer.jboss.org/thread/268163

Issue resolved after adding proper exclusion entries of container provided CXF3.1.4 and provided CXF version 2.7 or 2.4.4 (not sure about other lower versions)
jboss-deployment-structure.xml must be in the parent level META-INF in case your application has multiple modules (JAR, WAR, MDB)
These are my entries:
<!-- Exclusions allow you to prevent the server from automatically adding some dependencies -->
<exclusions>
<!-- Exclude Version cxf of JBOSS -->
<module name="org.apache.cxf" />
<!-- Exclude JAVA EE of JBOSS (javax.ws..) => Add dependency javax.annotation -->
<module name="javaee.api" />
<!-- Exclude RestEasy conflict (javax.ws.rs.ext.RunDelegate) -->
<module name="org.jboss.resteasy.resteasy-jackson-provider" />
<!-- module name="org.apache.log4j" />
<module name="org.apache.commons.logging"/ -->
<module name="org.jboss.as.jaxrs"/>
<module name="org.jboss.resteasy.resteasy-jaxrs"/>
<module name="org.jboss.resteasy.resteasy-cdi"/>
<module name="org.jboss.resteasy.jackson-provider"/>
<module name="org.jboss.resteasy.resteasy-atom-provider"/>
<module name="org.jboss.resteasy.resteasy-hibernatevalidator-provider"/>
<module name="org.jboss.resteasy.resteasy-jaxb-provider"/>
<module name="org.jboss.resteasy.resteasy-jettison-provider"/>
<module name="org.jboss.resteasy.resteasy-jsapi"/>
<module name="org.jboss.resteasy.resteasy-multipart-provider"/>
<module name="org.jboss.resteasy.resteasy-yaml-provider"/>
<module name="org.codehaus.jackson.jackson-core-asl"/>
<module name="org.codehaus.jackson.jackson-jaxrs"/>
<module name="org.codehaus.jackson.jackson-mapper-asl"/>
<module name="org.codehaus.jackson.jackson-xc"/>
<module name="org.codehaus.jettison"/>
<module name="javax.ws.rs.api"/>
</exclusions>

Related

Adding smallrye mutiny dependency in JBoss EAP 7.3

I have a microprofile application using Smallrye Mutiny, which I need to deploy on JBoss EAP 7.3. I have applied JBoss EAP XP patch to enable microprofile features. I have also added mutiny jar as a module in EAP.
Below are the module file contents
<?xml version="1.0" encoding="UTF-8"?>
<module xmlns="urn:jboss:module:1.1"
name="io.smallrye.reactive.mutiny">
<resources>
<resource-root path="mutiny-0.9.0.jar" />
</resources>
<dependencies>
<module name="org.reactivestreams" />
</dependencies>
</module>
And the module.xml for reactivestreams is
<?xml version="1.0" encoding="UTF-8"?>
<module xmlns="urn:jboss:module:1.1" name="org.reactivestreams">
<resources>
<resource-root path="reactive-streams-1.0.3.jar" />
</resources>
</module>
However in my application I'm getting the below Exception
Failed to define class io.smallrye.mutiny.Multi in Module "deployment.SampleReactive.war" from Service Module Loader: java.lang.NoClassDefFoundError: Failed to link io/smallrye/mutiny/Multi (Module "deployment.SampleReactive.war" from Service Module Loader): org/reactivestreams/Publisher
How can I configure JBoss EAP to work with reactive applications built using Microprofile? Any help is appreciated.
Edit: I have managed to get the app working on EAP 7.3. But now I am facing a different issue.
App has REST Apis which emit Uni and Multi. The REST API produces Json. But when I run this program in EAP, I see and object as the response instead of a JSON.
It seems that EAP is not able to convert Uni and Multi to JSON.
Is there any library that I need to add for this to work?

ModuleNotFoundException after Thorntail upgrade

I just upgraded the Thorntail version of my application from 2.5.0.Final to 2.6.0. Final.
My app is using a module (for authorization), which lies in a separate git repo, so I've included it in my pom.xml.
Since the upgrade I'm getting a ModuleNotFoundException when the module is called (authorization is triggered)
Caused by: org.jboss.modules.ModuleNotFoundException: org.apache.santuario.xmlsec
at org.jboss.modules.Module.addPaths(Module.java:1266) [backend-thorntail.jar:]
at org.jboss.modules.Module.link(Module.java:1622) [backend-thorntail.jar:]
at org.jboss.modules.Module.relinkIfNecessary(Module.java:1650) [backend-thorntail.jar:]
at org.jboss.modules.ModuleLoader.loadModule(ModuleLoader.java:299) [backend-thorntail.jar:]
at org.jboss.modules.ModuleLoader.loadModule(ModuleLoader.java:283) [backend-thorntail.jar:]
at org.jboss.as.security.plugins.SecurityActions.getModuleClassLoader(SecurityActions.java:50) [thorntailwildfly-security-18.0.1.Final5333088777079625058.jar:18.0.1.Final]
at org.jboss.as.security.plugins.ModuleClassLoaderLocator.get(ModuleClassLoaderLocator.java:65) [thorntailwildfly-security-18.0.1.Final5333088777079625058.jar:18.0.1.Final]
... 49 more
The problem is, that the org.apache.santuario.xmlsec dependency of the module is not being bundled in the thorntail jar, while all other dependencies are present in the jar.
This is the module.xml of the used module:
</module>
...
<dependencies>
<module name="javax.api"/>
<module name="javax.servlet.api"/>
<module name="org.apache.xalan"/>
<module name="org.apache.santuario.xmlsec"/>
<module name="org.picketbox"/>
<module name="org.jboss.logging"/>
</dependencies>
</module>
Does anyone have an idea how I can "force" Thorntail to include this dependency?
I also tried simply adding the latest version of the missing dependency in my pom.xml but unfortunately this doesn't help.
Any help is appreciated - thanks!

"Could not find default constructor" error during webapp deployment in WildFly 8.2

I am deploying a Spring 3.2.9 based web app within WildFly 8.2.0 using the following runtime descriptor
<jboss-deployment-structure>
<deployment>
<exclude-subsystems>
<subsystem name="jaxrs" />
<subsystem name="weld" />
</exclude-subsystems>
<exclusions>
<module name="org.apache.commons.logging" />
<module name="org.apache.log4j" />
<module name="org.hibernate"/>
<module name="org.jboss.logging.jul-to-slf4j-stub" />
<module name="org.jboss.logmanager" />
<module name="org.jboss.logmanager.log4j" />
<module name="org.slf4j" />
<module name="org.slf4j.impl"/>
</exclusions>
<dependencies>
<module name="org.javassist"/>
<module name="org.antlr"/>
<module name="org.jboss.jboss-transaction-spi"/>
<module name="org.jboss.marshalling"/>
<module name="org.jboss.marshalling.river"/>
<module name="org.dom4j"/>
<module name="org.scannotation.scannotation"/>
<module name="org.mariadb"/>
</dependencies>
</deployment>
</jboss-deployment-structure>
My expectation was that Spring instead of Weld (the default with WildFly) will be used as the DI engine
However when deploying our webapp, I am hitting the following error
The JobGridLiveListServiceImpl class has a single constructor that receives another bean via injection
2016-02-18 12:27:49,040 ERROR [org.jboss.msc.service.fail] (MSC service thread 1-3) MSC000001: Failed to start service jboss.deployment.unit."dfm-app.war".INSTALL: org.jboss.msc.service.StartException in service jboss.deployment.unit."dfm-app.war".INSTALL: JBAS018733: Failed to process phase INSTALL of deployment "dfm-app.war" at
org.jboss.as.server.deployment.DeploymentUnitPhaseService.start(DeploymentUnitPhaseService.java:166)
[wildfly-server-8.2.0.Final.jar:8.2.0.Final]
at
org.jboss.msc.service.ServiceControllerImpl$StartTask.startService(ServiceControllerImpl.java:1948)
[jboss-msc-1.2.2.Final.jar:1.2.2.Final]
at
org.jboss.msc.service.ServiceControllerImpl$StartTask.run(ServiceControllerImpl.java:1881)
[jboss-msc-1.2.2.Final.jar:1.2.2.Final]
at
java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
[rt.jar:1.8.0_51]
at
java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
[rt.jar:1.8.0_51]
at java.lang.Thread.run(Thread.java:745) [rt.jar:1.8.0_51] Caused by:
org.jboss.as.server.deployment.DeploymentUnitProcessingException:
JBAS011030: Could not configure component com.netapp.dfm.webui.server.job.JobGridLiveListServiceImpl
at
org.jboss.as.ee.component.deployers.EEModuleConfigurationProcessor.deploy(EEModuleConfigurationProcessor.java:95)
at
org.jboss.as.server.deployment.DeploymentUnitPhaseService.start(DeploymentUnitPhaseService.java:159)
[wildfly-server-8.2.0.Final.jar:8.2.0.Final]
... 5 more
Caused by:
org.jboss.as.server.deployment.DeploymentUnitProcessingException:
JBAS011054: Could not find default constructor for class com.netapp.dfm.webui.server.job.JobGridLiveListServiceImpl
at
org.jboss.as.ee.component.DefaultInterceptorConfigurator.configure(DefaultInterceptorConfigurator.java:92)
at
org.jboss.as.ee.component.deployers.EEModuleConfigurationProcessor.deploy(EEModuleConfigurationProcessor.java:81)
... 6 more
The same code was works fine on Jboss AS 6.1.
Any inputs on the probable reasons this exception is thrown?
I faced the same error on JBOSS EAP 7, in order to resolve I added a default constructor without parameters in the mentioned class, however this is only possible when the issue occurs for a cusom jar or external dependency which has been developed by us.

Why does my JBoss module throw a ClassCastException?

Hi StackOverflow Community,
I have a WAR which I have deployed to a JBoss Wildfly 8.2 instance. Also in Wildfly, I have created two modules:
a third party JMS JCA adapter module,
and a model module (model.jar) that contains message classes used to communicate between the JMS broker and the WAR
The WAR has a jboss-deployment-structure.xml that declares a dependency on the JCA module:
<?xml version='1.0' encoding='UTF-8'?>
<jboss-deployment-structure xmlns="urn:jboss:deployment-structure:1.2">
<deployment>
<dependencies>
<module name="com.thirdparty.mq.ra" slot="main"/>
<module name="com.company.model" slot="main">
</dependencies>
</deployment>
</jboss-deployment-structure>
The WAR has the model.jar file packaged in its WEB-INF/lib folder.
The JMS module has a dependency on the model module:
<?xml version="1.0" encoding="UTF-8"?>
<module xmlns="urn:jboss:module:1.3" name="com.thirdparty.mq.ra">
<resources>
<resource-root path="."/>
<resource-root path="thirdparty-jms-provider.jar"/>
...
<resource-root path="thirdparty-lib.jar"/>
</resources>
<dependencies>
<module name="com.company.model"/>
<module name="javax.api"/>
<module name="javax.jms.api"/>
<module name="javax.transaction.api"/>
<module name="javax.management.j2ee.api"/>
<module name="javax.resource.api"/>
<module name="org.jboss.invocation"/>
<module name="org.jboss.remote-naming" optional="true"/>
<module name="org.slf4j"/>
</dependencies>
</module>
When running, I get the following exception:
Caused by: java.lang.ClassCastException: com.company.model.web.dto.WebAuthenticationResponse cannot be cast to com.company.model.web.dto.WebAuthenticationResponse
I suspect it is a classloader issue. Is there some extra information I have to specify in the module.xml or jboss-deployment-structure.xml files?
Thanks for your help!
Assuming that your model.jar corresponds to your com.company.model module, your WAR classloader now sees the model classes twice, both from its own libraries in WEB-INF/lib and via the module dependency.
You should either import or embed a module/library, but not both.
By the way, importing a RAR module looks a bit suspicious. You should never depend on the implementation of a resource adapter. Maybe you can factor out an API module and import that.

JBoss AS7. How to load some.jar before war in deployment?

I have EAR which consist from war and jar.
project.ear
....package.war
....lib
.......library.jar
library.jar should be initialized before deploying war file.
My application.xml file:
<?xml version="1.0" encoding="UTF-8"?>
<application 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/application_6.xsd" version="6">
<display-name>project</display-name>
<initialize-in-order>true</initialize-in-order>
<module>
<java>library.jar</java>
</module>
<module>
<web>
<web-uri>package.war</web-uri>
<context-root>/</context-root>
</web>
</module>
<library-directory>lib</library-directory>
</application>
My jboss-deployment-structure.xml file:
<jboss-deployment-structure>
<ear-subdeployments-isolated>false</ear-subdeployments-isolated>
<deployment>
<dependencies>
//some modules
</dependencies>
</deployment>
<sub-deployment name="library.jar">
<resources>
<resource-root path="lib/library.jar"/>
</resources>
</sub-deployment>
<sub-deployment name="package.war">
<exclusions>
<module name="javax.faces.api" slot="main"/>
<module name="com.sun.jsf-impl" slot="main"/>
</exclusions>
</sub-deployment>
</jboss-deployment-structure>
But when JBoss deploying my app, I see next error in log file.
{"JBAS014671: Failed services" => {"jboss.deployment.unit.\"project.ear\".STRUCTURE" => "org.jboss.msc.service.StartException in servi
ce jboss.deployment.unit.\"project.ear\".STRUCTURE: JB
AS018733: Failed to process phase STRUCTURE of deployment \"project.ear\"
Caused by: org.jboss.as.server.deployment.DeploymentUnitProcessingException:
JBAS011037: Unable to process modules in application.xml for EAR [\"/C:/DEV/jbo
ss-eap-6.1/bin/content/project.ear\"], module file library.jar not found"}}
I need in strict loading of modules. Only when library.jar will be fully initialized, package.war should be deploying.
Separating your JMX beans setup to other deployment unit (like SAR or WAR) and setting this deployment as a EAR's dependency could to the trick.
As I already told before, I have to initiliaze spring JMX settings before another configuration. Spring parent context is a great way for solving this issue. Just define parentContextKey as you need and Spring will do everything itself.
https://spring.io/blog/2007/06/11/using-a-shared-parent-application-context-in-a-multi-war-spring-application/