-1

我使用带有 Glassfish Elastic Beanstalk 的预配置 AWS Linux AMI 来部署我的 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%)
4

1 回答 1

0

在网上挖掘并测试了一些东西之后。我设法找到了问题,glassfish 文件夹在 Amazon Glassfish AMI 上不可见。因此,您必须使用以下代码在您的网页(项目名称>网页)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
于 2017-07-14T11:15:57.413 回答