Error with JMS Appender in Log4j2 going to Wildfly 14 - java

Using Log4j2 2.11.1 with Wildfly 14.0.1, OpenJDK 11. We have a custom OSGi client application that logs both to a console appender and to a JMS appender to send logging events to the Wildfly server.
Prior to Log4j2, we were programmatically sticking a JMS appender into our Log4j configuration, which worked fine. This really wasn't necessary so with our recent upgrade to Log4j2, I'm trying to using a log4j2.xml configuration to handle all of that and simplify our code.
We have a client class that this successfully connecting to our Wildfly JMS and receiving messages, using the following:
topicConnFacName: com.rsc.mmpl.TopicConnectionFactory
initialContextFacName: org.jboss.naming.remote.client.InitialContextFactory
URL: http-remoting://JDEVDWS166:9090
Topic name: com.rsc.mmpl.MsgHndlrTopic
My log4j2.xml configuration is as follows:
<?xml version="1.0" encoding="UTF-8"?>
<Configuration status="INFO">
<Appenders>
<Console name="Console" target="SYSTEM_OUT">
<PatternLayout pattern="%p %d{yyyy-MMM-dd HH:mm:ss.SSS} %c{3}[line %L] - %m%n"/>
</Console>
<JMS name="jmsQueue" destinationBindingName="com.rsc.mmpl.MsgHndlrTopic"
factoryName="org.jboss.naming.remote.client.InitialContextFactory"
factoryBindingName="com.rsc.mmpl.TopicConnectionFactory"
ignoreExceptions="false"
providerURL="http-remoting://JDEVDWS166:9090">
<JsonLayout properties="true" complete="true"/>
</JMS>
</Appenders>
<Loggers>
<Root level="info">
<AppenderRef ref="Console"/>
<AppenderRef ref="jmsQueue"/>
</Root>
</Loggers>
</Configuration>
If I comment out my JMS Appender, it works fine, so I know that my log4j is setup correctly from a classpath perspective (log4j core and api jars, as well as jackson jars, and jboss-client.jar are all on the overall classpath).
However, when running my client app with the JMS Appender, I get the following error:
[stderr] Caused by: java.lang.NoClassDefFoundError: Could not initialize class org.jboss.remoting3.ConfigurationEndpointSupplier$Holder
[stderr] at org.jboss.remoting3.ConfigurationEndpointSupplier.get(ConfigurationEndpointSupplier.java:84)
[stderr] at org.jboss.remoting3.ConfigurationEndpointSupplier.get(ConfigurationEndpointSupplier.java:40)
[stderr] at org.wildfly.common.context.ContextManager.getPrivileged(ContextManager.java:286)
[stderr] at org.jboss.remoting3.Endpoint.getCurrent(Endpoint.java:81)
[stderr] at org.wildfly.naming.client.remote.RemoteNamingProviderFactory.getEndpoint(RemoteNamingProviderFactory.java:49)
[stderr] at org.wildfly.naming.client.remote.RemoteNamingProviderFactory.supportsUriScheme(RemoteNamingProviderFactory.java:40)
[stderr] at org.wildfly.naming.client.WildFlyRootContext.getProviderContext(WildFlyRootContext.java:784)
[stderr] at org.wildfly.naming.client.WildFlyRootContext.lookup(WildFlyRootContext.java:140)
[stderr] at java.naming/javax.naming.InitialContext.lookup(InitialContext.java:409)
[stderr] at org.apache.logging.log4j.core.net.JndiManager.lookup(JndiManager.java:172)
[stderr] at org.apache.logging.log4j.core.appender.mom.JmsManager.createConnection(JmsManager.java:323)
[stderr] at org.apache.logging.log4j.core.appender.mom.JmsManager.<init>(JmsManager.java:250)
[stderr] at org.apache.logging.log4j.core.appender.mom.JmsManager.<init>(JmsManager.java:54)
[stderr] at org.apache.logging.log4j.core.appender.mom.JmsManager$JmsManagerFactory.createManager(JmsManager.java:130)
[stderr] at org.apache.logging.log4j.core.appender.mom.JmsManager$JmsManagerFactory.createManager(JmsManager.java:125)
[stderr] at org.apache.logging.log4j.core.appender.AbstractManager.getManager(AbstractManager.java:113)
[stderr] at org.apache.logging.log4j.core.appender.mom.JmsAppender$Builder.build(JmsAppender.java:118)
[stderr] at org.apache.logging.log4j.core.appender.mom.JmsAppender$Builder.build(JmsAppender.java:50)
[stderr] at org.apache.logging.log4j.core.config.plugins.util.PluginBuilder.build(PluginBuilder.java:123)
[stderr] at org.apache.logging.log4j.core.config.AbstractConfiguration.createPluginObject(AbstractConfiguration.java:959)
[stderr] at org.apache.logging.log4j.core.config.AbstractConfiguration.createConfiguration(AbstractConfiguration.java:899)
[stderr] at org.apache.logging.log4j.core.config.AbstractConfiguration.createConfiguration(AbstractConfiguration.java:891)
[stderr] at org.apache.logging.log4j.core.config.AbstractConfiguration.doConfigure(AbstractConfiguration.java:514)
[stderr] at org.apache.logging.log4j.core.config.AbstractConfiguration.initialize(AbstractConfiguration.java:238)
[stderr] at org.apache.logging.log4j.core.config.AbstractConfiguration.start(AbstractConfiguration.java:250)
[stderr] at org.apache.logging.log4j.core.LoggerContext.setConfiguration(LoggerContext.java:547)
[stderr] at org.apache.logging.log4j.core.LoggerContext.reconfigure(LoggerContext.java:619)
[stderr] at org.apache.logging.log4j.core.LoggerContext.reconfigure(LoggerContext.java:636)
[stderr] at org.apache.logging.log4j.core.LoggerContext.start(LoggerContext.java:231)
[stderr] at org.apache.logging.log4j.core.impl.Log4jContextFactory.getContext(Log4jContextFactory.java:243)
[stderr] at org.apache.logging.log4j.core.impl.Log4jContextFactory.getContext(Log4jContextFactory.java:45)
[stderr] at org.apache.logging.log4j.LogManager.getContext(LogManager.java:174)
[stderr] at org.apache.logging.log4j.LogManager.getLogger(LogManager.java:648)
[stderr] at com.rsc.delphi.logger.log4j.Log4jLogger.<init>(Unknown Source)
[stderr] ... 20 more
Looking at the Holder source, it appears something is going wrong with the static block there but I can't for the life of me figure out what.
Is there any way to get more information to figure out what is failing here? Again, programmatically connecting to my Wildfly JMS is fine, just seems to be an issue with Log4j2.
Thanks in advance.

