2012-07-03 40 views
6

我在Java EE的初学者。今天,我尝试按照本教程学习Java EE: http://netbeans.org/kb/docs/javaee/javaee-gettingstarted.htmlJavaEE的项目无法部署

它基本上教会了如何使用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作为服务器,但它看起来像服务器拒绝连接。

+0

你可以发布glassfish server.log文件中的内容吗? – Preston

+0

我找不到它。它是玻璃鱼3.1.2。 – qusr

回答

4

在端口1527的Java DB运行它看起来像它不是在你的情况下运行。

单击您的NetBeans IDE中的“输出”选项卡,并查看“Java DB数据库进程”控制台。

您应该看到以下行:

Tue Jul 03 20:25:43 BST 2012 : Security manager installed using the Basic server security policy. 
Tue Jul 03 20:25:44 BST 2012 : Apache Derby Network Server - 10.8.1.2 - (1095077) started and ready to accept connections on port 1527 

如果你没有看到那些行试图调查为何Java DB的进程无法启动。

5

围棋persistence.xml文件,并添加在它的数据库连接池名称“JTA数据源”标签。

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

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

这对我有用,谢谢,但您应该添加的名称不是来自JDBC连接池的名称,而是来自JDBC资源的名称。 – 2013-06-12 14:06:26

2

转到GlassFish管理控制台,JDBC,JDBC连接池,并从连接池检查附加属性。在我的情况下,我有一个DerbyPool,其中PortNumber是1527,我改变了它。