Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [eclipselink-users] Eclipselink 1.1-M4 create OSGI EntityManagerFactory

That's all true Tom and i didn't figured out until yesterday so i downloaded the preview jar and ran it against it. I had some problems getting working the thing with nightly build 2907 which until yesterday appear to be the most recent (today appeared another one 2918) i will post the exception and other stuff today if that might be useful, anyway when i found that problem with 2907 i decided to download and older build 2887 and everything works, i haven't tested extensively but if i found something i will post it.  So resuming for everyone there trying to make it work with 2.0 i did it work with:

1.1.0 Nightly Build 2887 (20081204)
http://dev.eclipse.org/viewsvn/index.cgi/trunk/jpa/plugins/javax.persistence_2.0_preview.jar?root=RT_Eclipselink&view=log persistence 2.0 bundle required as Tom said.
If the older javax.peresistence 1.99 jar is still there delete it, in my personal experience that cause me a problem.
Finally this is the way i got a EntityManagerFactory within osgi:

HashMap<Object, Object> properties = new HashMap<Object, Object>();
properties.put(PersistenceUnitProperties.CLASSLOADER, this.getClass().getClassLoader());
factory = new PersistenceProvider().createEntityManagerFactory("x-unit", properties);

Additional you might need to import the org.eclipse.persistence.config AND org.eclipse.persistence.jpa.osgi packages to make this work.



On Wed, Dec 10, 2008 at 7:42 AM, Tom Ware <tom.ware@xxxxxxxxxx> wrote:
Hi Erasmo,

 The reason you are seeing the ClassNotFoundException on 1.1 is that 1.1 has
started to integrate support for the upcoming JPA 2.0 spec.
LockTimeoutException (and some other classes) are new to that spec.  You should
be able to solve that problem by getting a new version of the javax.persistence
bundle.  Try getting it from our subversion repository:

http://dev.eclipse.org/viewsvn/index.cgi/trunk/jpa/plugins/javax.persistence_2.0_preview.jar?root=RT_Eclipselink&view=log

 If you are having other problems getting OSGi working, please post the exact
problems.  The demo ran successfully for me recently, so some more details about what you are doing, would help me understand the deltas.

-Tom

Erasmo wrote:
Yes tim, everything works ok with the 1.0.1 i have even tested over 1.0.2. <http://1.0.2.> Right now im trying the milestone 4 of 1.1 and i get a:


java.lang.ClassNotFoundException: javax.persistence.LockTimeoutException

Some other nightly builds broke not being able to find PersistenceProvider. And it looks like the javax.persistence.Persistence aproach doesnt work under osgi breaking when they try to find or load the the PersistenceUnit.


