带有Elastic Beanstalk和Tomcat 7的ClassNotFoundException [英] ClassNotFoundException with Elastic Beanstalk and Tomcat 7

查看:217
本文介绍了带有Elastic Beanstalk和Tomcat 7的ClassNotFoundException的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试将一个Maven构建的Java Web应用程序部署到Elastic Beanstalk,该应用程序在Amazon Linux Tomcat 7版本下运行环境.即使在使用外部mysql数据库(XEROUND)的情况下,该应用程序也可以在localhost上正常运行.

I am trying to deploy a maven-built Java web app to Elastic Beanstalk, which is running an environment under the Amazon Linux Tomcat 7 version. The app works fine on localhost, even with an external mysql database (XEROUND).

我原始的context.xml具有如下资源:

My original context.xml has a resource as follows:

<Resource auth="Container"        
    driverClassName="com.mysql.jdbc.Driver" 
    logAbandoned="true" 
    maxActive="100" 
    maxIdle="30" 
    maxWait="10000" 
    name="jdbc/xxxx-01292013" 
    password="xxxx" 
    removeAbandoned="true" 
    removeAbandonedTimeout="60" 
    type="javax.sql.DataSource" 
    url="jdbc:mysql://instancexxxx.db.xeround.com:xxxx/xxxx-01292013?   autoReconnect=true"
    username="xxxx-general"/>

但是,当我运行此应用程序时,出现以下错误:

However, when I run this app, I get the following error:

java.lang.ClassNotFoundException: org.apache.tomcat.dbcp.dbcp.BasicDataSourceFactory

我尝试将以下几行添加到我的context.xml资源中:

I tried adding the following lines to my context.xml resource:

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

但是那也不起作用.然后,我尝试添加此行:

but that didn't work either. I then tried adding this line:

factory="org.apache.tomcat.jdbc.pool.DataSourceFactory"

但这给了我新的例外:

javax.naming.NamingException: com.mysql.jdbc.Driver

我在这里撞墙,有人知道我能做些什么来使它启动并运行吗?

I am pounding my head against a wall here, does anyone know what I can do to get this thing up and running?

推荐答案

好的,因此,在进行了更多试验并尝试了配置之后,我将以下内容放入context.xml资源标签中,以使我的应用正常工作:

Okay, so after some more experimentation and playing around with configurations, I have my app working by putting the following in my context.xml Resource tag:

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

以及我pom.xml文件中的以下内容:

and the following in my pom.xml file:

    <dependency>
        <groupId>commons-dbcp</groupId>
        <artifactId>commons-dbcp</artifactId>
        <version>1.4</version>
    </dependency>

    <dependency>
        <groupId>commons-pool</groupId>
        <artifactId>commons-pool</artifactId>
        <version>1.6</version>
    </dependency>

    <dependency>
        <groupId>commons-collections</groupId>
        <artifactId>commons-collections</artifactId>
        <version>3.2.1</version>
    </dependency>

此答案是通过此处的AWS论坛提供给我的.

但是,我将尝试使用的更好的解决方案是将.ebextensions文件放入我的应用程序中,为其编写一个.config文件,然后使其以这种方式工作.我认为这种方法将更适合长期使用,因为它将使我能够解决开发环境与弹性beantalk的Tomcat 7之间的任何进一步的配置不匹配问题.此解决方案也位于AWS论坛 ="https://forums.aws.amazon.com/thread.jspa?messageID=421387&#421387">此处

However, the better solution that I will be trying to get to work is by putting an .ebextensions file in my app, writing a .config file for it, and getting it to work that way. I think that this approach will be better suited long-term, as it will allow me to address any further configuration mis-match issues between my dev environment and elastic beanstalk's Tomcat 7. This solution is also laid out at the AWS Forums here, and here.

这篇关于带有Elastic Beanstalk和Tomcat 7的ClassNotFoundException的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