Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[eclipselink-users] Really weird bug with Eclipse 2.0

Hi,

I'm running a very simple JUnit test with EclipseLink 1.1 and everything works fine. But when I upgrade to 2.0, that's a different story.

I'm using a Maven structure, so under my src/test/resources I have the following persistence.xml :

<?xml version="1.0" encoding="UTF-8"?>
<persistence xmlns="http://java.sun.com/xml/ns/persistence" version="1.0">

    <persistence-unit name="chapter02PU" transaction-type="RESOURCE_LOCAL">
        <provider>org.eclipse.persistence.jpa.PersistenceProvider</provider>
        <class>com.apress.javaee6.chapter02.Book</class>
        <properties>
            <property name="eclipselink.target-database" value="DERBY"/>
            <property name="eclipselink.ddl-generation" value="drop-and-create-tables"/>
            <property name="eclipselink.logging.level" value="FINE"/>
            <property name="eclipselink.jdbc.driver" value="org.apache.derby.jdbc.EmbeddedDriver"/>
            <property name="eclipselink.jdbc.url" value="jdbc:derby:memory:chapter02DB;create=true"/>
            <property name="eclipselink.jdbc.user" value="APP"/>
            <property name="eclipselink.jdbc.password" value="APP"/>
        </properties>
    </persistence-unit>
</persistence> 


I'm using Derby 10.5 with in-memory database (jdbc:derby:memory). When I run my test (mvn test) I have the following stacktrace that tells me that EclipseLink needs to connect to Derby port 1527. That's the default port when Derby is running as a database server, not an in-memory db :


Running org.javaee6.chapter02.BookTest
[EL Info]: 2009-12-26 17:19:15.582--ServerSession(25383554)--EclipseLink, version: Eclipse Persistence Services - 2.0.0.v20091127-r5931
[EL Severe]: 2009-12-26 17:19:17.96--ServerSession(25383554)--Local Exception Stack:
Exception [EclipseLink-4002] (Eclipse Persistence Services - 2.0.0.v20091127-r5931): org.eclipse.persistence.exceptions.DatabaseException
Internal Exception: java.sql.SQLNonTransientConnectionException: java.net.ConnectException : l'erreur lors de la connexion au serveur localh
ost sur le port 1527 a Úmis le message Connection refused: connect.
Error Code: 40000
        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.startUp(ConnectionPool.java:433)
        at org.eclipse.persistence.sessions.server.ServerSession.connect(ServerSession.java:495)
        at org.eclipse.persistence.internal.sessions.DatabaseSessionImpl.login(DatabaseSessionImpl.java:632)
        at org.eclipse.persistence.internal.jpa.EntityManagerFactoryProvider.login(EntityManagerFactoryProvider.java:230)
        at org.eclipse.persistence.internal.jpa.EntityManagerSetupImpl.deploy(EntityManagerSetupImpl.java:368)
        at org.eclipse.persistence.internal.jpa.EntityManagerFactoryImpl.getServerSession(EntityManagerFactoryImpl.java:151)
        at org.eclipse.persistence.internal.jpa.EntityManagerFactoryImpl.createEntityManagerImpl(EntityManagerFactoryImpl.java:207)
        at org.eclipse.persistence.internal.jpa.EntityManagerFactoryImpl.createEntityManager(EntityManagerFactoryImpl.java:195)
        at org.javaee6.chapter02.BookTest.initEntityManager(BookTest.java:39)


That's because in src/main/resources I have the following persistence.xml that uses Derby DB server and not in-memory (I use in-memory for testing, and DB server for runtime) :


<?xml version="1.0" encoding="UTF-8"?>
<persistence xmlns="http://java.sun.com/xml/ns/persistence" version="1.0">

    <persistence-unit name="chapter02PU" transaction-type="RESOURCE_LOCAL">
        <provider>org.eclipse.persistence.jpa.PersistenceProvider</provider>
        <class>com.apress.javaee6.chapter02.Book</class>
        <properties>
            <property name="eclipselink.target-database" value="DERBY"/>
            <property name="eclipselink.ddl-generation" value="drop-and-create-tables"/>
            <property name="eclipselink.logging.level" value="FINE"/>
            <property name="eclipselink.jdbc.driver" value="org.apache.derby.jdbc.EmbeddedDriver"/>
            <property name="eclipselink.jdbc.url" value="jdbc:derby:memory:chapter02DB;create=true"/>
            <property name="eclipselink.jdbc.user" value="APP"/>
            <property name="eclipselink.jdbc.password" value="APP"/>
        </properties>
    </persistence-unit>
</persistence>


This is strange, it looks like EclipseLink mixes up the Derby server (persistence.xml in src/main/resources) and in-memory Derby (persistence.xml in src/test/resources). But what's really really weird, is when I delete the src/main/resources/persistence.xml and run mvn test, it works !

Again, all this works perfectly with EclipseLink 1.1. I've uploaded a very simple test at http://www.antoniogoncalves.org/xwiki/bin/download/Main/Attach/bugeclipselink.zip

If anybody has an idea...
Thanks,
Antonio

Back to the top