Only persistence units with transaction type JTA can be used as a container managed entity manager

NetBeans can use multiple deployment servers. When your web application uses the Entity Framework and you select the Glassfish server as the deployment server, you can get the error message when you try to run your application in the IDEÉ

Severe: Exception while preparing the app : The persistence-context-ref-name […] in module […] resolves to a persistence unit called […] which is of type RESOURCE_LOCAL. Only persistence units with transaction type JTA can be used as a container managed entity manager. Please verify your application.

When you first run the application NetBeans asks you to select the deployment server you want to use.

If only the Glassfish server is available, and Tomcat is installed on your workstation, add Tomcat to the available deployment servers.

Install Tomcat

For the Tomcat installation see Tomcat web server installation

Add Tomcat to the NetBeans server list

  1. In the Tools menu select Servers
  2. Click the Add Server button
  3. In the list select the Apache Tomcat or TomEEE server
  4. Click the Browse… button
  5. Select the Tomcat directory on your workstation
  6. Enter a Tomcat username and password for NetBeans, and click the Finish button.
  7. The user will be created in the tomcat-users.xml file in the Tomcat conf directory
  8. Click the Close button.

Select the Deployment Server

  1. Right-click the NetBeans project and select Run
  2. In the Select deployment server window select Apache Tomcat or TomEE

If the Select deployment server window does not pop up

  1. Right-click the NetBeans project and select Set Configuration -> Customize
  2. On the Run tab select the Apache server.

Starting of Tomcat failed, the server port 8080 is already in use

  1. If the Glassfish server already started, Tomcat cannot use the same ports and an error message will appear in the NetBeans RunOutput tab
  2. To stop the Glassfish server, restart your workstation.

Leave a Reply