You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@camel.apache.org by "Raul Kripalani (JIRA)" <ji...@apache.org> on 2012/10/20 18:04:12 UTC

[jira] [Created] (CAMEL-5722) Classloader mixup when consumers across bundles share the same camel-jetty port

Raul Kripalani created CAMEL-5722:
-------------------------------------

             Summary: Classloader mixup when consumers across bundles share the same camel-jetty port
                 Key: CAMEL-5722
                 URL: https://issues.apache.org/jira/browse/CAMEL-5722
             Project: Camel
          Issue Type: Bug
          Components: camel-jetty
    Affects Versions: 2.8.0
         Environment: OSGi environment, Karaf 2.2.2.
            Reporter: Raul Kripalani
            Assignee: Raul Kripalani
            Priority: Critical


Happens in an OSGi environment; but it is also applicable in modular servers which builds dynamic classloaders (e.g. JBoss AS) for each deployed artifact (WAR, module, EAR, etc.).

If bundles A and B are both creating camel-jetty consumers on the same TCP port, the consumers will share the underlying Jetty connector. Moreover, the Jetty connector is indeed created by the first consumer that initialises on that TCP port.

Since the Camel route executes on the Jetty Connector thread, all class resolutions will happen against the classloader of the bundle that initialises first.

This makes class resolution absolutely undeterministic and erratic. Quite a nasty bug IMHO.

Perhaps this can be fixed by adding a call to {{Thread.setContextClassLoader()}} passing the classloader of the JettyHttpEndpoint, as soon as a request comes in?

--
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] (CAMEL-5722) Classloader mixup when consumers across bundles share the same camel-jetty port

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

Claus Ibsen commented on CAMEL-5722:
------------------------------------

I guess a generic solution is to let the UnitOfWorkProcessor that is 1st on the route processors, set the TCCL and restore it on done. Then it may be a generic fix for all use-cases
                
> Classloader mixup when consumers across bundles share the same camel-jetty port
> -------------------------------------------------------------------------------
>
>                 Key: CAMEL-5722
>                 URL: https://issues.apache.org/jira/browse/CAMEL-5722
>             Project: Camel
>          Issue Type: Bug
>          Components: camel-jetty
>    Affects Versions: 2.8.0
>         Environment: OSGi environment, Karaf 2.2.2.
>            Reporter: Raul Kripalani
>            Assignee: Raul Kripalani
>            Priority: Critical
>
> Happens in an OSGi environment; but it is also applicable in modular servers that build dynamic classloaders (e.g. JBoss AS) per deployed artifacts (WAR, module, EAR, etc.).
> If bundles A and B are both creating camel-jetty consumers on the same TCP port, the consumers will share the underlying Jetty connector. Moreover, the Jetty connector is indeed created by the first consumer that initialises on that TCP port.
> Since the Camel route executes on the Jetty Connector thread, all class resolutions will happen against the classloader of the bundle that initialises first.
> This makes class resolution absolutely undeterministic and erratic. Quite a nasty bug IMHO.
> Perhaps this can be fixed by adding a call to {{Thread.setContextClassLoader()}} passing the classloader of the JettyHttpEndpoint, as soon as a request comes in?

--
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] (CAMEL-5722) Classloader mixup when consumers across bundles share the same camel-jetty port

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

Raul Kripalani commented on CAMEL-5722:
---------------------------------------

Yep, I committed fixes on r1400729 and r1400734 on 21/10. There was also some discussion on the mailing list regarding other cases to consider.

