解决tomcat引入spring容器出错
错误1:log4j:WARN Please initialize the log4j system properly.2013-1-15 20:22:28 org.apache.catalina.core.StandardContext filterStart严重: Exception starting filter struts2Class: com.opensymphony.x
错误1:
log4j:WARN Please initialize the log4j system properly.
2013-1-15 20:22:28 org.apache.catalina.core.StandardContext filterStart
严重: Exception starting filter struts2
Class: com.opensymphony.xwork2.spring.SpringObjectFactory
File: SpringObjectFactory.java
Method: getClassInstance
Line: 220 - com/opensymphony/xwork2/spring/SpringObjectFactory.java:220:-1
at org.apache.struts2.dispatcher.Dispatcher.init(Dispatcher.java:428)
at org.apache.struts2.dispatcher.ng.InitOperations.initDispatcher(InitOperations.java:69)
at org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter.init(StrutsPrepareAndExecuteFilter.java:51)
at org.apache.catalina.core.ApplicationFilterConfig.initFilter(ApplicationFilterConfig.java:273)
at org.apache.catalina.core.ApplicationFilterConfig.getFilter(ApplicationFilterConfig.java:254)
at org.apache.catalina.core.ApplicationFilterConfig.setFilterDef(ApplicationFilterConfig.java:372)
at org.apache.catalina.core.ApplicationFilterConfig.<init>(ApplicationFilterConfig.java:98)
at org.apache.catalina.core.StandardContext.filterStart(StandardContext.java:4584)
at org.apache.catalina.core.StandardContext$2.call(StandardContext.java:5262)
at org.apache.catalina.core.StandardContext$2.call(StandardContext.java:5257)
at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:303)
at java.util.concurrent.FutureTask.run(FutureTask.java:138)
at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
at java.lang.Thread.run(Thread.java:619)
Caused by: java.lang.NullPointerException
at com.opensymphony.xwork2.spring.SpringObjectFactory.getClassInstance(SpringObjectFactory.java:220)
at com.opensymphony.xwork2.config.providers.XmlConfigurationProvider.verifyResultType(XmlConfigurationProvider.java:530)
at com.opensymphony.xwork2.config.providers.XmlConfigurationProvider.addResultTypes(XmlConfigurationProvider.java:501)
at com.opensymphony.xwork2.config.providers.XmlConfigurationProvider.addPackage(XmlConfigurationProvider.java:457)
at com.opensymphony.xwork2.config.providers.XmlConfigurationProvider.loadPackages(XmlConfigurationProvider.java:275)
at org.apache.struts2.config.StrutsXmlConfigurationProvider.loadPackages(StrutsXmlConfigurationProvider.java:111)
at com.opensymphony.xwork2.config.impl.DefaultConfiguration.reloadContainer(DefaultConfiguration.java:204)
at com.opensymphony.xwork2.config.ConfigurationManager.getConfiguration(ConfigurationManager.java:66)
at org.apache.struts2.dispatcher.Dispatcher.init_PreloadConfiguration(Dispatcher.java:371)
at org.apache.struts2.dispatcher.Dispatcher.init(Dispatcher.java:415)
... 14 more
2013-1-15 20:22:28 org.apache.catalina.core.StandardContext startInternal
严重: Error filterStart
解决方案:
1).在项目的web.xml中配置:
<!-- 指定spring配置文件的路径 -->
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>/WEB-INF/classes/applicationContext.xml</param-value>
</context-param>
<!-- 实例化spring容器 -->
<listener>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>
2).在struts.xml中配置:
<struts>
<!-- 与spring集成的常量,让Spring接管struts去创建action对象 -->
<constant name="struts.objectFactory" value="spring" />
</struts>
错误2:
log4j:WARN Please initialize the log4j system properly.
2013-1-15 20:30:26 org.apache.catalina.core.ApplicationContext log
信息: Initializing Spring root WebApplicationContext
2013-1-15 20:30:31 java.util.prefs.WindowsPreferences <init>
警告: Could not open/create prefs root node Software\JavaSoft\Prefs at root 0x80000002. Windows RegCreateKeyEx(...) returned error code 5.
2013-1-15 20:30:31 java.util.prefs.WindowsPreferences WindowsRegOpenKey1
警告: Trying to recreate Windows registry node Software\JavaSoft\Prefs at root 0x80000002.
2013-1-15 20:30:31 java.util.prefs.WindowsPreferences openKey
警告: Could not open windows registry node Software\JavaSoft\Prefs at root 0x80000002. Windows RegOpenKey(...) returned error code 2.
2013-1-15 20:30:31 java.util.prefs.WindowsPreferences WindowsRegOpenKey1
警告: Trying to recreate Windows registry node Software\JavaSoft\Prefs at root 0x80000002.
2013-1-15 20:30:31 java.util.prefs.WindowsPreferences openKey
警告: Could not open windows registry node Software\JavaSoft\Prefs at root 0x80000002. Windows RegOpenKey(...) returned error code 2.
2013-1-15 20:30:31 java.util.prefs.WindowsPreferences WindowsRegOpenKey1
警告: Trying to recreate Windows registry node Software\JavaSoft\Prefs at root 0x80000002.
2013-1-15 20:30:31 java.util.prefs.WindowsPreferences openKey
警告: Could not open windows registry node Software\JavaSoft\Prefs at root 0x80000002. Windows RegOpenKey(...) returned error code 2.
2013-1-15 20:30:31 java.util.prefs.WindowsPreferences WindowsRegOpenKey1
警告: Trying to recreate Windows registry node Software\JavaSoft\Prefs at root 0x80000002.
2013-1-15 20:30:31 java.util.prefs.WindowsPreferences openKey
警告: Could not open windows registry node Software\JavaSoft\Prefs at root 0x80000002. Windows RegOpenKey(...) returned error code 2.
解决方案:
借鉴自百度方法,严重:StandardServer.await:create[8005]: java.net.BindException:Addressalreadyinuse:JVM_Bind 端口被占用了,8005出现这个问题可能有几种情况:
1.其它应用程序占用了该端口,dos命令查看端口:netstat -an|findstr "8080" 查看端口号8080和进程号,和 tasklist|findstr "6168" 占用端口占用进程号6168的占用者
2.tomcat自己占用了,而tomcat占用又可以分为两种,
1):系统中还有tomcat,并启动了;
2):你的IDE(集成开发环境)突然死掉了,但是tomcat其实并没有关,打开“Windows任务管理器”查看“进程”中,是不是有两个javaw.exe,占用资源小的就是tomcat启动的,大的是由eclipse或myeclipse启动的。
关闭两个javaw进程,重新启动tomcat就…………,这个问题其实可以不解决,项目可以跑起来了!
端口号查看:
Netstat
显示协议统计和当前的 TCP/IP 网络连接。该命令只有在安装了 TCP/IP 协议后才可以使用。
netstat [-a] [-e] [-n] [-s] [-p protocol] [-r] [interval]
参数
-a :显示所有连接和侦听端口。服务器连接通常不显示。
-e :显示以太网统计。该参数可以与 -s 选项结合使用。
-n :以数字格式显示地址和端口号(而不是尝试查找名称)。
-s :显示每个协议的统计。默认情况下,显示 TCP、UDP、ICMP 和 IP 的统计。-p 选项可以用来指定默认的子集。
-p protocol :显示由 protocol 指定的协议的连接;protocol 可以是 tcp 或 udp。如果与 -s 选项一同使用显示每个协议的统计,protocol 可以是 tcp、udp、icmp 或 ip。
-r 显示路由表的内容。
interval :重新显示所选的统计,在每次显示之间暂停 interval 秒。按 CTRL+B 停止重新显示统计。如果省略该参数,netstat 将打印一次当前的配置信息。
更多推荐
所有评论(0)