The Java EE project cannot be deployed

I am a beginner of Java EE Today, I try to learn Java EE according to this tutorial:

It basically teaches how to use NetBeans to create web applications from Java Web categories

When I run the application, I get the build failed error message as follows:

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 have opened the GlassFish server and selected GlassFish as the server when creating this project, but it seems that the server refused to connect

Solution

Go to persistence XML file and add a "JTA data source" tag with the database connection pool name

You can find the name of the connection pool in the GlassFish management console Resources – > JDBC - > JDBC connection pool

<persistence-unit name="Project-name">
    <jta-data-source>jdbc/MysqLpool</jta-data-source>
    <class>....</class>
</persistence-unit>
The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>