You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@cxf.apache.org by "Chaitanya Choleti (JIRA)" <ji...@apache.org> on 2009/03/04 15:43:56 UTC

[jira] Created: (CXF-2085) Applications classloader should be set during method invocations.

Applications classloader should be set during method invocations.
-----------------------------------------------------------------

                 Key: CXF-2085
                 URL: https://issues.apache.org/jira/browse/CXF-2085
             Project: CXF
          Issue Type: Bug
    Affects Versions: 2.2
            Reporter: Chaitanya Choleti
             Fix For: 2.2


Invocation of a JAX-RS method may depend on some application classes which may not be loaded already, they will be loaded during invocation. But during invocation the classloader will be CXF war application classloader, this will lead to NoClassDefFoundErrors. To avoid this root resource class' classloader should be set on the current thread.
Similar fix should be applied to provider methods such as readFrom, writeTo etc.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Updated: (CXF-2085) Applications classloader should be set during method invocations.

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

Chaitanya Choleti updated CXF-2085:
-----------------------------------

    Attachment: sources.zip

> Applications classloader should be set during method invocations.
> -----------------------------------------------------------------
>
>                 Key: CXF-2085
>                 URL: https://issues.apache.org/jira/browse/CXF-2085
>             Project: CXF
>          Issue Type: Bug
>    Affects Versions: 2.2
>            Reporter: Chaitanya Choleti
>             Fix For: 2.2
>
>         Attachments: cl_test.war, sources.zip
>
>
> Invocation of a JAX-RS method may depend on some application classes which may not be loaded already, they will be loaded during invocation. But during invocation the classloader will be CXF war application classloader, this will lead to NoClassDefFoundErrors. To avoid this root resource class' classloader should be set on the current thread.
> Similar fix should be applied to provider methods such as readFrom, writeTo etc.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Commented: (CXF-2085) Applications classloader should be set during method invocations.

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

Sergey Beryozkin commented on CXF-2085:
---------------------------------------

thanks - so if you expect the context loader be equal to that of the resource class (HelloClass in your example) loader, then why would not you do

HelloService.class.getClassLoader(), when loading the properties ?

> Applications classloader should be set during method invocations.
> -----------------------------------------------------------------
>
>                 Key: CXF-2085
>                 URL: https://issues.apache.org/jira/browse/CXF-2085
>             Project: CXF
>          Issue Type: Bug
>    Affects Versions: 2.2
>            Reporter: Chaitanya Choleti
>             Fix For: 2.2
>
>         Attachments: cl_test.war, sources.zip
>
>
> Invocation of a JAX-RS method may depend on some application classes which may not be loaded already, they will be loaded during invocation. But during invocation the classloader will be CXF war application classloader, this will lead to NoClassDefFoundErrors. To avoid this root resource class' classloader should be set on the current thread.
> Similar fix should be applied to provider methods such as readFrom, writeTo etc.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Resolved: (CXF-2085) Applications classloader should be set during method invocations.

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

Sergey Beryozkin resolved CXF-2085.
-----------------------------------

    Resolution: Fixed

> Applications classloader should be set during method invocations.
> -----------------------------------------------------------------
>
>                 Key: CXF-2085
>                 URL: https://issues.apache.org/jira/browse/CXF-2085
>             Project: CXF
>          Issue Type: Bug
>    Affects Versions: 2.2
>            Reporter: Chaitanya Choleti
>            Assignee: Sergey Beryozkin
>             Fix For: 2.2
>
>         Attachments: cl_test.war, new_cl_test.war, new_sources.zip, sources.zip
>
>
> Invocation of a JAX-RS method may depend on some application classes which may not be loaded already, they will be loaded during invocation. But during invocation the classloader will be CXF war application classloader, this will lead to NoClassDefFoundErrors. To avoid this root resource class' classloader should be set on the current thread.
> Similar fix should be applied to provider methods such as readFrom, writeTo etc.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Commented: (CXF-2085) Applications classloader should be set during method invocations.

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

Sergey Beryozkin commented on CXF-2085:
---------------------------------------

So why don't we use User.class.getClassLoader() in this case ? it will be the same loader which loaded the class which tries to load User, either HelloService or ByeService ?


> Applications classloader should be set during method invocations.
> -----------------------------------------------------------------
>
>                 Key: CXF-2085
>                 URL: https://issues.apache.org/jira/browse/CXF-2085
>             Project: CXF
>          Issue Type: Bug
>    Affects Versions: 2.2
>            Reporter: Chaitanya Choleti
>             Fix For: 2.2
>
>         Attachments: cl_test.war, new_cl_test.war, new_sources.zip, sources.zip
>
>
> Invocation of a JAX-RS method may depend on some application classes which may not be loaded already, they will be loaded during invocation. But during invocation the classloader will be CXF war application classloader, this will lead to NoClassDefFoundErrors. To avoid this root resource class' classloader should be set on the current thread.
> Similar fix should be applied to provider methods such as readFrom, writeTo etc.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Commented: (CXF-2085) Applications classloader should be set during method invocations.

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

Chaitanya Choleti commented on CXF-2085:
----------------------------------------

You are right, we can use User.class.getClassLoader() , but the application developer need not know how CXF works and may use Thread.currentThread().getContextClassLoader() . But I guess that is not your problem.

Thanks for the help.

> Applications classloader should be set during method invocations.
> -----------------------------------------------------------------
>
>                 Key: CXF-2085
>                 URL: https://issues.apache.org/jira/browse/CXF-2085
>             Project: CXF
>          Issue Type: Bug
>    Affects Versions: 2.2
>            Reporter: Chaitanya Choleti
>             Fix For: 2.2
>
>         Attachments: cl_test.war, new_cl_test.war, new_sources.zip, sources.zip
>
>
> Invocation of a JAX-RS method may depend on some application classes which may not be loaded already, they will be loaded during invocation. But during invocation the classloader will be CXF war application classloader, this will lead to NoClassDefFoundErrors. To avoid this root resource class' classloader should be set on the current thread.
> Similar fix should be applied to provider methods such as readFrom, writeTo etc.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Updated: (CXF-2085) Applications classloader should be set during method invocations.

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

Chaitanya Choleti updated CXF-2085:
-----------------------------------

    Attachment: cl_test.war

> Applications classloader should be set during method invocations.
> -----------------------------------------------------------------
>
>                 Key: CXF-2085
>                 URL: https://issues.apache.org/jira/browse/CXF-2085
>             Project: CXF
>          Issue Type: Bug
>    Affects Versions: 2.2
>            Reporter: Chaitanya Choleti
>             Fix For: 2.2
>
>         Attachments: cl_test.war
>
>
> Invocation of a JAX-RS method may depend on some application classes which may not be loaded already, they will be loaded during invocation. But during invocation the classloader will be CXF war application classloader, this will lead to NoClassDefFoundErrors. To avoid this root resource class' classloader should be set on the current thread.
> Similar fix should be applied to provider methods such as readFrom, writeTo etc.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Updated: (CXF-2085) Applications classloader should be set during method invocations.

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

Chaitanya Choleti updated CXF-2085:
-----------------------------------

    Attachment: new_cl_test.war

> Applications classloader should be set during method invocations.
> -----------------------------------------------------------------
>
>                 Key: CXF-2085
>                 URL: https://issues.apache.org/jira/browse/CXF-2085
>             Project: CXF
>          Issue Type: Bug
>    Affects Versions: 2.2
>            Reporter: Chaitanya Choleti
>             Fix For: 2.2
>
>         Attachments: cl_test.war, new_cl_test.war, new_sources.zip, sources.zip
>
>
> Invocation of a JAX-RS method may depend on some application classes which may not be loaded already, they will be loaded during invocation. But during invocation the classloader will be CXF war application classloader, this will lead to NoClassDefFoundErrors. To avoid this root resource class' classloader should be set on the current thread.
> Similar fix should be applied to provider methods such as readFrom, writeTo etc.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Commented: (CXF-2085) Applications classloader should be set during method invocations.

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

Chaitanya Choleti commented on CXF-2085:
----------------------------------------

