ModuleNotFoundException after Thorntail upgrade - wildfly

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!

Related

Wildfly Postgres JDBC module issue

I have postgres jdbc driver configured as module in Wildfly 10. What I am trying to do, is to use that driver as dependency in application that will be deployed on the server - so in application, I mark this dependency as provided (in pom.xml file) but it seems to be not working.
Current configuration:
Wildfly postgres module is added at wildfly-10.1.0.Final\modules\org\postgresql\main where there is: postgresql-9.4-1206-jdbc4.jar and module.xml with following content:
<module xmlns="urn:jboss:module:1.1" name="org.postgresql">
<resources>
<resource-root path="postgresql-9.4-1206-jdbc4.jar"/>
</resources>
<dependencies>
<module name="javax.api"/>
<module name="javax.transaction.api"/>
</dependencies>
</module>
Module is used to define datasource. To this point, everything is working well - with hibernate help tables are happily mapped to entities. Except one thing:
I started to map postgres-jsonb columns with use of javax.persistence.AttributeConverter and following happens:
Scenario 1
When I use postgresql-9.4-1206-jdbc4.jar as a provided (in pom.xml - deployed application), I get following error trying to convert anything:
Caused by: java.lang.ClassNotFoundException: org.postgresql.util.PGobject from [Module "deployment.priject-1.0.1.ear.project.data-1.0.1-SNAPSHOT.jar:main" from Service Module Loader]
at org.jboss.modules.ModuleClassLoader.findClass(ModuleClassLoader.java:198)
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)
... 269 more
Scenario 2
When I use postgresql-9.4-1206-jdbc4.jar with default scope, there is following error:
Caused by: java.lang.ClassCastException: org.postgresql.util.PGobject cannot be cast to org.postgresql.util.PGobject
at com.project.entity.util.converters.JSONBTypeConverter.convertToEntityAttribute(JSONBTypeConverter.java:33)
at com.project.entity.util.converters.JSONBTypeConverter.convertToEntityAttribute(JSONBTypeConverter.java:1)
at org.hibernate.type.descriptor.converter.AttributeConverterSqlTypeDescriptorAdapter$2.doConversion(AttributeConverterSqlTypeDescriptorAdapter.java:140)
... 266 more
Which means: class loader load the same jar two times, and can not cast this object to itself.
Question: Why provided scope of the dependency does not work for manually added (to wildfly) postgres driver? (I guess that would be the solution for me)
You need to use a jboss-deployment-structure.xml to add the module dependency to your deployment.
<jboss-deployment-structure>
<deployment>
<dependencies>
<module name="org.postgresql" />
</dependencies>
</deployment>
<sub-deployment name="project.data-1.0.1-SNAPSHOT.jar">
<dependencies>
<module name="org.postgresql" />
</dependencies>
</sub-deployment>
</jboss-deployment-structure>
Note the module dependency on the EAR may not be required. It just depends on how your EAR is setup.
Another option would be to add a Dependencies manifest entry. Since you're using Maven you could just use the maven-jar-plugin (since it appears this is a JAR inside an EAR) to create the entry.
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<configuration>
<archive>
<manifestEntries>
<Dependencies>org.postgresql</Dependencies>
</manifestEntries>
</archive>
</configuration>
</plugin>

CXF 2.7.0 web service deployment in Wildfly 10

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>

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 CLI adding module with optional dependency

I have a module.xml that looks like:
<module xmlns="urn:jboss:module:1.1" name="com.oracle">
<resources>
<resource-root path="ojdbc6.jar"/>
</resources>
<dependencies>
<module name="javax.api"/>
<module name="javax.transaction.api"/>
<module name="javax.servlet.api" optional="true"/>
</dependencies>
Using JBOSS-CLI one can do this:
./jboss-cli.sh -c --command="module add --name=com.oracle --resources=<path-to-file>/ojdbc6.jar --dependencies=javax.api,javax.transaction.api,javax.servlet.api"
to deploy the module. It is almost the same exact thing and the module.xml is generated; so I need not keep track of another xml.
But how can I get the 'optional="true"' from JBOSS-CLI?
Version: JBOSS-EAP 6.2.0. (would be great if I can find a solution that would work for either jboss 6.x EAP and wildfly 8x).
The CLI module command appears to only support simple dependencies.
You could work around it by supplying a pre-generated modules.xml file and specifying it in the CLI command using
--module-xml=filepath_to_modules.xml

JBoss 7.1 development issues

I am new to JBoss 7.1 and trying to migrate our appplication to migrate from jboss 6.0 to jboss 7.1 but at development time it loads only few specific jars automatically which is different from jboss 6.0 which loads all the jars from lib folder.If i add them externally then at deployement time it conflicts with the already available jars in jboss 7.1 /module folder.
so please let me know how to configure the jboss 7.1 so that it loads all or specified its internal jars.
If you need to use your own jar for the deployed application, then you can exclude these using a jboss-deployment-structure.xml file in your WEB-INF directory. Here is an example that describes about the format of the xml file.
I too faced same issue. One best thing I did was removing conflicting jars in JBoss lib folder as your deployment ear would have those already.
JBoss As 7.1 & JSF1.2, 2.0
Following required steps...
You have manually configure some files
1.Create folder MySQL folder\main folder
jboss-as-7.1.1.Final\modules\com\mysql
2.MySQL folder\module folder\add-> module.xml file and MySQL connector file
Module.xml code:
<?xml version="1.0" encoding="UTF-8"?>
<module xmlns="urn:jboss:module:1.1" name="com.mysql">
<resources>
<resource-root path="mysql-connector-java-5.1.10-bin.jar"/>
<!-- Insert resources here -->
</resources>
<dependencies>
<module name="javax.api"/>
<module name="javax.transaction.api"/>
<module name="javax.servlet.api" optional="true"/>
</dependencies>
</module>
3.Go to the JBoss-as-7.1.1.Final\modules\org\hibernate\main
open the module.xml file & add
<module name="com.mysql"/>
4.Go to the JBoss-as-7.1.1.Final\modules\org\jboss\as\weld\main
open the module.xml file & add
<module name="javax.faces.api" slot="1.2"/>
5.Go to the JBoss-as-7.1.1.Final\modules\org\jboss\weld\core\main
open the module.xml file & add
<module name="javax.faces.api" slot="1.2"/>