You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@camel.apache.org by "jacob vandergoot (JIRA)" <ji...@apache.org> on 2012/06/11 20:46:42 UTC

[jira] [Created] (CAMEL-5358) camel-castor does not work in apache service mix modules

jacob vandergoot created CAMEL-5358:
---------------------------------------

             Summary: camel-castor does not work in apache service mix modules
                 Key: CAMEL-5358
                 URL: https://issues.apache.org/jira/browse/CAMEL-5358
             Project: Camel
          Issue Type: Bug
          Components: osgi
    Affects Versions: 2.9.2, 2.8.5
         Environment: Apache Service Mix: MacOS, Linux, Windows
            Reporter: jacob vandergoot
             Fix For: 2.8.6, 2.9.3


Sorry for putting this in the wrong component but I did not see a camel-castor component.

By default, the castor org.exolab.castor.mapping.Mapping will use the class's class loader to resolve java classes declared in the castor mapping XML file.  However when the CastorDataFormat is used an a service mix OSGi module, the class loader the contains the Java classes is not the same as the class loader that loads the Mapping object.  Therefore it cannot load the mapping file because the Java classes cannot be resolved.  Instead the constructor that takes Classloader as an argument should be called when initializing the mapping object.  The classloader it should use is the same classloader used to resolve the castor mapping XML file.

The following change in AbstractCastorDataFormat seemed to resolve the problem.

