I'm trying to subscribe to GC notifications using GarbageCollectionNotificationInfo. The notifications work, but when I try use this mechanism inside Wildfly 8.2, I get a java.lang.NoClassDefFoundError:
java.lang.NoClassDefFoundError: com/sun/management/GarbageCollectionNotificationInfo
2017-02-06 08:40:09,156 ERROR [stderr] (Service Thread) at com.vonage.metrics.GCNotificationListener.handleNotification(GCNotificationListener.java:28)
2017-02-06 08:40:09,156 ERROR [stderr] (Service Thread) at sun.management.NotificationEmitterSupport.sendNotification(NotificationEmitterSupport.java:156)
2017-02-06 08:40:09,157 ERROR [stderr] (Service Thread) at sun.management.GarbageCollectorImpl.createGCNotification(GarbageCollectorImpl.java:147)
I found that in some cases you need to include dependencies in Jboss/Wildfly: https://docs.jboss.org/author/display/WFLY8/Class+Loading+in+WildFly
Do I need to somehow include the com.sun.* packages?
I've recently encountered the same issue, only with WildFly 10.1.0.Final.
The solution is to explicitly include com.sun.management classes using something like this in your jboss-deployment-structure.xml:
<?xml version="1.0" encoding="UTF-8"?>
<jboss-deployment-structure xmlns="urn:jboss:deployment-structure:1.2">
<deployment>
<dependencies>
<system>
<paths>
<path name="com/sun/management"/>
</paths>
</system>
</dependencies>
</deployment>
</jboss-deployment-structure>
Related
So i have one SOAP application which works fine with Wildfly another one earlier was built on apache cxf and was running on tomcat but i had to make it work with Wildfly so i added a Jboss-deployment-structure as below.
<?xml version='1.0' encoding='UTF-8'?> <jboss-deployment-structure xmlns="urn:jboss:deployment-structure:1.2"> <deployment>
<exclude-subsystems>
<subsystem name="webservices" />
</exclude-subsystems> </deployment> </jboss-deployment-structure>
After which both web services started working on same wildfly but i noticed that if deployed they work but when the server is restarted the One which was working fine with Jboss gives below error where as the Apache Cxf one is working fine.
2017-12-21 04:20:09,856 ERROR [io.undertow.request] (default task-1) UT005023: Exception handling request to /booking/ReservationService: java.lang.LinkageError: Failed to link com/sun/xml/messaging/saaj/soap/SOAPDocumentImpl (Module "deployment.CreateWS.war:main" from Service Module Loader)
at org.jboss.modules.ModuleClassLoader.defineClass(ModuleClassLoader.java:437)
at org.jboss.modules.ModuleClassLoader.loadClassLocal(ModuleClassLoader.java:269)
Caused by: java.lang.NoClassDefFoundError: com/sun/org/apache/xerces/internal/dom/DocumentImpl
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClass(ClassLoader.java:760)
at org.jboss.modules.ModuleClassLoader.doDefineOrLoadClass(ModuleClassLoader.java:353)
at org.jboss.modules.ModuleClassLoader.defineClass(ModuleClassLoader.java:432)
... 62 more
Caused by: java.lang.ClassNotFoundException: com.sun.org.apache.xerces.internal.dom.DocumentImpl from [Module "deployment.CreateWS.war:main" from Service Module Loader]
at org.jboss.modules.ModuleClassLoader.findClass(ModuleClassLoader.java:205)
at org.jboss.modules.ConcurrentClassLoader.performLoadClassUnchecked(ConcurrentClassLoader.java:455)
at org.jboss.modules.ConcurrentClassLoader.performLoadClassChecked(ConcurrentClassLoader.java:404)
at org.jboss.modules.ConcurrentClassLoader.performLoadClass(ConcurrentClassLoader.java:385)
at org.jboss.modules.ConcurrentClassLoader.loadClass(ConcurrentClassLoader.java:130)
... 66 more
where booking is the WS working with jboss and CreateWS is apache cxf one.
I resolved the issue by adding a manifest.mf file in META-INF folder with depedency to the webservice which stopped working and so whenever the server is restarted the old WS is loaded first and deployed.
Currently I try, for my first time, to use Wildfly with MongoDB and Hibernate OGM. When I deploy my Project to Wildfly, the following error occurs:
"{ \"WFLYCTL0080: Failed services\" => {\"jboss.deployment.unit.\\\"{MYAPP}.war\\\".STRUCTURE\" => \"org.jboss.msc.service.StartException in service jboss.deployment.unit.\\\"{MYAPP}.war\\\".STRUCTURE: WFLYSRV0153: Failed to process phase STRUCTURE of deployment \\\"{MYAPP}.war\\\"
Caused by: org.jboss.as.server.deployment.DeploymentUnitProcessingException: WFLYSRV0168: Error loading jboss-deployment-structure.xml from {MYUSERDIR}/wildfly10/standalone/deployments/{MYAPP}.war/WEB-INF/jboss-deployment-structure.xml
Caused by: javax.xml.stream.XMLStreamException: ParseError at [row,col]:[2,1]
Message: Unexpected element '{http://www.jboss.com/xml/ns/javaee}jboss-web'\"},
\"WFLYCTL0412: Required services that are not installed:\" => [\"jboss.deployment.unit.\\\"{MYAPP}.war\\\".STRUCTURE\"],
\"WFLYCTL0180: Services with missing/unavailable dependencies\" => undefined }"
My jboss-deployment-structure.xml looks like this:
<?xml version="1.0" encoding="UTF-8"?>
<jboss-deployment-structure>
<deployment>
<dependencies>
<module name="org.hibernate" slot="ogm" services="import" />
<module name="org.hibernate.ogm.mongodb" slot="main" services="import" />
</dependencies>
</deployment>
</jboss-deployment-structure>
This Jboss Document mentions to add Modules (which I did) to the Wildfly Folder and add an Entry to the Manifest.mf File which I created manually.
Does anybody have an idea, what to try next?
I would also appreciate a Recommendation for a good Tutorial.
Sidenotes:
NetBeans 8.2
Wildfly 10
MacOS
MongoDB on Ubuntu 16.04 VM
I googled a lot
The Tutorial I basically used
I am trying to upgrade my application from JBoss 7 to WildFly10, and I am getting a warning:
[0m[33m13:53:36,641 WARN [org.jboss.as.dependency.private] (MSC service thread 1-6)
WFLYSRV0018: Deployment "deployment.mywar.war" is using a private module
("org.jboss.as.jmx:main") which may be changed or removed in future versions
without notice.
The module is mentioned in jboss-deployment-structure.xml as follows:
<?xml version="1.0" encoding="UTF-8"?>
<jboss-deployment-structure >
<deployment>
<dependencies>
<module name="org.jboss.as.jmx"/>
</dependencies>
</deployment>
</jboss-deployment-structure>
how is called the new module for jmx? I tried to replace that with org.jboss.remoting-jmx but then I got
Invocation of init method failed;
nested exception is javax.management.JMRuntimeException:
Failed to load MBeanServerBuilder class org.jboss.as.jmx.PluggableMBeanServerBuilder:
java.lang.ClassNotFoundException: org.jboss.as.jmx.PluggableMBeanServerBuilder
according to WildFly forum it means nothing, see quote (source)
You got warning message as you are using internal "non-public" modules
from application server. Which just tells you that you should be
careful with this.
How can I log to console / server.log from within a jboss module?
Say that I have a class:
public class MyClass {
private static final Logger logger = LoggerFactory.getLogger(MyClass.class);
private boolean done = false;
public void doSomething() {
logger.info("Look ma, I'm logging!");
done = true;
}
public boolean isDone() {
return done;
}
}
If I want to log from a deployed artifact (e.g., MyWebProject.war), all I have to do is:
Compile against slf4j-api
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
<version>1.7.7</version>
<scope>provided</scope>
</dependency>
Deploy
./jboss-cli.sh -c "deploy MyWebProject.war"
Profit
2015-10-19 11:04:02,445 INFO [com.myCompany.MyClass] (default task-13) Look ma, I'm logging!
But for the life of mine, I can't manage to do the same from within a jboss module.
Example: If MyWebProject.war uses MyModule.jar, and MyModule.jar is deployed as a jboss module:
${jbossHome}/modules/com/mycompany/mymodule/main
|____ MyModule.jar
|____ module.xml
Module.xml
<?xml version="1.0" encoding="UTF-8"?>
<module xmlns="urn:jboss:module:1.1" name="com.mycompany.mymodule">
<resources>
<resource-root path="MyModule.jar" />
</resources>
<dependencies>
<module name="org.slf4j" />
</dependencies>
</module>
If I move MyClass into MyModule.jar and use it from MyWebProject.war I can see the side effects (e.g., isDone() == true) but nothing is written to server.log.
What am I missing? Do I need any other module dependencies but slf4j?
For further reference, my problem had nothing to do with logging. The above recipe works as expected. In fact I've suffered because of a red herring: my original module.xml was never really used. I was actually loading a old class with the same name in another module. This old version of the class had no logging and should not be there to begin with.
Anyway, I think that the root cause of my problem (besides my lack of attention) was a small bug in jboss-cli.
I was deploying mymodule with the following command:
module add --name=com.mycompany.mymodule \
--resources=MyModule.jar \
--dependencies=org.slf4j \
--main-class=com.mycompany.mymodule.Main
This command was generating a module.xml like this:
<?xml version="1.0" ?>
<module xmlns="urn:jboss:module:1.1" name="com.mycompany.mymodule">
<main-class value="com.mycompany.mymodule.Main"/>
<resources>
<resource-root path="MyModule.jar"/>
</resources>
<dependencies>
<module name="org.slf4j"/>
</dependencies>
</module>
When I've finally managed to get my web project to try to load mymodule it failed with a stack trace such as:
18:45:59,999 ERROR [org.jboss.msc.service.fail] (MSC service thread 1-7) MSC000001: Failed to start service jboss.module.service."deployment.MyWebProject.war".main: org.jboss.msc.service.StartException in service jboss.module.service."deployment.MyWebProject.war".main: WFLYSRV0179: Failed to load module: deployment.MyWebProject.war.war:main
at org.jboss.as.server.moduleservice.ModuleLoadService.start(ModuleLoadService.java:91)
at org.jboss.msc.service.ServiceControllerImpl$StartTask.startService(ServiceControllerImpl.java:1948)
at org.jboss.msc.service.ServiceControllerImpl$StartTask.run(ServiceControllerImpl.java:1881)
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.modules.ModuleLoadException: Error loading module from C:\opt\server\wildfly-9.0.1.Final\modules\com\mycompany\mymodule\main\module.xml
at org.jboss.modules.ModuleXmlParser.parseModuleXml(ModuleXmlParser.java:150)
at org.jboss.modules.ModuleXmlParser.parseModuleXml(ModuleXmlParser.java:127)
at org.jboss.modules.LocalModuleFinder$1.run(LocalModuleFinder.java:150)
at org.jboss.modules.LocalModuleFinder$1.run(LocalModuleFinder.java:144)
at java.security.AccessController.doPrivileged(Native Method)
at org.jboss.modules.LocalModuleFinder.findModule(LocalModuleFinder.java:144)
at org.jboss.modules.ModuleLoader.findModule(ModuleLoader.java:452)
at org.jboss.modules.ModuleLoader.loadModuleLocal(ModuleLoader.java:355)
at org.jboss.modules.ModuleLoader.preloadModule(ModuleLoader.java:302)
at org.jboss.modules.ModuleLoader.preloadExportedModule(ModuleLoader.java:313)
at org.jboss.modules.ModuleLoader.preloadModule(ModuleLoader.java:326)
at org.jboss.as.server.moduleservice.ServiceModuleLoader.preloadModule(ServiceModuleLoader.java:149)
at org.jboss.modules.ModuleLoader.loadModule(ModuleLoader.java:234)
at org.jboss.as.server.moduleservice.ModuleLoadService.start(ModuleLoadService.java:74)
... 5 more
Caused by: org.jboss.modules.xml.XmlPullParserException: Unexpected content of type 'element start' named 'main-class', text is: '<main-class value="com.mycompany.mymodule.Main"/>' (position: START_TAG seen ...n-class value="com.mycompany.mymodule.Main"/>... #5:54)
at org.jboss.modules.ModuleXmlParser.unexpectedContent(ModuleXmlParser.java:179)
at org.jboss.modules.ModuleXmlParser.parseMainClass(ModuleXmlParser.java:620)
at org.jboss.modules.ModuleXmlParser.parseModuleContents(ModuleXmlParser.java:445)
at org.jboss.modules.ModuleXmlParser.parseDocument(ModuleXmlParser.java:261)
at org.jboss.modules.ModuleXmlParser.parseModuleXml(ModuleXmlParser.java:148)
... 18 more
Taking a look at module-1_1.xsd I've found out that the main-class element was expecting a name attribute instead of a value attribute. So I've manually changed the module.xml to:
<main-class name="com.mycompany.mymodule.Main"/>
After I've restarted WildFly and redeployed my web project everything worked as expected.
I'm trying to deploy geoserver.war (2.2.1) on JBoss-AS 7.1.1-Final.
The log is uploaded to Pastebin, it's better readable there.
Beside two CNFE
07:23:51 java.lang.NoClassDefFoundError: com/sun/imageio/spi/FileImageOutputStreamSpi
07:24:01 java.lang.NoClassDefFoundError: com/sun/imageio/spi/FileImageOutputStreamSpi
I assume the main reason for failing is here
07:23:58,357 ERROR [org.apache.catalina.core.StandardContext]
(MSC service thread 1-6) Error listenerStart
07:23:58,357 ERROR [org.apache.catalina.core.StandardContext]
(MSC service thread 1-6) Context [/geoserver] startup failed due
to previous errors
Unfortunately I cannot identify any significant errors beside the CNFE and the Error listenerStart.
An alternative is creating the file jboss-deployment-structure.xml geoserver.war/WEB-INF with the following content:
<?xml version="1.0" encoding="UTF-8"?>
<jboss-deployment-structure xmlns="urn:jboss:deployment-structure:1.1">
<deployment>
<dependencies>
<system>
<paths>
<path name="com/sun/imageio/spi"/>
<path name="com/sun/imageio/plugins/common"/>
</paths>
</system>
</dependencies>
</deployment>
</jboss-deployment-structure>
I don't want to give a link-only reply, but this thread in the JBoss forums seems to describe the exact same problem, with solution:
https://community.jboss.org/thread/177472
I quote:
"I found that if I added
<path name="com/sun/imageio/spi"/>
to the module.xml file in the modules/sun/jdk/main directory then the ClassNotFoundException goes away."
Google: "classnotfound FileImageOutputStreamSpi"