VMware {code} Community
pwyzorski-wyzgu
Enthusiast
Enthusiast
Jump to solution

'persistence.xml' file placement to enable direct DB access from a Plug-in

Hey,

I'm trying to access a DB from within my Orchestrator plug-in, directly. I have a well formed .dar package, but when I restart the VMO service I get the following error:

2009-08-10 22:20:17.272-0700 ERROR javax.persistence.PersistenceException: No Persistence provider for EntityManager named stagebank_pu_mssql

2009-08-10 22:20:17.272-0700 ERROR at javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:55)

2009-08-10 22:20:17.272-0700 ERROR at javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:33)

2009-08-10 22:20:17.272-0700 ERROR at ppsb.stagebank.PersistenceManager.initialize(PersistenceManager.java:22)

2009-08-10 22:20:17.272-0700 ERROR at ppsb.stagebank.StageBank.getUniqueInstance(StageBank.java:55)

2009-08-10 22:20:17.272-0700 ERROR at ppsb.vmo.api.ppsbVmoPluginFactory.findRelation(ppsbVmoPluginFactory.java:217)

2009-08-10 22:20:17.272-0700 ERROR at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

2009-08-10 22:20:17.272-0700 ERROR at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)

2009-08-10 22:20:17.272-0700 ERROR at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)

2009-08-10 22:20:17.272-0700 ERROR at java.lang.reflect.Method.invoke(Unknown Source)

2009-08-10 22:20:17.272-0700 ERROR at ch.dunes.vso.sdk.TimeoutedInvoker.run(Unknown Source)

2009-08-10 22:20:17.272-0700 ERROR at java.lang.Thread.run(Unknown Source)

2009-08-10 22:20:17.272-0700 INFO javax.persistence.PersistenceException: No Persistence provider for EntityManager named stagebank_pu_mssql

Basically it's complaining that it can't find my 'persistence.xml' file which is located in the /META-INF/ folder in my .dar package. Where do I need to locate my 'persistence.xml' file so that VMO can find it and allow me to contact my DB?

regards,

~Patrick

Don't forget if the answers help, award points

Don't forget if the answers help, award points
Reply
0 Kudos
1 Solution

Accepted Solutions
admin
Immortal
Immortal
Jump to solution

Seems to be an error from the JPA implementation in Java 1.5

View solution in original post

Reply
0 Kudos
3 Replies
admin
Immortal
Immortal
Jump to solution

First of all, if you want to use JPA, you must install vCO in a path without space characters (default is c:\program files\... and is not working).

Then, you'll have to add a new constructor to your Adaptor class that allow you to save the server class loader statically:

    public static ClassLoader pluginClassLoader; 
    public MyAdaptor(ClassLoader aPluginClassLoader){
        pluginClassLoader = aPluginClassLoader;
    }

Finally, when you inity the JPA, you must first switch to the server class loader, then instantiate JPA and finally get back to plugin class loader.

ClassLoader originalClassLoader = Thread.currentThread().getContextClassLoader(); 
Thread.currentThread().setContextClassLoader(Adaptor.pluginClassLoader);

HashMap<String, String> configOverrides = loadConfiguration();
emf = Persistence.createEntityManagerFactory("JPAPersistance",configOverrides);

Thread.currentThread().setContextClassLoader(originalClassLoader); 

Reply
0 Kudos
pwyzorski-wyzgu
Enthusiast
Enthusiast
Jump to solution

Looks simple enough. What's the problem with the spaces in the installation path

Don't forget if the answers help, award points

Don't forget if the answers help, award points
Reply
0 Kudos
admin
Immortal
Immortal
Jump to solution

Seems to be an error from the JPA implementation in Java 1.5

Reply
0 Kudos