I am sorry. I was not clear enough last time. I hope this example explains why i want to use Thread.currentThread().getContextClassLoader() instead of HelloService.class.getClassLoader().

use the request urls :          new_cl_test/helloservice/hello and new_cl_test/byeservice/bye

Thank you for shuch a prompt response.

> Applications classloader should be set during method invocations.
> -----------------------------------------------------------------
>
>                 Key: CXF-2085
>                 URL: https://issues.apache.org/jira/browse/CXF-2085
>             Project: CXF
>          Issue Type: Bug
>    Affects Versions: 2.2
>            Reporter: Chaitanya Choleti
>             Fix For: 2.2
>
>         Attachments: cl_test.war, new_cl_test.war, new_sources.zip, sources.zip
>
>
> Invocation of a JAX-RS method may depend on some application classes which may not be loaded already, they will be loaded during invocation. But during invocation the classloader will be CXF war application classloader, this will lead to NoClassDefFoundErrors. To avoid this root resource class' classloader should be set on the current thread.
> Similar fix should be applied to provider methods such as readFrom, writeTo etc.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Assigned: (CXF-2085) Applications classloader should be set during method invocations.

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

Sergey Beryozkin reassigned CXF-2085:
-------------------------------------

    Assignee: Sergey Beryozkin

> Applications classloader should be set during method invocations.
> -----------------------------------------------------------------
>
>                 Key: CXF-2085
>                 URL: https://issues.apache.org/jira/browse/CXF-2085
>             Project: CXF
>          Issue Type: Bug
>    Affects Versions: 2.2
>            Reporter: Chaitanya Choleti
>            Assignee: Sergey Beryozkin
>             Fix For: 2.2
>
>         Attachments: cl_test.war, new_cl_test.war, new_sources.zip, sources.zip
>
>
> Invocation of a JAX-RS method may depend on some application classes which may not be loaded already, they will be loaded during invocation. But during invocation the classloader will be CXF war application classloader, this will lead to NoClassDefFoundErrors. To avoid this root resource class' classloader should be set on the current thread.
> Similar fix should be applied to provider methods such as readFrom, writeTo etc.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Commented: (CXF-2085) Applications classloader should be set during method invocations.

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

Sergey Beryozkin commented on CXF-2085:
---------------------------------------

Hi

Can you provide some simple test case please ? I'm not sure I understand. If a class lazily loaded when one of the resource class methods is being invoked then the resource class loader will be used to load the class first... 

 

> Applications classloader should be set during method invocations.
> -----------------------------------------------------------------
>
>                 Key: CXF-2085
>                 URL: https://issues.apache.org/jira/browse/CXF-2085
>             Project: CXF
>          Issue Type: Bug
>    Affects Versions: 2.2
>            Reporter: Chaitanya Choleti
>             Fix For: 2.2
>
>
> Invocation of a JAX-RS method may depend on some application classes which may not be loaded already, they will be loaded during invocation. But during invocation the classloader will be CXF war application classloader, this will lead to NoClassDefFoundErrors. To avoid this root resource class' classloader should be set on the current thread.
> Similar fix should be applied to provider methods such as readFrom, writeTo etc.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Commented: (CXF-2085) Applications classloader should be set during method invocations.

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

Sergey Beryozkin commented on CXF-2085:
---------------------------------------

Hi - my problem is to make sure things work well for a user :-)
Would you agree that by doing Thread.currentThread().getContextClassLoader() a user code  actually becomes more aware of how things work under the hood ? IMHO, User.class.getClassLoader() is more neutral and is likely to work better, especially given that you do expect the loader of User class (which is the same loader which loaded Hello/Bye service class) be equal to Thread.currentThread().getContextClassLoader().

Dan, others - any comments ? I've not seen JAXWSInvoker setting a Thread.currentThread().getContextClassLoader() to that of the class to be invoked...



