I am trying to configure Log4J 1.2.17 for JBoss EAP 6.4 and keep getting
ClassNotFoundException: org.apache.log4j.PropertyConfigurator.
I was not having this problem with EAP 6.2 and not sure what to do. The only support I could find was a migration guide but that didn't help much because everything it said to change I had already configured.
I found my problem. I orginally defined my dependency in my MANIFEST.MF like so:
Dependencies: org.apache.log4j
With this defined I get the above error. However when I remove this entry from my MANIFEST.MF and add the dependency to a jboss-deployment-structure.xml:
<jboss-deployment-structure>
<deployment>
<dependencies>
<module name ="org.apache.log4j"/>
</dependencies>
</deployment>
</jboss-deployment-structure>
My problem is resolved. Not sure if this is a bug or if it works as designed in EAP 6.4. I also tested that this solution is backwards compatible to EAP 6.2.
Related
I have come across a rather curious issue with wildfly classloading. I have a java-ee webapp, structured as follows:
some.ear
+- some.war
+- EJBs.jar
both the war and the jar require some spring classes to function properly. I defined a spring module containing the relevant classes. Within jboss-deployment-structure I have a section as follows:
<jboss-deployment-structure>
<deployment>
<dependencies>
...
<module name="org.springframework.spring-web"/>
...
</dependencies>
</deployment>
After launching my webapp, I get a ClassNotFoundException when deploying the war-archive.
If I add an additional section
<sub-deployment name="some.war">
<dependencies>
...
<module name="org.springframework.spring-web"/>
...
</dependencies>
</sub-deployment>
it works.
My understanding is, that every module from the main-deployment section should also be visible in all sub-deployments.
Can anyone shed some light on this issue?
Each sub-deployment would need it's own set of module dependencies. If you were to include the module libraries in the EAR/lib directory instead of creating a module then you'd not need to add the module dependency for each sub-deployment.
My problem is that i have an ejb which internally uses freemarker tool to generate a HTML page, built and deployed to JBoss EAP 6.4.10. When i try to access this functionality (which generates HTML code using freemarker tool), jboss throwing below errors:
java.lang.LinkageError: Failed to link freemarker/core/TemplateElement
Caused by: java.lang.NoClassDefFoundError: javax/swing/tree/TreeNode
I added freemarker jar in my jboss modules and it's module.xml looks like this:
<module xmlns="urn:jboss:module:1.1" name="org.freemarker">
<resources>
<resource-root path="freemarker-2.3.25.jar"/>
</resources>
<dependencies>
</dependencies>
</module>
Finally it is found out that the error is due to missing dependency 'javax.api' in freemaker's module.xml file, after adding this dependency in module.xml as below the problem has resolved.
<module xmlns="urn:jboss:module:1.1" name="org.freemarker">
<resources>
<resource-root path="freemarker-2.3.25.jar"/>
</resources>
<dependencies>
<module name="javax.api"/>
</dependencies>
The Google App Engine has this same problem, that some classes that are mandatory in Java SE aren't present there. So try to use org.freemarker:freemarker-gae instead of plain org.freemarker:freemarker.
What kind of platform is that anyway, why's that class missing? Is it Google App Engine?
Update: Certainly JBoss EAP's class loader doesn't export the javax.swing package from some reason (see comments). While using freemarker-gae works that around, then you have to be careful to exclude the non-gae FreeMarker-s coming from elsewhere as transitive Maven (or Gradle, etc.) dependencies. So it would be more maintainable to fix the JBoss modules configuration instead. I saw some start JBoss EAP with -Djboss.modules.system.pkgs=javax.swing, though if Swing is available for other modules in the same JVM, then there must be a more elegant solution, such as adding something to deployment-structure.xml, or if you define your own JBoss modules then to its module.xml. Maybe you should check which standard module exports the swing packages ("javax.api"?), and try to declare that module as a dependency.
I'm deploying an EAR application built with Maven which has the following dependency in one of the modules:
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-entitymanager</artifactId>
<version>5.1.0.Final</version>
</dependency>
When I try to deploy the application in a Glassfish Server 4.1 I get the following error:
Fatal: java.lang.NoSuchMethodError: org.jboss.logging.Logger.debugf(Ljava/lang/String;I)V
at org.hibernate.internal.NamedQueryRepository.checkNamedQueries(NamedQueryRepository.java:149)
I made some research to solve this problem and made the following attempts:
First Attempt
I found this question and used the script in this article to clean the Glassfish's osgi-cache, as suggested in the question and in this issue of the Glassfish/Payara Github repository. Restarted the server. Same error.
Second Attempt
I found this question and tried the suggestion of the first answer, like this: looking at the dependency tree, I see that hibernate-entitymanager has the following dependency:
<dependency>
<groupId>org.jboss.logging</groupId>
<artifactId>jboss-logging</artifactId>
<version>3.3.0.Final</version>
<scope>compile</scope>
</dependency>
So I searched at my Server installation and found the jboss-logging.jar. The installed version was 3.1.0-GA (I'm not sure right now, but surely it was a previous version of the dependency). I downloaded jboss-logging-3.3.0.Final.jar from the Maven Central Repository and replaced the one in my Server installation. Restarted the server. Same error.
Third Attempt
Some comments in the previous post (and others) suggested to add a property org.jboss.logging.provider=slf4j as I'm using these dependencies for logging:
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
<version>1.7.21</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-log4j12</artifactId>
<version>1.7.21</version>
<scope>test</scope>
</dependency>
I found some .properties files in the /glassfish/domains/domain1/config/ folder but none of them contains such a property and I don't know in which file to add that property. I also made some search in the Admin Console but I didn't found where to add properties. The only logging configuration I found was to configure logging levels.
After that I found where to put some JVM options for the Glassfish Server in the Admin Console and added -Dorg.jboss.logging.provider=slf4j as an option but did not work for me (even more, I had to reboot my computer to get Glassfish in ground zero)
Fourth Attempt
Before all this I had a problem and made another question in StackOverflow. Guided by this comment in that post I changed the project configuration but nothing happened (I solved that problem with a little change in my dependencies, answer still pending)
After all the attempts, I'm running out of ideas and the problem remains. I don't know what could be the problem. Any guide, help or answer will be really appreciated. If anybody needs more details about the situation just let me know.
Thanks in advance for your collaboration.
EDIT 1
I was searching and found this article which says something similar to what I did and adds a provided dependency for jboss-logging like this:
<dependency>
<groupId>org.jboss.logging</groupId>
<artifactId>jboss-logging</artifactId>
<version>3.3.0.Final</version>
<scope>provided</scope>
</dependency>
But the error remains. Apparently it's something with the Server but I can't figure out what. I'm using GlassFish Server Open Source Edition 4.1 (build 13)
I was using JBoss server 7.1 to deploy my project. In my case this error was due to the fact that the I was using jboss-logging-3.3.0.Final.jar in my project but the JBoss 7 had a jboss-logging-3.1.0.GA.jar (/opt/jboss-as-7.1.1.Final/modules/org/jboss/logging/main/) by default. So, may be this was due to the jar conflict or method was not present in the jboss-logging-3.1.0.GA.jar, I am not sure. But replacing the jboss-logging-3.1.0.GA.jar with jboss-logging-3.3.0.Final.jar and change mapping in module.xml (at the same above mentioned location) as follows
<module xmlns="urn:jboss:module:1.1" name="org.jboss.logging">
<resources>
<resource-root path="jboss-logging-3.3.0.Final.jar"/>
<!-- Insert resources here -->
</resources>
<dependencies>
<module name="org.jboss.logmanager"/>
</dependencies>
</module>
And the error was gone. Hope it helps.
This is because GlassFish ships with an earlier version of JBoss Logging and this is being picked up by your application hence the NoSuchMethod error. The version of JBoss Logging shipped with GlassFish 4.1 does not have the method defined. You can try and replace the version of jboss-logging in the modules directory of glassfish this may or may not work but it looks like you tried and failed with this approach.
Another option is to upgrade to the latest Payara 4.1.1.162 which ships with JBoss Logging 3.3.0.Final.
Block Glassfish for using its own lib when project lib is provided
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 have a simple piece of code instantiating a JBoss Hot Rod client and this is deployed in an .ear file on Jboss 7
System.out.println("Attempting to RemoteCacheManager at: "+ipAddress);
Configuration conf = new
ConfigurationBuilder().addServer().host(ipAddress).port(11222).build();
RemoteCacheManager manager = new RemoteCacheManager(conf);
RemoteCache defaultCache = manager.getCache();
System.out.println("SUCCESS OUT: Connected to RemoteCacheManager at: "+ipAddress);
logger.info("SUCCESS: Connected to RemoteCacheManager at {}",ipAddress);
However when I deploy the app it cannot find the the class/method RemoteCacheManager
Caused by: java.lang.NoSuchMethodError: org.infinispan.client.hotrod.RemoteCacheManager.<init>(Lorg/infinispan/client/hotrod/configuration/Configuration;)V
My App has a structure like this
--ear
---lib
---infinispan-client-hotrod-6.0.2-FINAL.jar
--- other .jars
---META-INF
---MANIFEST.MF
---myservice.jar
---mysrvice.war
This is caused because I include the latest hot rod client as a maven dependency but an older version is available as a module. How can I tell Jboss to exclude the older implementation in its module
Thanks
the issue in this case was not as I thought. The issue was JBoss already included an older version of hot rod as a module and hence the "java.lang.NoSuchMethodError"
The solution, to exclude a module and provide a new implementation via new maven dependency is to use the jboss-deployment-structure.xml. Place this file in ear>src>main>META-INF>application
I am being extra careful below by excluding from main deployment and subdeployment and left it here for illustration purposes. I will remove one entry later...
<?xml version="1.0"?>
<exclusions>
<module name="org.infinispan.client.hotrod"/>
</exclusions>
<sub-deployment name="myservice-ejb-1.0.1-SNAPSHOT.jar">
<!-- This corresponds to the module for a web deployment -->
<!-- it can use all the same tags as the <deployment> entry above -->
<exclusions>
<module name="org.infinispan.client.hotrod"/>
</exclusions>
</sub-deployment>
</deployment>
I'm migrating an application from Glassfish 2.1 to Jboss eap 6.0.1. Now I deploy my app in Jboss correctly but it doesn't work. I have made debug and I saw the problem. When the code arrives to this line:
OutputFormat format = OutputFormat(doc);
It fails. I made a new watch of "OutputFormat(doc)" and in the value appears this: Unknown type "org.apache.xml.serialize.OutputFormat"<
This class is inside xerces library. This library is installed as a module in my jboss. I have tried many things:
1.- Exclude jboss library and included the library in my war. Not deploy.
2.- Include my library (no JBoss' library) as a new module and, in the manifest, add this line: Dependencies: myModuleName. It deploys, but it doesn't work.
3.- The before "solution", and exclude jboss library. Not deploy.
This ocurred when the code arrives at the following line, and I have tried the same solutions:
XPathAPI.selectSingleNode( xmlTempDoc,"//a" )
The error at this time is: Unknown type "org.apache.xpath.XPathAPI"
This packages are in xercesImpl-2.9.1 and xalan-2.7.1 libraries respectively.
Can you help me, please?
Thanks,
Regards.
Try to exclude the default xalan and xerces libraries that come packaged witn JBoss EAP by adding jboss-deployment-structure.xml under /WEB-INF with below content:
<jboss-deployment-structure xmlns="urn:jboss:deployment-structure:1.2">
<deployment>
<exclusions>
<module name="org.apache.xalan" />
<module name="org.apache.xerces" />
</exclusions>
</deployment>
</jboss-deployment-structure>
Then include yours in some path such as /lib folder.