Looking at it, my first guess is that the issue doesn't lie in the top of the stack trace there. That class loading issue is likely originating from where log4j2 is getting the connection to the WildFly naming interface.
It looks like a new InitialContextFactory (subclassed) module is now provided. That means you'll have to change:
org.jboss.naming.remote.client.InitialContextFactory
To:
org.wildfly.naming.client.WildFlyInitialContextFactory
Not having looked too deeply into it, it looks like the new ICF has a little more fancy logic for handling ClassLoader issues than the old ICF...

Related

Liferay 6.0.6 JSF 2 portlet deployment issue

I have strange issue with Liferay 6.0.6 portlet deployment to Jboss EAP 5.2 server
The code that was working for years suddenly stopped deploying. Portlet is using JSF 2.1.21
The Error from server log:
2021-03-10 13:38:10,918 INFO [STDOUT] (com.liferay.portal.kernel.deploy.auto.AutoDeployScanner) Expanding: E:\Jboss\eap-5.2-Liferay-6.0.6\deploy\example-portlet-1.0-SNAPSHOT.war into E:\Jboss\eap-5.2-Liferay-6.0.6\jboss-as\server\default\javaiotmp\20210310133810918
2021-03-10 13:38:12,146 INFO [STDOUT] (com.liferay.portal.kernel.deploy.auto.AutoDeployScanner) Copying 1 file to E:\Jboss\eap-5.2-Liferay-6.0.6\jboss-as\server\default\javaiotmp\20210310133810918\WEB-INF
2021-03-10 13:38:12,305 INFO [STDOUT] (com.liferay.portal.kernel.deploy.auto.AutoDeployScanner) Copying 1 file to E:\Jboss\eap-5.2-Liferay-6.0.6\jboss-as\server\default\javaiotmp\20210310133810918\WEB-INF\classes
2021-03-10 13:38:12,324 INFO [STDOUT] (com.liferay.portal.kernel.deploy.auto.AutoDeployScanner) Copying 1 file to E:\Jboss\eap-5.2-Liferay-6.0.6\jboss-as\server\default\javaiotmp\20210310133810918\WEB-INF\classes
2021-03-10 13:38:12,734 ERROR [STDERR] (com.liferay.portal.kernel.deploy.auto.AutoDeployScanner) com.liferay.portal.kernel.xml.DocumentException: Error on line -1 of document : Premature end of file. Nested exception: Premature end of file.
2021-03-10 13:38:12,734 ERROR [STDERR] (com.liferay.portal.kernel.deploy.auto.AutoDeployScanner) at com.liferay.portal.xml.SAXReaderImpl.read(SAXReaderImpl.java:338)
2021-03-10 13:38:12,734 ERROR [STDERR] (com.liferay.portal.kernel.deploy.auto.AutoDeployScanner) at com.liferay.portal.kernel.xml.SAXReaderUtil.read(SAXReaderUtil.java:115)
2021-03-10 13:38:12,734 ERROR [STDERR] (com.liferay.portal.kernel.deploy.auto.AutoDeployScanner) at com.liferay.portal.tools.deploy.PortletDeployer.setupJSF(PortletDeployer.java:473)
2021-03-10 13:38:12,735 ERROR [STDERR] (com.liferay.portal.kernel.deploy.auto.AutoDeployScanner) at com.liferay.portal.tools.deploy.PortletDeployer.getExtraContent(PortletDeployer.java:144)
2021-03-10 13:38:12,735 ERROR [STDERR] (com.liferay.portal.kernel.deploy.auto.AutoDeployScanner) at com.liferay.portal.tools.deploy.BaseDeployer.updateWebXml(BaseDeployer.java:1414)
2021-03-10 13:38:12,735 ERROR [STDERR] (com.liferay.portal.kernel.deploy.auto.AutoDeployScanner) at com.liferay.portal.tools.deploy.BaseDeployer.deployDirectory(BaseDeployer.java:493)
2021-03-10 13:38:12,735 ERROR [STDERR] (com.liferay.portal.kernel.deploy.auto.AutoDeployScanner) at com.liferay.portal.tools.deploy.BaseDeployer.deployFile(BaseDeployer.java:828)
2021-03-10 13:38:12,735 ERROR [STDERR] (com.liferay.portal.kernel.deploy.auto.AutoDeployScanner) at com.liferay.portal.tools.deploy.BaseDeployer.deployFile(BaseDeployer.java:765)
2021-03-10 13:38:12,735 ERROR [STDERR] (com.liferay.portal.kernel.deploy.auto.AutoDeployScanner) at com.liferay.portal.tools.deploy.BaseDeployer.deploy(BaseDeployer.java:454)
2021-03-10 13:38:12,735 ERROR [STDERR] (com.liferay.portal.kernel.deploy.auto.AutoDeployScanner) at com.liferay.portal.deploy.auto.PortletAutoDeployer.autoDeploy(PortletAutoDeployer.java:92)
2021-03-10 13:38:12,735 ERROR [STDERR] (com.liferay.portal.kernel.deploy.auto.AutoDeployScanner) at com.liferay.portal.deploy.auto.PortletAutoDeployListener.deploy(PortletAutoDeployListener.java:78)
2021-03-10 13:38:12,735 ERROR [STDERR] (com.liferay.portal.kernel.deploy.auto.AutoDeployScanner) at com.liferay.portal.kernel.deploy.auto.AutoDeployDir.processFile(AutoDeployDir.java:180)
2021-03-10 13:38:12,735 ERROR [STDERR] (com.liferay.portal.kernel.deploy.auto.AutoDeployScanner) at com.liferay.portal.kernel.deploy.auto.AutoDeployDir.scanDirectory(AutoDeployDir.java:221)
2021-03-10 13:38:12,735 ERROR [STDERR] (com.liferay.portal.kernel.deploy.auto.AutoDeployScanner) at com.liferay.portal.kernel.deploy.auto.AutoDeployScanner.run(AutoDeployScanner.java:49)
2021-03-10 13:38:12,735 ERROR [STDERR] (com.liferay.portal.kernel.deploy.auto.AutoDeployScanner) Caused by: org.dom4j.DocumentException: Error on line -1 of document : Premature end of file. Nested exception: Premature end of file.
2021-03-10 13:38:12,735 ERROR [STDERR] (com.liferay.portal.kernel.deploy.auto.AutoDeployScanner) at org.dom4j.io.SAXReader.read(SAXReader.java:482)
2021-03-10 13:38:12,735 ERROR [STDERR] (com.liferay.portal.kernel.deploy.auto.AutoDeployScanner) at org.dom4j.io.SAXReader.read(SAXReader.java:264)
2021-03-10 13:38:12,735 ERROR [STDERR] (com.liferay.portal.kernel.deploy.auto.AutoDeployScanner) at com.liferay.portal.xml.SAXReaderImpl.read(SAXReaderImpl.java:335)
2021-03-10 13:38:12,735 ERROR [STDERR] (com.liferay.portal.kernel.deploy.auto.AutoDeployScanner) ... 13 more
2021-03-10 13:38:12,736 INFO [STDOUT] (com.liferay.portal.kernel.deploy.auto.AutoDeployScanner) 13:38:12,735 INFO [PortletAutoDeployListener:81] Portlets for E:\Jboss\eap-5.2-Liferay-6.0.6\deploy\example-portlet-1.0-SNAPSHOT.war copied successfully. Deployment will start in a few seconds.
Looking to liferay code it's failing trying to parse faces-config.xml file
faces-config.xml file:
<?xml version="1.0" encoding="UTF-8"?>
<faces-config version="2.0" 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/web-facesconfig_2_0.xsd">
<application>
<resource-bundle>
<base-name>com.medpro.messageresources.MessageResources</base-name>
<var>msg</var>
</resource-bundle>
<locale-config>
<default-locale>en_US</default-locale>
<supported-locale>en_US</supported-locale>
</locale-config>
<message-bundle>com.medpro.messageresources.MessageResources</message-bundle>
<el-resolver>org.springframework.web.jsf.el.SpringBeanFacesELResolver</el-resolver>
</application>
<lifecycle>
<phase-listener>com.liferay.faces.util.lifecycle.DebugPhaseListener</phase-listener>
</lifecycle>
</faces-config>
I don't see any issues with
eap-5.2-Liferay-6.0.6\jboss-as\server\default\javaiotmp\20210310133810918\WEB-INF\faces-config.xml
I also tried to download http://java.sun.com/xml/ns/javaee/web-facesconfig_2_0.xsd it's downloading valid xsd file.
Please advise what is possible reason for deployment failure ?
UPD:
please note that http://java.sun.com/xml/ns/javaee/web-facesconfig_2_0.xsd is redirected to http://www.oracle.com/webfolder/technetwork/jsc/xml/ns/javaee/web-facesconfig_2_0.xsd
if I replace the url in faces-config.xml to http://www.oracle.com/webfolder/technetwork/jsc/xml/ns/javaee/web-facesconfig_2_0.xsd the deployment works fine.

