我开发了一个基于Spring的小型Web应用程序来测试Spring RMI。在那里,我创建了一个简单的服务,根据输入参数生成问候消息,并将其返回给客户端。我的spring上下文文件如下所示:
<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"
/>
首先,我在运行tomcat服务器7的本地PC上部署了此应用程序,并且已成功部署。 然后我将此应用程序的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 :(得分:0)
港口已在使用:4777
使用尚未使用的端口。
或者在重新启动它之前确保您确定的应用程序已停止。
答案 1 :(得分:0)
在OpenShift中,可以使用端口范围:15000 - 35530绑定到内部IP。因此,您无法使用4477.请使用15000-35530之间的任何内容。另外,要了解这些是内部端口,这意味着您只能在应用程序中使用它们。阅读更多https://www.openshift.com/kb/kb-e1038-i-cant-bind-to-a-port