该程序在Windows Server 2008 R2中工作,但在Windows Server 2012 R2中不起作用

时间:2017-07-13 09:03:47

标签: java tomcat windows-server-2008-r2 windows-server-2012-r2

(请注意:如果不适合在此发布,请感谢管理员帮助将其删除。谢谢)

背景:在Windows Server 2008 r2中有一个部署在tomcat 8上的应用程序。目前服务器正在运行,应用程序正常运行。团队负责人告诉我们,该申请是由两年前已经辞职的程序员编写的。程序员辞职后,程序没有任何代码更改。

由于某些原因,我们必须将Windows server 2008 r2更改(升级)到Windows Server 2012 r2。

该应用程序需要运行java 1.7和tomcat 8,因此我们在windows server 2012 r2中安装了这些软件。

我们从Windows Server 2008 r2复制war文件并粘贴到windows server 2012 r2中。复制并粘贴war文件后,我们在tomcat Web应用程序管理器中部署war文件(与windows server 2008 r2中的操作相同)。

一旦我们部署了war文件,我们就会尝试启动应用程序。但是,当我们单击“开始”按钮时,我们等待一段时间,并且tomcat消息显示“FAIL - 无法启动上下文路径/路径名的应用程序”。

我们检查了软件版本,它们与Windows Server 2008 r2中的相同。

我们对此消息感到困惑,因为war文件在Windows Server 2008 r2中运行。

我们检查localhost.2017-07-13.log文件,我们注意到有一些例外。我们想在这里发布日志的内容。

13-Jul-2017 15:00:42.464 INFO [http-nio-8080-exec-8] 
org.apache.catalina.core.ApplicationContext.log Initializing Spring root 
WebApplicationContext
13-Jul-2017 15:00:43.214 SEVERE [http-nio-8080-exec-8] 
org.apache.catalina.core.StandardContext.listenerStart Exception sending 
context initialized event to listener instance of class 
org.springframework.web.context.ContextLoaderListener
org.springframework.beans.factory.BeanCreationException: Error creating bean 
with name 'dataSource' defined in ServletContext resource [/WEB-
INF/applicationContext.xml]: Error setting property values; nested exception 
is org.springframework.beans.PropertyBatchUpdateException; nested 
PropertyAccessExceptions (1) are:
PropertyAccessException 1: 
org.springframework.beans.MethodInvocationException: Property 
'driverClassName' threw exception; nested exception is 
java.lang.IllegalStateException: Could not load JDBC driver class 
[net.sourceforge.jtds.jdbc.Driver]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.app
lyPropertyValues(AbstractAutowireCapableBeanFactory.java:1279)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.pop
ulateBean(AbstractAutowireCapableBeanFactory.java:1010)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doC
reateBean(AbstractAutowireCapableBeanFactory.java:472)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory$1.r
un(AbstractAutowireCapableBeanFactory.java:409)
at java.security.AccessController.doPrivileged(Native Method)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.cre
ateBean(AbstractAutowireCapableBeanFactory.java:380)
at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(Abstra
ctBeanFactory.java:264)
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingle
ton(DefaultSingletonBeanRegistry.java:222)
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(Abstract
BeanFactory.java:261)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBe
anFactory.java:185)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBe
anFactory.java:164)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstanti
ateSingletons(DefaultListableBeanFactory.java:429)
at org.springframework.context.support.AbstractApplicationContext.finishBeanFactory
Initialization(AbstractApplicationContext.java:728)
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractA
pplicationContext.java:380)
at org.springframework.web.context.ContextLoader.createWebApplicationContext(Contex
tLoader.java:244)
at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextL
oader.java:187)
at org.springframework.web.context.ContextLoaderListener.contextInitialized(Context
LoaderListener.java:49)
at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4729
)
at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5167
)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:725)
at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:701)
at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:717)
at org.apache.catalina.startup.HostConfig.deployWAR(HostConfig.java:945)
at org.apache.catalina.startup.HostConfig.deployApps(HostConfig.java:466)
at org.apache.catalina.startup.HostConfig.check(HostConfig.java:1556)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.apache.tomcat.util.modeler.BaseModelMBean.invoke(BaseModelMBean.java:300)
at com.sun.jmx.interceptor.DefaultMBeanServerInterceptor.invoke(Unknown Source)
at com.sun.jmx.mbeanserver.JmxMBeanServer.invoke(Unknown Source)
at org.apache.catalina.manager.ManagerServlet.check(ManagerServlet.java:1460)
at org.apache.catalina.manager.HTMLManagerServlet.upload(HTMLManagerServlet.java:289)
at org.apache.catalina.manager.HTMLManagerServlet.doPost(HTMLManagerServlet.java:210)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:648)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:729)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:291)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.apache.catalina.filters.CsrfPreventionFilter.doFilter(CsrfPreventionFilter.java:213)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:239)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:239)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.apache.catalina.filters.SetCharacterEncodingFilter.doFilter(SetCharacterEncodingFilter.java:108)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:239)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:219)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:106)
at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:614)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:142)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:79)
at org.apache.catalina.valves.AbstractAccessLogValve.invoke(AbstractAccessLogValve.java:617)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:88)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:518)
at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1091)
at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:668)
at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1521)
at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.run(NioEndpoint.java:1478)
at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
at java.lang.Thread.run(Unknown Source)
Caused by: org.springframework.beans.PropertyBatchUpdateException; nested 
PropertyAccessExceptions (1) are:
PropertyAccessException 1: 
org.springframework.beans.MethodInvocationException: Property 
'driverClassName' threw exception; nested exception is 
java.lang.IllegalStateException: Could not load JDBC driver class 
[net.sourceforge.jtds.jdbc.Driver]
at org.springframework.beans.AbstractPropertyAccessor.setPropertyValues(AbstractPro
pertyAccessor.java:104)
at org.springframework.beans.AbstractPropertyAccessor.setPropertyValues(AbstractPro
pertyAccessor.java:59)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.app
lyPropertyValues(AbstractAutowireCapableBeanFactory.java:1276)
... 64 more

