Using JPA in a JPF application

  • Davilovick

    Davilovick - 2007-09-06


    Im using JPF to develop an application that have a plugin architecture.

    The problem come when im trying to use JPA (Java Persistence API).
    To develop a JPA application they need to create a folder named META-INF, and a file named persistence.xml in this folder.

    In a normal java application we put the META-INF folder in the default directory, and all is OK, but in a JPF architecture, the situations is more confusing..

    Thanks to everyone!!

    PD: Sorry with my english, I'm spanish

    • Chris Ward

      Chris Ward - 2007-09-07

      The solution depends on how they try to load that file. If they load it from the classpath, then you can add that custom folder to the classpath using your plugin.xml file and then that library should be able to find it just fine. An example of adding a folder to the classpath is included below. Please note that you should only have one "runtime" section, so just add the "library" section below to your existing runtime section.

            <library id="META-INF" path="META-INF/" type="resources">
               <export prefix="*" />

      Once you make that declaration, then just create the META-INF folder in the root of your plugin's folder.


    • Davilovick

      Davilovick - 2007-09-10

      Thanks for the reply.

      The application load the META-INF/persistene.xml directly from the classpath.

      I think that JPF only load class files from the classpath, and trunk all files that no have .class extension..

    • Chris Ward

      Chris Ward - 2007-09-10

      JPF will in fact load files from the classpath besides .class files. That is what the type="resources" part does instead of the normal type="code". We are using this to load all types of files extensively in our application without any problems. If this does not work for you then there might be some other problem. Sometimes it can be tricky when working with 3rd party libraries, which might require you to set the current context class loader to be the JPF class loader for your plugin. You can get your plugin class loader from the PluginManager class and then use code like the following to set the context class loader before calling a 3rd party library:



    • Davilovick

      Davilovick - 2007-09-11


      I´ve changed the ContextClassLoader, and load correctly the META-INF/persistence.xml file.

      Thank you  very much..


Log in to post a comment.

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:

No, thanks