gpt4 book ai didi

JavaEE 项目部署失败

转载 作者:塔克拉玛干 更新时间:2023-11-03 04:10:36 26 4
gpt4 key购买 nike

我是 Java EE 的初学者。今天我尝试按照本教程学习 Java EE: http://netbeans.org/kb/docs/javaee/javaee-gettingstarted.html

它主要讲授如何使用 Netbeans 从 Java Web 类别创建 Web 应用程序。

当我运行应用程序时,我收到了这样的构建失败错误消息:

  WebApplication1/build/web&name=WebApplication1&contextroot=/WebApplication1&force=true failed on GlassFish Server 3+ 

Error occurred during deployment: Exception while preparing the app : Exception [EclipseLink-4002] (Eclipse Persistence Services - 2.3.2.v20111125-r10461): org.eclipse.persistence.exceptions.DatabaseException

Internal Exception: java.sql.SQLException: Error in allocating a connection.
Cause: Connection could not be allocated because: java.net.ConnectException : Error connecting to server localhost on port 1527 with message Connection refused.

Error Code: 0. Please see server.log for more details.
WebApplication1/nbproject/build-impl.xml:721: The module has not been deployed.
See the server log for details.
BUILD FAILED (total time: 2 seconds)

在创建这个项目时,我已经打开了 glassfish 服务器并选择了 glassfish 作为服务器,但看起来服务器拒绝连接。

最佳答案

转到 persistence.xml 文件,并在其中添加带有您的数据库连接池名称的“jta-data-source”标签。

您可以在 Glassfish 管理控制台中找到连接池的名称。资源->JDBC->JDBC连接池

<persistence-unit name="Project-name">
<jta-data-source>jdbc/mysqlpool</jta-data-source>
<class>....</class>
</persistence-unit>

关于JavaEE 项目部署失败,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11319036/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com