Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [eclipselink-users] v. 1.0.2 EntityManagerFactoryImpl throwing null pointer exception on connection



Tom Ware wrote:
Hi Gordon,

  It sounds like you are using the default EclipseLink connection pool.

No doubt. I did try with
snip ...
emfProperties.put(JDBC_READ_CONNECTIONS_MIN, "1");
emfProperties.put(JDBC_WRITE_CONNECTIONS_MIN, "1");
// Ensure that no server-platform is configured
emfProperties.put(TARGET_SERVER, TargetServer.None);
etc
But the problem remained.

Is there any particular reason you have chosen to close your EntityManagerFactory? What happens if you simply acquire a new entityManager from the same factory? Do you have problems with the connection?

I did try some variations. Closing and recreating everything seemed
the most likely way to get a fresh start. Shot in the dark in other words.

I have just (re)tried: close the EntityManager and get a new one from
the existing factory; the problem appears unchanged.

One, perhaps interesting, note about the stack trace: EL logs
a successful login before throwing the null pointer exception.
I don't see the login success when the underlying network
connection is unavailable.

Thanks again,
Gordon

-Tom

Gordon Ferguson wrote:


Tom Ware wrote:
Hi Gordon,

  Are you running in JavaSE or in some kind of container?
JavaSE

  Are you using a connection pool?
not as far as I know. Should I be?

  Is it external to EclipseLink or EclipseLink's own connection pool?
n/a?

  How does your test obtain the connection and reestablish it?


 >>   emf = Persistence.createEntityManagerFactory(persistenceUnitLabel);
 >>   entityManager = emf.createEntityManager();


I am not surprised that the scenario you are describing is causing issues. EclipseLink has some strategies you can use to reestablish connections, but doing it somewhere EclipseLink is completely unaware of could cause an issue.

So, what is the most simple solution? The actual application runs in Tomcat; database is sometimes Oracle sometimes MySQL. (The JNDI stuff
seems to multiply code complexity, do I really have to go there? )

Many thanks,
Gordon


-Tom

Gordon Ferguson wrote:
Hi Tom,
It has been a few weeks but I'm back to this question.

The basic scenario I'm having trouble with is recovery after a
SQLException: Io exception: The Network Adapter could not establish the connection ...

My test case forces that error and then restores the underlying
connection. I then want to get EclipseLink going again.

Is there an api to get a (new?) working EntityMangager at this point?

What I'm trying is invoke close() both the EntityManager and the
EntityManagerFactory. (Nothing thrown by this.) Then I repeat this code:

protected  void privateInit(String persistenceUnitLabel, ...) {
emf = Persistence.createEntityManagerFactory(persistenceUnitLabel); entityManager = emf.createEntityManager();
  ...
}

and the first line creates the stack trace below.

Thanks for any suggestions,
Gordon

Tom Ware wrote:
Hi Gordon,

If EclipseLink is following the expected code path, the structConverters should be initialized inside the "if (state == STATE_PREDEPLOYED) {" code block below where the structConverters variable is being defined on the following line:

structConverters = processor.getStructConverters();

If you are not getting into that if statement and still getting to "addStructConverters(session, structConverters)" something strange is occurring with your deployment. It is hard to say what the problem is without more information about the symptoms of the problem you are seeing.

-Tom

Gordon Ferguson wrote:
Hello,

I'm using the SE approach and testing my 'recovery after error' logic.
I see the exception listed below. I looked at the code and found
EntityManagerSetupImpl.deploy() method initializes
structConverters to null in l.189
Then, in l. 319 passes that null to addStructConverters(...) which tries to add to the (null) List.
 List<StructConverter> structConverters = null;

SO, I'm wondering if this is just a coding typo or if I need to dig deeper
into why I'm in this state?

Any suggestions would be appreciated.

Thanks,
Gordon







Listing:

[EL Info]: 2008.10.30 11:53:03.781--ServerSession(653967)--EclipseLink, version: Eclipse Persistence Services - 1.0.2 (Build 20081024) Exception in thread "main" [EL Info]: 2008.10.30 11:53:10.328--ServerSession(653967)--file:/D:/projs/costar-1.3/jclass/-True-DevDev login successful
costar.dbaccess.DbAccessException: Could not access database.
at costar.dbaccess.jpa.CoStarJpaAccess.privateInit(CoStarJpaAccess.java:82) at costar.dbaccess.jpa.CoStarJpaAccess.<init>(CoStarJpaAccess.java:53) at costar.dbaccess.jpa.test.JpaConnectionCheckerChecker.main(JpaConnectionCheckerChecker.java:104)
Caused by: java.lang.NullPointerException
at org.eclipse.persistence.internal.jpa.EntityManagerSetupImpl.addStructConverters(EntityManagerSetupImpl.java:319) at org.eclipse.persistence.internal.jpa.EntityManagerSetupImpl.deploy(EntityManagerSetupImpl.java:249) at org.eclipse.persistence.internal.jpa.EntityManagerFactoryImpl.getServerSession(EntityManagerFactoryImpl.java:69) at org.eclipse.persistence.internal.jpa.EntityManagerFactoryImpl.createEntityManagerImpl(EntityManagerFactoryImpl.java:118) at org.eclipse.persistence.internal.jpa.EntityManagerFactoryImpl.createEntityManagerImpl(EntityManagerFactoryImpl.java:112) at org.eclipse.persistence.internal.jpa.EntityManagerFactoryImpl.createEntityManager(EntityManagerFactoryImpl.java:100) at costar.dbaccess.jpa.CostarJpaFacade.<init>(CostarJpaFacade.java:47) at costar.dbaccess.jpa.CoStarJpaAccess.privateInit(CoStarJpaAccess.java:80)
    ... 2 more

_______________________________________________
eclipselink-users mailing list
eclipselink-users@xxxxxxxxxxx
https://dev.eclipse.org/mailman/listinfo/eclipselink-users
_______________________________________________
eclipselink-users mailing list
eclipselink-users@xxxxxxxxxxx
https://dev.eclipse.org/mailman/listinfo/eclipselink-users

_______________________________________________
eclipselink-users mailing list
eclipselink-users@xxxxxxxxxxx
https://dev.eclipse.org/mailman/listinfo/eclipselink-users
_______________________________________________
eclipselink-users mailing list
eclipselink-users@xxxxxxxxxxx
https://dev.eclipse.org/mailman/listinfo/eclipselink-users

_______________________________________________
eclipselink-users mailing list
eclipselink-users@xxxxxxxxxxx
https://dev.eclipse.org/mailman/listinfo/eclipselink-users
_______________________________________________
eclipselink-users mailing list
eclipselink-users@xxxxxxxxxxx
https://dev.eclipse.org/mailman/listinfo/eclipselink-users



Back to the top