Announcement Announcement Module
Collapse
No announcement yet.
Eclipse RCP / HTTPInvoker / Classloading problems Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Eclipse RCP / HTTPInvoker / Classloading problems

    Hello,
    I am working on an Eclipse RCP (3.1 RC1) application that I want to use Spring (1.2) Remoting with. When running within eclipse I get a StackOverFlow exception due to a chain of neverending ClassNotFoundExceptions which originates in:


    Code:
    JdkDynamicAopProxy.getProxy() : 102
    
    > return Proxy.newProxyInstance(classLoader, proxiedInterfaces, this);
    This is when it is trying to create a org.springframework.remoting.httpinvoker.HttpInvok erProxyFactoryBean instance.

    I have seen various comments about Eclipse classloading, and how it can cause issues, but nothing that seems to have resolved my problem.

    Has anyone successfully implemented an eclipse rcp application using spring remoting? If so can you tell if and how you got around this problem?

    Thx,
    Evan

  • #2
    to answer my own question....

    FYI
    I found a solution on eclipse.rcp newsgroups that seems to do the trick...

    I load the application context in the constructor method of the plugin:

    Code:
    		Thread cur = Thread.currentThread();
    		ClassLoader ccl = cur.getContextClassLoader();
    		cur.setContextClassLoader(MyPlugin.getClassLoader()); 
    		ApplicationContext ctx = ApplicationContextFactory.getApplicationContext();
    		cur.setContextClassLoader(ccl);
    Code:
    	public static ClassLoader getClassLoader() {
    		
    		return MyPlugin.class.getClassLoader();
    	
    	}
    seems to work - for now.

    evan

    Comment


    • #3
      same problem

      hi Evan

      i've got the same problem .
      trying to get my object model via httpinvoker on a RCP application

      i was trying to load application context in my application class , and it doesn't work (stackOverflow)

      are you also running an eclipse RCP application ?

      i've tried to put your code in my constructor plug-in, but it failed on startup on a classnotfound exception . my application class is not found since i add my plugin class

      have you got an idea . (maybe my plugin.xml is bad)

      thanks

      David

      Comment


      • #4
        Use Buddy Classloading!

        Hi,


        We had the exact same problem. After googling for a day or so, I came across the following article:

        "Eclipse - a tale of two VMs (and many classloaders)"
        http://www.eclipsezone.com/articles/eclipse-vms/

        The section titled "ClassLoaders, Bundles and Buddies" is especially relevant, it describes the classloading mechanism of Eclipse and buddy classloading.

        CAUSE OF THE PROBLEM
        In our setup we wrapped the Spring jars in a plugin called SPRING-CLP.
        Our application plugin, PMGT-UI, depends on the SPRING-CLP plugin. From the PMGT-UI plugin we instantiatie a Spring HttpInvoker. This works because the plugin depends on the SPRING-CLP plugin. Now when we invoke a remote method, the Spring HttpInvoker will try to instantiate (e.g. with reflection) one of our custom classes that resides in the PMGT-UI plugin. When you read the above article it will become clear that this won't work: the HttpInvoker is loaded by the classloader of the SPRING-CLP plugin. The SPRING-CLP plugin has its own classloader that can only load its own classes or classes of plugings that it depends on. We can't add a dependency from the SPRING-CLP plugin to the PMGT-UI plugin, because this will create a circular dependency ...

        THE SOLUTION:
        Use buddy classloading. See the above mentioned article on how to do this:
        http://www.eclipsezone.com/articles/eclipse-vms/

        We still had to use the 'famous' eclipse loader trick around the part where we load the Spring context, but in combination with buddy classloading it worked!

        Good luck!



        Originally posted by axidavid
        hi Evan

        i've got the same problem .
        trying to get my object model via httpinvoker on a RCP application

        i was trying to load application context in my application class , and it doesn't work (stackOverflow)

        are you also running an eclipse RCP application ?

        i've tried to put your code in my constructor plug-in, but it failed on startup on a classnotfound exception . my application class is not found since i add my plugin class

        have you got an idea . (maybe my plugin.xml is bad)

        thanks

        David

        Comment


        • #5
          Could you elaborate on how you created a plugin from the Spring Project?

          Trying to create the plugin for Spring as you indicated. I used the Plugin wizard. Must I add the 3rd party jars as Project properties, AND as classpath entries in the Plugin Editor (Runtime tab).
          Also, I what is the 'famous eclipseloader trick'?

          Thanks!

          Comment


          • #6
            Randy,

            The 'famous eclipseloader trick' is that you exlicitly set the context classloader of the current thread.

            See:
            http://www.eclipsezone.com/eclipse/forums/t61831.html

            The easiest way to wrap the 3rd party jars is to use the plugin wizard:
            * Select 'file -> new -> other -> Plug-in Development -> plugin from existing JAR archives'
            * In the wizard that appears you add the third party jars with the button 'add external'
            * Complete the other steps of the wizard and it will generate the plugin for you

            Hope this helps.

            Martin

            Comment


            • #7
              Another obstacle on plugin creation

              Martin,

              Thanks for the information! So, I created the plugin and selected it as a dependency in my RCP plugin. When I launch my plugin, from the plugin wizard, it complains 'Missing required bundle Spring_0.0.0'.

              So, I assumed I need to export the spring plugin, using the wizard, and then make sure this new plugin exists in the eclipse/plugins directory. I do that, and restart Eclipse, but get the same error when trying to launch my RCP plugin.

              Any thoughts? By the way, I have read the 'Eclipse Rich Client Platform' by McAffer and Lemieux, so I have some experience with RCP, but am just stuck on this basic of problems.

              Thanks again.

              Randy

              Comment


              • #8
                Hey Randy,

                Double check that your new plugin is added to your launch configuration. Under Run, Run... check the launch configuration for your Eclipse Application configuration. There is a Plug-ins tab, that may be set to "choose plugins and fragments to launch from the list". Make sure your new plugin is checked, and also check the "add new workspace plugins to this launch configuration automatically".

                Comment

                Working...
                X