public XMLContext getXmlContext(ClassResolver resolver) throws Exception {
        if (xmlContext == null) {
            xmlContext = new XMLContext();

            if (ObjectHelper.isNotEmpty(getMappingFile())) {
                Mapping xmlMap = new Mapping(
                		Thread.currentThread().getContextClassLoader());
                xmlMap.loadMapping(resolver.loadResourceAsURL(getMappingFile()));
                xmlContext.addMapping(xmlMap);
            }






--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

[jira] [Updated] (CAMEL-5358) camel-castor does not work in apache service mix modules

Posted by "Christian Müller (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/CAMEL-5358?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Christian Müller updated CAMEL-5358:
------------------------------------

    Fix Version/s:     (was: 2.8.6)
                   2.11
                   2.10.1
    
> camel-castor does not work in apache service mix modules
> --------------------------------------------------------
>
>                 Key: CAMEL-5358
>                 URL: https://issues.apache.org/jira/browse/CAMEL-5358
>             Project: Camel
>          Issue Type: Bug
>          Components: osgi
>    Affects Versions: 2.8.5, 2.9.2
>         Environment: Apache Service Mix: MacOS, Linux, Windows
>            Reporter: jacob vandergoot
>            Assignee: Willem Jiang
>             Fix For: 2.9.3, 2.10.1, 2.11
>
>
> Sorry for putting this in the wrong component but I did not see a camel-castor component.
> By default, the castor org.exolab.castor.mapping.Mapping will use the class's class loader to resolve java classes declared in the castor mapping XML file.  However when the CastorDataFormat is used an a service mix OSGi module, the class loader the contains the Java classes is not the same as the class loader that loads the Mapping object.  Therefore it cannot load the mapping file because the Java classes cannot be resolved.  Instead the constructor that takes Classloader as an argument should be called when initializing the mapping object.  The classloader it should use is the same classloader used to resolve the castor mapping XML file.
> The following change in AbstractCastorDataFormat seemed to resolve the problem.
> public XMLContext getXmlContext(ClassResolver resolver) throws Exception {
>         if (xmlContext == null) {
>             xmlContext = new XMLContext();
>             if (ObjectHelper.isNotEmpty(getMappingFile())) {
>                 Mapping xmlMap = new Mapping(
>                 		Thread.currentThread().getContextClassLoader());
>                 xmlMap.loadMapping(resolver.loadResourceAsURL(getMappingFile()));
>                 xmlContext.addMapping(xmlMap);
>             }

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira

       

[jira] [Assigned] (CAMEL-5358) camel-castor does not work in apache service mix modules

Posted by "Willem Jiang (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/CAMEL-5358?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Willem Jiang reassigned CAMEL-5358:
-----------------------------------

    Assignee: Willem Jiang
    
> camel-castor does not work in apache service mix modules
> --------------------------------------------------------
>
>                 Key: CAMEL-5358
>                 URL: https://issues.apache.org/jira/browse/CAMEL-5358
>             Project: Camel
>          Issue Type: Bug
>          Components: osgi
>    Affects Versions: 2.8.5, 2.9.2
>         Environment: Apache Service Mix: MacOS, Linux, Windows
>            Reporter: jacob vandergoot
>            Assignee: Willem Jiang
>             Fix For: 2.8.6, 2.9.3
>
>
> Sorry for putting this in the wrong component but I did not see a camel-castor component.
> By default, the castor org.exolab.castor.mapping.Mapping will use the class's class loader to resolve java classes declared in the castor mapping XML file.  However when the CastorDataFormat is used an a service mix OSGi module, the class loader the contains the Java classes is not the same as the class loader that loads the Mapping object.  Therefore it cannot load the mapping file because the Java classes cannot be resolved.  Instead the constructor that takes Classloader as an argument should be called when initializing the mapping object.  The classloader it should use is the same classloader used to resolve the castor mapping XML file.
> The following change in AbstractCastorDataFormat seemed to resolve the problem.
> public XMLContext getXmlContext(ClassResolver resolver) throws Exception {
>         if (xmlContext == null) {
>             xmlContext = new XMLContext();
>             if (ObjectHelper.isNotEmpty(getMappingFile())) {
>                 Mapping xmlMap = new Mapping(
>                 		Thread.currentThread().getContextClassLoader());
>                 xmlMap.loadMapping(resolver.loadResourceAsURL(getMappingFile()));
>                 xmlContext.addMapping(xmlMap);
>             }

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

[jira] [Commented] (CAMEL-5358) camel-castor does not work in apache service mix modules

Posted by "jacob vandergoot (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/CAMEL-5358?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13293588#comment-13293588 ] 

jacob vandergoot commented on CAMEL-5358:
-----------------------------------------

The code I have included isn't quite right.  Using the Thread.currentThread().getContextClassLoader() may not work if the java objects are defined in a different OSGi bundle then where the data format is declared.
                
> camel-castor does not work in apache service mix modules
> --------------------------------------------------------
>
>                 Key: CAMEL-5358
>                 URL: https://issues.apache.org/jira/browse/CAMEL-5358
>             Project: Camel
>          Issue Type: Bug
>          Components: osgi
>    Affects Versions: 2.8.5, 2.9.2
>         Environment: Apache Service Mix: MacOS, Linux, Windows
>            Reporter: jacob vandergoot
>             Fix For: 2.8.6, 2.9.3
>
>
> Sorry for putting this in the wrong component but I did not see a camel-castor component.
> By default, the castor org.exolab.castor.mapping.Mapping will use the class's class loader to resolve java classes declared in the castor mapping XML file.  However when the CastorDataFormat is used an a service mix OSGi module, the class loader the contains the Java classes is not the same as the class loader that loads the Mapping object.  Therefore it cannot load the mapping file because the Java classes cannot be resolved.  Instead the constructor that takes Classloader as an argument should be called when initializing the mapping object.  The classloader it should use is the same classloader used to resolve the castor mapping XML file.
> The following change in AbstractCastorDataFormat seemed to resolve the problem.
> public XMLContext getXmlContext(ClassResolver resolver) throws Exception {
>         if (xmlContext == null) {
>             xmlContext = new XMLContext();
>             if (ObjectHelper.isNotEmpty(getMappingFile())) {
>                 Mapping xmlMap = new Mapping(
>                 		Thread.currentThread().getContextClassLoader());
>                 xmlMap.loadMapping(resolver.loadResourceAsURL(getMappingFile()));
>                 xmlContext.addMapping(xmlMap);
>             }

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

[jira] [Commented] (CAMEL-5358) camel-castor does not work in apache service mix modules

Posted by "Willem Jiang (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/CAMEL-5358?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13293690#comment-13293690 ] 

Willem Jiang commented on CAMEL-5358:
-------------------------------------

It is a common practice to use the TCCL to handle the issue that you faced, but when you need to load the classes from other bundle, you need to update your application bundle which holds the camel context to import the package which has the class from other bundle.
                
> camel-castor does not work in apache service mix modules
> --------------------------------------------------------
>
>                 Key: CAMEL-5358
>                 URL: https://issues.apache.org/jira/browse/CAMEL-5358
>             Project: Camel
>          Issue Type: Bug
>          Components: osgi
>    Affects Versions: 2.8.5, 2.9.2
>         Environment: Apache Service Mix: MacOS, Linux, Windows
>            Reporter: jacob vandergoot
>            Assignee: Willem Jiang
>             Fix For: 2.8.6, 2.9.3
>
>
> Sorry for putting this in the wrong component but I did not see a camel-castor component.
> By default, the castor org.exolab.castor.mapping.Mapping will use the class's class loader to resolve java classes declared in the castor mapping XML file.  However when the CastorDataFormat is used an a service mix OSGi module, the class loader the contains the Java classes is not the same as the class loader that loads the Mapping object.  Therefore it cannot load the mapping file because the Java classes cannot be resolved.  Instead the constructor that takes Classloader as an argument should be called when initializing the mapping object.  The classloader it should use is the same classloader used to resolve the castor mapping XML file.
> The following change in AbstractCastorDataFormat seemed to resolve the problem.
> public XMLContext getXmlContext(ClassResolver resolver) throws Exception {
>         if (xmlContext == null) {
>             xmlContext = new XMLContext();
>             if (ObjectHelper.isNotEmpty(getMappingFile())) {
>                 Mapping xmlMap = new Mapping(
>                 		Thread.currentThread().getContextClassLoader());
>                 xmlMap.loadMapping(resolver.loadResourceAsURL(getMappingFile()));
>                 xmlContext.addMapping(xmlMap);
>             }

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira