Home » Modeling » EMF "Technology" (Ecore Tools, EMFatic, etc) » [Teneo] Class loader issues within a plugin
[Teneo] Class loader issues within a plugin [message #108589] |
Mon, 28 January 2008 11:07 |
Florian Hackenberger 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
|
|
|
Re: [Teneo] Class loader issues within a plugin [message #108606 is a reply to message #108589] |
Mon, 28 January 2008 11:54 |
Martin Taal Messages: 5468 Registered: July 2009 |
Senior Member |
|
|
Hi Florian,
I think it is related to the Eclipse-BuddyPolicy setting.
Does the javax.jdo have this line in its manifest.mf:
Eclipse-BuddyPolicy: dependent
or do you use another setting?
The same buddypolicy should be set in the org.jpox plugin.
gr. Martin
DI Florian Hackenberger wrote:
> 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();
> }
>
--
With Regards, Martin Taal
Springsite/Elver.org
Office: Hardwareweg 4, 3821 BV Amersfoort
Postal: Nassaulaan 7, 3941 EC Doorn
The Netherlands
Tel: +31 (0)84 420 2397
Fax: +31 (0)84 225 9307
Mail: mtaal@springsite.com - mtaal@elver.org
Web: www.springsite.com - www.elver.org
|
|
| | | | | |
Re: [Teneo] Class loader issues within a plugin [message #109293 is a reply to message #108687] |
Tue, 29 January 2008 18:51 |
Eclipse User |
|
|
|
Originally posted by: tom.eiswind.de
It should be a matter of buddy-policies. i had lots of pain with spring
and hibernate on that, but finally with the right buddy policies
everything is fine. look at policy: registered and Register-Buddy.
Martin Taal schrieb:
> I just put all the jars in one plugin is this also a structure you can
> use? It would probably be easier. And if this works then you can try to
> move the jars to their individual plugins.
>
> gr. Martin
>
>
> DI Florian Hackenberger wrote:
>> Martin Taal wrote:
>>> Hi Florian,
>>> I think it is related to the Eclipse-BuddyPolicy setting.
>>> Does the javax.jdo have this line in its manifest.mf:
>>> Eclipse-BuddyPolicy: dependent
>>>
>>> or do you use another setting?
>>>
>>> The same buddypolicy should be set in the org.jpox plugin.
>>
>> My previous reply was a bit too enthusiastic. While your hint solved the
>> jpox <-> jdo cyclic dependency, the jpox plugin now fails to load the
>> org.postgresql classes. I read the articles [1] and [2] and I have
>> tried to
>> specify BP 'dependent' for both the jpox and jdo plugins, added the
>> postgre
>> plugin as a dependecy for both jdo and jpox, as well as my plugin project
>> and tried to use BP registered instead of dependent for both jpox and jdo
>> and registered my plugin masterDataEditor to both of them. Neither
>> solution
>> worked. BTW. the postgre dependency is always marked as 'reexport'. The
>> stacktrace is:
>>
>> org.jpox.exceptions.ClassNotResolvedException: Class
>> com.postgresql.Driver
>> was not found in the CLASSPATH. Please check your specification and your
>> CLASSPATH.
>> at
>> org.jpox.JDOClassLoaderResolver.classForName(JDOClassLoaderR esolver.java:214)
>>
>> at
>> org.jpox.JDOClassLoaderResolver.classForName(JDOClassLoaderR esolver.java:373)
>>
>> at
>> org.jpox.datasource.DriverManagerDataSource.<init>(DriverManagerDataSource.java:73)
>>
>> at
>> org.jpox.AbstractPersistenceManagerFactory.freezeConfigurati on(AbstractPersistenceManagerFactory.java:257)
>>
>> at
>> org.jpox.PersistenceManagerFactoryImpl.getPersistenceManager Factory(PersistenceManagerFactoryImpl.java:99)
>>
>> at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
>> at
>> sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAcce ssorImpl.java:39)
>>
>> at
>> sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMe thodAccessorImpl.java:25)
>>
>> at java.lang.reflect.Method.invoke(Method.java:597)
>> at
>> javax.jdo.JDOHelper.getPersistenceManagerFactory(JDOHelper.j ava:534)
>> 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)
>>
>> <snipped/>
>>
>> I'm a bit lost. Help is greatly appreciated :-)
>>
>> [1]http://www.eclipsezone.com/articles/eclipse-vms/
>> [2] http://wiki.eclipse.org/index.php/Context_Class_Loader_Enhan cements#Buddy_Policy
>>
>>
>> Cheers,
>> Florian
>>
>
>
|
|
|
Re: [Teneo] Class loader issues within a plugin [message #614111 is a reply to message #108589] |
Mon, 28 January 2008 11:54 |
Martin Taal Messages: 5468 Registered: July 2009 |
Senior Member |
|
|
Hi Florian,
I think it is related to the Eclipse-BuddyPolicy setting.
Does the javax.jdo have this line in its manifest.mf:
Eclipse-BuddyPolicy: dependent
or do you use another setting?
The same buddypolicy should be set in the org.jpox plugin.
gr. Martin
DI Florian Hackenberger wrote:
> 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();
> }
>
--
With Regards, Martin Taal
Springsite/Elver.org
Office: Hardwareweg 4, 3821 BV Amersfoort
Postal: Nassaulaan 7, 3941 EC Doorn
The Netherlands
Tel: +31 (0)84 420 2397
Fax: +31 (0)84 225 9307
Mail: mtaal@springsite.com - mtaal@elver.org
Web: www.springsite.com - www.elver.org
|
|
| | | | | | |
Goto Forum:
Current Time: Fri Apr 19 22:23:20 GMT 2024
Powered by FUDForum. Page generated in 0.04089 seconds
|