Announcement Announcement Module
Collapse
No announcement yet.
Help : problem on starting RMI service via Spring Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Help : problem on starting RMI service via Spring

    Hi everyone.

    When i start my Spring container with one rmi service, i get an error.
    Can someone help me out !!
    Thanks a lot

    config
    Code:
    <beans>
      <bean id="accountService"
    		class="com.iberville.account.AccountServiceSpringXMLImpl">
    		
    		<property name="userAccounts">
    			<list>
    				<bean id="Account_1" class="com.iberville.account.classes.Account" singleton="false">
    					<property name="id"><value>jojo</value></property>
    					<property name="boxNumber"><value>1</value></property>
    					<property name="userName"><value>Jxx Wxxht</value></property>
    					<property name="password"><value>jojonumberone</value></property>
    					<property name="email"><value>[email protected]</value></property>
    				</bean>
    				<bean id="Account_2" class="com.iberville.account.classes.Account" singleton="false">
    					<property name="boxNumber"><value>2</value></property>
    					<property name="id"><value>hevo</value></property>
    					<property name="userName"><value>xx xxer</value></property>
    					<property name="password"><value>hevoNumberone</value></property>
    					<property name="email"><value>[email protected]</value></property>					
    				</bean>
    				<bean id="Account_3" class="com.iberville.account.classes.Account" singleton="false">
    					<property name="boxNumber"><value>3</value></property>				
    					<property name="id"><value>manu</value></property>
    					<property name="userName"><value>xxuel xxnd</value></property>
    					<property name="password"><value>manuNumberOne</value></property>
    					<property name="email"><value>[email protected]</value></property>					
    				</bean>			
    			</list>
    		</property>
      </bean>
      
      
    	<bean class="org.springframework.remoting.rmi.RmiServiceExporter">
    		<property name="serviceName">
    			<value>AccountService</value>
    		</property>
    		<property name="service">
    			<ref bean="accountService"/>
    		</property>
    		<property name="serviceInterface">
    			<value>com.iberville.services.AccountService</value>
    		</property>
    		<property name="registryPort">
    			<value>1199</value>
    		</property> 	
    	</bean>
      
      
    </beans>
    ERROR
    Code:
      &#91;java&#93; &#91;2004-12-11 15&#58;20&#58;08,468 &#91;main&#93;&#93; WARN  org.springframework.remoting.rmi.RmiServiceExporter - Could not detect RMI registry - creating new one
         &#91;java&#93; &#91;2004-12-11 15&#58;20&#58;08,468 &#91;main&#93;&#93; INFO  org.springframework.remoting.rmi.RmiServiceExporter - Binding RMI service 'AccountService' to registry at port '1199'
         &#91;java&#93; &#91;2004-12-11 15&#58;20&#58;08,468 &#91;main&#93;&#93; INFO  org.springframework.beans.factory.support.DefaultListableBeanFactory - Destroying singletons in factory &#123;org.springframework.beans.factory.support.DefaultListableBeanFactory defining beans &#91;accountService,org.springframework.remoting.rmi.RmiServiceExporter&#93;; Root of BeanFactory hierarchy&#125;
         &#91;java&#93; &#91;2004-12-11 15&#58;20&#58;08,468 &#91;main&#93;&#93; DEBUG org.springframework.beans.factory.support.DefaultListableBeanFactory - Retrieving dependent beans for bean 'accountService'
         &#91;java&#93; &#91;2004-12-11 15&#58;20&#58;08,484 &#91;main&#93;&#93; DEBUG org.springframework.beans.factory.support.DefaultListableBeanFactory - Applying DestructionAwareBeanPostProcessors to bean with name 'accountService'
         &#91;java&#93; &#91;2004-12-11 15&#58;20&#58;08,484 &#91;main&#93;&#93; INFO  org.springframework.beans.factory.support.DefaultListableBeanFactory - Destroying inner beans in factory &#123;org.springframework.beans.factory.support.DefaultListableBeanFactory defining beans &#91;accountService,org.springframework.remoting.rmi.RmiServiceExporter&#93;; Root of BeanFactory hierarchy&#125;
         &#91;java&#93; org.springframework.beans.factory.BeanCreationException&#58; Error creating bean with name 'org.springframework.remoting.rmi.RmiServiceExporter' defined in class path resource &#91;AccountService.xml&#93;&#58; Initialization of bean failed; nested exception is java.rmi.server.ExportException&#58; object already exported
         &#91;java&#93; 	at org.apache.tools.ant.taskdefs.ExecuteJava.execute&#40;ExecuteJava.java&#58;172&#41;
         &#91;java&#93; 	at org.apache.tools.ant.taskdefs.Java.run&#40;Java.java&#58;705&#41;
         &#91;java&#93; 	at org.apache.tools.ant.taskdefs.Java.executeJava&#40;Java.java&#58;177&#41;
         &#91;java&#93; 	at org.apache.tools.ant.taskdefs.Java.execute&#40;Java.java&#58;83&#41;
         &#91;java&#93; 	at org.apache.tools.ant.UnknownElement.execute&#40;UnknownElement.java&#58;275&#41;
         &#91;java&#93; 	at org.apache.tools.ant.Task.perform&#40;Task.java&#58;364&#41;
         &#91;java&#93; 	at org.apache.tools.ant.Target.execute&#40;Target.java&#58;341&#41;
         &#91;java&#93; 	at org.apache.tools.ant.Target.performTasks&#40;Target.java&#58;369&#41;
         &#91;java&#93; 	at org.apache.tools.ant.Project.executeTarget&#40;Project.java&#58;1214&#41;
         &#91;java&#93; 	at org.apache.tools.ant.Project.executeTargets&#40;Project.java&#58;1062&#41;
         &#91;java&#93; 	at org.eclipse.ant.internal.ui.antsupport.InternalAntRunner.run&#40;InternalAntRunner.java&#58;377&#41;
         &#91;java&#93; 	at org.eclipse.ant.internal.ui.antsupport.InternalAntRunner.main&#40;InternalAntRunner.java&#58;135&#41;
         &#91;java&#93; Caused by&#58; org.springframework.beans.factory.BeanCreationException&#58; Error creating bean with name 'org.springframework.remoting.rmi.RmiServiceExporter' defined in class path resource &#91;AccountService.xml&#93;&#58; Initialization of bean failed; nested exception is java.rmi.server.ExportException&#58; object already exported
         &#91;java&#93; 	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean&#40;AbstractAutowireCapableBeanFactory.java&#58;300&#41;
         &#91;java&#93; 	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean&#40;AbstractAutowireCapableBeanFactory.java&#58;205&#41;
         &#91;java&#93; 	at org.springframework.beans.factory.support.AbstractBeanFactory.getBean&#40;AbstractBeanFactory.java&#58;204&#41;
         &#91;java&#93; 	at org.springframework.beans.factory.support.AbstractBeanFactory.getBean&#40;AbstractBeanFactory.java&#58;136&#41;
         &#91;java&#93; 	at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons&#40;DefaultListableBeanFactory.java&#58;236&#41;
         &#91;java&#93; 	at org.springframework.context.support.AbstractApplicationContext.refresh&#40;AbstractApplicationContext.java&#58;284&#41;
         &#91;java&#93; 	at org.springframework.context.support.ClassPathXmlApplicationContext.<init>&#40;ClassPathXmlApplicationContext.java&#58;80&#41;
         &#91;java&#93; 	at org.springframework.context.support.ClassPathXmlApplicationContext.<init>&#40;ClassPathXmlApplicationContext.java&#58;65&#41;
         &#91;java&#93; 	at startup.<init>&#40;startup.java&#58;23&#41;
         &#91;java&#93; 	at startup.main&#40;startup.java&#58;13&#41;
         &#91;java&#93; 	at sun.reflect.NativeMethodAccessorImpl.invoke0&#40;Native Method&#41;
         &#91;java&#93; 	at sun.reflect.NativeMethodAccessorImpl.invoke&#40;Unknown Source&#41;
         &#91;java&#93; 	at sun.reflect.DelegatingMethodAccessorImpl.invoke&#40;Unknown Source&#41;
         &#91;java&#93; 	at java.lang.reflect.Method.invoke&#40;Unknown Source&#41;
         &#91;java&#93; 	at org.apache.tools.ant.taskdefs.ExecuteJava.run&#40;ExecuteJava.java&#58;193&#41;
         &#91;java&#93; 	at org.apache.tools.ant.taskdefs.ExecuteJava.execute&#40;ExecuteJava.java&#58;130&#41;
         &#91;java&#93; 	... 11 more
         &#91;java&#93; Caused by&#58; java.rmi.server.ExportException&#58; object already exported
         &#91;java&#93; 	at sun.rmi.transport.ObjectTable.putTarget&#40;Unknown Source&#41;
         &#91;java&#93; 	at sun.rmi.transport.Transport.exportObject&#40;Unknown Source&#41;
         &#91;java&#93; 	at sun.rmi.transport.tcp.TCPTransport.exportObject&#40;Unknown Source&#41;
         &#91;java&#93; 	at sun.rmi.transport.tcp.TCPEndpoint.exportObject&#40;Unknown Source&#41;
         &#91;java&#93; 	at sun.rmi.transport.LiveRef.exportObject&#40;Unknown Source&#41;
         &#91;java&#93; 	at sun.rmi.server.UnicastServerRef.exportObject&#40;Unknown Source&#41;
         &#91;java&#93; 	at java.rmi.server.UnicastRemoteObject.exportObject&#40;Unknown Source&#41;
         &#91;java&#93; 	at java.rmi.server.UnicastRemoteObject.exportObject&#40;Unknown Source&#41;
         &#91;java&#93; 	at org.springframework.remoting.rmi.RmiServiceExporter.afterPropertiesSet&#40;RmiServiceExporter.java&#58;160&#41;
         &#91;java&#93; 	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods&#40;AbstractAutowireCapableBeanFactory.java&#58;1057&#41;
         &#91;java&#93; 	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean&#40;AbstractAutowireCapableBeanFactory.java&#58;287&#41;
         &#91;java&#93; 	... 26 more
         &#91;java&#93; --- Nested Exception ---
         &#91;java&#93; org.springframework.beans.factory.BeanCreationException&#58; Error creating bean with name 'org.springframework.remoting.rmi.RmiServiceExporter' defined in class path resource &#91;AccountService.xml&#93;&#58; Initialization of bean failed; nested exception is java.rmi.server.ExportException&#58; object already exported
         &#91;java&#93; java.rmi.server.ExportException&#58; object already exported
         &#91;java&#93; 	at sun.rmi.transport.ObjectTable.putTarget&#40;Unknown Source&#41;
         &#91;java&#93; 	at sun.rmi.transport.Transport.exportObject&#40;Unknown Source&#41;
         &#91;java&#93; 	at sun.rmi.transport.tcp.TCPTransport.exportObject&#40;Unknown Source&#41;
         &#91;java&#93; 	at sun.rmi.transport.tcp.TCPEndpoint.exportObject&#40;Unknown Source&#41;
         &#91;java&#93; 	at sun.rmi.transport.LiveRef.exportObject&#40;Unknown Source&#41;
         &#91;java&#93; 	at sun.rmi.server.UnicastServerRef.exportObject&#40;Unknown Source&#41;
         &#91;java&#93; 	at java.rmi.server.UnicastRemoteObject.exportObject&#40;Unknown Source&#41;
         &#91;java&#93; 	at java.rmi.server.UnicastRemoteObject.exportObject&#40;Unknown Source&#41;
         &#91;java&#93; 	at org.springframework.remoting.rmi.RmiServiceExporter.afterPropertiesSet&#40;RmiServiceExporter.java&#58;160&#41;
         &#91;java&#93; 	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods&#40;AbstractAutowireCapableBeanFactory.java&#58;1057&#41;
         &#91;java&#93; 	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean&#40;AbstractAutowireCapableBeanFactory.java&#58;287&#41;
         &#91;java&#93; 	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean&#40;AbstractAutowireCapableBeanFactory.java&#58;205&#41;
         &#91;java&#93; 	at org.springframework.beans.factory.support.AbstractBeanFactory.getBean&#40;AbstractBeanFactory.java&#58;204&#41;
         &#91;java&#93; 	at org.springframework.beans.factory.support.AbstractBeanFactory.getBean&#40;AbstractBeanFactory.java&#58;136&#41;
         &#91;java&#93; 	at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons&#40;DefaultListableBeanFactory.java&#58;236&#41;
         &#91;java&#93; 	at org.springframework.context.support.AbstractApplicationContext.refresh&#40;AbstractApplicationContext.java&#58;284&#41;
         &#91;java&#93; 	at org.springframework.context.support.ClassPathXmlApplicationContext.<init>&#40;ClassPathXmlApplicationContext.java&#58;80&#41;
         &#91;java&#93; 	at org.springframework.context.support.ClassPathXmlApplicationContext.<init>&#40;ClassPathXmlApplicationContext.java&#58;65&#41;
         &#91;java&#93; 	at startup.<init>&#40;startup.java&#58;23&#41;
         &#91;java&#93; 	at startup.main&#40;startup.java&#58;13&#41;
         &#91;java&#93; 	at sun.reflect.NativeMethodAccessorImpl.invoke0&#40;Native Method&#41;
         &#91;java&#93; 	at sun.reflect.NativeMethodAccessorImpl.invoke&#40;Unknown Source&#41;
         &#91;java&#93; 	at sun.reflect.DelegatingMethodAccessorImpl.invoke&#40;Unknown Source&#41;
         &#91;java&#93; 	at java.lang.reflect.Method.invoke&#40;Unknown Source&#41;
         &#91;java&#93; 	at org.apache.tools.ant.taskdefs.ExecuteJava.run&#40;ExecuteJava.java&#58;193&#41;
         &#91;java&#93; 	at org.apache.tools.ant.taskdefs.ExecuteJava.execute&#40;ExecuteJava.java&#58;130&#41;
         &#91;java&#93; 	at org.apache.tools.ant.taskdefs.Java.run&#40;Java.java&#58;705&#41;
         &#91;java&#93; 	at org.apache.tools.ant.taskdefs.Java.executeJava&#40;Java.java&#58;177&#41;
         &#91;java&#93; 	at org.apache.tools.ant.taskdefs.Java.execute&#40;Java.java&#58;83&#41;
         &#91;java&#93; 	at org.apache.tools.ant.UnknownElement.execute&#40;UnknownElement.java&#58;275&#41;
         &#91;java&#93; 	at org.apache.tools.ant.Task.perform&#40;Task.java&#58;364&#41;
         &#91;java&#93; 	at org.apache.tools.ant.Target.execute&#40;Target.java&#58;341&#41;
         &#91;java&#93; 	at org.apache.tools.ant.Target.performTasks&#40;Target.java&#58;369&#41;
         &#91;java&#93; 	at org.apache.tools.ant.Project.executeTarget&#40;Project.java&#58;1214&#41;
         &#91;java&#93; 	at org.apache.tools.ant.Project.executeTargets&#40;Project.java&#58;1062&#41;
         &#91;java&#93; 	at org.eclipse.ant.internal.ui.antsupport.InternalAntRunner.run&#40;InternalAntRunner.java&#58;377&#41;
         &#91;java&#93; 	at org.eclipse.ant.internal.ui.antsupport.InternalAntRunner.main&#40;InternalAntRunner.java&#58;135&#41;

  • #2
    I found the problem !! is it normal and why ?

    If the remote object extends UnicastRemoteObject Spring container crashes during load time.

    Comment


    • #3
      Has this been resolved? I'm having the same problem...


      I get a java.rmi.server.ExportException: object already exported...


      Here's more detail about what I'm trying to do:
      ==================


      If I allow spring to create an instance of my rmi object ( eg extends UnicastRemoteObject ), and then use RmiServiceExporter to make it available.

      For example if i have a rmi capable class (e.g. RemoteFoo ) :

      =============================

      <bean id="theFoo" class="RemoteFoo"/>

      <bean id="theFooRmi" class="org.springframework.remoting.rmi.RmiService Exporter">
      <property name="service"><ref local="theFoo"/></property>
      <property name="serviceInterface">
      <value>IRemoteFoo</value>
      </property>
      <property name="serviceName"><value>theFooService</value></property>
      <property name="registryPort"><value>1099</value></property>
      </bean>

      =================

      Here is the full stack trace:

      org.springframework.beans.factory.BeanCreationExce ption: Error creating bean with name 'theFooRmi' defined in file [c:\throwtest.server.xml]: Initialization of bean failed; nested exception is java.rmi.server.ExportException: object already exported
      java.rmi.server.ExportException: object already exported
      at sun.rmi.transport.ObjectTable.putTarget(Unknown Source)
      at sun.rmi.transport.Transport.exportObject(Unknown Source)
      at sun.rmi.transport.tcp.TCPTransport.exportObject(Un known Source)
      at sun.rmi.transport.tcp.TCPEndpoint.exportObject(Unk nown Source)
      at sun.rmi.transport.LiveRef.exportObject(Unknown Source)
      at sun.rmi.server.UnicastServerRef.exportObject(Unkno wn Source)
      at sun.rmi.server.UnicastServerRef.exportObject(Unkno wn Source)
      at java.rmi.server.UnicastRemoteObject.exportObject(U nknown Source)
      at java.rmi.server.UnicastRemoteObject.exportObject(U nknown Source)
      at org.springframework.remoting.rmi.RmiServiceExporte r.afterPropertiesSet(RmiServiceExporter.java:225)
      at org.springframework.beans.factory.support.Abstract AutowireCapableBeanFactory.invokeInitMethods(Abstr actAutowireCapableBeanFactory.java:1065)
      at org.springframework.beans.factory.support.Abstract AutowireCapableBeanFactory.createBean(AbstractAuto wireCapableBeanFactory.java:343)
      at org.springframework.beans.factory.support.Abstract AutowireCapableBeanFactory.createBean(AbstractAuto wireCapableBeanFactory.java:260)
      at org.springframework.beans.factory.support.Abstract BeanFactory.getBean(AbstractBeanFactory.java:221)
      at org.springframework.beans.factory.support.Abstract BeanFactory.getBean(AbstractBeanFactory.java:145)
      at org.springframework.beans.factory.support.DefaultL istableBeanFactory.preInstantiateSingletons(Defaul tListableBeanFactory.java:282)
      at org.springframework.context.support.AbstractApplic ationContext.refresh(AbstractApplicationContext.ja va:317)
      at org.springframework.context.support.FileSystemXmlA pplicationContext.<init>(FileSystemXmlApplicationC ontext.java:82)
      at org.springframework.context.support.FileSystemXmlA pplicationContext.<init>(FileSystemXmlApplicationC ontext.java:67)
      at org.springframework.context.support.FileSystemXmlA pplicationContext.<init>(FileSystemXmlApplicationC ontext.java:58)
      at bar.SpringDispenser.<init>(SpringDispenser.java:24 )
      at bar.SpringDispenser.init(SpringDispenser.java:33)
      at throwtest.Server.main(Server.java:37)

      Comment


      • #4
        Re: I found the problem !! is it normal and why ?

        Originally posted by hevo
        If the remote object extends UnicastRemoteObject Spring container crashes during load time.
        If it's a bug/defect I think a case in JIRA should be opened for this. Otherwise the developers of Spring isn't aware of this bug

        Comment


        • #5
          I have been struggling with this problem for the better part of a day before coming to an acceptable solution.

          The problem is caused by the UnicastRemoteObject parameterless constructor that will automatically try and register the RMI object at port 0.

          Usually, that is not what you want, and you will want to unregister the object by calling the static method UnicastRemoteObject.unexportObject(Remote, boolean).

          To get around this problem I created an auxiliary static factory method that automatically unregisters the RMI Remote object after instantiation.

          Here is the bit of relevant code, I assume that RemoteSomething is the subinterface of java.rmi.remote that you wish to have:
          Code:
            public static RemoteSomething getRemoteSomething()
            {
              RemoteSomething result = new RemoteSomething();
              UnicastRemoteObject.unexportObject(result, true);
              return result;
            }

          Comment


          • #6
            Glad to hear you're using this: I plan to keep it much more aggressively up-to-date than has been the case in the past, but don't hesitate to let me know if you find errors or need clarifications.

            Comment


            • #7
              Thank you in advance!

              In the meantime, I have made a refactoring so that only one method is applied to unexport any UnicastRemoteObject (at the price of a slightly more complex spring configuration)

              Here is the factory method definition:

              Code:
              package utility;
              
              public class UnicastRemoteObjectUnexporter
              {
                public static Remote unexport(Remote unexported) throws NoSuchObjectException
                {
                  UnicastRemoteObject.unexportObject(unexported, true);
                  return unexported;
                }
              }
              And the corresponding Spring configuration:
              Code:
                <bean id="rmi-something" class="utility.UnicastRemoteObjectUnexporter" factory-method="unexport">
                  <constructor-arg>
                    <bean id="your bean definition"/>
                  </constructor-arg>
                </bean>
              For a more permanent solution, I believe that spring default behaviour should be to unregister UnicastRemoteObject automatically.

              Edit: I guess I'll take some time to see whether that bug has been reported.

              Edit 2: I couldn't find it immediately, so I reported the bug on ticket SPR-6277 (http://jira.springframework.org/browse/SPR-6277)
              Last edited by jhominal; Oct 27th, 2009, 07:38 AM. Reason: Adding whether I reported the problem or not.

              Comment

              Working...
              X