Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
AW: [eclipselink-dev]EntityManagerJUnitTestSuite.testLockWithJoinedInheritanceStrategy:NPE

Hi Andrei,

the fix fixes the issue I observed.

Thanks a lot!

-Adrian

=======

Adrian Görler
SAP AG

Pflichtangaben/Mandatory Disclosure Statements: http://www.sap.com/company/legal/impressum.epx


-----Ursprüngliche Nachricht-----
Von: Andrei Ilitchev [mailto:andrei.ilitchev@xxxxxxxxxx]
Gesendet: Montag, 7. Dezember 2009 23:29
An: Goerler, Adrian
Cc: Dev mailing list for Eclipse Persistence Services
Betreff: Re: [eclipselink-dev]EntityManagerJUnitTestSuite.testLockWithJoinedInheritanceStrategy:NPE

Hi Adrian,

I apologize for the delay.

I still don't understand why (and if) the password becomes corrupted.

Could you please try applying the patch in Bug 297137 - Passing the same
user/password to both createEMF and createEM causes EM to open new
connection
https://bugs.eclipse.org/bugs/show_bug.cgi?id=297137

Thanks,

Andrei
----- Original Message -----
From: "Goerler, Adrian" <adrian.goerler@xxxxxxx>
To: "Andrei Ilitchev" <andrei.ilitchev@xxxxxxxxxx>
Cc: "Dev mailing list for Eclipse Persistence Services"
<eclipselink-dev@xxxxxxxxxxx>
Sent: Wednesday, December 02, 2009 3:05 AM
Subject: AW:
[eclipselink-dev]EntityManagerJUnitTestSuite.testLockWithJoinedInheritanceStrategy:NPE


Hi Andrei,

I was a bit short in my explanation:

testEMCloseAndOpen and testEMFactoryCloseAndOpen use the DriverWrapper. The
DriverWrapper seems to be a JDBC driver that registers with the
java.sql.DriverManager. It accepts just the same URLs as the MySQL Driver
but is chained after the MySQL driver.

testEMCloseAndOpen and testEMFactoryCloseAndOpen reset the DriverWrapper
after usage setting the driverName of the wrapped driver to null.

In testLockWithJoinedInheritanceStrategy it is attempted to create a
connection. But for the some reason, the password encoding is broken and it
is attempted to connect to the MySQL driver using an encoded password, which
fails with an SQLException. Now the java.sql.DriverManager tries the next
driver registered (the DriverWrapper), which throws the NPE as the
driverName is null.


If I do not run testEMCloseAndOpen and testEMFactoryCloseAndOpen but only
testNoPersistOnFlushProperties and testLockWithJoinedInheritanceStrategy, I
don't get the NPE in the driver wrapper but only the causing SQL Exception:

Internal Exception: java.sql.SQLException: Access denied for user
'me'@'localhost' (using password: YES)
Error Code: 1045
        at
org.eclipse.persistence.exceptions.DatabaseException.sqlException(DatabaseException.java:324)
        at
org.eclipse.persistence.exceptions.DatabaseException.sqlException(DatabaseException.java:319)
        at
org.eclipse.persistence.sessions.DefaultConnector.connect(DefaultConnector.java:138)
        at
org.eclipse.persistence.sessions.DatasourceLogin.connectToDatasource(DatasourceLogin.java:162)
        at
org.eclipse.persistence.internal.databaseaccess.DatasourceAccessor.connectInternal(DatasourceAccessor.java:327)
        at
org.eclipse.persistence.internal.databaseaccess.DatabaseAccessor.connectInternal(DatabaseAccessor.java:294)
        at
org.eclipse.persistence.internal.databaseaccess.DatasourceAccessor.connect(DatasourceAccessor.java:415)
        at
org.eclipse.persistence.sessions.server.ConnectionPool.buildConnection(ConnectionPool.java:155)
        at
org.eclipse.persistence.sessions.server.ConnectionPool.acquireConnection(ConnectionPool.java:97)
        at
org.eclipse.persistence.sessions.server.ServerSession.acquireClientConnection(ServerSession.java:241)
        at
org.eclipse.persistence.sessions.server.ClientSession.basicBeginTransaction(ClientSession.java:130)
        at
org.eclipse.persistence.internal.sessions.AbstractSession.beginTransaction(AbstractSession.java:580)
        at
org.eclipse.persistence.internal.sessions.UnitOfWorkImpl.beginTransaction(UnitOfWorkImpl.java:546)
        at
org.eclipse.persistence.internal.sessions.UnitOfWorkImpl.commitToDatabase(UnitOfWorkImpl.java:1346)
        at
