I'm trying to convert my project from EAP 6.3 to Wildfly Swarm...
I'm having some trouble with CXF.
I've got the fraction dependency:
<dependency>
<groupId>org.wildfly.swarm</groupId>
<artifactId>camel-cxf</artifactId>
</dependency>
And then later, I include this, because otherwise I get a "package org.apache.cxf.message does not exist" error in my Camel Processor code
<dependency>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-rt-transports-http</artifactId>
<version>3.1.9</version>
</dependency>
So if I include it, I get the error:
Apache CXF library (cxf-core-3.1.9.jar) detected in ws endpoint
deployment; either provide a proper deployment replacing embedded
libraries with container module dependencies or disable the
webservices subsystem for the current deployment adding a proper
jboss-deployment-structure.xml descriptor to it. The former approach
is recommended, as the latter approach causes most of the webservices
Java EE and any JBossWS specific functionality to be disabled.
Ok, so maybe there's a lib conflict between the camel-cxf modules and my jar... or it's not picking up my jboss-deployment-structure.xml file?
I've tried a few things as suggested by other posts.
I tried adding this to jboss-deployment-structure.xml under ${basedir}/src/main/webapp/WEB-INF and adding the xml file to the webResources of the maven-war-plugin.
<deployment>
<exclude-subsystems>
<subsystem name="webservices" />
</exclude-subsystems>
</deployment>
I've also tried adding this to jboss-deployment-structure.xml:
<dependencies>
<module name="org.apache.cxf" />
<module name="org.apache.cxf.impl" />
</dependencies>
But I keep getting that error. So I'm not sure how to resolve this conflict. Any idea?
One Approach is to use Jboss provided CXF libraries and set <scope>provided</scope> for cxf-rt-transports-http, so that it compiles and but not package the CXF dependencies .
You find more on Jboss specific configuration
Related
I am relatively new to the whole JBoss ecosystem and am migrating an application from EAP 6.4 to EAP 7.1. I keep getting the issue:
.DeploymentUnitProcessingException: WFLYWS0059: Apache CXF library (cxf-core-(version).jar) detected in ws endpoint deployment; either provide a proper deployment replacing embedded libraries with container module dependencies or disable the webservices subsystem for the current deployment adding a proper jboss-deployment-structure.xml descriptor to it
where (version) changes on my altered attempts - changing the dependencyManagement in pom.xml.
Below is my dependencyManagement in my pom.xml file - the first is what it was on eap 6.4, the second was me attempting to upgrade it to v 7, and the third is what I have currently, copy-pasted from another application that does work on EAP 7.1:
<dependencyManagement>
<dependencies>
<!--<dependency>-->
<!--<groupId>org.jboss.fuse.bom</groupId>-->
<!--<artifactId>jboss-fuse-parent</artifactId>-->
<!--<version>6.3.0.redhat-283</version>-->
<!--<type>pom</type>-->
<!--<scope>import</scope>-->
<!--</dependency>
<!--<dependency>-->
<!--<!– https://mvnrepository.com/artifact/org.jboss.fuse/jboss-fuse-parent –>-->
<!--<groupId>org.jboss.fuse</groupId>-->
<!--<artifactId>jboss-fuse-parent</artifactId>-->
<!--<version>7.0.0.fuse-000191-redhat-1</version>-->
<!--<type>pom</type>-->
<!--<scope>import</scope>-->
<!--</dependency>-->
<dependency>
<groupId>org.jboss.bom</groupId>
<version>7.1.0.GA</version>
<artifactId>jboss-eap-javaee7-with-spring4</artifactId>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>
I have also tried updating the jboss-deployment-structure.xml to exclude webservices (which leads no NoClassDefFoundErrors), and have tried adding dependency modules apache.cxf and apache.cxf.impl.
In my eap 7.1 instance, the modules folder has a system/layers/base/org/apache/cxf/main/cxf-core-3.1.12.redhat-1.jar, which is what I believe is clashing with the cxf-core library in my application.
One thing I'm not quite sure of is that the people I took over this application from kept mentioning that it required FUSE, however outside of the fuse BOM in the pom.xml it seems deployed on a standard EAP 6.4 instance so I'm not sure if I'm missing something.
How do I go about ignoring this library or fixing this?
Thanks
EDIT:
The only cxf in the pom is as follows:
<dependency>
<groupId>org.apache.camel</groupId>
<artifactId>camel-cxf</artifactId>
</dependency>
and
<plugins>
<plugin>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-codegen-plugin</artifactId>
<version>${apache.cxf.version}</version>
<executions>
I am very new to Maven and am trying to use it to load the JARs I need for a web project.
I have been using the goal dependency:copy-dependencies and have set the output path to <project>\WEB-INF\libs. This has worked well so far.
I now want to intergrate the latest version of Swagger which has the following POM:
<!-- https://mvnrepository.com/artifact/io.swagger.core.v3/swagger-project -->
<dependency>
<groupId>io.swagger.core.v3</groupId>
<artifactId>swagger-project</artifactId>
<version>2.0.0-rc4</version>
<type>pom</type>
</dependency>
All this does is to load the POM to the libs folder.
Is it possible to recursively resolve POMs in the dependencies list or have I misunderstood something basic?
As has been said in the comment, take out the pom:
<!-- https://mvnrepository.com/artifact/io.swagger.core.v3/swagger-project -->
<dependency>
<groupId>io.swagger.core.v3</groupId>
<artifactId>swagger-project</artifactId>
<version>2.0.0-rc4</version>
</dependency>
The default type is jar so you don't need it, other types are pom, war, ear.
Make sure you have your proxy set in your settings.xml, which should be in ~/.m2 directory.
Consider following structure of jboss-deployment-structure.xml inside META-INF of ear
<!-- Make sub deployments not isolated so they can see each others classes without a Class-Path entry (default is true) -->
<ear-subdeployments-isolated>false</ear-subdeployments-isolated>
<deployment>
<!-- Exclusions allow you to prevent the server from automatically adding some dependencies -->
<exclusions>
<module name="org.apache.xerces" />
</exclusions>
</deployment>
<sub-deployment name="mySubDeployment.war">
<exclusions>
<module name="org.apache.log4j" />
</exclusions>
<dependencies>
<system>
<paths>
<path name="com/sun/org/apache/xerces/internal/dom"/>
<path name="com/sun/org/apache/xerces/internal/xni"/>
<path name="com/sun/org/apache/xerces/internal/jaxp"/>
</paths>
</system>
</dependencies>
</sub-deployment>
Given that, I have excluded default org.apache.xerces module from deployment (line#11) and deployed custom xercesImpl.jar in APP-INF/lib folder or ear. Also I have added path dependencies for mySubDeployment.war sub-deployment.
From where classes of xerces will be loaded for mySubDeployment.war? From the default com.apache.xerces module of WildFly or custom jar deployed in APP-INF/lib?
What is the exact meaning of adding path dependencies in sub-deployment? Will that ignore the exclusions (i.e. org.apache.xerces here) under main deployment?
You shouldn't really need those paths. You'll also have to exclude xerces for each sub-deployment.
Also the APP-INF directory is not a standard Java EE directory. You'll need to put libraries in the /lib directory of your EAR.
I am doing migration from JDev 12.1.3 to 12.2.0. Now there was some problem durnng compilation but it has been resolved by modifiying class path.
Now when I go for deployment then it showing me one exception. That is ...
"java.lang.NoSuchMethodError: org.jboss.logging.Logger.debugf(Ljava/lang/String;I)V"
I am using following dependencies..
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-core</artifactId>
<version>5.2.0.Final</version>
<type>jar</type>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.hibernate.common</groupId>
<artifactId>hibernate-commons-annotations</artifactId>
<version>5.0.1.Final</version>
<type>jar</type>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.hibernate.javax.persistence</groupId>
<artifactId>hibernate-jpa-2.1-api</artifactId>
<version>1.0.0.Final</version>
<type>jar</type>
<scope>provided</scope>
</dependency>
Apart from these dependencies I also looked into "C:\oracle_home12c\wlserver\modules" folder and found there was one "org.jboss.logging.jboss-logging.jar" file.
I replaced the maven repo file from "jboss-logging-3.3.0.Final".
I also looked into "jboss-logging-3.3.0.Final" jar file. There is one Logger class file but it does not contain the debugf(String) method.
Exception type;
Caused by: java.lang.NoSuchMethodError: org.jboss.logging.Logger.debugf(Ljava/lang/String;I)V
at org.hibernate.internal.NamedQueryRepository.checkNamedQueries(NamedQueryRepository.java:149)
at org.hibernate.internal.SessionFactoryImpl.checkNamedQueries(SessionFactoryImpl.java:764)
at org.hibernate.internal.SessionFactoryImpl.<init>(SessionFactoryImpl.java:495)
at org.hibernate.boot.internal.SessionFactoryBuilderImpl.build(SessionFactoryBuilderImpl.java:444)
at org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl.build(EntityManagerFactoryBuilderImpl.java:802)
at org.hibernate.jpa.HibernatePersistenceProvider.createContainerEntityManagerFactory(HibernatePersistenceProvider.java:135)
at weblogic.persistence.BasePersistenceUnitInfo.initializeEntityManagerFactory(BasePersistenceUnitInfo.java:611)
Can someone help to get rid off this problem?
Thanks in advance
If you are using the glassfish server the the problem might be with the lib provided by glassfish. This error is caused by the use of incompatible version.
Just create a glassfish-web.xml file in the WEB-INF directory. The contents of the file are shown below:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE glassfish-web-app PUBLIC "-//GlassFish.org//DTD GlassFish Application Server 3.1 Servlet 3.0//EN" "http://glassfish.org/dtds/glassfish-web-app_3_0-1.dtd">
<glassfish-web-app>
<class-loader delegate="false"/>
</glassfish-web-app>
This ensures that glassfish does not load it's internal libraries, but libraries from your project.
I don't know how JDev classloading works, but maybe it takes the a wrong version of jboss-logging which doesn't have the method? Try removing that from the modules dir. And make sure that your app bundles jboss-logging in the .war. It should be brought in by Hibernate's dependencies. If not, add it to the pom.xml.
I'm migrating an application from JBoss 6.1.0 JBoss EAP 4.2.xa.
I know I have changed many things, one of the most important is that JBoss now includes most of the framework / most used libraries (modules), which is great (war files smaller).
Now, I have two applications, both mounted with Spring / CXF and Maven2. One exposes a web services and the second for the first client.
The problem is in the client application, at runtime, when I try to instantiate the proxy web service I get the following error:
------ java.lang.NoClassDefFoundError: org/apache/cxf/jaxws/JaxWsProxyFactoryBean
at es....MyFactory.getService_WSC(MyFactory.java:59)
...
at javax.servlet.http.HttpServlet.service(HttpServlet.java:847)
...
at org.jboss.as.web.security.SecurityContextAssociationValve.invoke(SecurityContextAssociationValve.java:169)
...
at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:920)
at java.lang.Thread.run(Thread.java:662) Caused by: java.lang.ClassNotFoundException: org.apache.cxf.jaxws.JaxWsProxyFactoryBean from [Module "deployment.myapp.war:main" from Service Module Loader]
at org.jboss.modules.ModuleClassLoader.findClass(ModuleClassLoader.java:196)
at org.jboss.modules.ConcurrentClassLoader.performLoadClassUnchecked(ConcurrentClassLoader.java:444)
at org.jboss.modules.ConcurrentClassLoader.performLoadClassChecked(ConcurrentClassLoader.java:432)
at org.jboss.modules.ConcurrentClassLoader.performLoadClassChecked(ConcurrentClassLoader.java:399)
at org.jboss.modules.ConcurrentClassLoader.performLoadClass(ConcurrentClassLoader.java:374)
at org.jboss.modules.ConcurrentClassLoader.loadClass(ConcurrentClassLoader.java:119) ... 21 more ------
In my pom.xml, I have the following (CXF as provided):
<properties>
<cxf.version>2.6.6</cxf.version>
<cxf.scope>provided</cxf.scope>
</properties>
<!-- CXF -->
<dependency>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-rt-frontend-jaxws</artifactId>
<version>${cxf.version}</version>
<scope>${cxf.scope}</scope>
</dependency>
<dependency>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-rt-transports-http</artifactId>
<version>${cxf.version}</version>
<exclusions>
<exclusion>
<artifactId>commons-logging</artifactId>
<groupId>commons-logging</groupId>
</exclusion>
</exclusions>
<scope>${cxf.scope}</scope>
</dependency>
<dependency>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-rt-ws-security</artifactId>
<version>${cxf.version}</version>
<scope>${cxf.scope}</scope>
</dependency>
Could include CXF libraries but presumably this is not necessary and that JBoss EAP 6 already has them?, Though, if this is so why do I get the error above NoClassDefFoundError -> Caused by: java.lang.ClassNotFoundException?
Thank you!
Finally I've solved it.
First of all, thank willome response.
By the nature of the services architecture (implemented with Apache CXF) I preferred to solve using CXF.
JBoss EAP 6 embed a full version of CXF framework, with the particularity that is "divided" into modules and the key has been to identify exactly the modules included in the application.
The good thing about all this is that the war now are very light, and you can NOT include the vast majority of frameworks / libraries ... in my case I went from one war of 30MB to final 5MB.
Then finally I added the file to the application jboss-deployment-structure.xml, with the following contents:
<?xml version="1.0" encoding="UTF-8"?>
<jboss-deployment-structure>
<deployment>
<dependencies>
<module name="org.jboss.ws.cxf.jbossws-cxf-client" services="import" />
<module name="org.apache.cxf.impl">
<imports>
<include path="META-INF"/>
<include path="META-INF/cxf"/>
</imports>
</module>
<!-- ... -->
</dependencies>
</deployment>
</jboss-deployment-structure>
And I kept the scope "provided" in my pom.xm for CXF framework.
Your CXF libraries scope is <cxf.scope>provided</cxf.scope>. I am not sure if JBoss EAP 6 is embedding CXF-jaxrs (the REST part of CXF - you should inspect the jboss version of CXF 2.4.x-redhat-1). I think it uses Rest Easy instead. So it will not find org/apache/cxf/jaxws/JaxWsProxyFactoryBean.
Change the scope of cxf-rt-frontend-jaxws from provided to compile.
See https://access.redhat.com/site/articles/112673 to get the list of all embedded libs inside Jboss EAP 6.x