Skip to main content

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

Hello Antonio,

There were many changes from 1.1 to 2.0, but I do not know of any personally that would account for the behavior you are seeing, but someone else might be able to comment further. You statement doesn't make sense to me though - if the tests will overwrite the main/resources/persistence.xml file with the correct file, this would imply that both files are exactly the same - so where is the incorrect login coming from? I still believe you have a version of the incorrect persistence.xml file on your classpath with the same persistence unit name being used. As mentioned, this would be incorrect and cause problems when loading persistence units. What do the logs show during start up - it should show each persistence unit it finds getting loaded.

Best Regards,
Chris

Antonio Goncalves wrote:
When I'm doing tests Maven will overwrite the src/main/resources/persistence.xml with the src/test/resources/persistence.xml. As I said, this behaviour works fine with EclipseLink 1.1.
Antonio

2010/1/5 christopher delahunt <christopher.delahunt@xxxxxxxxxx <mailto:christopher.delahunt@xxxxxxxxxx>>

    Hello Antonio,

    When you look for the persistence unit named "chapter02PU",
    providers will find two persistence.xml files on your classpath,
    both with persistence units named "chapter02PU".  It is luck of
    the draw as to which one will be returned.

    It is required to give them unique names if both are on the
    classpath so that they can be distinguished from each other.

    Best Regards,
    Chris

    Antonio Goncalves wrote:

        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
        ------------------------------------------------------------------------

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




--
--
Antonio Goncalves (antonio.goncalves@xxxxxxxxx <mailto:antonio.goncalves@xxxxxxxxx>)
Software architect

Web site : www.antoniogoncalves.org <http://www.antoniogoncalves.org>
Blog: agoncal.wordpress.com <http://agoncal.wordpress.com>
Feed: feeds2.feedburner.com/AntonioGoncalves <http://feeds2.feedburner.com/AntonioGoncalves>
Paris JUG leader : www.parisjug.org <http://www.parisjug.org>
LinkedIn: www.linkedin.com/in/agoncal <http://www.linkedin.com/in/agoncal>
------------------------------------------------------------------------

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


Back to the top