users@jaxb.java.net

Re: Unable to find a JAXB implementation to delegate.

From: Wolfgang Laun <wolfgang.laun_at_gmail.com>
Date: Thu, 10 Jul 2014 07:13:56 +0200

Hi Greg,

so what is the standard way of making the Java beans known to CXF's WSDL?
It should be able to accept a list of Java packages (containing
annotated Java classes, possibly created by the XML Schema compiler
xjc) *or* a list of Java classes, equally annotated. This should
include com.onesteel.reinforcing.pms.OsrJdeRteSvc.ListAllEventsRequest
(no Impl!)

Since the code snippet does a
   new ListAllEventsRequestImpl() // Impl!
I suspect that you might be running into the problem that JAXB doesn't
do Java interfaces. Your beans may implement any number of interfaces,
but the
JAXB context must be based on class types.

For marshalling, you create a Java object that's annotated with
@XmlRootElement, new + default constructor is fine, and you set the
properties, calling setters as required.

That's about all I can contribute. - You might update you SO question
- I don't think it's the right question to ask.

Cheers
Wolfgang



On 10/07/2014, Greg Pagendam-Turner <greg.pagendam-turner_at_onesteel.com> wrote:
> Ok Wolfgang,
>
> The createContext function was created by wsdl2java as part of the grails
> cxf plugin.
>
> Have removed the XmlSeeAlso.
>
>
> Stack trace is now:
> 2014-07-10 13:13:20,060 [http-bio-9080-exec-8] ERROR
> errors.GrailsExceptionResolver - JAXBException occurred when processing
> request: [GET] /osrpms/rte/getSubscriptionsAsJSON - parameters:
> _: 1404961994724
> com.onesteel.reinforcing.pms.OsrJdeRteSvc.ListAllEventsRequest is not known
> to this context. Stacktrace follows:
> Message: com.onesteel.reinforcing.pms.OsrJdeRteSvc.ListAllEventsRequest is
> not known to this context
> Line | Method
> ->> 624 | getBeanInfo in
> com.sun.xml.bind.v2.runtime.JAXBContextImpl
> - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
> | 145 | serializeBody in
> com.sun.xml.bind.v2.runtime.ElementBeanInfoImpl$1
> | 131 | serializeBody . . . . in ''
> | 333 | serializeBody in
> com.sun.xml.bind.v2.runtime.ElementBeanInfoImpl
> | 340 | serializeRoot . . . . in ''
> | 76 | serializeRoot in ''
> | 494 | childAsRoot . . . . . in
> com.sun.xml.bind.v2.runtime.XMLSerializer
> | 323 | write in
> com.sun.xml.bind.v2.runtime.MarshallerImpl
> | 251 | marshal . . . . . . . in ''
> | 95 | marshal in
> javax.xml.bind.helpers.AbstractMarshallerImpl
> | 554 | writeObject . . . . . in org.apache.cxf.jaxb.JAXBEncoderDecoder
> | 236 | marshall in ''
> | 168 | write . . . . . . . . in org.apache.cxf.jaxb.io.DataWriterImpl
> | 110 | writeParts in
> org.apache.cxf.interceptor.AbstractOutDatabindingInterceptor
> | 68 | handleMessage . . . . in
> org.apache.cxf.interceptor.BareOutInterceptor
> | 262 | doIntercept in
> org.apache.cxf.phase.PhaseInterceptorChain
> | 531 | doInvoke . . . . . . . in org.apache.cxf.endpoint.ClientImpl
> | 464 | invoke in ''
> | 367 | invoke . . . . . . . . in ''
> | 320 | invoke in ''
> | 89 | invokeSync . . . . . . in org.apache.cxf.frontend.ClientProxy
> | 134 | invoke in org.apache.cxf.jaxws.JaxWsClientProxy
> | 61 | getSubscriptionsAsJSON in
> com.onesteel.reinforcing.pms.controller.RteController
> | 198 | doFilter in
> grails.plugin.cache.web.filter.PageFragmentCachingFilter
> | 63 | doFilter . . . . . . . in
> grails.plugin.cache.web.filter.AbstractFilter
> | 1145 | runWorker in
> java.util.concurrent.ThreadPoolExecutor
> | 615 | run . . . . . . . . . in
> java.util.concurrent.ThreadPoolExecutor$Worker
> ^ 722 | run in java.lang.Thread
>
>
> My function is:
> def getSubscriptionsAsJSON() {
> def jsonResponse = [:]
> URL wsdlURL = JdeRteListenerPortService.WSDL_LOCATION;
>
>
> def url = grailsApplication.config.pms.svcBaseUrl
>
> log.debug("Calling web service to get events to url: ${url}")
>
> QName SERVICE_NAME = new
> QName("http://www.onesteel.com/osr/JdeRteListener",
> "JdeRteListenerPortService");
> JdeRteListenerPortService ss = new JdeRteListenerPortService(wsdlURL,
> SERVICE_NAME);
> JdeRteListenerPort port = ss.getJdeRteListenerPortSoap11();
>
> BindingProvider provider = (BindingProvider) port
> provider.getRequestContext().putAt(BindingProvider.ENDPOINT_ADDRESS_PROPERTY,
> url)
> ListAllEventsRequestImpl request = new ListAllEventsRequestImpl()
> request.requestorId = loggedInUserService.username
>
>
> ListAllEventsResponse response = port.listAllEvents(request)
>
>
> jsonResponse['subscriptions'] = response.subscriptionCollection
>
> render jsonResponse as JSON
> }
>
> How should I create the ListAllEventsRequestImpl object? Is just using 'new'
> ok?
>
>
> I'm using Grails 2.3.8 on JDK 1.7.0_17
>
>
> The Grails CXF plugin pulls in:
> +--- org.grails.plugins:cxf:1.1.3
> | \--- com.sun.xml.bind:jaxb-impl:2.2.6
> | \--- org.apache.cxf:cxf-rt-frontend-jaxrs:2.6.2
> | \--- org.apache.cxf:cxf-api:2.6.2
> | \--- org.codehaus.woodstox:woodstox-core-asl:4.1.4
> | \--- org.codehaus.woodstox:stax2-api:3.1.1
> | \--- org.apache.ws.xmlschema:xmlschema-core:2.0.3
> | \---
> org.apache.geronimo.specs:geronimo-javamail_1.4_spec:1.7.1
> | \--- org.apache.cxf:cxf-rt-core:2.6.2
> | \--- javax.ws.rs:jsr311-api:1.1.1
> | \--- org.apache.cxf:cxf-rt-bindings-xml:2.6.2
> | \--- org.apache.cxf:cxf-rt-transports-http:2.6.2
> | \--- org.apache.cxf:cxf-rt-frontend-jaxws:2.6.2
> | \--- xml-resolver:xml-resolver:1.2
> | \--- org.apache.cxf:cxf-rt-bindings-soap:2.6.2
> | \--- org.apache.cxf:cxf-rt-databinding-jaxb:2.6.2
> | \--- org.apache.cxf:cxf-rt-frontend-simple:2.6.2
> | \--- org.apache.cxf:cxf-rt-ws-addr:2.6.2
> | \--- org.apache.cxf:cxf-rt-ws-policy:2.6.2
> | \--- org.apache.neethi:neethi:3.0.2
> | \--- commons-cli:commons-cli:1.2
> | \--- org.apache.cxf:cxf-tools-wsdlto-frontend-jaxws:2.6.2
> | \--- org.apache.cxf:cxf-tools-common:2.6.2
> | \--- org.apache.cxf:cxf-tools-wsdlto-core:2.6.2
> | \--- org.apache.cxf:cxf-tools-validator:2.6.2
> | \--- org.apache.velocity:velocity:1.7
> | \--- wsdl4j:wsdl4j:1.6.2
> | \--- com.sun.xml.bind:jaxb-xjc:2.2.6
> | \--- org.apache.cxf:cxf-tools-wsdlto-databinding-jaxb:2.6.2
>
>
> -----Original Message-----
> From: Wolfgang Laun [mailto:wolfgang.laun_at_gmail.com]
> Sent: Wednesday, 9 July 2014 6:49 PM
> To: users_at_jaxb.java.net
> Subject: Re: Unable to find a JAXB implementation to delegate.
>
> In org.apache.cxf.common.jaxb.JAXBContextCache$2, there is a call:
>
> JAXBContext.newInstance ( Class[] classesToBeBound,
> Map<String,?> properties )
>
> Then I see:
>
> ContextFinder.find( classesToBeBound, properties);
>
> which finds a ./jaxb.properties which defines a
>
> JAXB_CONTEXT_FACTORY =
> com.onesteel.reinforcing.pms.OsrJdeRteSvc.impl.JAXBContextFactory
>
> and promptly invokes (still passing the same Class[])
>
> JAXBContextFactory.createContext( null, classes, properties);
>
> Well, this is your code, and you should know why and how it invokes
>
> JAXBContext newInstance( Class[] classesToBeBound,
> Map<String,?> properties )
>
> which brings us (as you may have noted) back to square one.
>
> You can find the Java sources of javax.xml.bind,
> http://grepcode.com/file/repository.grepcode.com/java/root/jdk/openjdk/7u40-b43
>
> (You didn't tell me your Java version, but the source lines match very
> well.)
>
> And it's your code that throws that exception, so you should be able to
> avoid an infinite recursion, and fix the exception thrown. Adding an
> XmlSeeAlso isn't going to help.
>
> Cheers
> Wolfgang
>
>
> On 09/07/2014, Greg Pagendam-Turner <greg.pagendam-turner_at_onesteel.com>
> wrote:
>> Sure Wolfgang. Point taken.
>>
>> Full stack trace of my current error is:
>>
>> 2014-07-09 15:58:00,566 [http-bio-9080-exec-9] ERROR
>> errors.GrailsExceptionResolver - JAXBException occurred when
>> processing
>> request: [GET] /osrpms/rte/getSubscriptionsAsJSON - parameters:
>> _: 1404885477056
>> Unable to find a JAXB implementation to delegate. Stacktrace follows:
>> Message: Unable to find a JAXB implementation to delegate
>> Line | Method
>> ->> 138 | createContext in
>> com.onesteel.reinforcing.pms.OsrJdeRteSvc.impl.JAXBContextFactory
>> - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
>> -
>> | 248 | newInstance in javax.xml.bind.ContextFinder
>> | 235 | newInstance . . . . . . . . in ''
>> | 385 | find in ''
>> | 637 | newInstance . . . . . . . . in javax.xml.bind.JAXBContext
>> | 142 | createContext in
>> com.onesteel.reinforcing.pms.OsrJdeRteSvc.impl.JAXBContextFactory
>> | 248 | newInstance . . . . . . . . in javax.xml.bind.ContextFinder
>> | 235 | newInstance in ''
>> | 385 | find . . . . . . . . . . . in ''
>> | 637 | newInstance in javax.xml.bind.JAXBContext
>> | 268 | run . . . . . . . . . . . . in
>> org.apache.cxf.common.jaxb.JAXBContextCache$2
>> | 267 | run in ''
>> | 266 | createContext . . . . . . . in
>> org.apache.cxf.common.jaxb.JAXBContextCache
>> | 172 | getCachedContextAndSchemas in ''
>> | 454 | createJAXBContextAndSchemas in
>> org.apache.cxf.jaxb.JAXBDataBinding
>> | 322 | initialize in ''
>> | 86 | initializeDataBindings . . in
>> org.apache.cxf.service.factory.AbstractServiceFactoryBean
>> | 430 | buildServiceFromWSDL in
>> org.apache.cxf.service.factory.ReflectionServiceFactoryBean
>> | 534 | initializeServiceModel . . in ''
>> | 248 | create in ''
>> | 205 | create . . . . . . . . . . in
>> org.apache.cxf.jaxws.support.JaxWsServiceFactoryBean
>> | 101 | createEndpoint in
>> org.apache.cxf.frontend.AbstractWSDLBasedEndpointFactory
>> | 90 | create . . . . . . . . . . in
>> org.apache.cxf.frontend.ClientFactoryBean
>> | 155 | create in
>> org.apache.cxf.frontend.ClientProxyFactoryBean
>> | 156 | create . . . . . . . . . . in
>> org.apache.cxf.jaxws.JaxWsProxyFactoryBean
>> | 469 | createPort in
>> org.apache.cxf.jaxws.ServiceImpl
>> | 336 | getPort . . . . . . . . . . in ''
>> | 323 | getPort in ''
>> | 119 | getPort . . . . . . . . . . in javax.xml.ws.Service
>> | 87 | getJdeRteListenerPortSoap11 in
>> com.onesteel.reinforcing.pms.OsrJdeRteSvc.JdeRteListenerPortService
>> | 48 | getSubscriptionsAsJSON . . in
>> com.onesteel.reinforcing.pms.controller.RteController
>> | 198 | doFilter in
>> grails.plugin.cache.web.filter.PageFragmentCachingFilter
>> | 63 | doFilter . . . . . . . . . in
>> grails.plugin.cache.web.filter.AbstractFilter
>> | 1145 | runWorker in
>> java.util.concurrent.ThreadPoolExecutor
>> | 615 | run . . . . . . . . . . . . in
>> java.util.concurrent.ThreadPoolExecutor$Worker
>> ^ 722 | run in java.lang.Thread
>>
>> Is any further information requested?
>>
>>
>> Greg
>>
>>
>> -----Original Message-----
>> From: Wolfgang Laun [mailto:wolfgang.laun_at_gmail.com]
>> Sent: Wednesday, 9 July 2014 3:17 PM
>> To: users_at_jaxb.java.net
>> Subject: Re: Unable to find a JAXB implementation to delegate.
>>
>> It's important to quote error messages verbatim, as would be the
>> inclusion of a stack dump. It's possible that more information about
>> the configuration would help someone else on the list.
>>
>> -W
>>
>> On 09/07/2014, Greg Pagendam-Turner
>> <greg.pagendam-turner_at_onesteel.com>
>> wrote:
>>> Thanks for your response Wolfgang.
>>>
>>> The error message was actually:
>>> mypackage.pms.OsrJdeRteSvc.ListAllEventsRequest is not known to this
>>> context
>>>
>>> Any other ideas?
>>>
>>> Greg
>>>
>>>
>>> -----Original Message-----
>>> From: Wolfgang Laun [mailto:wolfgang.laun_at_gmail.com]
>>> Sent: Tuesday, 8 July 2014 4:24 PM
>>> To: users_at_jaxb.java.net
>>> Subject: Re: Unable to find a JAXB implementation to delegate.
>>>
>>> I see
>>> mypackage.pms.ListAllEventsRequest
>>> as opposed to
>>> mypackage.pms.OsrJdeRteSvc.ListAllEventsRequest
>>>
>>> -W
>>>
>>>
>>> On 08/07/2014, Greg Pagendam-Turner
>>> <greg.pagendam-turner_at_onesteel.com>
>>> wrote:
>>>> Hi,
>>>>
>>>> I'm using Grails with the CXF plugin to call a web service.
>>>>
>>>> When I make the call I get the error:
>>>>
>>>> Unable to find a JAXB implementation to delegate.
>>>>
>>>> The JAXB source recommends in this situation to contact the JAXB
>>>> users list so here I am.
>>>>
>>>> I was getting the error:
>>>>
>>>> Class not known to this context for class:
>>>> mypackage.pms.ListAllEventsRequest.
>>>>
>>>> So added to the Port class:
>>>>
>>>> @XmlSeeAlso({mypackage.pms.OsrJdeRteSvc.impl.ObjectFactory.class,
>>>> mypackage.pms.OsrJdeRteSvc.ListAllEventsRequest.class})
>>>>
>>>> Please help. What further information might you require to help me
>>>> fix this issue?
>>>>
>>>>
>>>> Greg
>>>>
>>>>
>>>>
>>>>
>>>> The material contained in this email is confidential and may be
>>>> subject to legal privilege and/or copyright. Please do not
>>>> re-transmit, distribute, copy or commercialise any of the material
>>>> in this message unless you are authorised to do so. If you are not
>>>> the intended recipient, use, disclosure or copying of this
>>>> information is prohibited. If you have received this document in
>>>> error, please advise the sender and delete the document. None of
>>>> Arrium Limited, its related bodies corporate or the sender accept
>>>> responsibility for any viruses contained in this email or any
>>>> attachments.
>>>> All and any rights as to confidentiality, legal professional
>>>> privilege and copyright are expressly reserved.
>>>>
>>>
>>>
>>> The material contained in this email is confidential and may be
>>> subject to legal privilege and/or copyright. Please do not
>>> re-transmit, distribute, copy or commercialise any of the material in
>>> this message unless you are authorised to do so. If you are not the
>>> intended recipient, use, disclosure or copying of this information is
>>> prohibited. If you have received this document in error, please
>>> advise the sender and delete the document. None of Arrium Limited,
>>> its related bodies corporate or the sender accept responsibility for
>>> any viruses contained in this email or any attachments.
>>> All and any rights as to confidentiality, legal professional
>>> privilege and copyright are expressly reserved.
>>>
>>
>>
>> The material contained in this email is confidential and may be
>> subject to legal privilege and/or copyright. Please do not
>> re-transmit, distribute, copy or commercialise any of the material in
>> this message unless you are authorised to do so. If you are not the
>> intended recipient, use, disclosure or copying of this information is
>> prohibited. If you have received this document in error, please advise
>> the sender and delete the document. None of Arrium Limited, its
>> related bodies corporate or the sender accept responsibility for any
>> viruses contained in this email or any attachments.
>> All and any rights as to confidentiality, legal professional privilege
>> and copyright are expressly reserved.
>>
>
>
> The material contained in this email is confidential and may be subject to
> legal privilege and/or copyright. Please do not re-transmit, distribute,
> copy or commercialise any of the material in this message unless you are
> authorised to do so. If you are not the intended recipient, use, disclosure
> or copying of this information is prohibited. If you have received this
> document in error, please advise the sender and delete the document. None of
> Arrium Limited, its related bodies corporate or the sender accept
> responsibility for any viruses contained in this email or any attachments.
> All and any rights as to confidentiality, legal professional privilege and
> copyright are expressly reserved.
>