Claus, that's another solution, but most consumers allow for some custom logic to execute before the route kicks in, e.g. HttpBinding and the like. The UoW processor wouldn't account for those scenarios, or would it?

                
> Classloader mixup when consumers across bundles share the same camel-jetty port
> -------------------------------------------------------------------------------
>
>                 Key: CAMEL-5722
>                 URL: https://issues.apache.org/jira/browse/CAMEL-5722
>             Project: Camel
>          Issue Type: Bug
>          Components: camel-jetty
>    Affects Versions: 2.8.0
>         Environment: OSGi environment, Karaf 2.2.2.
>            Reporter: Raul Kripalani
>            Assignee: Raul Kripalani
>            Priority: Critical
>
> Happens in an OSGi environment; but it is also applicable in modular servers that build dynamic classloaders (e.g. JBoss AS) per deployed artifacts (WAR, module, EAR, etc.).
> If bundles A and B are both creating camel-jetty consumers on the same TCP port, the consumers will share the underlying Jetty connector. Moreover, the Jetty connector is indeed created by the first consumer that initialises on that TCP port.
> Since the Camel route executes on the Jetty Connector thread, all class resolutions will happen against the classloader of the bundle that initialises first.
> This makes class resolution absolutely undeterministic and erratic. Quite a nasty bug IMHO.
> Perhaps this can be fixed by adding a call to {{Thread.setContextClassLoader()}} passing the classloader of the JettyHttpEndpoint, as soon as a request comes in?

--
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] (CAMEL-5722) Classloader mixup when consumers across bundles share the same camel-jetty port

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

Raul Kripalani commented on CAMEL-5722:
---------------------------------------

Yep, filed CAMEL-5748.
                
> Classloader mixup when consumers across bundles share the same camel-jetty port
> -------------------------------------------------------------------------------
>
>                 Key: CAMEL-5722
>                 URL: https://issues.apache.org/jira/browse/CAMEL-5722
>             Project: Camel
>          Issue Type: Bug
>          Components: camel-jetty
>    Affects Versions: 2.8.0
>         Environment: OSGi environment, Karaf 2.2.2.
>            Reporter: Raul Kripalani
>            Assignee: Raul Kripalani
>            Priority: Critical
>
> Happens in an OSGi environment; but it is also applicable in modular servers that build dynamic classloaders (e.g. JBoss AS) per deployed artifacts (WAR, module, EAR, etc.).
> If bundles A and B are both creating camel-jetty consumers on the same TCP port, the consumers will share the underlying Jetty connector. Moreover, the Jetty connector is indeed created by the first consumer that initialises on that TCP port.
> Since the Camel route executes on the Jetty Connector thread, all class resolutions will happen against the classloader of the bundle that initialises first.
> This makes class resolution absolutely undeterministic and erratic. Quite a nasty bug IMHO.
> Perhaps this can be fixed by adding a call to {{Thread.setContextClassLoader()}} passing the classloader of the JettyHttpEndpoint, as soon as a request comes in?

--
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] [Updated] (CAMEL-5722) Classloader mixup when consumers across bundles share the same camel-jetty port

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

Raul Kripalani updated CAMEL-5722:
----------------------------------

    Fix Version/s: 2.11.0
                   2.10.3
                   2.9.5
    
> Classloader mixup when consumers across bundles share the same camel-jetty port
> -------------------------------------------------------------------------------
>
>                 Key: CAMEL-5722
>                 URL: https://issues.apache.org/jira/browse/CAMEL-5722
>             Project: Camel
>          Issue Type: Bug
>          Components: camel-jetty
>    Affects Versions: 2.8.0
>         Environment: OSGi environment, Karaf 2.2.2.
>            Reporter: Raul Kripalani
>            Assignee: Raul Kripalani
>            Priority: Critical
>             Fix For: 2.9.5, 2.10.3, 2.11.0
>
>
> Happens in an OSGi environment; but it is also applicable in modular servers that build dynamic classloaders (e.g. JBoss AS) per deployed artifacts (WAR, module, EAR, etc.).
> If bundles A and B are both creating camel-jetty consumers on the same TCP port, the consumers will share the underlying Jetty connector. Moreover, the Jetty connector is indeed created by the first consumer that initialises on that TCP port.
> Since the Camel route executes on the Jetty Connector thread, all class resolutions will happen against the classloader of the bundle that initialises first.
> This makes class resolution absolutely undeterministic and erratic. Quite a nasty bug IMHO.
> Perhaps this can be fixed by adding a call to {{Thread.setContextClassLoader()}} passing the classloader of the JettyHttpEndpoint, as soon as a request comes in?

