here is my config file[bean.xml]:
Here is my Class:Code:<bean id="jndiTemplate" class="org.springframework.jndi.JndiTemplate"> <property name="environment"> <props> <prop key="java.naming.factory.initial">com.sun.jndi.cosnaming.CNCtxFactory</prop> <prop key="java.naming.provider.url">iiop://localhost:55555</prop> </props> </property> </bean> <bean id="iiop" class="org.springframework.remoting.rmi.JndiRmiServiceExporter"> <property name="jndiTemplate"> <ref bean="jndiTemplate"/> </property> <property name="jndiName"> <value>helloService</value> </property> <property name="service"> <ref bean="hello"/> </property> </bean> <bean id="hello" class="net.fox.HelloImpl"/>
Code:package net.fox; import java.rmi.Remote; import java.rmi.RemoteException; /** * @author Administrator * * TODO To change the template for this generated type comment go to * Window - Preferences - Java - Code Style - Code Templates */ public interface Hello extends Remote { String sayHello(String name) throws RemoteException; } ///-- package net.fox; import java.rmi.RemoteException; import java.rmi.server.RemoteObject; import java.rmi.server.RemoteRef; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; /** * @author Administrator * * TODO To change the template for this generated type comment go to * Window - Preferences - Java - Code Style - Code Templates */ public class HelloImpl extends RemoteObject implements Hello { /** * */ protected static final Log log = LogFactory.getLog(HelloImpl.class); public HelloImpl() { super(); // TODO Auto-generated constructor stub } /** * @param arg0 */ public HelloImpl(RemoteRef arg0) { super(arg0); // TODO Auto-generated constructor stub } /* (non-Javadoc) * @see net.fox.Hello#sayHello(java.lang.String) */ public String sayHello(String name) throws RemoteException { // TODO Auto-generated method stub //log.info("我在RMI的服务器端,客户端正在调用'sayHello'方法。 "); log.info("Hello " + name); return "hello" + name; } } ////---Main import org.springframework.context.ApplicationContext; import org.springframework.context.support.FileSystemXmlApplicationContext; import org.springframework.remoting.rmi.JndiRmiServiceExporter; public class Main { public static void main(String[] args) { ApplicationContext ac = new FileSystemXmlApplicationContext("bean.xml"); JndiRmiServiceExporter iiop =(JndiRmiServiceExporter)ac.getBean("iiop"); } }
Here is error Message:
Code:2005-7-13 9:40:40 com.sun.corba.se.impl.transport.SocketOrChannelConnectionImpl <init> 警告: "IOP00410201: (COMM_FAILURE) Connection failure: socketType: IIOP_CLEAR_TEXT; hostname: localhost; port: 55555" org.omg.CORBA.COMM_FAILURE: vmcid: SUN minor code: 201 completed: No at com.sun.corba.se.impl.logging.ORBUtilSystemException.connectFailure(Unknown Source) at com.sun.corba.se.impl.logging.ORBUtilSystemException.connectFailure(Unknown Source) at com.sun.corba.se.impl.transport.SocketOrChannelConnectionImpl.<init>(Unknown Source) at com.sun.corba.se.impl.transport.SocketOrChannelConnectionImpl.<init>(Unknown Source) at com.sun.corba.se.impl.transport.SocketOrChannelContactInfoImpl.createConnection(Unknown Source) at com.sun.corba.se.impl.protocol.CorbaClientRequestDispatcherImpl.beginRequest(Unknown Source) at com.sun.corba.se.impl.protocol.CorbaClientDelegateImpl.request(Unknown Source) at com.sun.corba.se.impl.resolver.BootstrapResolverImpl.invoke(Unknown Source) at com.sun.corba.se.impl.resolver.BootstrapResolverImpl.resolve(Unknown Source) at com.sun.corba.se.impl.resolver.CompositeResolverImpl.resolve(Unknown Source) at com.sun.corba.se.impl.resolver.CompositeResolverImpl.resolve(Unknown Source) at com.sun.corba.se.impl.resolver.CompositeResolverImpl.resolve(Unknown Source) at com.sun.corba.se.impl.orb.ORBImpl.resolve_initial_references(Unknown Source) at com.sun.jndi.cosnaming.CNCtx.setOrbAndRootContext(Unknown Source) at com.sun.jndi.cosnaming.CNCtx.initUsingIiopUrl(Unknown Source) at com.sun.jndi.cosnaming.CNCtx.initUsingUrl(Unknown Source) at com.sun.jndi.cosnaming.CNCtx.initOrbAndRootContext(Unknown Source) at com.sun.jndi.cosnaming.CNCtx.<init>(Unknown Source) at com.sun.jndi.cosnaming.CNCtxFactory.getInitialContext(Unknown Source) at javax.naming.spi.NamingManager.getInitialContext(Unknown Source) at javax.naming.InitialContext.getDefaultInitCtx(Unknown Source) at javax.naming.InitialContext.init(Unknown Source) at javax.naming.InitialContext.<init>(Unknown Source) at org.springframework.jndi.JndiTemplate.createInitialContext(JndiTemplate.java:105) at org.springframework.jndi.JndiTemplate.execute(JndiTemplate.java:83) at org.springframework.jndi.JndiTemplate.rebind(JndiTemplate.java:184) at org.springframework.remoting.rmi.JndiRmiServiceExporter.afterPropertiesSet(JndiRmiServiceExporter.java:93) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:962) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:354) at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:223) at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:147) at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:277) at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:312) at org.springframework.context.support.FileSystemXmlApplicationContext.<init>(FileSystemXmlApplicationContext.java:82) at org.springframework.context.support.FileSystemXmlApplicationContext.<init>(FileSystemXmlApplicationContext.java:67) at org.springframework.context.support.FileSystemXmlApplicationContext.<init>(FileSystemXmlApplicationContext.java:58) at Main.main(Main.java:21) Caused by: java.net.ConnectException: Connection refused: connect at sun.nio.ch.Net.connect(Native Method) at sun.nio.ch.SocketChannelImpl.connect(Unknown Source) at java.nio.channels.SocketChannel.open(Unknown Source) at com.sun.corba.se.impl.transport.DefaultSocketFactoryImpl.createSocket(Unknown Source) ... 35 more Exception in thread "main" org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'iiop' defined in file [C:\eclipse\workspace\iiop\bean.xml]: Initialization of bean failed; nested exception is javax.naming.CommunicationException: Cannot connect to ORB javax.naming.CommunicationException: Cannot connect to ORB [Root exception is org.omg.CORBA.COMM_FAILURE: vmcid: SUN minor code: 201 completed: No] at com.sun.jndi.cosnaming.CNCtx.setOrbAndRootContext(Unknown Source) at com.sun.jndi.cosnaming.CNCtx.initUsingIiopUrl(Unknown Source) at com.sun.jndi.cosnaming.CNCtx.initUsingUrl(Unknown Source) at com.sun.jndi.cosnaming.CNCtx.initOrbAndRootContext(Unknown Source) at com.sun.jndi.cosnaming.CNCtx.<init>(Unknown Source) at com.sun.jndi.cosnaming.CNCtxFactory.getInitialContext(Unknown Source) at javax.naming.spi.NamingManager.getInitialContext(Unknown Source) at javax.naming.InitialContext.getDefaultInitCtx(Unknown Source) at javax.naming.InitialContext.init(Unknown Source) at javax.naming.InitialContext.<init>(Unknown Source) at org.springframework.jndi.JndiTemplate.createInitialContext(JndiTemplate.java:105) at org.springframework.jndi.JndiTemplate.execute(JndiTemplate.java:83) at org.springframework.jndi.JndiTemplate.rebind(JndiTemplate.java:184) at org.springframework.remoting.rmi.JndiRmiServiceExporter.afterPropertiesSet(JndiRmiServiceExporter.java:93) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:962) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:354) at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:223) at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:147) at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:277) at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:312) at org.springframework.context.support.FileSystemXmlApplicationContext.<init>(FileSystemXmlApplicationContext.java:82) at org.springframework.context.support.FileSystemXmlApplicationContext.<init>(FileSystemXmlApplicationContext.java:67) at org.springframework.context.support.FileSystemXmlApplicationContext.<init>(FileSystemXmlApplicationContext.java:58) at Main.main(Main.java:21) Caused by: org.omg.CORBA.COMM_FAILURE: vmcid: SUN minor code: 201 completed: No at com.sun.corba.se.impl.logging.ORBUtilSystemException.connectFailure(Unknown Source) at com.sun.corba.se.impl.logging.ORBUtilSystemException.connectFailure(Unknown Source)2005-07-13 09:40:40,312 INFO [org.springframework.beans.factory.support.DefaultListableBeanFactory] - Destroying singletons in factory {org.springframework.beans.factory.support.DefaultListableBeanFactory defining beans [jndiTemplate,iiop,hello]; root of BeanFactory hierarchy} at com.sun.corba.se.impl.transport.SocketOrChannelConnectionImpl.<init>(Unknown Source) at com.sun.corba.se.impl.transport.SocketOrChannelConnectionImpl.<init>(Unknown Source) at com.sun.corba.se.impl.transport.SocketOrChannelContactInfoImpl.createConnection(Unknown Source) at com.sun.corba.se.impl.protocol.CorbaClientRequestDispatcherImpl.beginRequest(Unknown Source) at com.sun.corba.se.impl.protocol.CorbaClientDelegateImpl.request(Unknown Source) at com.sun.corba.se.impl.resolver.BootstrapResolverImpl.invoke(Unknown Source) at com.sun.corba.se.impl.resolver.BootstrapResolverImpl.resolve(Unknown Source) at com.sun.corba.se.impl.resolver.CompositeResolverImpl.resolve(Unknown Source) at com.sun.corba.se.impl.resolver.CompositeResolverImpl.resolve(Unknown Source) at com.sun.corba.se.impl.resolver.CompositeResolverImpl.resolve(Unknown Source) at com.sun.corba.se.impl.orb.ORBImpl.resolve_initial_references(Unknown Source) ... 24 more Caused by: java.net.ConnectException: Connection refused: connect at sun.nio.ch.Net.connect(Native Method) at sun.nio.ch.SocketChannelImpl.connect(Unknown Source) at java.nio.channels.SocketChannel.open(Unknown Source) at com.sun.corba.se.impl.transport.DefaultSocketFactoryImpl.createSocket(Unknown Source) ... 35 more
What is the problem?? Please Help me!


Reply With Quote