我们不明白为什么程序在Windows Server 2008 r2中运行但它在Windows Server 2012 r2中不起作用?

目前我们仍在查找该程序的源代码,但是从日志文件中,它提到了[/WEB-INF/applicationContext.xml]和[net.sourceforge.jtds.jdbc.Driver],我们猜测什么时候我们得到源代码,我们需要找到xml文件和驱动程序,它是否正确?

请感谢您的建议。谢谢。

修改

我们只找到源代码,然后打开applicationContext.xml,net.sourceforge.jtds.jdbc.Driver就有了一个bean。不知道为什么它在Windows Server 2012 r2中不起作用。

这是代码:

    <?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xmlns:aop="http://www.springframework.org/schema/aop"
    xmlns:tx="http://www.springframework.org/schema/tx"
    xmlns:jee="http://www.springframework.org/schema/jee"
    xsi:schemaLocation="http://www.springframework.org/schema/beans
                        http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
                        http://www.springframework.org/schema/tx
                        http://www.springframework.org/schema/tx/spring-tx-2.5.xsd
                        http://www.springframework.org/schema/aop
                        http://www.springframework.org/schema/aop/spring-aop-2.5.xsd
                        http://www.springframework.org/schema/jee
                        http://www.springframework.org/schema/jee/spring-jee-2.5.xsd">

<bean class="org.springframework.orm.jpa.support.PersistenceAnnotationBeanPostProcessor" />

<bean id="dataSource" class="org.springframework.jdbc.datasource.DriverManagerDataSource">
    <property name="driverClassName" value="net.sourceforge.jtds.jdbc.Driver" />


    <property name="url" value="jdbc:jtds:sqlserver://{host}:1433;DatabaseName=myDB" /> 

    <property name="username" value="user" />
    <property name="password" value="Password" />
</bean>

</beans>

1 个答案:

答案 0 :(得分:1)

你说(强调我的)

  

该应用程序需要运行java 1.7和tomcat 8,因此我们已安装   Windows server 2012 r2中的那些软件。

     

我们从Windows Server 2008 r2复制war 文件并粘贴到Windows中   server 2012 r2。复制并粘贴war文件后,我们部署了战争   tomcat web应用程序管理器中的文件(Windows中的相同操作)   server 2008 r2)。

错误消息显示

  

java.lang.IllegalStateException:无法加载JDBC驱动程序类   [net.sourceforge.jtds.jdbc.Driver]

意思是:您没有充分重现原始实现。因为你可能想念的不仅仅是这个驱动程序(它可能只是第一个失败)我建议在两个目录上完全区分。找出两个安装中部署的内容。

提示:Tomcat在 lib 目录中有一个全局类路径,其中包含每个webapp都可以使用的代码。