Announcement Announcement Module
Collapse
No announcement yet.
Toplink not using datasource from applicationContext Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

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

  • #2
    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.

    Comment


    • #3
      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, 09:05 AM. Reason: spelling

      Comment


      • #4
        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.

        Comment


        • #5
          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.

          Comment

          Working...
          X