--
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] (CAMEL-5722) Classloader mixup when consumers across bundles share the same camel-jetty port

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

Raul Kripalani commented on CAMEL-5722:
---------------------------------------

Thanks a lot for the indications. I have confirmed that setting the TCCL to the classloader from CamelContext.getApplicationContextClassLoader() does the trick.

Since the Jetty consumer is async, I just wondered if we also have to do something special on the AsyncCallbacks?
                
> Classloader mixup when consumers across bundles share the same camel-jetty port
> -------------------------------------------------------------------------------
>
>                 Key: CAMEL-5722
>                 URL: https://issues.apache.org/jira/browse/CAMEL-5722
>             Project: Camel
>          Issue Type: Bug
>          Components: camel-jetty
>    Affects Versions: 2.8.0
>         Environment: OSGi environment, Karaf 2.2.2.
>            Reporter: Raul Kripalani
>            Assignee: Raul Kripalani
>            Priority: Critical
>
> Happens in an OSGi environment; but it is also applicable in modular servers that build dynamic classloaders (e.g. JBoss AS) per deployed artifacts (WAR, module, EAR, etc.).
> If bundles A and B are both creating camel-jetty consumers on the same TCP port, the consumers will share the underlying Jetty connector. Moreover, the Jetty connector is indeed created by the first consumer that initialises on that TCP port.
> Since the Camel route executes on the Jetty Connector thread, all class resolutions will happen against the classloader of the bundle that initialises first.
> This makes class resolution absolutely undeterministic and erratic. Quite a nasty bug IMHO.
> Perhaps this can be fixed by adding a call to {{Thread.setContextClassLoader()}} passing the classloader of the JettyHttpEndpoint, as soon as a request comes in?

--
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] [Work started] (CAMEL-5722) Classloader mixup when consumers across bundles share the same camel-jetty port

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

Work on CAMEL-5722 started by Raul Kripalani.

> Classloader mixup when consumers across bundles share the same camel-jetty port
> -------------------------------------------------------------------------------
>
>                 Key: CAMEL-5722
>                 URL: https://issues.apache.org/jira/browse/CAMEL-5722
>             Project: Camel
>          Issue Type: Bug
>          Components: camel-jetty
>    Affects Versions: 2.8.0
>         Environment: OSGi environment, Karaf 2.2.2.
>            Reporter: Raul Kripalani
>            Assignee: Raul Kripalani
>            Priority: Critical
>
> Happens in an OSGi environment; but it is also applicable in modular servers that build dynamic classloaders (e.g. JBoss AS) per deployed artifacts (WAR, module, EAR, etc.).
> If bundles A and B are both creating camel-jetty consumers on the same TCP port, the consumers will share the underlying Jetty connector. Moreover, the Jetty connector is indeed created by the first consumer that initialises on that TCP port.
> Since the Camel route executes on the Jetty Connector thread, all class resolutions will happen against the classloader of the bundle that initialises first.
> This makes class resolution absolutely undeterministic and erratic. Quite a nasty bug IMHO.
> Perhaps this can be fixed by adding a call to {{Thread.setContextClassLoader()}} passing the classloader of the JettyHttpEndpoint, as soon as a request comes in?

--
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] (CAMEL-5722) Classloader mixup when consumers across bundles share the same camel-jetty port

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

Raul Kripalani commented on CAMEL-5722:
---------------------------------------

I think this can also be a problem in the Direct VM component, if a new Exchange is not created at the consumer side... I'll check.
                