JMSException for HornetQ in Wildfly 10

I am running more than one schedulers at a time with 1000ms and 500ms repeatInterval. The schedular reads some messages from queue, processes them, and store in a MySQL database. In middle of these process sometimes I am getting this kind of exceptions.
javax.jms.JMSException: AMQ119014: Timed out after waiting 30,000 ms for response when sending packet 71
2020-02-25 12:05:27,483 ERROR [stderr] (DefaultQuartzScheduler_Worker-5) at org.apache.activemq.artemis.core.protocol.core.impl.ChannelImpl.sendBlocking(ChannelImpl.java:398)
2020-02-25 12:05:27,483 ERROR [stderr] (DefaultQuartzScheduler_Worker-5) at org.apache.activemq.artemis.core.protocol.core.impl.ChannelImpl.sendBlocking(ChannelImpl.java:304)
2020-02-25 12:05:27,484 ERROR [stderr] (DefaultQuartzScheduler_Worker-5) at org.apache.activemq.artemis.core.protocol.core.impl.ActiveMQSessionContext.sendFullMessage(ActiveMQSessionContext.java:378)
2020-02-25 12:05:27,484 ERROR [stderr] (DefaultQuartzScheduler_Worker-5) at org.apache.activemq.artemis.core.client.impl.ClientProducerImpl.sendRegularMessage(ClientProducerImpl.java:286)
2020-02-25 12:05:27,485 ERROR [stderr] (DefaultQuartzScheduler_Worker-5) at org.apache.activemq.artemis.core.client.impl.ClientProducerImpl.doSend(ClientProducerImpl.java:264)
2020-02-25 12:05:27,485 ERROR [stderr] (DefaultQuartzScheduler_Worker-5) at org.apache.activemq.artemis.core.client.impl.ClientProducerImpl.send(ClientProducerImpl.java:122)
2020-02-25 12:05:27,485 ERROR [stderr] (DefaultQuartzScheduler_Worker-5) at org.apache.activemq.artemis.jms.client.ActiveMQMessageProducer.doSendx(ActiveMQMessageProducer.java:477)
2020-02-25 12:05:27,486 ERROR [stderr] (DefaultQuartzScheduler_Worker-5) at org.apache.activemq.artemis.jms.client.ActiveMQMessageProducer.send(ActiveMQMessageProducer.java:173)
2020-02-25 12:05:27,486 ERROR [stderr] (DefaultQuartzScheduler_Worker-5) at com.ecomm.web.jmsqueue.SubmitToJMS.sendJMSMessagewithpriority(SubmitToJMS.java:197)
2020-02-25 12:05:27,486 ERROR [stderr] (DefaultQuartzScheduler_Worker-5) at com.ecomm.web.jmsqueue.InputMsgNewServerQueue.sendtosenderQueue(InputMsgNewServerQueue.java:78)
2020-02-25 12:05:27,486 ERROR [stderr] (DefaultQuartzScheduler_Worker-5) at com.pl4sms.web.thread.InputMsgSchHighPriority.execute(InputMsgSchHighPriority.java:36)
2020-02-25 12:05:27,487 ERROR [stderr] (DefaultQuartzScheduler_Worker-5) at org.quartz.core.JobRunShell.run(JobRunShell.java:202)
2020-02-25 12:05:27,487 ERROR [stderr] (DefaultQuartzScheduler_Worker-5) at org.quartz.simpl.SimpleThreadPool$WorkerThread.run(SimpleThreadPool.java:525)
2020-02-25 12:05:27,487 ERROR [stderr] (DefaultQuartzScheduler_Worker-5) Caused by: ActiveMQConnectionTimedOutException[errorType=CONNECTION_TIMEDOUT message=AMQ119014: Timed out after waiting 30,000 ms for response when sending packet 71]
2020-02-25 12:05:27,488 ERROR [stderr] (DefaultQuartzScheduler_Worker-5) ... 13 more
2020-02-25 12:05:27,488 ERROR [com.ecomm.web.jmsqueue.SubmitToJMS] (DefaultQuartzScheduler_Worker-5) javax.jms.JMSException: AMQ119014: Timed out after waiting 30,000 ms for response when sending packet 71
Could you describe your problem at least a little. A CONNECTION_TIMEDOUT jut means that you can't connect which is some configuration issue.
Your class com.ecomm.web.jmsqueue.SubmitToJMS is attempting to send a message, but this operation is timing out waiting for a response from the broker. You should either increase the time out on the client (e.g. by using the callTimeout parameter on the client URL, defaults to 30000 milliseconds) or investigate why the broker receiving the message isn't responding to the client within the allotted time.
Just in case. I had the same problem with camel routing.
.transacted() option removed this problem:
from("timer:hello?period=10s")
.routeId("hello1")
.transacted()
.setBody(simple("This is plain string"))
.to("jms:queue:consumerQueueName");
java 18 + wildfly 20 + artemis 2.25.0
all via JNDI

