Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF "Technology" (Ecore Tools, EMFatic, etc)  » [Teneo] Class loader issues within a plugin
[Teneo] Class loader issues within a plugin [message #614110] Mon, 28 January 2008 11:07
Florian Hackenberger is currently offline Florian HackenbergerFriend
Messages: 123
Registered: July 2009
Senior Member
Hi!

I'm trying to use Teneo within an Eclipse plugin project. Unfortunately I'm
running into issues concerning the interdependencies of the JPOX, Teneo and
JDO plugins. My plugin configuration is:

Plugin name depends on jar file included

javax.jdo - jdo2-api-2.0.jar

org.jpox javax.jdo (reexport) jpox-1.1.9.jar
org.postgresql

masterDataEditor org.jpox
org.eclipse.emf.teneo.jpox
org.eclipse.emf.teneo.eclipse

This gives me the following exception upon executing the code further down:
java.lang.ClassNotFoundException: org.jpox.PersistenceManagerFactoryImpl
at java.lang.ClassLoader.findClass(ClassLoader.java:358)
at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
at
org.eclipse.core.runtime.internal.adaptor.ContextFinder.load Class(ContextFinder.java:124)
at java.lang.ClassLoader.loadClass(ClassLoader.java:251)
at javax.jdo.JDOHelper.getPersistenceManagerFactory(JDOHelper.j ava:530)
at javax.jdo.JDOHelper.getPersistenceManagerFactory(JDOHelper.j ava:478)
at
org.eclipse.emf.teneo.jpox.JpoxDataStore.createSchema(JpoxDa taStore.java:526)
at
org.eclipse.emf.teneo.jpox.JpoxDataStore.initialize(JpoxData Store.java:217)
at
org.acoveo.callcenter.masterdataeditor.NavigationView.create SampleData(NavigationView.java:195)
at
org.acoveo.callcenter.masterdataeditor.NavigationView.create PartControl(NavigationView.java:170)
at
org.eclipse.ui.internal.ViewReference.createPartHelper(ViewR eference.java:370)
at org.eclipse.ui.internal.ViewReference.createPart(ViewReferen ce.java:227)
at
org.eclipse.ui.internal.WorkbenchPartReference.getPart(Workb enchPartReference.java:592)
at org.eclipse.ui.internal.PartPane.setVisible(PartPane.java:29 9)
at org.eclipse.ui.internal.ViewPane.setVisible(ViewPane.java:53 1)
<snipped/>

Teneo is at version 0.8.0.v200712280940 installed from the EMFT update site.

The problem seems to be that the class loader of the javax.jdo plugin cannot
find the jpox classes (which doesn't come as a surprise). However, I can't
solve the problem by letting javax.jdo depend on org.jpox, because that
would result in a cyclic dependency graph (and org.jpox required javax.jdo
as well). Before using Teneo, I simply passed my plugin's
(masterDataEditor) classloader to the JDOHelper class:

PersistenceManagerFactory factory =
JDOHelper.getPersistenceManagerFactory("jpox_postgre.properties ",
Activator.class.getClassLoader());
persistenceManager = factory.getPersistenceManager();

That solved the dependency problems, because both the javax.jdo as well as
the org.jpox plugins are visible to the class loader of my plugin. Could
someone please tell me how to proceed with Teneo in order to achieve the
same effect?

Cheers,
Florian


Here is the code I'm trying to run:

Properties properties = new Properties();
properties.setProperty(PMFConfiguration.JDO_DATASTORE_DRIVER NAME_PROPERTY, "com.postgresql.Driver");
properties.setProperty(PMFConfiguration.JDO_DATASTORE_URL_PR OPERTY, "jdbc:postgresql://localhost/asterisk");
properties.setProperty(PMFConfiguration.JDO_DATASTORE_USERNA ME_PROPERTY, "asterisk");
properties.setProperty(PMFConfiguration.JDO_DATASTORE_PASSWO RD_PROPERTY, "aiLiegh0");

String pmfName = "MyPMF"; // the name of the JpoxDataStore
JpoxDataStore jpoxDataStore =
JpoxHelper.INSTANCE.createRegisterDataStore(pmfName);
jpoxDataStore.setProperties(properties);
jpoxDataStore.setEPackages(new EPackage[]{MasterdataPackage.eINSTANCE});
jpoxDataStore.initialize();

// TODO Auto-generated method stub
PersistenceManagerFactory pmf = jpoxDataStore.getPMF();
PersistenceManager pm = pmf.getPersistenceManager();
Transaction tx=pm.currentTransaction();
try
{
tx.begin();

AgentGroup agentGroup = MasterdataFactory.eINSTANCE.createAgentGroup();
agentGroup.setName("myAgentGroup");
agentGroup.setMusicClass("mymusicclass");
pm.makePersistent(agentGroup);

Agent agent = MasterdataFactory.eINSTANCE.createAgent();
agent.setAgentId("6000");
agent.setName("Florian Hackenberger");
agent.setPassword("6000");
pm.makePersistent(agent);

tx.commit();
}
finally
{
if (tx.isActive())
{
tx.rollback();
}

pm.close();
}

--
Florian Hackenberger
Previous Topic:[Emfatic] Source
Next Topic:[Teneo] Bug 216658
Goto Forum:
  


Current Time: Sun Sep 20 02:38:49 GMT 2020

Powered by FUDForum. Page generated in 0.01843 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top