2013-04-28 49 views
1

我開發了一個基於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此應用程序?

謝謝!在使用

回答

0

端口已:4777

使用的端口,是不是已經在使用。

或者讓您確定的應用程序在您重新啓動之前確實停止。

+0

我已經運行「netstat a | grep $ OPENSHIFT_INTERNAL_IP」來檢查當前正在運行的端口。但港口4447不在那裏。我也隨機嘗試了不同的端口(1099,9999等)。但他們沒有工作。它嘗試所有不同的端口是不實際的。你有沒有看到**權限被拒絕**異常。所以我想這是關於openshift服務器端口綁定的權限。有關於此的任何想法? – 2013-04-29 04:37:01

+0

錯誤消息中的端口號是4777,但'權限被拒絕'表示您需要設置Windows防火牆規則。 – EJP 2013-04-29 04:51:33

+0

感謝您的幫助!是的,可能是防火牆是問題。但我認爲我們沒有權限在openshift服務器中以用戶身份更改防火牆設置。 – 2013-04-29 09:24:41

0

在OpenShift中,可以綁定到端口範圍爲15000 - 35530的內部IP。因此,您不能使用4477.使用15000-35530之間的任何內容。另外,要明白這些是內部端口,這意味着您只能從應用程序中使用它們。閱讀更多在https://www.openshift.com/kb/kb-e1038-i-cant-bind-to-a-port

+0

但我也嘗試過幾個端口之間的端口範圍:15000 - 35530之後,我得到了相同的結果(java.net.BindException:權限被拒絕)。是的,我知道我無法從外部訪問這些端口。但首先我想成功部署我的應用程序。然後,我必須找到一種方法將我的rmi端口轉發到可從外部訪問的端口。 – 2013-05-01 05:45:32

+0

剛剛嘗試過端口25530並得到了相同的結果。 http://pastebin.com/09c7znA3 – 2013-05-01 06:16:10