You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@cxf.apache.org by "Shaun Montgomery (JIRA)" <ji...@apache.org> on 2012/11/09 19:02:12 UTC

[jira] [Created] (CXF-4626) JAXB Marshalling error class not known to this context

Shaun Montgomery created CXF-4626:
-------------------------------------

             Summary: JAXB Marshalling error class not known to this context
                 Key: CXF-4626
                 URL: https://issues.apache.org/jira/browse/CXF-4626
             Project: CXF
          Issue Type: Bug
          Components: JAXB Databinding
    Affects Versions: 2.5.4
         Environment: Windows 7, Netbeans 7.1.2, 
            Reporter: Shaun Montgomery


I am trying to update a web service client and change it from using pregenerated classes using wsdl2java to dynamically loading the wsdl and creating the client.  The application needs to dynamically load the request and response structures and uses java reflection to display the contents of the response.  I use the following code to create the dynamic client:

            JaxWsDynamicClientFactory dcf = JaxWsDynamicClientFactory.newInstance();
            Logger.getLogger(AXAddressService.class.getName()).log(Level.INFO,"Dynamically loading wsdl from " + theWsdlLocation);
            ClassLoader clBefore = Thread.currentThread().getContextClassLoader();
            dynClient = dcf.createClient(theWsdlLocation, bindingFileList);
            if (dynClient == null) {
                Logger.getLogger(AXAddressService.class.getName()).log(Level.SEVERE,"dynClient creation not successful");
            } else {
                Logger.getLogger(AXAddressService.class.getName()).log(Level.INFO,"Successful creation of service client from wsdl at " + theWsdlLocation);
            }
            
            Bus bus = ((EndpointImpl) dynClient.getEndpoint()).getBus();   
            PolicyInterceptorProviderRegistry pipr = bus.getExtension(PolicyInterceptorProviderRegistry.class);   
            pipr.register(new XRMAuthPolicyProvider());
            
            http = (HTTPConduit) dynClient.getConduit();
// ************************            
            HTTPClientPolicy httpClientPolicy = new HTTPClientPolicy();
            httpClientPolicy.setConnectionTimeout(36000);
            httpClientPolicy.setAllowChunking(false);
            http.setClient(httpClientPolicy);

I then use the following code to invoke the read method on the service:

            Class asrReqClass = Class.forName("com.microsoft.schemas.dynamics._2008._01.services.AddressServiceReadRequest");
            Object asrReq = asrReqClass.newInstance();
            EntityKeyList ekl = CreateEntityKeyList(keys);
            
            Method setEntityKeyListMethod = asrReq.getClass().getMethod("setEntityKeyList", EntityKeyList.class);
            setEntityKeyListMethod.invoke(asrReq, ekl);
            
            Object [] asrRespObjs = dynClient.invoke("read", asrReq);

I have also tried to use the context loader to load the asrReq class.
If I add code to create a JAXBContext, I am able to marshall the asrReq class correctly.

The Exception I am getting is:

