Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

JavaEE project fail to deploy

I am beginner in Java EE. Today I tried to learn Java EE by following this tutorial: http://netbeans.org/kb/docs/javaee/javaee-gettingstarted.html

It basically teaches how to create a Web Application from Java Web categories using Netbeans.

When I run the application, I got the Build Failed error message like this:

  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)

I already turn glassfish server on and choose glassfish as the server when creating this project but it looks like the server denies connection.

like image 275
u19964 Avatar asked Jul 03 '12 20:07

u19964


3 Answers

Go persistence.xml file, and add "jta-data-source" tag with your database connection pool name in it.

You can find the name of your connection pool in Glassfish admin console. Resources->JDBC->JDBC Connection Pools

<persistence-unit name="Project-name">
    <jta-data-source>jdbc/mysqlpool</jta-data-source>
    <class>....</class>
</persistence-unit>
like image 153
Mike Avatar answered Nov 18 '22 10:11

Mike


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.

like image 4
munyengm Avatar answered Nov 18 '22 09:11

munyengm


Go to Glassfish admin console, JDBC, JDBC Connection Pools, and check the Additional Properties from your Connection Pools. In my case, i have a DerbyPool, where the PortNumber was 1527, i changed it.

like image 2
Aleja Chica Avatar answered Nov 18 '22 10:11

Aleja Chica