> Applications classloader should be set during method invocations.
> -----------------------------------------------------------------
>
>                 Key: CXF-2085
>                 URL: https://issues.apache.org/jira/browse/CXF-2085
>             Project: CXF
>          Issue Type: Bug
>    Affects Versions: 2.2
>            Reporter: Chaitanya Choleti
>             Fix For: 2.2
>
>         Attachments: cl_test.war, new_cl_test.war, new_sources.zip, sources.zip
>
>
> Invocation of a JAX-RS method may depend on some application classes which may not be loaded already, they will be loaded during invocation. But during invocation the classloader will be CXF war application classloader, this will lead to NoClassDefFoundErrors. To avoid this root resource class' classloader should be set on the current thread.
> Similar fix should be applied to provider methods such as readFrom, writeTo etc.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Commented: (CXF-2085) Applications classloader should be set during method invocations.

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

Sergey Beryozkin commented on CXF-2085:
---------------------------------------

It's an interesting comment which made me think that equally there could be an application code there depending on whatever xml parser provided by the container environment.
That said I've decided to introduce a property, which, if set, will lead to a thread context loader set to that of the resource class loader,
name of the property is "org.apache.cxf.serviceloader-context", I could not think of a shorter/better name

can be set up like this :

<jaxrs:server address="/">
    <jaxrs:properties>
       <entry key="org.apache.cxf.serviceloader-context" value="true"/>
    </jaxrs:properties>
  </jaxrs:server> 

I think it's a reasonable compromise

> Applications classloader should be set during method invocations.
> -----------------------------------------------------------------
>
>                 Key: CXF-2085
>                 URL: https://issues.apache.org/jira/browse/CXF-2085
>             Project: CXF
>          Issue Type: Bug
>    Affects Versions: 2.2
>            Reporter: Chaitanya Choleti
>            Assignee: Sergey Beryozkin
>             Fix For: 2.2
>
>         Attachments: cl_test.war, new_cl_test.war, new_sources.zip, sources.zip
>
>
> Invocation of a JAX-RS method may depend on some application classes which may not be loaded already, they will be loaded during invocation. But during invocation the classloader will be CXF war application classloader, this will lead to NoClassDefFoundErrors. To avoid this root resource class' classloader should be set on the current thread.
> Similar fix should be applied to provider methods such as readFrom, writeTo etc.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Updated: (CXF-2085) Applications classloader should be set during method invocations.

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

Chaitanya Choleti updated CXF-2085:
-----------------------------------

    Attachment: new_sources.zip

> Applications classloader should be set during method invocations.
> -----------------------------------------------------------------
>
>                 Key: CXF-2085
>                 URL: https://issues.apache.org/jira/browse/CXF-2085
>             Project: CXF
>          Issue Type: Bug
>    Affects Versions: 2.2
>            Reporter: Chaitanya Choleti
>             Fix For: 2.2
>
>         Attachments: cl_test.war, new_cl_test.war, new_sources.zip, sources.zip
>
>
> Invocation of a JAX-RS method may depend on some application classes which may not be loaded already, they will be loaded during invocation. But during invocation the classloader will be CXF war application classloader, this will lead to NoClassDefFoundErrors. To avoid this root resource class' classloader should be set on the current thread.
> Similar fix should be applied to provider methods such as readFrom, writeTo etc.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Commented: (CXF-2085) Applications classloader should be set during method invocations.

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

Daniel Kulp commented on CXF-2085:
----------------------------------


The JAXWS invoker probably SHOULD set it.   If the user has a specific XML parser or similar that they want to use (which could be different than the one CXF is using), without the classloader being set, that won't really work.    

> Applications classloader should be set during method invocations.
> -----------------------------------------------------------------
>
>                 Key: CXF-2085
>                 URL: https://issues.apache.org/jira/browse/CXF-2085
>             Project: CXF
>          Issue Type: Bug
>    Affects Versions: 2.2
>            Reporter: Chaitanya Choleti
>             Fix For: 2.2
>
>         Attachments: cl_test.war, new_cl_test.war, new_sources.zip, sources.zip
>
>
> Invocation of a JAX-RS method may depend on some application classes which may not be loaded already, they will be loaded during invocation. But during invocation the classloader will be CXF war application classloader, this will lead to NoClassDefFoundErrors. To avoid this root resource class' classloader should be set on the current thread.
> Similar fix should be applied to provider methods such as readFrom, writeTo etc.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.