> Classloader mixup when consumers across bundles share the same camel-jetty port
> -------------------------------------------------------------------------------
>
>                 Key: CAMEL-5722
>                 URL: https://issues.apache.org/jira/browse/CAMEL-5722
>             Project: Camel
>          Issue Type: Bug
>          Components: camel-jetty
>    Affects Versions: 2.8.0
>         Environment: OSGi environment, Karaf 2.2.2.
>            Reporter: Raul Kripalani
>            Assignee: Raul Kripalani
>            Priority: Critical
>
> Happens in an OSGi environment; but it is also applicable in modular servers that build dynamic classloaders (e.g. JBoss AS) per deployed artifacts (WAR, module, EAR, etc.).
> If bundles A and B are both creating camel-jetty consumers on the same TCP port, the consumers will share the underlying Jetty connector. Moreover, the Jetty connector is indeed created by the first consumer that initialises on that TCP port.
> Since the Camel route executes on the Jetty Connector thread, all class resolutions will happen against the classloader of the bundle that initialises first.
> This makes class resolution absolutely undeterministic and erratic. Quite a nasty bug IMHO.
> Perhaps this can be fixed by adding a call to {{Thread.setContextClassLoader()}} passing the classloader of the JettyHttpEndpoint, as soon as a request comes in?

--
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] [Updated] (CAMEL-5722) Classloader mixup when consumers across bundles share the same camel-jetty port

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

Raul Kripalani updated CAMEL-5722:
----------------------------------

    Description: 
Happens in an OSGi environment; but it is also applicable in modular servers that build dynamic classloaders (e.g. JBoss AS) per deployed artifacts (WAR, module, EAR, etc.).

If bundles A and B are both creating camel-jetty consumers on the same TCP port, the consumers will share the underlying Jetty connector. Moreover, the Jetty connector is indeed created by the first consumer that initialises on that TCP port.

Since the Camel route executes on the Jetty Connector thread, all class resolutions will happen against the classloader of the bundle that initialises first.

This makes class resolution absolutely undeterministic and erratic. Quite a nasty bug IMHO.

Perhaps this can be fixed by adding a call to {{Thread.setContextClassLoader()}} passing the classloader of the JettyHttpEndpoint, as soon as a request comes in?

  was:
Happens in an OSGi environment; but it is also applicable in modular servers which builds dynamic classloaders (e.g. JBoss AS) for each deployed artifact (WAR, module, EAR, etc.).

If bundles A and B are both creating camel-jetty consumers on the same TCP port, the consumers will share the underlying Jetty connector. Moreover, the Jetty connector is indeed created by the first consumer that initialises on that TCP port.

Since the Camel route executes on the Jetty Connector thread, all class resolutions will happen against the classloader of the bundle that initialises first.

This makes class resolution absolutely undeterministic and erratic. Quite a nasty bug IMHO.

Perhaps this can be fixed by adding a call to {{Thread.setContextClassLoader()}} passing the classloader of the JettyHttpEndpoint, as soon as a request comes in?

    
> Classloader mixup when consumers across bundles share the same camel-jetty port
> -------------------------------------------------------------------------------
>
>                 Key: CAMEL-5722
>                 URL: https://issues.apache.org/jira/browse/CAMEL-5722
>             Project: Camel
>          Issue Type: Bug
>          Components: camel-jetty
>    Affects Versions: 2.8.0
>         Environment: OSGi environment, Karaf 2.2.2.
>            Reporter: Raul Kripalani
>            Assignee: Raul Kripalani
>            Priority: Critical
>
> Happens in an OSGi environment; but it is also applicable in modular servers that build dynamic classloaders (e.g. JBoss AS) per deployed artifacts (WAR, module, EAR, etc.).
> If bundles A and B are both creating camel-jetty consumers on the same TCP port, the consumers will share the underlying Jetty connector. Moreover, the Jetty connector is indeed created by the first consumer that initialises on that TCP port.
> Since the Camel route executes on the Jetty Connector thread, all class resolutions will happen against the classloader of the bundle that initialises first.
> This makes class resolution absolutely undeterministic and erratic. Quite a nasty bug IMHO.
> Perhaps this can be fixed by adding a call to {{Thread.setContextClassLoader()}} passing the classloader of the JettyHttpEndpoint, as soon as a request comes in?