org.eclipse.persistence.internal.sessions.RepeatableWriteUnitOfWork.commitToDatabase(RepeatableWriteUnitOfWork.java:547)
        at
org.eclipse.persistence.internal.sessions.UnitOfWorkImpl.commitToDatabaseWithChangeSet(UnitOfWorkImpl.java:1510)
        at
org.eclipse.persistence.internal.sessions.RepeatableWriteUnitOfWork.commitRootUnitOfWork(RepeatableWriteUnitOfWork.java:200)
        at
org.eclipse.persistence.internal.sessions.UnitOfWorkImpl.commitAndResume(UnitOfWorkImpl.java:1131)
        at
org.eclipse.persistence.internal.jpa.transaction.EntityTransactionImpl.commitInternal(EntityTransactionImpl.java:84)
        at
org.eclipse.persistence.internal.jpa.transaction.EntityTransactionImpl.commit(EntityTransactionImpl.java:63)
        at
org.eclipse.persistence.testing.framework.junit.JUnitTestCase.commitTransaction(JUnitTestCase.java:267)
        at
org.eclipse.persistence.testing.tests.jpa.advanced.EntityManagerJUnitTestSuite.testLockWithJoinedInheritanceStrategy(EntityManagerJUnitTestSuite.java:1919)
        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 junit.framework.TestCase.runTest(TestCase.java:168)
        at junit.framework.TestCase.runBare(TestCase.java:134)
        at
org.eclipse.persistence.testing.framework.junit.JUnitTestCase.runBare(JUnitTestCase.java:428)
        at junit.framework.TestResult$1.protect(TestResult.java:110)
        at junit.framework.TestResult.runProtected(TestResult.java:128)
        at junit.framework.TestResult.run(TestResult.java:113)
        at junit.framework.TestCase.run(TestCase.java:124)
        at junit.framework.TestSuite.runTest(TestSuite.java:232)
        at junit.framework.TestSuite.run(TestSuite.java:227)
        at
org.eclipse.jdt.internal.junit.runner.junit3.JUnit3TestReference.run(JUnit3TestReference.java:130)
        at
org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
        at
org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:467)
        at
org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:683)
        at
org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:390)
        at
org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:197)
Caused by: java.sql.SQLException: Access denied for user 'me'@'localhost'
(using password: YES)
        at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:1055)
        at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:956)
        at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:3536)
        at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:3468)
        at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:917)
        at com.mysql.jdbc.MysqlIO.secureAuth411(MysqlIO.java:3974)
        at com.mysql.jdbc.MysqlIO.doHandshake(MysqlIO.java:1282)
        at
com.mysql.jdbc.ConnectionImpl.createNewIO(ConnectionImpl.java:2142)
        at com.mysql.jdbc.ConnectionImpl.<init>(ConnectionImpl.java:773)
        at com.mysql.jdbc.JDBC4Connection.<init>(JDBC4Connection.java:46)
        at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native
Method)
        at
sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)
        at
sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)
        at java.lang.reflect.Constructor.newInstance(Constructor.java:513)
        at com.mysql.jdbc.Util.handleNewInstance(Util.java:406)
        at
com.mysql.jdbc.ConnectionImpl.getInstance(ConnectionImpl.java:352)
        at
com.mysql.jdbc.NonRegisteringDriver.connect(NonRegisteringDriver.java:282)
        at java.sql.DriverManager.getConnection(DriverManager.java:582)
        at java.sql.DriverManager.getConnection(DriverManager.java:154)
<----- this is atempted with the wrong password
        at
org.eclipse.persistence.sessions.DefaultConnector.connect(DefaultConnector.java:98)
        ... 38 more


So, strictly speaking it is not a repro for the NPE but for the cause of the
NPE. Strange that it is working on your side. Sabine is observing the same
issue.

Best regards,

Adrian



Adrian Görler
SAP AG

Pflichtangaben/Mandatory Disclosure Statements:
http://www.sap.com/company/legal/impressum.epx



-----Ursprüngliche Nachricht-----
Von: eclipselink-dev-bounces@xxxxxxxxxxx
[mailto:eclipselink-dev-bounces@xxxxxxxxxxx] Im Auftrag von Andrei Ilitchev
Gesendet: Dienstag, 1. Dezember 2009 18:00
An: Dev mailing list for Eclipse Persistence Services
Betreff: Re:
[eclipselink-dev]EntityManagerJUnitTestSuite.testLockWithJoinedInheritanceStrategy:
NPE

Hi Adrian,

DriverWrapper class that appears on the stack is a test helper class that
currently used only in two EntitymanagerJUnitTsetSuite tests:
testEMCloseAndOpen and testEMFactoryCloseAndOpen.

These two tests use DriverWrapper to simulate dropped connections:
        HashMap properties = new