Nov 9, 2012 9:58:06 AM org.apache.cxf.phase.PhaseInterceptorChain doDefaultLogging
WARNING: Interceptor for {http://schemas.microsoft.com/dynamics/2008/01/services}AddressService#{http://schemas.microsoft.com/dynamics/2008/01/services}read has thrown exception, unwinding now
org.apache.cxf.interceptor.Fault: Marshalling Error: com.microsoft.schemas.dynamics._2008._01.services.AddressServiceReadRequest is not known to this context
	at org.apache.cxf.jaxb.JAXBEncoderDecoder.marshall(JAXBEncoderDecoder.java:261)
	at org.apache.cxf.jaxb.io.DataWriterImpl.write(DataWriterImpl.java:169)
...

I would really appreciate some help with this.  I've already spent too much time trying to figure it out and a solution is critical.

Thanks in advance.

Shaun



--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira

[jira] [Commented] (CXF-4626) JAXB Marshalling error class not known to this context

Posted by "Daniel Kulp (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/CXF-4626?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13494348#comment-13494348 ] 

Daniel Kulp commented on CXF-4626:
----------------------------------


A testcase for this would be super helpful.  Most likely you have some classes that were generated from the schema already on the classpath that is causing some sort of conflict.   The fact that you have:

Method setEntityKeyListMethod = asrReq.getClass().getMethod("setEntityKeyList", EntityKeyList.class);

seems to indicate that as you are referencing the EntityKeyList class directly.   
                
> JAXB Marshalling error class not known to this context
> ------------------------------------------------------
>
>                 Key: CXF-4626
>                 URL: https://issues.apache.org/jira/browse/CXF-4626
>             Project: CXF
>          Issue Type: Bug
>          Components: JAXB Databinding
>    Affects Versions: 2.5.4
>         Environment: Windows 7, Netbeans 7.1.2, 
>            Reporter: Shaun Montgomery
>
> I am trying to update a web service client and change it from using pregenerated classes using wsdl2java to dynamically loading the wsdl and creating the client.  The application needs to dynamically load the request and response structures and uses java reflection to display the contents of the response.  I use the following code to create the dynamic client:
>             JaxWsDynamicClientFactory dcf = JaxWsDynamicClientFactory.newInstance();
>             Logger.getLogger(AXAddressService.class.getName()).log(Level.INFO,"Dynamically loading wsdl from " + theWsdlLocation);
>             ClassLoader clBefore = Thread.currentThread().getContextClassLoader();
>             dynClient = dcf.createClient(theWsdlLocation, bindingFileList);
>             if (dynClient == null) {
>                 Logger.getLogger(AXAddressService.class.getName()).log(Level.SEVERE,"dynClient creation not successful");
>             } else {
>                 Logger.getLogger(AXAddressService.class.getName()).log(Level.INFO,"Successful creation of service client from wsdl at " + theWsdlLocation);
>             }
>             
>             Bus bus = ((EndpointImpl) dynClient.getEndpoint()).getBus();   
>             PolicyInterceptorProviderRegistry pipr = bus.getExtension(PolicyInterceptorProviderRegistry.class);   
>             pipr.register(new XRMAuthPolicyProvider());
>             
>             http = (HTTPConduit) dynClient.getConduit();
> // ************************            
>             HTTPClientPolicy httpClientPolicy = new HTTPClientPolicy();
>             httpClientPolicy.setConnectionTimeout(36000);
>             httpClientPolicy.setAllowChunking(false);
>             http.setClient(httpClientPolicy);
> I then use the following code to invoke the read method on the service:
>             Class asrReqClass = Class.forName("com.microsoft.schemas.dynamics._2008._01.services.AddressServiceReadRequest");
>             Object asrReq = asrReqClass.newInstance();
>             EntityKeyList ekl = CreateEntityKeyList(keys);
>             
>             Method setEntityKeyListMethod = asrReq.getClass().getMethod("setEntityKeyList", EntityKeyList.class);
>             setEntityKeyListMethod.invoke(asrReq, ekl);
>             
>             Object [] asrRespObjs = dynClient.invoke("read", asrReq);
> I have also tried to use the context loader to load the asrReq class.
> If I add code to create a JAXBContext, I am able to marshall the asrReq class correctly.
> The Exception I am getting is:
> Nov 9, 2012 9:58:06 AM org.apache.cxf.phase.PhaseInterceptorChain doDefaultLogging
> WARNING: Interceptor for {http://schemas.microsoft.com/dynamics/2008/01/services}AddressService#{http://schemas.microsoft.com/dynamics/2008/01/services}read has thrown exception, unwinding now
> org.apache.cxf.interceptor.Fault: Marshalling Error: com.microsoft.schemas.dynamics._2008._01.services.AddressServiceReadRequest is not known to this context
> 	at org.apache.cxf.jaxb.JAXBEncoderDecoder.marshall(JAXBEncoderDecoder.java:261)
> 	at org.apache.cxf.jaxb.io.DataWriterImpl.write(DataWriterImpl.java:169)
> ...
> I would really appreciate some help with this.  I've already spent too much time trying to figure it out and a solution is critical.
> Thanks in advance.
> Shaun

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira