Amazon AWS Glassfish Mysqldatasource类名错误或未设置classpath

时间:2017-07-12 11:12:18

标签: amazon-web-services amazon-ec2 glassfish aws-ebs

我使用预配置的AWS Linux AMI和Glassfish Elastic Beanstalk来部署我的java Web服务。我已设法设置我的RDS,并且在运行本地连接到AWS RDS的glassfish时工作正常。只有在AWS EBS上运行Web服务时才会出现此问题。从我可以看到它似乎是mysql连接器,但由于某些原因没有被应用程序检测到。不幸的是,Glassfish文件夹隐藏在linux EC2中。任何人都可以建议我应该采取什么措施来解决这个异常?

     remote failure: Error occurred during deployment: Exception while deploying the app [current-app] : Exception [EclipseLink-4002] (Eclipse Persistence Services - 2.5.2.v20140319-9ad6abd): org.eclipse.persistence.exceptions.DatabaseException

    Internal Exception: java.sql.SQLException: Error in allocating a connection. Cause: Class name is wrong or classpath is not set for : com.mysql.jdbc.jdbc2.optional.MysqlDataSource

Error Code: 0. Please see server.log for more details.
    Command deploy failed.

我有SSH并运行此yum,但它没有解决问题。

sudo yum install mysql-connector-java

由于

     adding: WEB-INF/lib/aopalliance-repackaged-2.5.0-b32.jar (deflated 34%)
  adding: WEB-INF/lib/javassist-3.20.0-GA.jar (deflated 7%)
  adding: WEB-INF/lib/javax.ws.rs-api-2.0.1.jar (deflated 14%)
  adding: WEB-INF/lib/jersey-container-servlet-2.25.1.jar (deflated 21%)
  adding: WEB-INF/lib/validation-api-1.1.0.Final.jar (deflated 25%)
  adding: WEB-INF/lib/mysql-connector-java-6.0.6.jar (deflated 6%)
  adding: WEB-INF/lib/jersey-common-2.25.1.jar (deflated 12%)
  adding: WEB-INF/lib/hk2-utils-2.5.0-b32.jar (deflated 12%)
  adding: WEB-INF/lib/javax.inject-2.5.0-b32.jar (deflated 24%)
  adding: WEB-INF/lib/osgi-resource-locator-1.0.1.jar (deflated 15%)
  adding: WEB-INF/lib/jersey-server-2.25.1.jar (deflated 14%)
  adding: WEB-INF/lib/jersey-guava-2.25.1.jar (deflated 15%)
  adding: WEB-INF/lib/hk2-api-2.5.0-b32.jar (deflated 13%)
  adding: WEB-INF/lib/hk2-locator-2.5.0-b32.jar (deflated 7%)
  adding: WEB-INF/lib/jersey-client-2.25.1.jar (deflated 12%)
  adding: WEB-INF/lib/jersey-media-jaxb-2.25.1.jar (deflated 14%)
  adding: WEB-INF/lib/jersey-container-servlet-core-2.25.1.jar (deflated 16%)

1 个答案:

答案 0 :(得分:0)

在网上挖掘并测试一些东西之后。我设法找到了问题,在Glass Glassfish AMI上看不到glassfish文件夹。因此,您必须使用以下代码在Web页面(项目名称> Web页面)Netbeans项目中创建Dockerfile(无文件扩展名)。由于某些原因,我的应用程序不会拿起domain1 / lib中的jar,所以我把它放在glassfish / lib上

# Use the AWS Elastic Beanstalk GlassFish image
FROM amazon/aws-eb-glassfish:4.1-jdk8-onbuild-3.5.1

EXPOSE 8080 3306

# Install MySQL dependencies
RUN curl -L -o /usr/local/glassfish4/glassfish/domains/domain1/lib/mysql-connector-java-5.1.23.jar https://repo1.maven.org/maven2/mysql/mysql-connector-java/5.1.23/mysql-connector-java-5.1.23.jar  
RUN curl -L -o /usr/local/glassfish4/glassfish/lib/mysql-connector-java-5.1.23.jar https://repo1.maven.org/maven2/mysql/mysql-connector-java/5.1.23/mysql-connector-java-5.1.23.jar  
RUN /usr/local/glassfish4/bin/asadmin restart-domain