当前位置 : 主页 > 网页制作 > Nodejs >

搭建Rop Webservice框架遇见的坑

来源:互联网 收集:自由互联 发布时间:2021-06-24
Rop框架的作用以及导入所需要的jar包,配置rop.xml 和rop.properties网上有很多资料,这里不再赘述,说两个遇见的坑: 按照网上的资料, 天坑1:配置好后,在tomcat下面启动,错误信息如下

Rop框架的作用以及导入所需要的jar包,配置rop.xml 和rop.properties网上有很多资料,这里不再赘述,说两个遇见的坑:

按照网上的资料,

天坑1:配置好后,在tomcat下面启动,错误信息如下:

SEVERE: StandardWrapper.Throwable
java.lang.NullPointerException
	at com.rop.RopServlet.init(RopServlet.java:60)
	at org.apache.catalina.core.StandardWrapper.initServlet(StandardWrapper.java:1269)
	at org.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper.java:1182)
	at org.apache.catalina.core.StandardWrapper.load(StandardWrapper.java:1072)
	at org.apache.catalina.core.StandardContext.loadOnStartup(StandardContext.java:5368)
	at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5660)
	at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:145)
	at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1571)
	at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1561)
	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)

十二月 02, 2016 9:08:56 上午 org.apache.catalina.core.StandardContext loadOnStartup
SEVERE: Servlet [rop] in web application [/TestRop] threw load() exception
java.lang.NullPointerException
	at com.rop.RopServlet.init(RopServlet.java:60)
	at org.apache.catalina.core.StandardWrapper.initServlet(StandardWrapper.java:1269)
	at org.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper.java:1182)
	at org.apache.catalina.core.StandardWrapper.load(StandardWrapper.java:1072)
	at org.apache.catalina.core.StandardContext.loadOnStartup(StandardContext.java:5368)
	at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5660)
	at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:145)
	at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1571)
	at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1561)
	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)
空指针异常,很自然想到是缺少jar包,实际上是rop框架严重依赖于spring框架,在web.xml加上spring的监听器搞定

<listener>
		<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>

天坑2:

SEVERE: StandardWrapper.Throwable
org.springframework.beans.factory.NoSuchBeanDefinitionException: No unique bean of type [com.rop.ServiceRouter] is defined: expected single bean but found 0: 
	at org.springframework.beans.factory.support.DefaultListableBeanFactory.getBean(DefaultListableBeanFactory.java:276)
	at org.springframework.context.support.AbstractApplicationContext.getBean(AbstractApplicationContext.java:1125)
	at com.rop.RopServlet.init(RopServlet.java:60)
	at org.apache.catalina.core.StandardWrapper.initServlet(StandardWrapper.java:1269)
	at org.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper.java:1182)
	at org.apache.catalina.core.StandardWrapper.load(StandardWrapper.java:1072)
	at org.apache.catalina.core.StandardContext.loadOnStartup(StandardContext.java:5368)
	at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5660)
	at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:145)
	at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1571)
	at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1561)
	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)

十二月 02, 2016 9:21:36 上午 org.apache.catalina.core.StandardContext loadOnStartup
SEVERE: Servlet [rop] in web application [/projectName] threw load() exception
org.springframework.beans.factory.NoSuchBeanDefinitionException: No unique bean of type [com.rop.ServiceRouter] is defined: expected single bean but found 0: 
	at org.springframework.beans.factory.support.DefaultListableBeanFactory.getBean(DefaultListableBeanFactory.java:276)
	at org.springframework.context.support.AbstractApplicationContext.getBean(AbstractApplicationContext.java:1125)
	at com.rop.RopServlet.init(RopServlet.java:60)
	at org.apache.catalina.core.StandardWrapper.initServlet(StandardWrapper.java:1269)
	at org.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper.java:1182)
	at org.apache.catalina.core.StandardWrapper.load(StandardWrapper.java:1072)
	at org.apache.catalina.core.StandardContext.loadOnStartup(StandardContext.java:5368)
	at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5660)
	at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:145)
	at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1571)
	at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1561)
	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)
ServiceRouter
给人的感觉又是缺少jar包,但是rop.jar里面有 ServiceRouter的实现。

问题的原因,在于web.xml配置里面,没有找到rop.xml的配置,这里的param-name只能叫contextConfigLocation,改成其他名字就会报错

<context-param>
		<param-name>contextConfigLocation</param-name>
		<param-value>classpath:rop.xml</param-value>
</context-param>

那如果改成contextConfigLocation,不是很Spring的DispatcherServlet配置重名了吗?,别急,可以重名,但是不能用同一个<context-param>,解决办法,spring的配置用</init-param>

<servlet>
		<servlet-name>projectName</servlet-name>
		<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
		<init-param>
			<param-name>contextConfigLocation</param-name>
			<param-value>classpath:applicationContext.xml</param-value>
		</init-param>
		<load-on-startup>1</load-on-startup>
</servlet>
希望对你有所帮助
网友评论