ClassNotFoundException: javax.xml.datatype.DatatypeFactory in wildfly-9.0.2.Final

Enviornment - AS#wildfly-9.0.2.Final,
BuildingTool#ant,
JDK#jdk1.8.0_66
Following class is accessed from my java code, which is causing errror.
javax.xml.datatype.DatatypeFactory
Java claas has been configured as a module
jaroneapi'==>module add --name=jaroneapi --resources=~/modules/jaroneapi.jar
package api.jarone.com.pojo;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.GregorianCalendar;
import javax.xml.datatype.XMLGregorianCalendar;
import javax.xml.datatype.DatatypeFactory;
public class TestJarOneDetails {
public XMLGregorianCalendar convertDatetoXMLGregorian(String inputDate)
{
XMLGregorianCalendar date2 = null;
try {
System.out.println("[TestJarOne][convertDatetoXMLGregorian] This class is present in " +
"jaroneapi.jar which has been configured as a module 'module add --name=jaroneapi --resources=~/modules/jaroneapi.jar' ");
SimpleDateFormat fmt = new SimpleDateFormat("dd MMM yyyy HH:mm:ss");
Date date = fmt.parse(inputDate);
GregorianCalendar c = new GregorianCalendar();
c.setTime(date);
date2 = DatatypeFactory.newInstance().newXMLGregorianCalendar(c);
} catch (Exception e) {
e.printStackTrace();
}
return date2;
}
}
Following error occurred while accessing above 'TestJarOneDetails' class.
10:43:13,337 ERROR [org.jboss.as.ejb3.invocation] (default task-1) WFLYEJB0034: EJB Invocation failed on component ClientTestHelperBean for method public abstract java.lang.String client.test.ejb.session.ClientTestHelperLocal.getValueByParamName(int,java.lang.String,java.lang.String) throws java.lang.Exception: javax.ejb.EJBException: WFLYEJB0442: Unexpected Error
at org.jboss.as.ejb3.tx.CMTTxInterceptor.handleExceptionInOurTx(CMTTxInterceptor.java:184)
at org.jboss.as.ejb3.tx.CMTTxInterceptor.invokeInOurTx(CMTTxInterceptor.java:277)
Caused by: java.lang.NoClassDefFoundError: javax/xml/datatype/DatatypeFactory
at api.jarone.com.pojo.TestJarOneDetails.convertDatetoXMLGregorian(TestJarOneDetails.java:21)
at client.test.ejb.session.ClientTestHelperBean.getValueByParamName(ClientTestHelperBean.java:50)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
Caused by: java.lang.ClassNotFoundException: javax.xml.datatype.DatatypeFactory from [Module "jaroneapi:main" from local module loader #707f7052 (finder: local module finder #11028347 (roots: /home/cmsim/manish/wildfly-9.0.2.Final/modules,/home/cmsim/manish/wildfly-9.0.2.Final/modules/system/layers/base))]
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)
10:43:13,341 ERROR [stderr] (default task-1) javax.ejb.EJBException: WFLYEJB0442: Unexpected Error
10:43:13,341 ERROR [stderr] (default task-1) at org.jboss.as.ejb3.tx.CMTTxInterceptor.handleExceptionInOurTx(CMTTxInterceptor.java:184)
10:43:13,341 ERROR [stderr] (default task-1) at org.jboss.as.ejb3.tx.CMTTxInterceptor.invokeInOurTx(CMTTxInterceptor.java:277)
10:43:13,341 ERROR [stderr] (default task-1) at org.jboss.as.ejb3.tx.CMTTxInterceptor.required(CMTTxInterceptor.java:327)
10:43:13,342 ERROR [stderr] (default task-1) at org.jboss.as.ejb3.tx.CMTTxInterceptor.processInvocation(CMTTxInterceptor.java:239)
10:43:13,361 ERROR [stderr] (default task-1) Caused by: java.lang.ClassNotFoundException: javax.xml.datatype.DatatypeFactory from [Module "jaroneapi:main" from local module loader #707f7052 (finder: local module finder #11028347 (roots: /home/cmsim/manish/wildfly-9.0.2.Final/modules,/home/cmsim/manish/wildfly-9.0.2.Final/modules/system/layers/base))]
10:43:13,361 ERROR [stderr] (default task-1) at org.jboss.modules.ModuleClassLoader.findClass(ModuleClassLoader.java:205)
10:43:13,361 ERROR [stderr] (default task-1) at org.jboss.modules.ConcurrentClassLoader.performLoadClassUnchecked(ConcurrentClassLoader.java:455)
10:43:13,361 ERROR [stderr] (default task-1) at org.jboss.modules.ConcurrentClassLoader.performLoadClassChecked(ConcurrentClassLoader.java:404)
10:43:13,361 ERROR [stderr] (default task-1) at org.jboss.modules.ConcurrentClassLoader.performLoadClass(ConcurrentClassLoader.java:385)
I think i have to configure module 'jaroneapi' with some dependencies, but what will be dependency as 'javax.xml.datatype.DatatypeFactory' is present in /jdk1.8.0_66/jre/lib/rt.jar.
You need to add a dependency on the javax.api module in your module. For the command you just need to add --dependencies=javax.api
module add --name=jaroneapi --resources=~/modules/jaroneapi.jar --dependencies=javax.api
Or you can just edit the module.xml and add the dependency manually.
<module xmlns="urn:jboss:module:1.3" name="jaroneapi">
<resources>
<resource-root path="jaroneapi.jar"/>
</resources>
<dependencies>
<module name="javax.api"/>
</dependencies>
</module>

resteasy integration with dsl-json - unable to register reader

I'm trying to integrate dsl-json with resteasy for de/serialization.But it throws an exception
java.io.IOException: Unable to find reader for provided type: class com.x.y.api.v1.resource.A and fallback serialization is not registered.
17:04:51,705 ERROR [stderr] (default task-2) Found reader for: class com.x.y.api.v1.resource.A so try deserializing into that instead?
17:04:51,705 ERROR [stderr] (default task-2) Alternatively, try initializing system with custom fallback or register specified type using registerReader into class com.dslplatform.json.DslJson
17:04:51,705 ERROR [stderr] (default task-2) at com.dslplatform.json.DslJson.showErrorMessage(DslJson.java:650)
17:04:51,706 ERROR [stderr] (default task-2) at com.dslplatform.json.DslJson.deserialize(DslJson.java:980)
17:04:51,706 ERROR [stderr] (default task-2) at com.x.y.provider.DSLJsonProvider.readFrom(DSLJsonProvider.java:41)
17:04:51,706 ERROR [stderr] (default task-2) at org.jboss.resteasy.core.interception.AbstractReaderInterceptorContext.readFrom(AbstractReaderInterceptorContext.java:61)
17:04:51,706 ERROR [stderr] (default task-2) at org.jboss.resteasy.core.interception.ServerReaderInterceptorContext.readFrom(ServerReaderInterceptorContext.java:60)
17:04:51,706 ERROR [stderr] (default task-2) at org.jboss.resteasy.core.interception.AbstractReaderInterceptorContext.proceed(AbstractReaderInterceptorContext.java:53)
17:04:51,707 ERROR [stderr] (default task-2) at org.jboss.resteasy.security.doseta.DigitalVerificationInterceptor.aroundReadFrom(DigitalVerificationInterceptor.java:34)
17:04:51,707 ERROR [stderr] (default task-2) at org.jboss.resteasy.core.interception.AbstractReaderInterceptorContext.proceed(AbstractReaderInterceptorContext.java:55)
17:04:51,707 ERROR [stderr] (default task-2) at org.jboss.resteasy.plugins.interceptors.encoding.GZIPDecodingInterceptor.aroundReadFrom(GZIPDecodingInterceptor.java:59)
17:04:51,707 ERROR [stderr] (default task-2) at org.jboss.resteasy.core.interception.AbstractReaderInterceptorContext.proceed(AbstractReaderInterceptorContext.java:55)
17:04:51,707 ERROR [stderr] (default task-2) at org.jboss.resteasy.core.MessageBodyParameterInjector.inject(MessageBodyParameterInjector.java:151)
17:04:51,708 ERROR [stderr] (default task-2) at org.jboss.resteasy.core.MethodInjectorImpl.injectArguments(MethodInjectorImpl.java:91)
17:04:51,708 ERROR [stderr] (default task-2) at org.jboss.resteasy.core.MethodInjectorImpl.invoke(MethodInjectorImpl.java:114)
17:04:51,708 ERROR [stderr] (default task-2) at org.jboss.resteasy.core.ResourceMethodInvoker.invokeOnTarget(ResourceMethodInvoker.java:295)
17:04:51,708 ERROR [stderr] (default task-2) at org.jboss.resteasy.core.ResourceMethodInvoker.invoke(ResourceMethodInvoker.java:249)
17:04:51,708 ERROR [stderr] (default task-2) at org.jboss.resteasy.core.ResourceMethodInvoker.invoke(ResourceMethodInvoker.java:236)
17:04:51,709 ERROR [stderr] (default task-2) at org.jboss.resteasy.core.SynchronousDispatcher.invoke(SynchronousDispatcher.java:395)
17:04:51,709 ERROR [stderr] (default task-2) at org.jboss.resteasy.core.SynchronousDispatcher.invoke(SynchronousDispatcher.java:202)
17:04:51,709 ERROR [stderr] (default task-2) at org.jboss.resteasy.plugins.server.servlet.ServletContainerDispatcher.service(ServletContainerDispatcher.java:221)
17:04:51,710 ERROR [stderr] (default task-2) at org.jboss.resteasy.plugins.server.servlet.HttpServletDispatcher.service(HttpServletDispatcher.java:56)
17:04:51,710 ERROR [stderr] (default task-2) at org.jboss.resteasy.plugins.server.servlet.HttpServletDispatcher.service(HttpServletDispatcher.java:51)
My DSLJsonProvider class looks like this.
package com.x.y.provider;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.lang.annotation.Annotation;
import java.lang.reflect.Type;
import javax.ws.rs.Consumes;
import javax.ws.rs.Produces;
import javax.ws.rs.WebApplicationException;
import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.MultivaluedMap;
import javax.ws.rs.ext.MessageBodyReader;
import javax.ws.rs.ext.MessageBodyWriter;
import javax.ws.rs.ext.Provider;
import com.dslplatform.json.DslJson;
import com.dslplatform.json.JsonReader;
import com.dslplatform.json.JsonReader.ReadObject;
import com.dslplatform.json.JsonWriter;
#SuppressWarnings("rawtypes")
#Provider
#Consumes({MediaType.APPLICATION_JSON, "text/json"})
#Produces({MediaType.APPLICATION_JSON, "text/json"})
public class DSLJsonProvider extends DslJson implements MessageBodyWriter, MessageBodyReader {
#Override
public boolean isReadable(Class type, Type genericType, Annotation[] annotations,
javax.ws.rs.core.MediaType mediaType) {
return true;
}
#SuppressWarnings("unchecked")
#Override
public Object readFrom(Class type, Type genericType, Annotation[] annotations, javax.ws.rs.core.MediaType mediaType,
MultivaluedMap httpHeaders, InputStream entityStream) throws IOException, WebApplicationException {
DslJson<Object> dslJson = new DslJson<Object>();
try {
dslJson.registerReader(type,null);//Here I need help
return dslJson.deserialize(type, entityStream, new byte[1024]);
} catch (Exception e) {
e.printStackTrace();
} finally {
entityStream.close();
}
return null;
}
#Override
public boolean isWriteable(Class type, Type genericType, Annotation[] annotations,
javax.ws.rs.core.MediaType mediaType) {
return true;
}
#Override
public long getSize(Object t, Class type, Type genericType, Annotation[] annotations,
javax.ws.rs.core.MediaType mediaType) {
return -1;
}
#Override
#SuppressWarnings("resource")
public void writeTo(Object t, Class type, Type genericType, Annotation[] annotations,
javax.ws.rs.core.MediaType mediaType, MultivaluedMap httpHeaders, OutputStream entityStream)
throws IOException, WebApplicationException {
JsonWriter writer = new JsonWriter();
try {
//Need help to register writer
writer.toStream(entityStream);
} catch (Exception e) {
e.printStackTrace();
}
}
}
Edit 1:
My pom.xml
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.x.y</groupId>
<artifactId>project-web</artifactId>
<version>1.0.0-SNAPSHOT</version>
<packaging>war</packaging>
<name>project-web</name>
<dependencies>
<dependency>
<groupId>io.undertow</groupId>
<artifactId>undertow-core</artifactId>
<version>1.3.20.Final</version>
</dependency>
<dependency>
<groupId>io.undertow</groupId>
<artifactId>undertow-servlet</artifactId>
<version>1.3.20.Final</version>
</dependency>
<dependency>
<groupId>com.dslplatform</groupId>
<artifactId>dsl-json</artifactId>
<version>0.9.5</version>
</dependency>
<dependency>
<groupId>javax.ws.rs</groupId>
<artifactId>javax.ws.rs-api</artifactId>
<version>2.0.1</version>
</dependency>
<dependency>
<groupId>org.jboss.resteasy</groupId>
<artifactId>resteasy-jaxrs</artifactId>
<version>3.0.16.Final</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId>
<version>2.7.3</version>
</dependency>
<dependency>
<groupId>org.jboss.resteasy</groupId>
<artifactId>resteasy-jackson-provider</artifactId>
<version>3.0.16.Final</version>
</dependency>
<dependency>
<groupId>com.dslplatform</groupId>
<artifactId>dsl-json-java8</artifactId>
<version>0.9.7</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.3</version>
<configuration>
<annotationProcessors>
<annotationProcessor>com.dslplatform.json.CompiledJsonProcessor</annotationProcessor>
</annotationProcessors>
</configuration>
</plugin>
</plugins>
</build>
</project>
I'm kinda blocked at trying to register readers and writers.Any lead is appreciated.
Resource :
dsl-json : https://github.com/ngs-doo/dsl-json
Thanks in advance.
The error message says it's unable to find reader for: com.x.y.api.v1.resource.A
It's either you forgot to add #CompiledJson to that class or for some reason it was not picked up with ServiceLoader.
If you want to register your own reader for JsonReader.ReadObject you can look into geom readers although I think you probably just want to add annotation for compiler to pick it up.
Processor for those annotations lives in a separate library (processor) so mostly probably you didn't include it or added it as annotation processor.
You need to get rid of dslJson.registerReader(type,null); since that will override correct reader.
I updated dsl-json README, since I did encounter such errors occasionally. Namely: "During startup DslJson loads services through ServiceLoader. For this to work META-INF/services/com.dslplatform.json.Configuration must exist with the content of dsl_json.json.ExternalSerialization which is the class crated during compilation step. In certain scenarios this file is not copied to APK or to the appropriate jar/war file. You can work around it by creating such file in your project under src/main/resources/META-INF/services as workaround for the used package/build tool."
I would be interested more in your setup so if this fixes the problem for you please submit an issue on the repository so it can be properly resolved.
I got same issue, and fixed by add default constructor to deserialized class

XMLStreamException :Trying to output second root, StaXparser

writer.writeStartElement(startElement.getName().getLocalPart());
//when i run on standalone machine with one thread, it works fine, but when i run the multiple jobs with multiple threads on the server it gives me the following error at
writer.writeStartElement(startElement.getName().getLocalPart());
javax.xml.stream.XMLStreamException: Trying to output second root, <element>
ERROR [STDERR] (JBossQuartzScheduler_Worker-4) javax.xml.stream.XMLStreamException:
Trying to output second root, <handset>
ERROR [STDERR] (JBossQuartzScheduler_Worker-4) at com.ctc.wstx.sw.BaseStreamWriter.throwOutputError(BaseStreamWriter.java:1473)
ERROR [STDERR] (JBossQuartzScheduler_Worker-4) at com.ctc.wstx.sw.BaseStreamWriter.throwOutputError(BaseStreamWriter.java:1480)
ERROR [STDERR] (JBossQuartzScheduler_Worker-4) at com.ctc.wstx.sw.BaseStreamWriter.reportNwfStructure(BaseStreamWriter.java:1508)
ERROR [STDERR] (JBossQuartzScheduler_Worker-4) at com.ctc.wstx.sw.BaseNsStreamWriter.checkStartElement(BaseNsStreamWriter.java:444)
ERROR [STDERR] (JBossQuartzScheduler_Worker-4) at com.ctc.wstx.sw.BaseNsStreamWriter.writeStartElement(BaseNsStreamWriter.java:292)

Categories