我開發了一個基於Spring的小型Web應用程序來測試Spring RMI。在那裏,我創建了一個簡單的服務,根據輸入參數生成問候消息並將其返回給客戶端。我的Spring上下文文件看起來像這樣:openshift中的Java RMI端口綁定錯誤
<bean id="registry"
class="org.springframework.remoting.rmi.RmiRegistryFactoryBean">
<property name="port" value="4777"/>
</bean>
<bean id="greetingService" class="com.greeting.GreetingServiceImpl" >
</bean>
<bean class="org.springframework.remoting.rmi.RmiServiceExporter"
p:service-ref="greetingService"
p:serviceName="greetingRmiService"
p:serviceInterface="com.greeting.GreetingService"
p:registry-ref="registry"
/>
首先我在本地PC上運行Tomcat服務器部署7本應用程序並將其成功部署。 然後我把這個應用程序的war文件上傳到Openshift tomcat 7 DIY服務器。但它沒有部署我的應用程序,並在日誌文件中給出了這個錯誤。
SEVERE: Context initialization failed org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'registry' defined in ServletCo ntext resource [/WEB-INF/applicationContext.xml]: Invocation of init method failed; nested exception is java.rmi.serve r.ExportException: Port already in use: 4777; nested exception is: java.net.BindException: Permission denied at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowir eCapableBeanFactory.java:1420) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireC apableBeanFactory.java:519) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCap ableBeanFactory.java:456) at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:293) at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanReg istry.java:222) at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:290) at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:192) at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListab leBeanFactory.java:567) at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractAppl icationContext.java:895) at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:425) at org.springframework.web.context.ContextLoader.createWebApplicationContext(ContextLoader.java:282) at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:204) at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:47) at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4791) at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5285) at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150) at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:901) at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:877) at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:618) at org.apache.catalina.startup.HostConfig.deployDirectory(HostConfig.java:1100) at org.apache.catalina.startup.HostConfig$DeployDirectory.run(HostConfig.java:1618) at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:471) at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:334) at java.util.concurrent.FutureTask.run(FutureTask.java:166) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615) at java.lang.Thread.run(Thread.java:722) Caused by: java.rmi.server.ExportException: Port already in use: 4777; nested exception is: java.net.BindException: Permission denied at sun.rmi.transport.tcp.TCPTransport.listen(TCPTransport.java:328) at sun.rmi.transport.tcp.TCPTransport.exportObject(TCPTransport.java:236) at sun.rmi.transport.tcp.TCPEndpoint.exportObject(TCPEndpoint.java:411) at sun.rmi.transport.LiveRef.exportObject(LiveRef.java:147) at sun.rmi.server.UnicastServerRef.exportObject(UnicastServerRef.java:207) at sun.rmi.registry.RegistryImpl.setup(RegistryImpl.java:123) at sun.rmi.registry.RegistryImpl.(RegistryImpl.java:109) at java.rmi.registry.LocateRegistry.createRegistry(LocateRegistry.java:203) at org.springframework.remoting.rmi.RmiRegistryFactoryBean.getRegistry(RmiRegistryFactoryBean.java:267) at org.springframework.remoting.rmi.RmiRegistryFactoryBean.getRegistry(RmiRegistryFactoryBean.java:236) at org.springframework.remoting.rmi.RmiRegistryFactoryBean.getRegistry(RmiRegistryFactoryBean.java:193) at org.springframework.remoting.rmi.RmiRegistryFactoryBean.afterPropertiesSet(RmiRegistryFactoryBean.java:164) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAuto wireCapableBeanFactory.java:1477) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowir eCapableBeanFactory.java:1417) ... 26 more Caused by: java.net.BindException: Permission denied
如何修復這個錯誤,並得到部署在Openshift此應用程序?
謝謝!在使用
我已經運行「netstat a | grep $ OPENSHIFT_INTERNAL_IP」來檢查當前正在運行的端口。但港口4447不在那裏。我也隨機嘗試了不同的端口(1099,9999等)。但他們沒有工作。它嘗試所有不同的端口是不實際的。你有沒有看到**權限被拒絕**異常。所以我想這是關於openshift服務器端口綁定的權限。有關於此的任何想法? – 2013-04-29 04:37:01
錯誤消息中的端口號是4777,但'權限被拒絕'表示您需要設置Windows防火牆規則。 – EJP 2013-04-29 04:51:33
感謝您的幫助!是的,可能是防火牆是問題。但我認爲我們沒有權限在openshift服務器中以用戶身份更改防火牆設置。 – 2013-04-29 09:24:41