--
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] (CAMEL-5722) Classloader mixup when consumers across bundles share the same camel-jetty port

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

Raul Kripalani commented on CAMEL-5722:
---------------------------------------

Have only been able to test in Camel 2.8.0. Will test on a later release and provide feedback.
                
> Classloader mixup when consumers across bundles share the same camel-jetty port
> -------------------------------------------------------------------------------
>
>                 Key: CAMEL-5722
>                 URL: https://issues.apache.org/jira/browse/CAMEL-5722
>             Project: Camel
>          Issue Type: Bug
>          Components: camel-jetty
>    Affects Versions: 2.8.0
>         Environment: OSGi environment, Karaf 2.2.2.
>            Reporter: Raul Kripalani
>            Assignee: Raul Kripalani
>            Priority: Critical
>
> Happens in an OSGi environment; but it is also applicable in modular servers which builds dynamic classloaders (e.g. JBoss AS) for each deployed artifact (WAR, module, EAR, etc.).
> If bundles A and B are both creating camel-jetty consumers on the same TCP port, the consumers will share the underlying Jetty connector. Moreover, the Jetty connector is indeed created by the first consumer that initialises on that TCP port.
> Since the Camel route executes on the Jetty Connector thread, all class resolutions will happen against the classloader of the bundle that initialises first.
> This makes class resolution absolutely undeterministic and erratic. Quite a nasty bug IMHO.
> Perhaps this can be fixed by adding a call to {{Thread.setContextClassLoader()}} passing the classloader of the JettyHttpEndpoint, as soon as a request comes in?

--
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] (CAMEL-5722) Classloader mixup when consumers across bundles share the same camel-jetty port

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

Claus Ibsen commented on CAMEL-5722:
------------------------------------

Any update on this issue?
                
> Classloader mixup when consumers across bundles share the same camel-jetty port
> -------------------------------------------------------------------------------
>
>                 Key: CAMEL-5722
>                 URL: https://issues.apache.org/jira/browse/CAMEL-5722
>             Project: Camel
>          Issue Type: Bug
>          Components: camel-jetty
>    Affects Versions: 2.8.0
>         Environment: OSGi environment, Karaf 2.2.2.
>            Reporter: Raul Kripalani
>            Assignee: Raul Kripalani
>            Priority: Critical
>
> Happens in an OSGi environment; but it is also applicable in modular servers that build dynamic classloaders (e.g. JBoss AS) per deployed artifacts (WAR, module, EAR, etc.).
> If bundles A and B are both creating camel-jetty consumers on the same TCP port, the consumers will share the underlying Jetty connector. Moreover, the Jetty connector is indeed created by the first consumer that initialises on that TCP port.
> Since the Camel route executes on the Jetty Connector thread, all class resolutions will happen against the classloader of the bundle that initialises first.
> This makes class resolution absolutely undeterministic and erratic. Quite a nasty bug IMHO.
> Perhaps this can be fixed by adding a call to {{Thread.setContextClassLoader()}} passing the classloader of the JettyHttpEndpoint, as soon as a request comes in?

--
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] (CAMEL-5722) Classloader mixup when consumers across bundles share the same camel-jetty port

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

Raul Kripalani commented on CAMEL-5722:
---------------------------------------

Working on a fix. So far I have an itest-osgi that reproduces the issue.
                
> Classloader mixup when consumers across bundles share the same camel-jetty port
> -------------------------------------------------------------------------------
>
>                 Key: CAMEL-5722
>                 URL: https://issues.apache.org/jira/browse/CAMEL-5722
>             Project: Camel
>          Issue Type: Bug
>          Components: camel-jetty
>    Affects Versions: 2.8.0
>         Environment: OSGi environment, Karaf 2.2.2.
>            Reporter: Raul Kripalani
>            Assignee: Raul Kripalani
>            Priority: Critical
>
> Happens in an OSGi environment; but it is also applicable in modular servers that build dynamic classloaders (e.g. JBoss AS) per deployed artifacts (WAR, module, EAR, etc.).
> If bundles A and B are both creating camel-jetty consumers on the same TCP port, the consumers will share the underlying Jetty connector. Moreover, the Jetty connector is indeed created by the first consumer that initialises on that TCP port.
> Since the Camel route executes on the Jetty Connector thread, all class resolutions will happen against the classloader of the bundle that initialises first.
> This makes class resolution absolutely undeterministic and erratic. Quite a nasty bug IMHO.
> Perhaps this can be fixed by adding a call to {{Thread.setContextClassLoader()}} passing the classloader of the JettyHttpEndpoint, as soon as a request comes in?

