将我的环境从Apache Tomcat 6.0.37升级到8.0.44并将Java从1.7.0_45升级到1.8.0_131后,我的一个webapps将无法部署,而其他webapps运行时没有问题。
我的开发环境如下。
Product Version: NetBeans IDE 8.2 (Build 201609300101)
Updates: NetBeans IDE is updated to version NetBeans 8.2 Patch 2
Java: 1.8.0_131; Java HotSpot(TM) 64-Bit Server VM 25.131-b11
Runtime: Java(TM) SE Runtime Environment 1.8.0_131-b11
System: Windows 7 version 6.1 running on amd64; Cp1252; en_US (nb)
User directory: C:\Users\heinzk\AppData\Roaming\NetBeans\8.2
Cache directory: C:\Users\heinzk\AppData\Local\NetBeans\Cache\8.2
当我尝试运行或调试有问题的webapp(在这些升级之前工作正常)时,我得到以下服务器输出。
Using CATALINA_BASE: "C:\Program Files\Apache Software Foundation\Tomcat 8.0"
Using CATALINA_HOME: "C:\Program Files\Apache Software Foundation\Tomcat 8.0"
Using CATALINA_TMPDIR: "C:\Program Files\Apache Software Foundation\Tomcat 8.0\temp"
Using JRE_HOME: "C:\Program Files\Java\jdk1.8.0_131"
Using CLASSPATH: "C:\Program Files\Apache Software Foundation\Tomcat 8.0\bin\bootstrap.jar;C:\Program Files\Apache Software Foundation\Tomcat 8.0\bin\tomcat-juli.jar"
Listening for transport dt_shmem at address: tomcat_shared_memory_id
20-Jun-2017 12:52:55.059 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Server version: Apache Tomcat/8.0.44
20-Jun-2017 12:52:55.064 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Server built: May 10 2017 17:21:09 UTC
20-Jun-2017 12:52:55.064 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Server number: 8.0.44.0
20-Jun-2017 12:52:55.064 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log OS Name: Windows 7
20-Jun-2017 12:52:55.064 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log OS Version: 6.1
20-Jun-2017 12:52:55.065 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Architecture: amd64
20-Jun-2017 12:52:55.065 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Java Home: C:\Program Files\Java\jdk1.8.0_131\jre
20-Jun-2017 12:52:55.065 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log JVM Version: 1.8.0_131-b11
20-Jun-2017 12:52:55.065 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log JVM Vendor: Oracle Corporation
20-Jun-2017 12:52:55.065 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log CATALINA_BASE: C:\Program Files\Apache Software Foundation\Tomcat 8.0
20-Jun-2017 12:52:55.065 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log CATALINA_HOME: C:\Program Files\Apache Software Foundation\Tomcat 8.0
20-Jun-2017 12:52:55.066 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Djava.util.logging.config.file=C:\Program Files\Apache Software Foundation\Tomcat 8.0\conf\logging.properties
20-Jun-2017 12:52:55.066 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Djava.util.logging.manager=org.apache.juli.ClassLoaderLogManager
20-Jun-2017 12:52:55.066 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Dcom.sun.jmxremote.port=9876
20-Jun-2017 12:52:55.066 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Dcom.sun.jmxremote.ssl=false
20-Jun-2017 12:52:55.066 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Dcom.sun.jmxremote.authenticate=false
20-Jun-2017 12:52:55.066 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Dhttp.nonProxyHosts=localhost|127.0.0.1|US3C0771A3E9F2
20-Jun-2017 12:52:55.066 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Djdk.tls.ephemeralDHKeySize=2048
20-Jun-2017 12:52:55.067 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Djava.protocol.handler.pkgs=org.apache.catalina.webresources
20-Jun-2017 12:52:55.067 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -agentlib:jdwp=transport=dt_shmem,address=tomcat_shared_memory_id,server=y,suspend=n
20-Jun-2017 12:52:55.067 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Djava.endorsed.dirs=C:\Program Files\Apache Software Foundation\Tomcat 8.0\endorsed
20-Jun-2017 12:52:55.067 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Dcatalina.base=C:\Program Files\Apache Software Foundation\Tomcat 8.0
20-Jun-2017 12:52:55.067 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Dcatalina.home=C:\Program Files\Apache Software Foundation\Tomcat 8.0
20-Jun-2017 12:52:55.067 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Djava.io.tmpdir=C:\Program Files\Apache Software Foundation\Tomcat 8.0\temp
20-Jun-2017 12:52:55.067 INFO [main] org.apache.catalina.core.AprLifecycleListener.lifecycleEvent The APR based Apache Tomcat Native library which allows optimal performance in production environments was not found on the java.library.path: C:\Program Files\Java\jdk1.8.0_131\bin;C:\Windows\Sun\Java\bin;C:\Windows\system32;C:\Windows;C:\ProgramData\Oracle\Java\javapath;C:\Program Files (x86)\RSA SecurID Token Common;C:\Program Files (x86)\Intel\iCLS Client\;C:\Program Files\Intel\iCLS Client\;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Program Files (x86)\Intel\OpenCL SDK\2.0\bin\x86;C:\Program Files (x86)\Intel\OpenCL SDK\2.0\bin\x64;C:\Program Files\Intel\Intel(R) Management Engine Components\DAL;C:\Program Files\Intel\Intel(R) Management Engine Components\IPT;C:\Program Files (x86)\Intel\Intel(R) Management Engine Components\DAL;C:\Program Files (x86)\Intel\Intel(R) Management Engine Components\IPT;C:\Program Files\Intel\WiFi\bin\;C:\Program Files\Common Files\Intel\WirelessCommon\;C:\Program Files (x86)\Perforce;C:\Program Files (x86)\Tools;C:\Program Files\adt-bundle-windows-x86_64-20140321\sdk\tools;C:\Program Files\Git\cmd;C:\cygwin64\bin;C:\Program Files\Microsoft SQL Server\130\Tools\Binn\;C:\Users\heinzk\.dnx\bin;C:\Program Files\Microsoft DNX\Dnvm\;C:\Program Files (x86)\Windows Kits\8.1\Windows Performance Toolkit\;C:\Program Files (x86)\WebEx\Productivity Tools;C:\Program Files (x86)\WebEx\PTools020000000;C:\Program Files (x86)\Scrivener;C:\Program Files (x86)\Scrivener\Aspell;C:\Program Files (x86)\Scrivener\Aspell\bin;.
20-Jun-2017 12:52:55.499 INFO [main] org.apache.coyote.AbstractProtocol.init Initializing ProtocolHandler ["http-nio-8080"]
20-Jun-2017 12:52:59.671 INFO [main] org.apache.tomcat.util.net.NioSelectorPool.getSharedSelector Using a shared selector for servlet write/read
20-Jun-2017 12:52:59.676 INFO [main] org.apache.coyote.AbstractProtocol.init Initializing ProtocolHandler ["ajp-nio-8009"]
20-Jun-2017 12:52:59.685 INFO [main] org.apache.tomcat.util.net.NioSelectorPool.getSharedSelector Using a shared selector for servlet write/read
20-Jun-2017 12:52:59.686 INFO [main] org.apache.catalina.startup.Catalina.load Initialization processed in 5325 ms
20-Jun-2017 12:52:59.751 INFO [main] org.apache.catalina.core.StandardService.startInternal Starting service Catalina
20-Jun-2017 12:52:59.752 INFO [main] org.apache.catalina.core.StandardEngine.startInternal Starting Servlet Engine: Apache Tomcat/8.0.44
20-Jun-2017 12:52:59.765 INFO [localhost-startStop-1] org.apache.catalina.startup.HostConfig.deployDescriptor Deploying configuration descriptor C:\Program Files\Apache Software Foundation\Tomcat 8.0\conf\Catalina\localhost\Device_Monitor.xml
20-Jun-2017 12:53:05.430 SEVERE [localhost-startStop-1] org.apache.catalina.core.ContainerBase.addChildInternal ContainerBase.addChild: start:
org.apache.catalina.LifecycleException: Failed to start component [StandardEngine[Catalina].StandardHost[localhost].StandardContext[/Device_Monitor]]
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:162)
at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:753)
at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:729)
at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:717)
at org.apache.catalina.startup.HostConfig.deployDescriptor(HostConfig.java:587)
at org.apache.catalina.startup.HostConfig$DeployDescriptor.run(HostConfig.java:1798)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at java.lang.Thread.run(Thread.java:748)
Caused by: java.lang.NullPointerException
at java.util.Hashtable.get(Hashtable.java:363)
at java.util.Properties.getProperty(Properties.java:969)
at org.apache.catalina.startup.ContextConfig.authenticatorConfig(ContextConfig.java:400)
at org.apache.catalina.startup.ContextConfig.configureStart(ContextConfig.java:794)
at org.apache.catalina.startup.ContextConfig.lifecycleEvent(ContextConfig.java:307)
at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:95)
at org.apache.catalina.util.LifecycleBase.fireLifecycleEvent(LifecycleBase.java:90)
at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5213)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:145)
... 10 more
不幸的是,HashTable上的NullPointerException没有多大帮助。
context.xml文件始终如下所示。
<?xml version="1.0" encoding="UTF-8"?>
<Context path="/Device_Monitor"/>
显然,正在检索属性名称为null的属性。但是,由于堆栈跟踪被截断,我不知道它可能是什么。
有没有办法获得“原因”堆栈跟踪的平衡?
对于这个新环境,context.xml文件是否可能不完整?
web.xml的示例如下。
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE web-app PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN" "http://java.sun.com/dtd/web-app_2_3.dtd">
<web-app>
<display-name>Device Monitor</display-name>
<description>Device Monitor application to monitor devices</description>
<context-param>
<param-name>db_hostname</param-name>
<param-value>device-monitor-database</param-value>
<description>Database server hostname/IP address</description>
</context-param>
<context-param>
<param-name>db_name</param-name>
<param-value>device_monitor</param-value>
<description>Database schema name</description>
</context-param>
<context-param>
<param-name>db_password</param-name>
<param-value>device_monitor</param-value>
<description>Database account password</description>
</context-param>
<context-param>
<param-name>db_username</param-name>
<param-value>device_monitor</param-value>
<description>Database account username</description>
</context-param>
<context-param>
<param-name>db_trim_connections</param-name>
<param-value>True</param-value>
<description>Set true to dynamically trim database conections</description>
</context-param>
<context-param>
<param-name>max_HTTP_requests</param-name>
<param-value>25</param-value>
<description>Maximum number of HTTP requests that
may be processed at a time.
Set to "0" (zero) for no limit</description>
</context-param>
<servlet>
<servlet-name>DM Database</servlet-name>
<description>Start first to ensure table definitions are loaded
so any needed repairs can be initiated</description>
<servlet-class>database.Main</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet>
<servlet-name>DM Message</servlet-name>
<description>Start next to ensure only old messages are cleared and
caches are preloaded</description>
<servlet-class>message.Main</servlet-class>
<load-on-startup>2</load-on-startup>
</servlet>
<servlet>
<servlet-name>DM GlobalSetting</servlet-name>
<description>This servlet is loaded next to read the global settings
stored in the database before anything other than messages starts</description>
<servlet-class>globalSetting.Main</servlet-class>
<load-on-startup>3</load-on-startup>
</servlet>
<servlet>
<servlet-name>DM Device</servlet-name>
<description>Load after messages to update the health status of each
device per any uncleared messages</description>
<servlet-class>device.Main</servlet-class>
<init-param>
<param-name>removeDeletionsAfterMonths</param-name>
<param-value>6</param-value>
</init-param>
<init-param>
<param-name>deleteChangesAfterMonths</param-name>
<param-value>6</param-value>
</init-param>
<load-on-startup>4</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>DM Database</servlet-name>
<url-pattern>/Database</url-pattern>
</servlet-mapping>
<servlet-mapping>
<servlet-name>DM Device</servlet-name>
<url-pattern>/Device</url-pattern>
</servlet-mapping>
<servlet-mapping>
<servlet-name>DM Message</servlet-name>
<url-pattern>/Message</url-pattern>
</servlet-mapping>
<servlet-mapping>
<servlet-name>DM GlobalSetting</servlet-name>
<url-pattern>/GlobalSetting</url-pattern>
</servlet-mapping>
<session-config>
<session-timeout>600</session-timeout>
</session-config>
<welcome-file-list>
<welcome-file>index.jsp</welcome-file>
</welcome-file-list>
<login-config>
<realm-name>Device-Monitor</realm-name>
</login-config>
</web-app>
答案 0 :(得分:0)
下载并查看相关的Tomcat源文件以及读取javadoc并检查/比较本投影机和那些工作之间的context.xml和web.xml文件后,我在web.xml中发现以下内容文件导致问题。
<login-config>
<realm-name>Device-Monitor</realm-name>
</login-config>
删除此login-config元素后,我的应用程序启动时没有问题。
奇怪的是,这不会在Tomcat 6.0和Java 1.7下的开发环境中引起问题。