On Tue, Dec 9, 2008 at 4:57 PM, Tim Hollosy <hollosyt@xxxxxxxxx <mailto:hollosyt@xxxxxxxxx>> wrote:

   Doug Clarke should be able to answer you, the osgi EMF creation can be
   a moving target.

   I dont have the latest build in front of me at the moment, but I wrote
   the tutorial around  the 1.0.1 OSGI release.

   ./tch



   On Tue, Dec 9, 2008 at 7:50 PM, Erasmo <einundswanzig@xxxxxxxxx
   <mailto:einundswanzig@xxxxxxxxx>> wrote:
    > Thanks Tom and Tim.
    >
    > I have seen the examples before but it looks like something has
   change in
    > the most recent builds since i receive a:
    >
    > org.eclipse.persistence.config.PersistenceUnitProperties cannot
   be resolved.
    > org.eclipse.persistence.jpa.osgi.PersistenceProvider cannot be
   resolved.
    >
    > Once i import those packages, it still says:
    >
    > Access restriction: the method createEntityManagerFactory(String,
   Map) from
    > the type PersistenceProvider is not accessible due to a
   restriction on
    > required library ...
    >
    > If i use the
   Persistence.createEntityManagerFactory(persistenceUnitName) i
    > get an error saying wasn't able to load that persistence unit
   name. what can
    > i do? Against which build was run the svn demo?
    >
    >
    >
    >
    > On Mon, Dec 8, 2008 at 6:23 AM, Tim Hollosy <hollosyt@xxxxxxxxx
   <mailto:hollosyt@xxxxxxxxx>> wrote:
    >>
    >> Also check out my article here:
    >>
    >>
   http://www.weheartcode.com/2008/08/27/eclipselink-in-j2se-rcp-applications/
    >>
    >> It explains one way:
    >>
    >>     properties.put(PersistenceUnitProperties.TARGET_DATABASE,
   "Derby");
    >>        properties.put(PersistenceUnitProperties.JDBC_DRIVER,
    >>                "org.apache.derby.jdbc.ClientDriver");
    >>        properties.put(PersistenceUnitProperties.JDBC_URL,
    >>                "jdbc:derby://localhost:1527/sample;create=true");
    >>        properties.put(PersistenceUnitProperties.JDBC_USER, "app");
    >>        properties.put(PersistenceUnitProperties.JDBC_PASSWORD,
   "app");
    >>        properties
    >>                   .put(PersistenceUnitProperties.JDBC_READ_CONNECTIONS_MIN,
    >> "1");
    >>
    >>
    properties.put(PersistenceUnitProperties.JDBC_WRITE_CONNECTIONS_MIN,
    >>                "1");
    >>
    >>        properties.put(PersistenceUnitProperties.BATCH_WRITING,
   "JDBC");
    >>        properties.put(PersistenceUnitProperties.CLASSLOADER,
    >> ComicsEntityManagerFactory.class.getClassLoader());
    >>        properties.put("eclipselink.logging.level", "FINE");
    >>        properties.put("eclipselink.logging.timestamp", "false");
    >>        properties.put("eclipselink.logging.session", "false");
    >>        properties.put("eclipselink.logging.thread", "false");
    >>
    >>        emf = new
    >> PersistenceProvider().createEntityManagerFactory("comics",
    >>                properties);
    >>
    >>
    >> ./tch
    >>
    >>
    >>
    >> On Mon, Dec 8, 2008 at 9:19 AM, Tom Ware <tom.ware@xxxxxxxxxx
   <mailto:tom.ware@xxxxxxxxxx>> wrote:
    >> > Hi Erasmo,
    >> >
    >> >  A good way to get started with EclipseLink and OSGi is by
   looking at
    >> > our
    >> > RCP demo.  It creates an EntityManager using OSGi and does
   some simple
    >> > queries.
    >> >
    >> >  The instructions about how to use it our in the examples
   folder of our
    >> > SVN
    >> > view.  Here is a link to the file so you can see it.
    >> >
    >> >
    >> >
   http://dev.eclipse.org/viewsvn/index.cgi/trunk/examples/org.eclipse.persistence.example.jpa.rcp.comics/ReadMe.txt?root=RT_Eclipselink&view=log
   <http://dev.eclipse.org/viewsvn/index.cgi/trunk/examples/org.eclipse.persistence.example.jpa.rcp.comics/ReadMe.txt?root=RT_Eclipselink&view=log>
    >> >
    >> >  All the instructions you need can be found in that file.
    >> >
    >> > -Tom
    >> >
    >> > http://wiki.eclipse.org/SVN_Howto
    >> >
    >> > Erasmo wrote:
    >> >>
    >> >> Does anybody knows how to create an EntityManagerFactory
   under osgi
    >> >> using
    >> >> eclipselink milestone 4? It looks like the old
    >> >> PersistentProvider.createEntityManagerFactory is dead or
   something,
    >> >> because
    >> >> its commanded to throw an exception if someone calls its
   code. Any
    >> >> tester
    >> >> outthere working with M4?
    >> >>
    >> >> Any help appreciated.
    >> >>
    >> >>
    >> >>
    >> >>
   ------------------------------------------------------------------------
    >> >>
    >> >> _______________________________________________
    >> >> eclipselink-users mailing list
    >> >> eclipselink-users@xxxxxxxxxxx
   <mailto:eclipselink-users@xxxxxxxxxxx>

    >> >> https://dev.eclipse.org/mailman/listinfo/eclipselink-users
    >> >
    >> > _______________________________________________
    >> > eclipselink-users mailing list
    >> > eclipselink-users@xxxxxxxxxxx
   <mailto:eclipselink-users@xxxxxxxxxxx>

    >> > https://dev.eclipse.org/mailman/listinfo/eclipselink-users
    >> >
    >> _______________________________________________
    >> eclipselink-users mailing list
    >> eclipselink-users@xxxxxxxxxxx <mailto:eclipselink-users@xxxxxxxxxxx>

    >> https://dev.eclipse.org/mailman/listinfo/eclipselink-users
    >
    >
    > _______________________________________________
    > eclipselink-users mailing list
    > eclipselink-users@xxxxxxxxxxx <mailto:eclipselink-users@xxxxxxxxxxx>

    > https://dev.eclipse.org/mailman/listinfo/eclipselink-users
    >
    >
   _______________________________________________
   eclipselink-users mailing list
   eclipselink-users@xxxxxxxxxxx <mailto:eclipselink-users@xxxxxxxxxxx>

   https://dev.eclipse.org/mailman/listinfo/eclipselink-users



------------------------------------------------------------------------

_______________________________________________
eclipselink-users mailing list
eclipselink-users@xxxxxxxxxxx
https://dev.eclipse.org/mailman/listinfo/eclipselink-users

_______________________________________________
eclipselink-users mailing list
eclipselink-users@xxxxxxxxxxx
https://dev.eclipse.org/mailman/listinfo/eclipselink-users


Back to the top