persistence.xml i classloader

0

Jak toplink szuka pliku persistence.xml ? Problem polega na tym, że jar, w którym ten plik się znajduje jest ładowany dynamicznie. W efekcie mam coś takiego:

Thread.currentThread().getContextClassLoader().getResource("META-INF/persistence.xml").getPath()

i powyższe wywołania znajduje zasób.

ClassLoader.getSystemClassLoader().getResource("META-INF/persistence.xml").getPath()

A to już nie działa.
Toplink przy próbie inicjalizacji EntityManagera wyrzuca coś takiego:

javax.persistence.PersistenceException: No Persistence provider for EntityManager named mysql: Provider named oracle.toplink.essentials.PersistenceProvider threw unexpected exception at create EntityManagerFactory: oracle.toplink.essentials.exceptions.PersistenceUnitLoadingException Local Exception Stack: Exception [TOPLINK-30005] (Oracle TopLink Essentials - 2.0.1 (Build b09d-fcs (12 /06/2007))): oracle.toplink.essentials.exceptions.PersistenceUnitLoadingException
Exception Description: An exception was thrown while searching for persistence archives with ClassLoader: java.net.FactoryURLClassLoader@16504faInternal Exception: java.lang.IllegalArgumentException: URI is not hierarchical
        at oracle.toplink.essentials.exceptions.PersistenceUnitLoadingException.
exceptionSearchingForPersistenceResources(PersistenceUnitLoadingException.java:1
43)
        at oracle.toplink.essentials.ejb.cmp3.EntityManagerFactoryProvider.creat
eEntityManagerFactory(EntityManagerFactoryProvider.java:169)
        at javax.persistence.Persistence.createEntityManagerFactory(Persistence.
java:110)
        at javax.persistence.Persistence.createEntityManagerFactory(Persistence.
java:83)
        at org.shell.db.DBManager.<init>(DBManager.java:15)
        at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)

        at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)

        at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Sou
rce)
        at java.lang.reflect.Constructor.newInstance(Unknown Source)
        at java.lang.Class.newInstance0(Unknown Source)
        at java.lang.Class.newInstance(Unknown Source)
0

Sam instacjuj TopLinka...

Rozumiem ze pewne zasoby mozna ladowac dynamicznie ale zeby persistance.xml po co????????

1 użytkowników online, w tym zalogowanych: 0, gości: 1