users@glassfish.java.net

RE: Stuck w/ persistence exception

From: Martin Gainty <mgainty_at_hotmail.com>
Date: Wed, 28 Apr 2010 16:47:37 -0400

Hi Sean

How does the grant look in $GF_HOME/domains/domain1/config/server.policy

// Hibernate classes will acquire all permissions (read/execute/connect/delete/and anything else) by default
grant codeBase "file:${HibernateBaseFilder}/lib/-" {
    permission java.security.AllPermission;
};

?
Martin Gainty
______________________________________________
Verzicht und Vertraulichkeitanmerkung/Note de déni et de confidentialité
 
Diese Nachricht ist vertraulich. Sollten Sie nicht der vorgesehene Empfaenger sein, so bitten wir hoeflich um eine Mitteilung. Jede unbefugte Weiterleitung oder Fertigung einer Kopie ist unzulaessig. Diese Nachricht dient lediglich dem Austausch von Informationen und entfaltet keine rechtliche Bindungswirkung. Aufgrund der leichten Manipulierbarkeit von E-Mails koennen wir keine Haftung fuer den Inhalt uebernehmen.
Ce message est confidentiel et peut être privilégié. Si vous n'êtes pas le destinataire prévu, nous te demandons avec bonté que pour satisfaire informez l'expéditeur. N'importe quelle diffusion non autorisée ou la copie de ceci est interdite. Ce message sert à l'information seulement et n'aura pas n'importe quel effet légalement obligatoire. Étant donné que les email peuvent facilement être sujets à la manipulation, nous ne pouvons accepter aucune responsabilité pour le contenu fourni.




From: Sean.Comerford_at_espn.com
To: users_at_glassfish.dev.java.net
Date: Wed, 28 Apr 2010 16:35:30 -0400
Subject: Stuck w/ persistence exception




Stuck w/ persistence exception


So I’m stumped by a strange exception I’m seeing and hoping maybe someone has seen something similar.



My app + config works fine in my standalone dev instance but my prod clustered instance is not (though I’m not sure it’s at all related to clustering).



I have an EJB getting an EMF injected:



@PersistenceUnit(unitName="NbaJpa")

private EntityManagerFactory entityManagerFactory;



That persistence unit is in turn configured to a the JDBC resource:



<persistence-unit name="NbaJpa" transaction-type="RESOURCE_LOCAL">

        <provider>org.hibernate.ejb.HibernatePersistence</provider>

        <non-jta-data-source>jdbc/SportwareNBA</non-jta-data-source>



That JDBC resource is properly configured and targeted + enabled on the cluster instance I’m running on. If I do the Ping test from the admin console, it succeeds.



But at runtime, when I access the EJB using JPA, I’m getting a connection refused exception and it seems to be trying to access the local derby DB on port 1527 (see last part of stack trace below).



Any ideas what to look at? Why would it be trying to access derby instead of the jdbc resource specified in my persistence.xml?



Caused by: javax.persistence.PersistenceException: org.hibernate.exception.GenericJDBCException: Cannot open connection

    at org.hibernate.ejb.AbstractEntityManagerImpl.throwPersistenceException(AbstractEntityManagerImpl.java:614)

    at org.hibernate.ejb.AbstractEntityManagerImpl.find(AbstractEntityManagerImpl.java:202)

    at com.espn.sports.dao.JpaDAOImpl.findById(JpaDAOImpl.java:273)

    at com.espn.sports.ws.basketball.BasketballTeamService.getTeam(BasketballTeamService.java:30)

    at com.espn.sports.ws.basketball.BasketballService.getTeam(BasketballService.java:155)

    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)

    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)

    at java.lang.reflect.Method.invoke(Method.java:597)

    at com.sun.enterprise.security.application.EJBSecurityManager.runMethod(EJBSecurityManager.java:1011)

    at com.sun.enterprise.security.SecurityUtil.invoke(SecurityUtil.java:175)

    at com.sun.ejb.containers.BaseContainer.invokeTargetBeanMethod(BaseContainer.java:2920)

    at com.sun.ejb.containers.BaseContainer.intercept(BaseContainer.java:4011)

    at com.sun.ejb.containers.EJBObjectInvocationHandler.invoke(EJBObjectInvocationHandler.java:203)

    ... 17 more

Caused by: org.hibernate.exception.GenericJDBCException: Cannot open connection

    at org.hibernate.exception.SQLStateConverter.handledNonSpecificException(SQLStateConverter.java:126)

    at org.hibernate.exception.SQLStateConverter.convert(SQLStateConverter.java:114)

    at org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:66)

    at org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:52)

    at org.hibernate.jdbc.ConnectionManager.openConnection(ConnectionManager.java:449)

    at org.hibernate.jdbc.ConnectionManager.getConnection(ConnectionManager.java:167)

    at org.hibernate.jdbc.AbstractBatcher.prepareQueryStatement(AbstractBatcher.java:161)

    at org.hibernate.loader.Loader.prepareQueryStatement(Loader.java:1577)

    at org.hibernate.loader.Loader.doQuery(Loader.java:696)

    at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:259)

    at org.hibernate.loader.Loader.loadEntity(Loader.java:1885)

    at org.hibernate.loader.entity.AbstractEntityLoader.load(AbstractEntityLoader.java:71)

    at org.hibernate.loader.entity.AbstractEntityLoader.load(AbstractEntityLoader.java:65)

    at org.hibernate.persister.entity.AbstractEntityPersister.load(AbstractEntityPersister.java:3062)

    at org.hibernate.event.def.DefaultLoadEventListener.loadFromDatasource(DefaultLoadEventListener.java:434)

    at org.hibernate.event.def.DefaultLoadEventListener.doLoad(DefaultLoadEventListener.java:415)

    at org.hibernate.event.def.DefaultLoadEventListener.load(DefaultLoadEventListener.java:165)

    at org.hibernate.event.def.DefaultLoadEventListener.proxyOrLoad(DefaultLoadEventListener.java:223)

    at org.hibernate.event.def.DefaultLoadEventListener.onLoad(DefaultLoadEventListener.java:126)

    at org.hibernate.impl.SessionImpl.fireLoad(SessionImpl.java:906)

    at org.hibernate.impl.SessionImpl.get(SessionImpl.java:843)

    at org.hibernate.impl.SessionImpl.get(SessionImpl.java:836)

    at org.hibernate.ejb.AbstractEntityManagerImpl.find(AbstractEntityManagerImpl.java:182)

    ... 29 more

Caused by: 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: connect.

    at com.sun.gjc.spi.base.DataSource.getConnection(DataSource.java:115)

    at org.hibernate.ejb.connection.InjectedDataSourceConnectionProvider.getConnection(InjectedDataSourceConnectionProvider.java:46)

    at org.hibernate.jdbc.ConnectionManager.openConnection(ConnectionManager.java:446)

    ... 47 more



-- 
Sean Comerford, Software Engineer
ESPN.com Site Architecture Group
Office: 860.766.6454    Cell: 860.329.5842
 		 	   		  
_________________________________________________________________
The New Busy is not the old busy. Search, chat and e-mail from your inbox.
http://www.windowslive.com/campaign/thenewbusy?ocid=PID28326::T:WLMTAGL:ON:WL:en-US:WM_HMP:042010_3