|
From: Johnson, S. [USA] <joh...@ba...> - 2014-02-03 14:22:54
|
Hi All, First post, long-time lurker. I have posted this same question to StackOverflow and not had any bites yet. I've broken the issue down to the bare essentials – but I'm fairly clueless about where to go next. I have posted the code here: https://bitbucket.org/johnson_shawn/stackoverflow-21471310 – Basically I'm trying to take a label/value object list and marshal it to <XmlElementName label="Human Readable Label">Value Goes Here</XmlElementName>. In a larger project with a crazy class path, it runs fine from the main. When run through JBoss+RESTEasy I get the following (partial) stack: INFO [stdout] org.jboss.resteasy.plugins.providers.jaxb.JAXBMarshalException: javax.xml.bind.MarshalException 21:02:19,959 INFO [stdout] - with linked exception: 21:02:19,959 INFO [stdout] [com.sun.istack.SAXException2 21:02:19,959 INFO [stdout] java.lang.NullPointerException] 21:02:19,959 INFO [stdout] at org.jboss.resteasy.plugins.providers.jaxb.AbstractJAXBProvider.writeTo(AbstractJAXBProvider.java:148) 21:02:19,960 INFO [stdout] at org.jboss.resteasy.core.interception.MessageBodyWriterContextImpl.proceed(MessageBodyWriterContextImpl.java:117) 21:02:19,960 More info here: http://stackoverflow.com/questions/21471310/error-when-more-than-one-item-to-list-of-objects-using-jaxbs-xmlanyelement-and Any ideas for debugging further or other brilliant answers will be greatly appreciated! |
|
From: Bill B. <bb...@re...> - 2014-02-03 15:19:39
|
You'll have to point out what resteasy version you are using so I can match the line numbers in you stack trace up. On 2/3/2014 8:48 AM, Johnson, Shawn [USA] wrote: > Hi All, > First post, long-time lurker. I have posted this same question to > StackOverflow and not had any bites yet. I've broken the issue down to > the bare essentials – but I'm fairly clueless about where to go next. I > have posted the code here: > https://bitbucket.org/johnson_shawn/stackoverflow-21471310 – Basically > I'm trying to take a label/value object list and marshal it to > <XmlElementName label="Human Readable Label">Value Goes > Here</XmlElementName>. In a larger project with a crazy class path, it > runs fine from the main. When run through JBoss+RESTEasy I get the > following (partial) stack: > > INFO [stdout] > org.jboss.resteasy.plugins.providers.jaxb.JAXBMarshalException: > javax.xml.bind.MarshalException 21:02:19,959 > INFO [stdout] - with linked exception: 21:02:19,959 > INFO [stdout] [com.sun.istack.SAXException2 21:02:19,959 > INFO [stdout] java.lang.NullPointerException] 21:02:19,959 > INFO [stdout] at > org.jboss.resteasy.plugins.providers.jaxb.AbstractJAXBProvider.writeTo(AbstractJAXBProvider.java:148) > 21:02:19,960 > INFO [stdout] at > org.jboss.resteasy.core.interception.MessageBodyWriterContextImpl.proceed(MessageBodyWriterContextImpl.java:117) > 21:02:19,960 > > More info here: > http://stackoverflow.com/questions/21471310/error-when-more-than-one-item-to-list-of-objects-using-jaxbs-xmlanyelement-and > > Any ideas for debugging further or other brilliant answers will be > greatly appreciated! > > > ------------------------------------------------------------------------------ > Managing the Performance of Cloud-Based Applications > Take advantage of what the Cloud has to offer - Avoid Common Pitfalls. > Read the Whitepaper. > http://pubads.g.doubleclick.net/gampad/clk?id=121051231&iu=/4140/ostg.clktrk > > > > _______________________________________________ > Resteasy-users mailing list > Res...@li... > https://lists.sourceforge.net/lists/listinfo/resteasy-users > -- Bill Burke JBoss, a division of Red Hat http://bill.burkecentral.com |
|
From: Johnson, S. [USA] <joh...@ba...> - 2014-02-03 16:11:15
|
Bill, thanks for the reply. Sorry for leaving out the version info – partially because I've tried 3 different configs. Below is the stack trace from JBoss AS 7.2 – which I left with it's included version of RESTEasy 2.3.5. I can also repeat this with 3.0.6 if that's more helpful? 10:55:30,747 INFO [org.jboss.modules] (main) JBoss Modules version 1.2.0.CR1 10:55:31,120 INFO [org.jboss.msc] (main) JBoss MSC version 1.0.4.GA 10:55:31,178 INFO [org.jboss.as] (MSC service thread 1-6) JBAS015899: JBoss AS 7.2.0.Final "Janus" starting 10:55:31,967 INFO [org.jboss.as.server.deployment.scanner] (DeploymentScanner-threads - 1) JBAS015003: Found resteasy-sample.war in deployment directory. To trigger deployment create a file called resteasy-sample.war.dodeploy 10:55:32,007 INFO [org.xnio] (MSC service thread 1-5) XNIO Version 3.0.7.GA 10:55:32,010 INFO [org.jboss.as.server] (Controller Boot Thread) JBAS015888: Creating http management service using socket-binding (management-http) 10:55:32,013 INFO [org.xnio.nio] (MSC service thread 1-5) XNIO NIO Implementation Version 3.0.7.GA 10:55:32,021 INFO [org.jboss.remoting] (MSC service thread 1-5) JBoss Remoting version 3.2.14.GA 10:55:32,054 INFO [org.jboss.as.clustering.infinispan] (ServerService Thread Pool -- 29) JBAS010280: Activating Infinispan subsystem. 10:55:32,056 INFO [org.jboss.as.security] (ServerService Thread Pool -- 42) JBAS013171: Activating Security Subsystem 10:55:32,059 INFO [org.jboss.as.naming] (ServerService Thread Pool -- 37) JBAS011800: Activating Naming Subsystem 10:55:32,062 INFO [org.jboss.as.jsf] (ServerService Thread Pool -- 35) JBAS012605: Activated the following JSF Implementations: [main, 1.2] 10:55:32,068 INFO [org.jboss.as.security] (MSC service thread 1-1) JBAS013170: Current PicketBox version=4.0.15.Final 10:55:32,103 INFO [org.jboss.as.webservices] (ServerService Thread Pool -- 46) JBAS015537: Activating WebServices Extension 10:55:32,127 INFO [org.jboss.as.connector.logging] (MSC service thread 1-5) JBAS010408: Starting JCA Subsystem (JBoss IronJacamar 1.0.15.Final) 10:55:32,138 INFO [org.jboss.as.naming] (MSC service thread 1-7) JBAS011802: Starting Naming Service 10:55:32,141 INFO [org.jboss.as.mail.extension] (MSC service thread 1-13) JBAS015400: Bound mail session [java:jboss/mail/Default] 10:55:32,184 INFO [org.jboss.as.connector.subsystems.datasources] (ServerService Thread Pool -- 25) JBAS010403: Deploying JDBC-compliant driver class org.h2.Driver (version 1.3) 10:55:32,306 INFO [org.jboss.ws.common.management] (MSC service thread 1-7) JBWS022052: Starting JBoss Web Services - Stack CXF Server 4.1.3.Final 10:55:32,406 INFO [org.apache.coyote.http11] (MSC service thread 1-6) JBWEB003001: Coyote HTTP/1.1 initializing on : http-localhost/127.0.0.1:8080 10:55:32,413 INFO [org.apache.coyote.http11] (MSC service thread 1-6) JBWEB003000: Coyote HTTP/1.1 starting on: http-localhost/127.0.0.1:8080 10:55:32,567 INFO [org.jboss.as.connector.subsystems.datasources] (MSC service thread 1-6) JBAS010400: Bound data source [java:jboss/datasources/ExampleDS] 10:55:32,694 INFO [org.jboss.as.server.deployment.scanner] (MSC service thread 1-9) JBAS015012: Started FileSystemDeploymentService for directory /Users/shawnjohnson/erule-dev/jboss-as-7.2.0.Final/standalone/deployments 10:55:32,699 INFO [org.jboss.as.server.deployment] (MSC service thread 1-4) JBAS015876: Starting deployment of "resteasy-sample.war" (runtime-name: "resteasy-sample.war") 10:55:32,705 INFO [org.jboss.as.remoting] (MSC service thread 1-6) JBAS017100: Listening on 127.0.0.1:9999 10:55:32,705 INFO [org.jboss.as.remoting] (MSC service thread 1-5) JBAS017100: Listening on 127.0.0.1:4447 10:55:33,001 INFO [org.jboss.web] (ServerService Thread Pool -- 52) JBAS018210: Register web context: /resteasy-sample 10:55:33,129 INFO [org.jboss.as.server] (ServerService Thread Pool -- 26) JBAS018559: Deployed "resteasy-sample.war" (runtime-name : "resteasy-sample.war") 10:55:33,135 INFO [org.jboss.as] (Controller Boot Thread) JBAS015961: Http management interface listening on http://127.0.0.1:9990/management 10:55:33,136 INFO [org.jboss.as] (Controller Boot Thread) JBAS015951: Admin console listening on http://127.0.0.1:9990 10:55:33,136 INFO [org.jboss.as] (Controller Boot Thread) JBAS015874: JBoss AS 7.2.0.Final "Janus" started in 2724ms - Started 162 of 219 services (56 services are passive or on-demand) 10:57:50,400 INFO [org.hibernate.validator.internal.util.Version] (http-localhost/127.0.0.1:8080-1) HV000001: Hibernate Validator 4.3.1.Final 10:57:50,505 INFO [org.jboss.resteasy.spi.ResteasyDeployment] (http-localhost/127.0.0.1:8080-1) Deploying javax.ws.rs.core.Application: class non.sample.resteasy.JaxRsActivator 10:57:50,681 WARN [org.jboss.resteasy.core.SynchronousDispatcher] (http-localhost/127.0.0.1:8080-1) Failed executing GET /test: org.jboss.resteasy.plugins.providers.jaxb.JAXBMarshalException: javax.xml.bind.MarshalException - with linked exception: [com.sun.istack.SAXException2 java.lang.NullPointerException] at org.jboss.resteasy.plugins.providers.jaxb.AbstractJAXBProvider.writeTo(AbstractJAXBProvider.java:148) [resteasy-jaxb-provider-2.3.5.Final.jar:] at org.jboss.resteasy.core.interception.MessageBodyWriterContextImpl.proceed(MessageBodyWriterContextImpl.java:117) [resteasy-jaxrs-2.3.5.Final.jar:] at org.jboss.resteasy.plugins.interceptors.encoding.GZIPEncodingInterceptor.write(GZIPEncodingInterceptor.java:104) [resteasy-jaxrs-2.3.5.Final.jar:] at org.jboss.resteasy.core.interception.MessageBodyWriterContextImpl.proceed(MessageBodyWriterContextImpl.java:123) [resteasy-jaxrs-2.3.5.Final.jar:] at org.jboss.resteasy.core.ServerResponse.writeTo(ServerResponse.java:250) [resteasy-jaxrs-2.3.5.Final.jar:] at org.jboss.resteasy.core.SynchronousDispatcher.writeJaxrsResponse(SynchronousDispatcher.java:602) [resteasy-jaxrs-2.3.5.Final.jar:] at org.jboss.resteasy.core.SynchronousDispatcher.invoke(SynchronousDispatcher.java:528) [resteasy-jaxrs-2.3.5.Final.jar:] at org.jboss.resteasy.core.SynchronousDispatcher.invoke(SynchronousDispatcher.java:126) [resteasy-jaxrs-2.3.5.Final.jar:] at org.jboss.resteasy.plugins.server.servlet.ServletContainerDispatcher.service(ServletContainerDispatcher.java:208) [resteasy-jaxrs-2.3.5.Final.jar:] at org.jboss.resteasy.plugins.server.servlet.HttpServletDispatcher.service(HttpServletDispatcher.java:55) [resteasy-jaxrs-2.3.5.Final.jar:] at org.jboss.resteasy.plugins.server.servlet.HttpServletDispatcher.service(HttpServletDispatcher.java:50) [resteasy-jaxrs-2.3.5.Final.jar:] at javax.servlet.http.HttpServlet.service(HttpServlet.java:847) [jboss-servlet-api_3.0_spec-1.0.2.Final.jar:1.0.2.Final] at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:295) [jbossweb-7.2.0.Final.jar:7.2.0.Final] at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:214) [jbossweb-7.2.0.Final.jar:7.2.0.Final] at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:230) [jbossweb-7.2.0.Final.jar:7.2.0.Final] at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:149) [jbossweb-7.2.0.Final.jar:7.2.0.Final] at org.jboss.as.web.security.SecurityContextAssociationValve.invoke(SecurityContextAssociationValve.java:169) [jboss-as-web-7.2.0.Final.jar:7.2.0.Final] at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:145) [jbossweb-7.2.0.Final.jar:7.2.0.Final] at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:97) [jbossweb-7.2.0.Final.jar:7.2.0.Final] at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:102) [jbossweb-7.2.0.Final.jar:7.2.0.Final] at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:336) [jbossweb-7.2.0.Final.jar:7.2.0.Final] at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:856) [jbossweb-7.2.0.Final.jar:7.2.0.Final] at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:653) [jbossweb-7.2.0.Final.jar:7.2.0.Final] at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:920) [jbossweb-7.2.0.Final.jar:7.2.0.Final] at java.lang.Thread.run(Thread.java:744) [rt.jar:1.7.0_45] Caused by: javax.xml.bind.MarshalException - with linked exception: [com.sun.istack.SAXException2 java.lang.NullPointerException] at com.sun.xml.bind.v2.runtime.MarshallerImpl.write(MarshallerImpl.java:326) at com.sun.xml.bind.v2.runtime.MarshallerImpl.marshal(MarshallerImpl.java:251) at javax.xml.bind.helpers.AbstractMarshallerImpl.marshal(AbstractMarshallerImpl.java:74) [jboss-jaxb-api_2.2_spec-1.0.4.Final.jar:1.0.4.Final] at org.jboss.resteasy.plugins.providers.jaxb.AbstractJAXBProvider.writeTo(AbstractJAXBProvider.java:144) [resteasy-jaxb-provider-2.3.5.Final.jar:] ... 24 more Caused by: com.sun.istack.SAXException2 java.lang.NullPointerException at com.sun.xml.bind.v2.runtime.XMLSerializer.reportError(XMLSerializer.java:247) at com.sun.xml.bind.v2.runtime.XMLSerializer.reportError(XMLSerializer.java:262) at com.sun.xml.bind.v2.runtime.reflect.AdaptedLister$ListIteratorImpl.next(AdaptedLister.java:115) at com.sun.xml.bind.v2.runtime.property.ArrayReferenceNodeProperty.serializeListBody(ArrayReferenceNodeProperty.java:107) at com.sun.xml.bind.v2.runtime.property.ArrayERProperty.serializeBody(ArrayERProperty.java:159) at com.sun.xml.bind.v2.runtime.ClassBeanInfoImpl.serializeBody(ClassBeanInfoImpl.java:358) at com.sun.xml.bind.v2.runtime.XMLSerializer.childAsSoleContent(XMLSerializer.java:593) at com.sun.xml.bind.v2.runtime.ClassBeanInfoImpl.serializeRoot(ClassBeanInfoImpl.java:340) at com.sun.xml.bind.v2.runtime.XMLSerializer.childAsRoot(XMLSerializer.java:494) at com.sun.xml.bind.v2.runtime.MarshallerImpl.write(MarshallerImpl.java:323) ... 27 more Caused by: java.lang.NullPointerException at com.sun.xml.bind.v2.runtime.reflect.AdaptedLister.getAdapter(AdaptedLister.java:68) at com.sun.xml.bind.v2.runtime.reflect.AdaptedLister.access$000(AdaptedLister.java:55) at com.sun.xml.bind.v2.runtime.reflect.AdaptedLister$ListIteratorImpl.next(AdaptedLister.java:113) ... 34 more Re: [Resteasy-users] Error marshaling w/ XmlAnyElement + Element Adapter - simple JBoss 7 + RESTEasy project From: Bill Burke <bburke@re...> - 2014-02-03 15:19 You'll have to point out what resteasy version you are using so I can match the line numbers in you stack trace up. From: <Johnson>, Shawn Johnson <joh...@ba...<mailto:joh...@ba...>> Date: Monday, February 3, 2014 8:47 AM To: "res...@li...<mailto:res...@li...>" <res...@li...<mailto:res...@li...>> Subject: Error marshaling w/ XmlAnyElement + Element Adapter - simple JBoss 7 + RESTEasy project Hi All, First post, long-time lurker. I have posted this same question to StackOverflow and not had any bites yet. I've broken the issue down to the bare essentials – but I'm fairly clueless about where to go next. I have posted the code here: https://bitbucket.org/johnson_shawn/stackoverflow-21471310 – Basically I'm trying to take a label/value object list and marshal it to <XmlElementName label="Human Readable Label">Value Goes Here</XmlElementName>. In a larger project with a crazy class path, it runs fine from the main. When run through JBoss+RESTEasy I get the following (partial) stack: INFO [stdout] org.jboss.resteasy.plugins.providers.jaxb.JAXBMarshalException: javax.xml.bind.MarshalException 21:02:19,959 INFO [stdout] - with linked exception: 21:02:19,959 INFO [stdout] [com.sun.istack.SAXException2 21:02:19,959 INFO [stdout] java.lang.NullPointerException] 21:02:19,959 INFO [stdout] at org.jboss.resteasy.plugins.providers.jaxb.AbstractJAXBProvider.writeTo(AbstractJAXBProvider.java:148) 21:02:19,960 INFO [stdout] at org.jboss.resteasy.core.interception.MessageBodyWriterContextImpl.proceed(MessageBodyWriterContextImpl.java:117) 21:02:19,960 More info here: http://stackoverflow.com/questions/21471310/error-when-more-than-one-item-to-list-of-objects-using-jaxbs-xmlanyelement-and Any ideas for debugging further or other brilliant answers will be greatly appreciated! |
|
From: Johnson, S. [USA] <joh...@ba...> - 2014-02-03 16:17:08
|
Bill, thanks for the reply. Sorry for leaving out the version info partially because I've tried 3 different configs. Below is the stack trace from JBoss AS 7.2 which I left with it's included version of RESTEasy 2.3.5. I can also repeat this with 3.0.6 if that's more helpful? [Previous message was too long for the mailing list] Here is a link to the full stack trace using RESTEasy 2.3.5. http://pastebin.com/eFiBgfYQ Re: [Resteasy-users] Error marshaling w/ XmlAnyElement + Element Adapter - simple JBoss 7 + RESTEasy project From: Bill Burke <bburke@re...> - 2014-02-03 15:19 You'll have to point out what resteasy version you are using so I can match the line numbers in you stack trace up. |
|
From: Jean-François H. <jfh...@gm...> - 2014-02-04 07:59:40
|
I had a similar problem, but the stacktrace was not exactly the same. This NPE sounds like a jaxb-impl bug of 2.2.4 version, see https://jaxb.java.net/2.2.6/docs/ch02.html. Version 2.2.4 is embedded by JBoss7.1.x, you should replace jaxb-impl with 2.2.5. Can you also check in your "crazy class path" project what is your version af jaxb-impl ? I'll try to find time to check out and run your project. 2014-02-03 Johnson, Shawn [USA] <joh...@ba...>: > Bill, thanks for the reply. Sorry for leaving out the version info > partially because I've tried 3 different configs. Below is the stack > trace from JBoss AS 7.2 which I left with it's included version of > RESTEasy 2.3.5. I can also repeat this with > 3.0.6 if that's more helpful? > > [Previous message was too long for the mailing list] > > > Here is a link to the full stack trace using RESTEasy 2.3.5. > http://pastebin.com/eFiBgfYQ > > > Re: [Resteasy-users] Error marshaling w/ XmlAnyElement + Element Adapter - > simple JBoss 7 + RESTEasy project > From: Bill Burke <bburke@re...> - 2014-02-03 15:19 > You'll have to point out what resteasy version you are using so I can > match the line numbers in you stack trace up. > > > > ------------------------------------------------------------------------------ > Managing the Performance of Cloud-Based Applications > Take advantage of what the Cloud has to offer - Avoid Common Pitfalls. > Read the Whitepaper. > > http://pubads.g.doubleclick.net/gampad/clk?id=121051231&iu=/4140/ostg.clktrk > _______________________________________________ > Resteasy-users mailing list > Res...@li... > https://lists.sourceforge.net/lists/listinfo/resteasy-users > |
|
From: Jean-François H. <jfh...@gm...> - 2014-02-04 09:26:05
|
I've tested with JAXB 2.2.5, it's the same problem, so forget my previous
mail.
With the following method in LabelValueAdapter, there's no more NPE :
@Override
public Element marshal(LabelValue labelValueModel) throws Exception {
Element e =
DocumentBuilderFactory.newInstance().newDocumentBuilder().newDocument().createElement(getCleanLabel(labelValueModel.getLabel()));
e.setTextContent(labelValueModel.getValue());
return e;
}
With this result :
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<testModel>
<DISTILLED_WATER>Deer Park</DISTILLED_WATER>
<MINERAL_WATER>Mountain Stream</MINERAL_WATER>
<PURIFIED_WATER>Mr. Water</PURIFIED_WATER>
</testModel>
I have removed all adapter class private attributes and usage JAXBElement,
it seems there is a problem calling a JAXB marshaller inside an adapter.
JAXB marshalling is not "reentrant" ?
2014-02-04 Jean-François HEROUARD <jfh...@gm...>:
> I had a similar problem, but the stacktrace was not exactly the same. This
> NPE sounds like a jaxb-impl bug of 2.2.4 version, see
> https://jaxb.java.net/2.2.6/docs/ch02.html. Version 2.2.4 is embedded by
> JBoss7.1.x, you should replace jaxb-impl with 2.2.5. Can you also check in
> your "crazy class path" project what is your version af jaxb-impl ?
> I'll try to find time to check out and run your project.
>
>
> 2014-02-03 Johnson, Shawn [USA] <joh...@ba...>:
>
> Bill, thanks for the reply. Sorry for leaving out the version info
>> partially because I've tried 3 different configs. Below is the stack
>> trace from JBoss AS 7.2 which I left with it's included version of
>> RESTEasy 2.3.5. I can also repeat this with
>> 3.0.6 if that's more helpful?
>>
>> [Previous message was too long for the mailing list]
>>
>>
>> Here is a link to the full stack trace using RESTEasy 2.3.5.
>> http://pastebin.com/eFiBgfYQ
>>
>>
>> Re: [Resteasy-users] Error marshaling w/ XmlAnyElement + Element Adapter -
>> simple JBoss 7 + RESTEasy project
>> From: Bill Burke <bburke@re...> - 2014-02-03 15:19
>> You'll have to point out what resteasy version you are using so I can
>> match the line numbers in you stack trace up.
>>
>>
>>
>> ------------------------------------------------------------------------------
>> Managing the Performance of Cloud-Based Applications
>> Take advantage of what the Cloud has to offer - Avoid Common Pitfalls.
>> Read the Whitepaper.
>>
>> http://pubads.g.doubleclick.net/gampad/clk?id=121051231&iu=/4140/ostg.clktrk
>> _______________________________________________
>> Resteasy-users mailing list
>> Res...@li...
>> https://lists.sourceforge.net/lists/listinfo/resteasy-users
>>
>
>
|
|
From: Johnson, S. [USA] <joh...@ba...> - 2014-02-04 15:57:50
|
Thanks so much Jean-François. I had taken that example from another site
– where they used the both JAXBElement as well as dom.Element – to add the
attribute to the label. Is there another way to accomplish something like
this? Since this is only marshaling my Java objects, I have a lot of
flexibility on how I structure my class.
<DISTILLED_WATER label="Distilled Water">Deer Park</DISTILLED_WATER>
<MINERAL_WATER label="Mineral Water">Mountain Stream</MINERAL_WATER>
<PURIFIED_WATER label="Mineral Water">Mr. Water</PURIFIED_WATER>
From: Jean-François HEROUARD <jfh...@gm...>
Date: Tuesday, February 4, 2014 4:25 AM
To: Shawn Johnson <joh...@ba...>
Cc: "res...@li..."
<res...@li...>
Subject: [External] Re: [Resteasy-users] Error marshaling w/
XmlAnyElement + Element Adapter - simple JBoss 7 + RESTEasy project
I've tested with JAXB 2.2.5, it's the same problem, so forget my previous
mail.
With the following method in LabelValueAdapter, there's no more NPE :
@Override
public Element marshal(LabelValue labelValueModel) throws Exception {
Element e =
DocumentBuilderFactory.newInstance().newDocumentBuilder().newDocument().cre
ateElement(getCleanLabel(labelValueModel.getLabel()));
e.setTextContent(labelValueModel.getValue());
return e;
}
With this result :
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<testModel>
<DISTILLED_WATER>Deer Park</DISTILLED_WATER>
<MINERAL_WATER>Mountain Stream</MINERAL_WATER>
<PURIFIED_WATER>Mr. Water</PURIFIED_WATER>
</testModel>
I have removed all adapter class private attributes and usage JAXBElement,
it seems there is a problem calling a JAXB marshaller inside an adapter.
JAXB marshalling is not "reentrant" ?
2014-02-04 Jean-François HEROUARD <jfh...@gm...>:
I had a similar problem, but the stacktrace was not exactly the same. This
NPE sounds like a jaxb-impl bug of 2.2.4 version, see
https://jaxb.java.net/2.2.6/docs/ch02.html. Version 2.2.4 is embedded by
JBoss7.1.x, you should replace jaxb-impl with 2.2.5. Can you also check in
your "crazy class path" project what
is your version af jaxb-impl ?
I'll try to find time to check out and run your project.
2014-02-03 Johnson, Shawn [USA] <joh...@ba...>:
Bill, thanks for the reply. Sorry for leaving out the version info
partially because I've tried 3 different configs. Below is the stack
trace from JBoss AS 7.2 which I left with it's included version of
RESTEasy 2.3.5. I can also repeat this with
3.0.6 if that's more helpful?
[Previous message was too long for the mailing list]
Here is a link to the full stack trace using RESTEasy 2.3.5.
http://pastebin.com/eFiBgfYQ
Re: [Resteasy-users] Error marshaling w/ XmlAnyElement + Element Adapter -
simple JBoss 7 + RESTEasy project
From: Bill Burke <bburke@re...> - 2014-02-03 15:19
You'll have to point out what resteasy version you are using so I can
match the line numbers in you stack trace up.
---------------------------------------------------------------------------
---
Managing the Performance of Cloud-Based Applications
Take advantage of what the Cloud has to offer - Avoid Common Pitfalls.
Read the Whitepaper.
http://pubads.g.doubleclick.net/gampad/clk?id=121051231&iu=/4140/ostg.clktr
k
_______________________________________________
Resteasy-users mailing list
Res...@li...
https://lists.sourceforge.net/lists/listinfo/resteasy-users
|
|
From: Jean-François H. <jfh...@gm...> - 2014-02-04 16:16:48
|
With a small change I got your sample :
public class LabelValueAdapter extends XmlAdapter<Element, LabelValue> {
@Override
public Element marshal(LabelValue labelValueModel) throws Exception {
Element e =
DocumentBuilderFactory.newInstance().newDocumentBuilder().newDocument().createElement(getCleanLabel(labelValueModel.getLabel()));
e.setAttribute("label", labelValueModel.getLabel());
e.setTextContent(labelValueModel.getValue());
return e;
}
@Override
public LabelValue unmarshal(Element element) throws Exception {
throw new UnsupportedOperationException();
}
private String getCleanLabel(String attributeLabel) {
attributeLabel = attributeLabel.replaceAll("dk_",
"").replaceAll("[()]", "")
.replaceAll("[^\\w\\s]", "_").replaceAll(" ", "_")
.toUpperCase();
return attributeLabel;
}
}
2014-02-04 Johnson, Shawn [USA] <joh...@ba...>:
> Thanks so much Jean-François. I had taken that example from another site
> - where they used the both JAXBElement as well as dom.Element - to add the
> attribute to the label. Is there another way to accomplish something like
> this? Since this is only marshaling my Java objects, I have a lot of
> flexibility on how I structure my class.
>
> <DISTILLED_WATER label="Distilled Water">Deer Park</DISTILLED_WATER>
> <MINERAL_WATER label="Mineral Water">Mountain Stream</MINERAL_WATER>
> <PURIFIED_WATER label="Mineral Water">Mr. Water</PURIFIED_WATER>
>
>
> From: Jean-François HEROUARD <jfh...@gm...>
> Date: Tuesday, February 4, 2014 4:25 AM
> To: Shawn Johnson <joh...@ba...>
> Cc: "res...@li..."
> <res...@li...>
> Subject: [External] Re: [Resteasy-users] Error marshaling w/
> XmlAnyElement + Element Adapter - simple JBoss 7 + RESTEasy project
>
>
> I've tested with JAXB 2.2.5, it's the same problem, so forget my previous
> mail.
>
> With the following method in LabelValueAdapter, there's no more NPE :
> @Override
> public Element marshal(LabelValue labelValueModel) throws Exception {
> Element e =
> DocumentBuilderFactory.newInstance().newDocumentBuilder().newDocument().cre
> ateElement(getCleanLabel(labelValueModel.getLabel()));
> e.setTextContent(labelValueModel.getValue());
> return e;
> }
>
>
> With this result :
> <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
> <testModel>
> <DISTILLED_WATER>Deer Park</DISTILLED_WATER>
> <MINERAL_WATER>Mountain Stream</MINERAL_WATER>
> <PURIFIED_WATER>Mr. Water</PURIFIED_WATER>
> </testModel>
> I have removed all adapter class private attributes and usage JAXBElement,
> it seems there is a problem calling a JAXB marshaller inside an adapter.
> JAXB marshalling is not "reentrant" ?
>
>
>
>
> 2014-02-04 Jean-François HEROUARD <jfh...@gm...>:
>
> I had a similar problem, but the stacktrace was not exactly the same. This
> NPE sounds like a jaxb-impl bug of 2.2.4 version, see
> https://jaxb.java.net/2.2.6/docs/ch02.html. Version 2.2.4 is embedded by
> JBoss7.1.x, you should replace jaxb-impl with 2.2.5. Can you also check in
> your "crazy class path" project what
> is your version af jaxb-impl ?
>
> I'll try to find time to check out and run your project.
>
>
>
> 2014-02-03 Johnson, Shawn [USA] <joh...@ba...>:
>
>
> Bill, thanks for the reply. Sorry for leaving out the version info -
> partially because I've tried 3 different configs. Below is the stack
> trace from JBoss AS 7.2 - which I left with it's included version of
> RESTEasy 2.3.5. I can also repeat this with
> 3.0.6 if that's more helpful?
>
>
> [Previous message was too long for the mailing list]
>
>
> Here is a link to the full stack trace using RESTEasy 2.3.5.
> http://pastebin.com/eFiBgfYQ
>
>
> Re: [Resteasy-users] Error marshaling w/ XmlAnyElement + Element Adapter -
> simple JBoss 7 + RESTEasy project
> From: Bill Burke <bburke@re...> - 2014-02-03 15:19
> You'll have to point out what resteasy version you are using so I can
> match the line numbers in you stack trace up.
>
>
>
> ---------------------------------------------------------------------------
> ---
> Managing the Performance of Cloud-Based Applications
> Take advantage of what the Cloud has to offer - Avoid Common Pitfalls.
> Read the Whitepaper.
> http://pubads.g.doubleclick.net/gampad/clk?id=121051231&iu=/4140/ostg.clktr
> k
> _______________________________________________
> Resteasy-users mailing list
> Res...@li...
> https://lists.sourceforge.net/lists/listinfo/resteasy-users
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
> ------------------------------------------------------------------------------
> Managing the Performance of Cloud-Based Applications
> Take advantage of what the Cloud has to offer - Avoid Common Pitfalls.
> Read the Whitepaper.
>
> http://pubads.g.doubleclick.net/gampad/clk?id=121051231&iu=/4140/ostg.clktrk
> _______________________________________________
> Resteasy-users mailing list
> Res...@li...
> https://lists.sourceforge.net/lists/listinfo/resteasy-users
>
|