Announcement Announcement Module
Collapse
No announcement yet.
Redeploy problem with Spring RMI Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • 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?

    Thanks

  • #2
    Chris,

    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.

    Rob

    Comment


    • #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.

      Code:
      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
      java.lang.NoSuchMethodError
              at .<clinit>&#40;Unknown Source&#41;
              at java.lang.reflect.Constructor.newInstance&#40;Native Method&#41;
              at java.lang.reflect.Proxy.newProxyInstance&#40;Proxy.java&#58;557&#41;
              at org.springframework.aop.framework.JdkDynamicAopProxy.getProxy&#40;JdkDyna
      micAopProxy.java&#58;194&#41;
              at org.springframework.aop.framework.JdkDynamicAopProxy.getProxy&#40;JdkDyna
      micAopProxy.java&#58;182&#41;
              at org.springframework.aop.framework.ProxyFactory.getProxy&#40;ProxyFactory.
      java&#58;66&#41;
              at org.springframework.aop.framework.ProxyFactory.getProxy&#40;ProxyFactory.
      java&#58;82&#41;
              at org.springframework.remoting.rmi.RmiProxyFactoryBean.afterPropertiesS
      et&#40;RmiProxyFactoryBean.java&#58;68&#41;
              at org.springframework.beans.factory.support.AbstractAutowireCapableBean
      Factory.invokeInitMethods&#40;AbstractAutowireCapableBeanFactory.java&#58;991&#41;
              at org.springframework.beans.factory.support.AbstractAutowireCapableBean
      Factory.createBean&#40;AbstractAutowireCapableBeanFactory.java&#58;288&#41;
              at org.springframework.beans.factory.support.AbstractAutowireCapableBean
      Factory.createBean&#40;AbstractAutowireCapableBeanFactory.java&#58;208&#41;
              at org.springframework.beans.factory.support.AbstractBeanFactory.getBean
      &#40;AbstractBeanFactory.java&#58;204&#41;
              at org.springframework.beans.factory.support.AbstractBeanFactory.getBean
      &#40;AbstractBeanFactory.java&#58;136&#41;
              at org.springframework.beans.factory.support.AbstractAutowireCapableBean
      Factory.resolveReference&#40;AbstractAutowireCapableBeanFactory.java&#58;903&#41;
              at org.springframework.beans.factory.support.AbstractAutowireCapableBean
      Factory.resolveValueIfNecessary&#40;AbstractAutowireCapableBeanFactory.java&#58;844&#41;
              at org.springframework.beans.factory.support.AbstractAutowireCapableBean
      Factory.applyPropertyValues&#40;AbstractAutowireCapableBeanFactory.java&#58;785&#41;
      Here's the xml for my cpmsRmiProxy bean:
      Code:
          <bean id="cpmsRmiProxy" class="org.springframework.remoting.rmi.RmiProxyFactoryBean">
              <property name="serviceInterface">
                  <value>org.stl.cpmsserver.business.CpmsServerIntf</value>
              </property>
              <property name="serviceUrl"><value></value></property>
              <property name="lookupStubOnStartup"><value>false</value></property>
              <property name="refreshStubOnConnectFailure"><value>true</value></proper
      ty>
          </bean>
      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 . . .

      Comment


      • #4
        Chris,

        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.

        Rob

        Comment


        • #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.

          Comment


          • #6
            Chris,

            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.

            Rob

            Comment


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

              Comment


              • #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.

                Comment


                • #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 .

                  Comment

                  Working...
                  X