2014-01-20 43 views
1

我正在嘗試更新Web應用程序以使用DBCP。事物在本地運行良好(Windows安裝上的典型Tomcat)。然而,DEV服務器上(EC2 LINUX AMI; Tomcat作爲服務),我收到以下將jar添加到Tomcat服務安裝的lib文件夾後出現ClassNotFoundException

Could not create resource factory instance [Root exception is java.lang.ClassNotFoundException: org.apache.tomcat.dbcp.dbcp.BasicDataSourceFactory] 

我已經縮小下來(我認爲)的/lib文件夾原本沒有tomcat-jdbc.ja

因爲我已經加入這個jar,並用以下重新啓動Tomcat實例...

sudo service tomcat7 restart 

但是,我仍然得到同樣的ClassNotFoundException。我怎樣才能讓Tomcat服務識別tomcat-dbcp.jar

編輯 - 這裏的堆棧跟蹤時運行sudo service tomcat7 start

Jan 20, 2014 5:30:35 PM org.apache.catalina.startup.ClassLoaderFactory validateFile 
WARNING: Problem with JAR file [/usr/share/java/tomcat7/log4j.jar], exists: [false], canRead: [false] 
Jan 20, 2014 5:30:35 PM org.apache.catalina.startup.ClassLoaderFactory validateFile 
WARNING: Problem with JAR file [/usr/share/java/tomcat7/log4j.jar], exists: [false], canRead: [false] 
Jan 20, 2014 5:30:36 PM org.apache.catalina.core.AprLifecycleListener init 
INFO: The APR based Apache Tomcat Native library which allows optimal performance in production environments was not found on the java.library.path: /usr/lib/jvm/java-1.6.0-openjdk-1.6.0.0.x86_64/jre/lib/amd64/server:/usr/lib/jvm/java-1.6.0-openjdk-1.6.0.0.x86_64/jre/lib/amd64:/usr/lib/jvm/java-1.6.0-openjdk-1.6.0.0.x86_64/jre/../lib/amd64:/usr/java/packages/lib/amd64:/usr/lib64:/lib64:/lib:/usr/lib 
Jan 20, 2014 5:30:37 PM org.apache.coyote.AbstractProtocol init 
INFO: Initializing ProtocolHandler ["http-bio-8080"] 
Jan 20, 2014 5:30:37 PM org.apache.coyote.AbstractProtocol init 
INFO: Initializing ProtocolHandler ["ajp-bio-8009"] 
Jan 20, 2014 5:30:37 PM org.apache.catalina.startup.Catalina load 
INFO: Initialization processed in 1404 ms 
Jan 20, 2014 5:30:37 PM org.apache.catalina.core.StandardService startInternal 
INFO: Starting service Catalina 
Jan 20, 2014 5:30:37 PM org.apache.catalina.core.StandardEngine startInternal 
INFO: Starting Servlet Engine: Apache Tomcat/7.0.40 
Jan 20, 2014 5:30:37 PM org.apache.catalina.startup.HostConfig deployWAR 
INFO: Deploying web application archive /var/lib/tomcat7/webapps/ROOT.war 
Jan 20, 2014 5:30:47 PM org.apache.catalina.core.StandardContext addApplicationListener 
INFO: The listener "org.apache.myfaces.webapp.StartupServletContextListener" is already configured for this context. The duplicate definition has been ignored. 
Jan 20, 2014 5:30:47 PM org.apache.catalina.core.NamingContextListener addResource 
WARNING: Failed to register in JMX: javax.naming.NamingException: Could not create resource factory instance [Root exception is java.lang.ClassNotFoundException: org.apache.tomcat.dbcp.dbcp.BasicDataSourceFactory] 
Jan 20, 2014 5:30:50 PM org.apache.coyote.AbstractProtocol start 
INFO: Starting ProtocolHandler ["http-bio-8080"] 
Jan 20, 2014 5:30:50 PM org.apache.coyote.AbstractProtocol start 
INFO: Starting ProtocolHandler ["ajp-bio-8009"] 
Jan 20, 2014 5:30:50 PM org.apache.catalina.startup.Catalina start 
INFO: Server startup in 12969 ms 
+0

您是否可以在日誌文件夾中包含完整的調用堆棧? –

+0

當然,只是用stacktrace編輯 – hypno7oad

回答

4

萬一別人之後這個問題,這裏是我如何解決它。

在我的context.xml文件我已經到了下面的屬性標籤

factory="org.apache.commons.dbcp.BasicDataSourceFactory" 

...所以我最終標籤看起來像....

<Resource name="jdbc/resourceName" 
    auth="Container" 
    type="javax.sql.DataSource" 
    logAbandoned="false" 
    maxActive="100" 
    maxIdle="30" 
    maxWait="10000" 
    username= "username" 
    password="password" 
    driverClassName="com.mysql.jdbc.Driver" 
    factory="org.apache.commons.dbcp.BasicDataSourceFactory" 
    url="jdbc:mysql://your.mysql.host"/> 

基本上,我只是強迫它恢復到不使用Tomcat的DBCP類。

相關問題