HashMap(JUnitTestCaseHelper.getDatabaseProperties());
        properties.put(PersistenceUnitProperties.JDBC_DRIVER,
DriverWrapper.class.getName());
        properties.put(PersistenceUnitProperties.JDBC_URL,
DriverWrapper.codeUrl(originalConnectionString));
        getEntityManagerFactory(properties);

I can't explain how DriverWrapper would show up when none of these two tests
have run (your reproducing the problem with just two tests).

However if one or both these tests have run before,
it is possible that the JDBC_DRIVER and JDBC_URL they provided are still
used by the factory
(though each of the two tests supposed to clean up after themselves).

You could comment out testEMCloseAndOpen and testEMFactoryCloseAndOpen -
that should remove any usage of DriverWrapper.

But to get to the bottom of it we need to figure out why the factory (or the
server session owned by the factory) is not properly cleaned up of
DriverWrapper.

I can't reproduce the problem so far.

Thanks,

Andrei


----- Original Message -----
From: "Goerler, Adrian" <adrian.goerler@xxxxxxx>
To: "tom Ware" <tom.ware@xxxxxxxxxx>
Cc: "Dev mailing list for Eclipse Persistence Services"
<eclipselink-dev@xxxxxxxxxxx>
Sent: Tuesday, December 01, 2009 11:26 AM
Subject: AW:
[eclipselink-dev]EntityManagerJUnitTestSuite.testLockWithJoinedInheritanceStrategy:
NPE


Hi Tom, all,

I have correctly set the driver name in test.properties.

The issue is something different. This is what I have found out so far:

EntityManagerJUnitTestSuite.testLockWithJoinedInheritanceStrategy is the
only test failing for me.

I can reproduce the issue by reducing the testsuite as follows:

    public static Test suite() {
        TestSuite suite = new TestSuite();
        suite.setName("EntityManagerJUnitTestSuite");

        suite.addTest(new
EntityManagerJUnitTestSuite("testNoPersistOnFlushProperties"));

        suite.addTest(new
EntityManagerJUnitTestSuite("testLockWithJoinedInheritanceStrategy"));

        return suite;
    }

It appears that the database passwords are kept in some encrypted form and
that the test "testNoPersistOnFlushProperties" confuses the encryption
somehow.

"testLockWithJoinedInheritanceStrategy" then fails to create a connection as
it attempts to use an encrypted password to connect.

Anyone any idea on this?


-Adrian

Adrian Görler
SAP AG

Pflichtangaben/Mandatory Disclosure Statements:
http://www.sap.com/company/legal/impressum.epx


-----Ursprüngliche Nachricht-----
Von: eclipselink-dev-bounces@xxxxxxxxxxx
[mailto:eclipselink-dev-bounces@xxxxxxxxxxx] Im Auftrag von Tom Ware
Gesendet: Dienstag, 1. Dezember 2009 15:14
An: Dev mailing list for Eclipse Persistence Services
Betreff: Re: [eclipselink-dev]
EntityManagerJUnitTestSuite.testLockWithJoinedInheritanceStrategy: NPE

Hi Adrian,

   It looks like driverName is null in the call:

                 driver = (Driver)Class.forName(driverName, true,
Thread.currentThread().getContextClassLoader()).newInstance();

   Driver name should come from a file called test.properties.  There are
test.properties files in <base>/jpa/eclipselink.jpa.test and
<base>/foundation/eclipselink.core.test.  Depending on whether you are
running
the jpa tests or the core tests, those files will be used to get the driver
name.  To override those files, put a file called test.properties in your
<user-home> directory and override any settings you need to override.

-Tom