--
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] [Closed] (CAMEL-5722) Classloader mixup when consumers across bundles share the same camel-jetty port

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

Raul Kripalani closed CAMEL-5722.
---------------------------------

    Resolution: Fixed
    
> Classloader mixup when consumers across bundles share the same camel-jetty port
> -------------------------------------------------------------------------------
>
>                 Key: CAMEL-5722
>                 URL: https://issues.apache.org/jira/browse/CAMEL-5722
>             Project: Camel
>          Issue Type: Bug
>          Components: camel-jetty
>    Affects Versions: 2.8.0
>         Environment: OSGi environment, Karaf 2.2.2.
>            Reporter: Raul Kripalani
>            Assignee: Raul Kripalani
>            Priority: Critical
>             Fix For: 2.9.5, 2.10.3, 2.11.0
>
>
> Happens in an OSGi environment; but it is also applicable in modular servers that build dynamic classloaders (e.g. JBoss AS) per deployed artifacts (WAR, module, EAR, etc.).
> If bundles A and B are both creating camel-jetty consumers on the same TCP port, the consumers will share the underlying Jetty connector. Moreover, the Jetty connector is indeed created by the first consumer that initialises on that TCP port.
> Since the Camel route executes on the Jetty Connector thread, all class resolutions will happen against the classloader of the bundle that initialises first.
> This makes class resolution absolutely undeterministic and erratic. Quite a nasty bug IMHO.
> Perhaps this can be fixed by adding a call to {{Thread.setContextClassLoader()}} passing the classloader of the JettyHttpEndpoint, as soon as a request comes in?

--
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] (CAMEL-5722) Classloader mixup when consumers across bundles share the same camel-jetty port

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

Willem Jiang commented on CAMEL-5722:
-------------------------------------

We have faced the same issue in camel-jaxb, to resolve it we put the bundle class loader as application class laoder into the bus and it can be get by the CXF run time, so the TCCL can be set with the application class loader whenever the camel need. 
@Raul, to resolve the issue that you faced, you can use the CamelContext.getApplicationContxt() to set the TCCL on the CamelContinuationServlet.
                
> Classloader mixup when consumers across bundles share the same camel-jetty port
> -------------------------------------------------------------------------------
>
>                 Key: CAMEL-5722
>                 URL: https://issues.apache.org/jira/browse/CAMEL-5722
>             Project: Camel
>          Issue Type: Bug
>          Components: camel-jetty
>    Affects Versions: 2.8.0
>         Environment: OSGi environment, Karaf 2.2.2.
>            Reporter: Raul Kripalani
>            Assignee: Raul Kripalani
>            Priority: Critical
>
> Happens in an OSGi environment; but it is also applicable in modular servers that build dynamic classloaders (e.g. JBoss AS) per deployed artifacts (WAR, module, EAR, etc.).
> If bundles A and B are both creating camel-jetty consumers on the same TCP port, the consumers will share the underlying Jetty connector. Moreover, the Jetty connector is indeed created by the first consumer that initialises on that TCP port.
> Since the Camel route executes on the Jetty Connector thread, all class resolutions will happen against the classloader of the bundle that initialises first.
> This makes class resolution absolutely undeterministic and erratic. Quite a nasty bug IMHO.
> Perhaps this can be fixed by adding a call to {{Thread.setContextClassLoader()}} passing the classloader of the JettyHttpEndpoint, as soon as a request comes in?

--
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