Results 1 to 1 of 1
- 08-19-2016, 07:40 PM #1
Member
- Join Date
- Aug 2016
- Posts
- 2
- Rep Power
- 0
Glassfish + Eclipse => Problem with Redeploy und EJB (Resource not available)
Hey everybody,
I've got started learning some Java EE stuff and choose the Glassfish server as application server for the first example. There I observe an behavior, that I do not understood completely, and hopefully here is anybody who can help.
My application is really simple, consists of content copied out from an tutorial and represents and guestbook java EE application with a jsp servlet web tier and the webbrowser as client.
The behavior is, that when I run the application the first time in the glassfish application server, everything is okay. But if I change something that requires an redeploy, I got the following error:
HTTP Status 404 - Not Found
type Status report
messageNot Found
descriptionThe requested resource is not available.
------------------------------------------------------------
GlassFish Server Open Source Edition 4.1.1
In the output I got the following warnings multiple times:
Warning: Ignoring WEB-INF/ because the containing archive D:\glassfish\glassfish4\glassfish\domains\domain1\ applications\Guestbook recorded it as a pre-existing stale file
So I played a little bit with the error and I figured out that the problem seems to be the EntityManager, which is injected into my EJB as PersistenceContext from the application server.
If i remove the EntityManager from my EJB, the problem is solved. I guess that the problem is, that I never dispose or close the EntityManager, but cause in the tutorials I saw this is never done I am not sure to do it or not.
The examples I found that dispose the EntityManager are these who provides a factory method to obtain the EntityManager manually....
Here is my EJB:
Java Code:package guest; import java.util.List; import javax.ejb.Stateless; import javax.persistence.EntityManager; import javax.persistence.PersistenceContext; import javax.persistence.TypedQuery; @Stateless public class GuestDao { // Injected database connection: @PersistenceContext private EntityManager em; // Stores a new guest: public void persist(Guest guest) { em.persist(guest); } // Retrieves all the guests: public List<Guest> getAllGuests() { TypedQuery<Guest> query = em.createQuery( "SELECT g FROM Guest g ORDER BY g.id", Guest.class); return query.getResultList(); } }
Kind regards
Similar Threads
-
Eclipse error: Scanner resource leak
By NorrinGalan in forum EclipseReplies: 0Last Post: 02-07-2014, 04:40 AM -
Resource leak on eclipse. How to fix?
By the5thace in forum New To JavaReplies: 3Last Post: 07-12-2012, 03:29 PM -
Install GlassFish on Eclipse Helios: CREDENTIAL_ERROR
By mirty89 in forum EclipseReplies: 0Last Post: 09-30-2011, 12:27 PM -
eclipse with glassfish problem
By mos33 in forum EclipseReplies: 0Last Post: 12-30-2009, 09:39 PM -
Jboss redeploy JMS service
By subhendu.snandi in forum Enterprise JavaBeans (EJB)Replies: 2Last Post: 10-31-2009, 07:36 AM
Bookmarks