Goerler, Adrian wrote:
> Hi,
>
> executing the JPA LRG tests on MySQL, I am observing the following issue
> with EntityManagerJUnitTestSuite.testLockWithJoinedInheritanceStrategy:
>
> Exception Description: DriverWrapper: failed to instantiate null
> Internal Exception: java.lang.NullPointerException
>
> Local Exception Stack:
> Exception [EclipseLink-0] (Eclipse Persistence Services -
> 2.0.0.qualifier):
> org.eclipse.persistence.testing.framework.TestProblemException
> Exception Description: DriverWrapper: failed to instantiate null
> Internal Exception: java.lang.NullPointerException
> at
> org.eclipse.persistence.testing.framework.DriverWrapper.getDriver(DriverWrapper.java:191)
> at
> org.eclipse.persistence.testing.framework.DriverWrapper.connect(DriverWrapper.java:226)
> at java.sql.DriverManager.getConnection(DriverManager.java:582)
> at java.sql.DriverManager.getConnection(DriverManager.java:154)
> at
> org.eclipse.persistence.sessions.DefaultConnector.connect(DefaultConnector.java:98)
> at
> org.eclipse.persistence.sessions.DatasourceLogin.connectToDatasource(DatasourceLogin.java:162)
> at
> org.eclipse.persistence.internal.databaseaccess.DatasourceAccessor.connectInternal(DatasourceAccessor.java:327)
> at
> org.eclipse.persistence.internal.databaseaccess.DatabaseAccessor.connectInternal(DatabaseAccessor.java:294)
> at
> org.eclipse.persistence.internal.databaseaccess.DatasourceAccessor.connect(DatasourceAccessor.java:415)
> at
> org.eclipse.persistence.sessions.server.ConnectionPool.buildConnection(ConnectionPool.java:155)
> at
> org.eclipse.persistence.sessions.server.ConnectionPool.acquireConnection(ConnectionPool.java:97)
> at
> org.eclipse.persistence.sessions.server.ServerSession.acquireClientConnection(ServerSession.java:241)
> at
> org.eclipse.persistence.sessions.server.ClientSession.basicBeginTransaction(ClientSession.java:130)
> at
> org.eclipse.persistence.internal.sessions.AbstractSession.beginTransaction(AbstractSession.java:580)
> at
> org.eclipse.persistence.internal.sessions.UnitOfWorkImpl.beginTransaction(UnitOfWorkImpl.java:546)
> at
> org.eclipse.persistence.queries.ObjectLevelReadQuery.executeDatabaseQuery(ObjectLevelReadQuery.java:973)
> at
> org.eclipse.persistence.queries.DatabaseQuery.execute(DatabaseQuery.java:675)
> at
> org.eclipse.persistence.queries.ObjectLevelReadQuery.execute(ObjectLevelReadQuery.java:958)
> at
> org.eclipse.persistence.queries.ReadObjectQuery.execute(ReadObjectQuery.java:399)
> at
> org.eclipse.persistence.queries.ObjectLevelReadQuery.executeInUnitOfWork(ObjectLevelReadQuery.java:1021)
> at
> org.eclipse.persistence.internal.sessions.UnitOfWorkImpl.internalExecuteQuery(UnitOfWorkImpl.java:2863)
> at
> org.eclipse.persistence.internal.sessions.AbstractSession.executeQuery(AbstractSession.java:1225)
> at
> org.eclipse.persistence.internal.sessions.AbstractSession.executeQuery(AbstractSession.java:1207)
> at
> org.eclipse.persistence.internal.sessions.AbstractSession.executeQuery(AbstractSession.java:1167)
> at
> org.eclipse.persistence.internal.jpa.EntityManagerImpl.executeQuery(EntityManagerImpl.java:733)
> at
> org.eclipse.persistence.internal.jpa.EntityManagerImpl.lock(EntityManagerImpl.java:1495)
> at
> org.eclipse.persistence.testing.tests.jpa.advanced.EntityManagerJUnitTestSuite.testLockWithJoinedInheritanceStrategy(EntityManagerJUnitTestSuite.java:1943)
> at
> org.eclipse.persistence.testing.framework.junit.JUnitTestCase.runBare(JUnitTestCase.java:428)
> at
> org.eclipse.persistence.testing.framework.TestExecutor.execute(TestExecutor.java:248)
> at
> org.eclipse.persistence.testing.framework.TestModel.execute(TestModel.java:208)
> at
> org.eclipse.persistence.testing.framework.TestCollection.run(TestCollection.java:313)
> Caused by: java.lang.NullPointerException
> at java.lang.Class.forName0(Native Method)
> at java.lang.Class.forName(Class.java:247)
> at
> org.eclipse.persistence.testing.framework.DriverWrapper.getDriver(DriverWrapper.java:189)
>
> So far, I have not been able to hunt it down.
>
> Is anyone observing this also or knows how to fix this?
>
> -Adrian
>
>
> *Adrian Görler
> **SAP AG
>
> *Pflichtangaben/Mandatory Disclosure Statements:
> _http://www.sap.com/company/legal/impressum.epx_
>
>
>
>
>
> ------------------------------------------------------------------------
>
> _______________________________________________
> eclipselink-dev mailing list
> eclipselink-dev@xxxxxxxxxxx
> https://dev.eclipse.org/mailman/listinfo/eclipselink-dev
_______________________________________________
eclipselink-dev mailing list
eclipselink-dev@xxxxxxxxxxx
https://dev.eclipse.org/mailman/listinfo/eclipselink-dev
_______________________________________________
eclipselink-dev mailing list
eclipselink-dev@xxxxxxxxxxx
https://dev.eclipse.org/mailman/listinfo/eclipselink-dev

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



Back to the top