Results 1 to 5 of 5

Thread: Toplink not using datasource from applicationContext

  1. #1
    Join Date
    Jul 2007
    Posts
    7

    Default Toplink not using datasource from applicationContext

    I have the below applicationContext.

    My problem is in glassfish using TopLink jpa, toplink is trying to use the default datasource instead of what I have specified in spring. I can tell this because the exception thrown is a sql exception thrown when toplink is trying to connect to the derby datapool instead of my datasource.

    I have added -javaagent:${com.sun.aas.instanceRoot}/lib/spring-agent.jar to my vm config and the log looks like it is loaded.

    Any ideas as to why the entitymanager is using the default connection instead of what I specify in spring?

    I am guessing maybe the the app servers entitymanager is being injected instead of the spring defined one. Though I have followed the many examples around and I think this should not be the case.

    Does spring just create another entitymanager or does it use/modify the app servers?

    I have atteched my applicationContext.xml and persistence.xml in the one file.
    Attached Files Attached Files

  2. #2
    Join Date
    Jun 2006
    Location
    The Netherlands
    Posts
    13,629

    Default

    I expect that you explicitly defined an DataSource in your persistence.xml file so that one is going to be used in favor of the on configured in spring.
    Marten Deinum
    Java Consultant / Pragmatist / Open Source Enthousiast / Author


    Pro Spring MVC: With Web Flow
    Conspect

    Have you read the reference guide.
    Use the [ code ] tags, young padawan

  3. #3
    Join Date
    Jul 2007
    Posts
    7

    Default

    No I didn't that I can tell.

    My persistence.xml only containsthe unit name and that is it.

    Code:
    <persistence>
    	<persistence-unit name="jpaUnit">
    	</persistence-unit>
    </persistence>
    Last edited by wizhippo; Oct 3rd, 2008 at 09:05 AM. Reason: spelling

  4. #4
    Join Date
    Feb 2009
    Location
    hbg, pa
    Posts
    7

    Default Similar issue with petclinic. any ideas?

    Did you ever determine the issue with this?

    I have the same problem trying to run the Petclinic sample after setting up a workspace inside of Jdeveloper 10.1.3.4 and using the applicationContext-jpa.xml setup.

    The persistence.xml in that example has no mention of a datasource. It's all in the applicationContext file. BUT, it still doesn't connect to the database. It appears to be attempting to connect to an OracleDS datasource. This must be defined inside of glassfish/toplink as some sort of default, in combination with how the persistence.xml is loaded.

    The only workarounds that I have so far are:
    1. Define a jdbc/oracleDS datasource
    2. or rename persistence.xml to persistence-xxx.xml and then point the applicationContext-jpa.xml to that file. In that case, I have to define a persistenceUnitManager inside of the context file as well and pass reference that from the EntityManager bean.

    I really wish this example had more instructions.

  5. #5
    Join Date
    Jul 2007
    Posts
    7

    Default

    I have not used it in a while as the project ended up being php based. But if I recall I think my problem was that I did not have

    <property name="eclipselink.target-server" value="SunAS9"/>

    or simular added to my persitence config.

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •