7

私はJava EEの初心者です。今日、私はこのチュートリアルに従って Java EE を学ぼうとしました: http://netbeans.org/kb/docs/javaee/javaee-gettingstarted.html

基本的に、Netbeans を使用して Java Web カテゴリから Web アプリケーションを作成する方法を説明します。

アプリケーションを実行すると、次のような Build Failed エラー メッセージが表示されました。

  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)

このプロジェクトを作成するときに、すでにグラスフィッシュ サーバーをオンにして、グラスフィッシュをサーバーとして選択していますが、サーバーが接続を拒否しているようです。

4

3 に答える 3

8

ファイルに移動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>
于 2012-08-02T21:54:29.887 に答える
4

The Java DB runs on port 1527. It looks like it's not running in your case.

Click on the "Output" tab in your NetBeans IDE and view the "Java DB Database Process" console.

You should see the following lines:

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

If you don't see those lines try to investigate why the Java DB process is not starting up.

于 2012-07-03T21:02:47.443 に答える
2

Glassfish 管理コンソール、JDBC、JDBC 接続プールに移動し、接続プールの追加プロパティを確認します。私の場合、PortNumber が 1527 の DerbyPool があり、変更しました。

于 2015-08-14T19:32:44.103 に答える