Announcement Announcement Module
No announcement yet.
Redeploy problem with Spring RMI Page Title Module
Move Remove Collapse
Conversation Detail Module
  • Filter
  • Time
  • Show
Clear All
new posts

  • Redeploy problem with Spring RMI

    I have been refactoring my RMI implementations to use the Spring support classes. I have a J2EE app which is a client to two standalone RMI services on remote servers.

    The Spring support makes the code a lot simpler and cleaner, and in particular makes configuring the service port for passage through a firewall very simple.

    However I now find that while my app works fine when the appserver is started up, I get problems with ClassCastExceptions when I redeploy the app, on the classes that are being transferred in the rmi invocations.
    I am using JBoss 3.2.5, Spring 1.1.

    Any suggestions as to what might cause this? or any lifecycle methods I should be using to make sure all the classes get cleared when the app is undeployed?


  • #2

    I encountered a similar problem in JBoss so hopefully this will help

    The problem sounds like you are deploying classes with your application that are also included in the JBoss distribution. It is best to avoid deploying classes with your app that JBoss already has. Find out which class is causing the problem and then locate the JAR file that contains the classes and exclude it from your application. The classes should still be available from JBoss so the app will run okay, but you will be able to redeploy without any problems.



    • #3
      Thanks for the reply. It prompted me to think that I'd put aopalliance.jar in the jboss server lib instead of in my application. I had a similar problem with spring.jar a while back. So I moved it into the app (and out of the jboss lib).
      But it hasn't solved the problem. Now I get the following error on redeploy (works fine on appserver startup).
      I'm guessing that this is just another symptom of the same old classloader problem.

      org.springframework.beans.factory.BeanCreationException: Error creating bean wit
      h name 'cpmsRmiProxy' defined in class path resource [wo_bus_config.xml]: Initia
      lization of bean failed; nested exception is java.lang.NoSuchMethodError: null
              at .<clinit>&#40;Unknown Source&#41;
              at java.lang.reflect.Constructor.newInstance&#40;Native Method&#41;
              at java.lang.reflect.Proxy.newProxyInstance&#40;;557&#41;
              at org.springframework.aop.framework.JdkDynamicAopProxy.getProxy&#40;JdkDyna;194&#41;
              at org.springframework.aop.framework.JdkDynamicAopProxy.getProxy&#40;JdkDyna;182&#41;
              at org.springframework.aop.framework.ProxyFactory.getProxy&#40;ProxyFactory.
              at org.springframework.aop.framework.ProxyFactory.getProxy&#40;ProxyFactory.
              at org.springframework.remoting.rmi.RmiProxyFactoryBean.afterPropertiesS
      Here's the xml for my cpmsRmiProxy bean:
          <bean id="cpmsRmiProxy" class="org.springframework.remoting.rmi.RmiProxyFactoryBean">
              <property name="serviceInterface">
              <property name="serviceUrl"><value></value></property>
              <property name="lookupStubOnStartup"><value>false</value></property>
              <property name="refreshStubOnConnectFailure"><value>true</value></proper
      However I don't think this is a Spring issue. I get this problem on my development server. I am setting up a new live server for this app, and on there, I don't get the problem; same apperserver, same app. I've been through the jboss libs to make sure they both have exactly the same set of jars in them.

      There must be something different; I just don't know what it is . . .


      • #4

        This does look like some kind of class loading issue related to the proxy.

        If you are deploying this into a web app in Jboss you could try switching to the Tomcat classloader or try setting up a classloader specific to your app. To switch to Tomcat classloader you need to set the JBossWebLoader attribute to true inside <SERVER_HOME>/tomcatXXXX.sar/META-INF/jboss-service.xml.

        I don't remember the specifics of how you configure a classloader repository just for your app, but you find details in the JBoss docs, which I believe are now free. If you can't find the info, post back and I'll look it up for you when I get back to work on Monday.



        • #5
          Thanks for these ideas. I haven't tried the different classloaders; but I have been doing some investigation, and found some interesting results. I'll document them here in the hope that they may be useful to others.

          First of all, I am using Spring 1.1, jboss 3.2.5, and in different places, both j2sdk1_3_1_04 and j2sdk1.4.2_05.

          My application always works fine on initial startup of the appserver; it is only on attempts to redeploy the app that I get problems.
          My app is an rmi client of two separate rmi services.
          The problems only began to appear when I converted my client code to use the Spring rmi support using aop, and consequently, needed to include aopalliance.jar with my app. Before that it would redeploy without any problems.

          I have identified two separate issues:

          1. Exceptions relating to the Spring/aopalliance classes. In various different circumstances I would get various errors related to these classes, but all in the general category where a class is not recognised as being the same as itself; something I have come to equate with classloading problems.
          The problem arose when I had another app deployed which also used spring.jar. In all cases spring.jar was deployed with the apps, and it was not in the appserver lib. I was able to work around the problem by also deploying aopalliance.jar with the other app, even though that app didn't need aopalliance.jar. After that, I could redeploy without these errors.

          2. Exceptions relating to the classes of the objects that are transferred by the rmi calls. Similar classloader-type errors on redeploy. This set of problems occur with j2sdk1_3_1_04, but dissapear with j2sdk1.4.2_05.

          All in all it has been a time consuming and frustrating experience, and I wouldn't be surprised if further similar issues surface - I may not have got to the bottom of it.

          And I don't know which, if any, of spring, aopalliance or jboss are to blame. But certainly something seems a bit strange.


          • #6

            I had similar problems when using Axis in a JBoss application, because some of the classes in some of the Axis JARS were already deployed in JBoss. The only way I managed to get around this was by either using the Tomcat classloader or by creating a separate class repository for my application.



            • #7
              Thanks. If I have further problems I'll try that.


              • #8
                I've had some further problems, not to do with proxies this time but may be related to axis.
                Anyway I I've set the app to have its own class repository, as you suggested, and it seems to have fixed the problem.

                Thanks for the help.


                • #9
                  Class Cast Exception on RMI clien side

                  Hi all,
                  I am using RMIServiceExporter To export the Service. I have configured the bean according to the Steps given in Spring In Action latest book.

                  And on client side i am using RMIProxyBeanFactory .
                  But as i am running the RMI server its working fine . But when i am trying to get bean On client side and Type Casting it to RMIProxyBeanFactory its giving class cast exception. $Proxy1 can not be cast to RMIProxyBeanFactory. Please help me.

                  Even what should i do to look up the Spring RMI Server by using simple RMI way ?
                  Please assist as i am very new to Spring .