[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [Newsgroup Home]
[news.eclipse.rt.eclipselink] Re: Equinox weaving configuration - Clasloading issue

Shaun, James, thanks for all the information, i'll try everything. But I
still have some questions and comments, though.

First of all, when I said that I started the fragments I did not mean
that I literally tried to start them (by using the "start bundle"
command on the console, as fragments cannot be started at all), I meant
that I checked them to be loaded in the eclipse run configuration, sorry
for being not clear at that point.

My first problem is that I do not really know where to put the line

osgi.framework.extensions=org.eclipse.persistence.jpa.equinox.weaving.

I know it belongs in the config.ini, and in a deployed equinox runtime
environment (i'm using inside an tomcat container using the
servletbridge) I have a config.ini where I can put the line.

The problem is that I would like to launch the application form inside
Eclipse using an OSGi launch configuration, and there is simply no
option in that dialog where I could place a config.ini file that should
be used (or I just didn't find it yet). There is such an option in the
"eclipse application" ("use an existing config.ini as template"), but I
could not get that to work as I need to provide an eclipse application
to start, which I don't have since I'm using pure OSGi for the
serverside here).

I tried to give the line as an argument (on the "arguments tab" in the
launch configuration dialog) like this:

-Declipse.ignoreApp=true -Dosgi.noShutdown=true -Xms512m -Xmx512m
-Dosgi.framework.extensions=org.eclipse.persistence.jpa.equinox.weaving

Maybe this is wrong or does nothing at all.

But what really puzzles me is the classloading problem, I would have
expected some errors on indirection or something. As soon as the
fragments are checked in the launch configuration, eclipselink complains
about not being able to find the (entity) classes defined in the
persistence.xml

To be honest I'm not quite sure that I understood all of your
suggestions right, but I think the root of the problem is probably that
I didn't place the aforementioned framework extensions configuration
line in the right place, so maybe we should start solving this first.

For the sake of completeness I post the short status and the exception
message, maybe it helps. The exception occurs when
Persistence.createEntityManager() is called in this part of code:


HashMap<String, Object> props = new HashMap<String, Object>();
			props.put(PersistenceUnitProperties.EXCLUSIVE_CONNECTION_MODE, "Always");
entityManagerFactory = Persistence.createEntityManagerFactory("tup_pu",
props);



Here is the short status output:


id	State       Bundle
0	ACTIVE      org.eclipse.osgi_3.4.2.R34x_v20080826-1230
	            Fragments=1
1	RESOLVED
org.eclipse.persistence.jpa.equinox.weaving_1.1.2.v20090612-r4475
	            Master=0
2	ACTIVE      com.springsource.org.aopalliance_1.0.0
3	ACTIVE      com.tp.server.persistence_1.0.0
4	ACTIVE      com.tp.server.remoting_1.0.0
5	ACTIVE      com.tp.server.persistence.internal_1.0.0
6	ACTIVE      org.eclipse.persistence.jpa_1.1.2.v20090612-r4475
	            Fragments=35
7	ACTIVE      com.springsource.net.sf.cglib_2.1.3
8	ACTIVE      org.eclipse.osgi.services_3.1.200.v20071203
9	RESOLVED    org.eclipse.persistence.oracle_1.1.2.v20090612-r4475
	            Master=44
10	ACTIVE      com.tp.server.lisa.masterdata.internal_1.0.0
11	ACTIVE      org.eclipse.persistence.antlr_1.1.2.v20090612-r4475
12	ACTIVE      com.tp.server.util_1.0.0
13	ACTIVE      org.springframework.osgi.web_1.2.0
14	ACTIVE      com.tp.server.config.ui.internal_1.0.0
15	ACTIVE      org.springframework.web_2.5.6
16	ACTIVE      com.springsource.slf4j.api_1.5.0
	            Fragments=24
17	ACTIVE      com.tp.oracledriver_1.0.0
18	ACTIVE      org.springframework.osgi.extender_1.2.0
19	ACTIVE      org.springframework.beans_2.5.6
20	ACTIVE      org.eclipse.equinox.http.servlet_1.0.100.v20080427-0830
21	ACTIVE      org.springframework.osgi.core_1.2.0
22	ACTIVE      javax.persistence_1.99.0.v200906021518
23	ACTIVE      com.tp.server.lisa.core_1.0.0
24	RESOLVED    com.springsource.slf4j.log4j_1.5.0
	            Master=16
25	ACTIVE      com.tp.server.config.ui_1.0.0
26	ACTIVE      com.tp.server.lisa.masterdata_1.0.0
27	ACTIVE      org.eclipse.equinox.http.jetty_2.0.0.v20090429-1630
28	ACTIVE      org.springframework.osgi.io_1.2.0
29	ACTIVE      org.springframework.orm_2.5.6
30	ACTIVE      org.springframework.core_2.5.6
31	ACTIVE      org.springframework.aop_2.5.6
32	ACTIVE      com.springsource.slf4j.org.apache.commons.logging_1.5.0
33	ACTIVE      com.tp.server.lisa.core.internal_1.0.0
34	ACTIVE      org.mortbay.jetty.server_6.1.15.v200904241724
35	RESOLVED    org.eclipse.persistence.jpa.equinox_1.1.2.v20090612-r4475
	            Master=6
36	ACTIVE      javax.servlet_2.5.0.v200806031605
37	RESOLVED    org.springframework.osgi.log4j.config_1.0.0
	            Master=38
38	ACTIVE      org.springframework.osgi.log4j.osgi_1.2.15.SNAPSHOT
	            Fragments=37
39	ACTIVE      org.springframework.transaction_2.5.6
40	ACTIVE      org.springframework.web.servlet_2.5.6
41	ACTIVE      org.mortbay.jetty.util_6.1.15.v200904241724
42	ACTIVE      org.eclipse.equinox.common_3.4.0.v20080421-2006
43	ACTIVE      org.springframework.context_2.5.6
44	ACTIVE      org.eclipse.persistence.core_1.1.2.v20090612-r4475
	            Fragments=9


And the exception message:


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

javax.persistence.PersistenceException: Exception [EclipseLink-28018]
(Eclipse Persistence Services - 1.1.2.v20090612-r4475):
org.eclipse.persistence.exceptions.EntityManagerSetupException
Exception Description: Predeployment of PersistenceUnit [tup_pu] failed.
Internal Exception: Exception [EclipseLink-7156] (Eclipse Persistence
Services - 1.1.2.v20090612-r4475):
org.eclipse.persistence.exceptions.ValidationException
Exception Description: Unable to find the class named
[com.tp.server.lisa.core.Company]. Ensure the class name/path is correct
and available to the classloader.
Internal Exception: java.lang.ClassNotFoundException:
com.tp.server.lisa.core.Company
	at
org.eclipse.persistence.internal.jpa.EntityManagerSetupImpl.predeploy(EntityManagerSetupImpl.java:878)
	at
org.eclipse.persistence.jpa.PersistenceProvider.createEntityManagerFactory(PersistenceProvider.java:162)
	at
org.eclipse.persistence.jpa.PersistenceProvider.createEntityManagerFactory(PersistenceProvider.java:67)
	at javax.persistence.Persistence.createEntityManagerFactory(Unknown Source)
	at
com.tp.server.persistence.internal.Activator.getEntityManagerFactory(Activator.java:49)
	at
com.tp.server.persistence.internal.TransactionManagerBean.login(TransactionManagerBean.java:26)
	at
com.tp.server.persistence.internal.TransactionManagerBean$$FastClassByCGLIB$$d216f03b.invoke(<generated>)
	at net.sf.cglib.proxy.MethodProxy.invoke(MethodProxy.java:149)
	at
org.springframework.aop.framework.Cglib2AopProxy$CglibMethodInvocation.invokeJoinpoint(Cglib2AopProxy.java:700)
	at
org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:149)
	at
org.springframework.aop.support.DelegatingIntroductionInterceptor.doProceed(DelegatingIntroductionInterceptor.java:131)
	at
org.springframework.aop.support.DelegatingIntroductionInterceptor.invoke(DelegatingIntroductionInterceptor.java:119)
	at
org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:171)
	at
org.springframework.aop.framework.Cglib2AopProxy$DynamicAdvisedInterceptor.intercept(Cglib2AopProxy.java:635)
	at
com.tp.server.persistence.internal.TransactionManagerBean$$EnhancerByCGLIB$$3f29ba32.login(<generated>)
	at
com.tp.server.persistence.internal.PersistenceSessionBean.login(PersistenceSessionBean.java:36)
	at
com.tp.server.persistence.internal.PersistenceSessionBean$$FastClassByCGLIB$$21a5a443.invoke(<generated>)
	at net.sf.cglib.proxy.MethodProxy.invoke(MethodProxy.java:149)
	at
org.springframework.aop.framework.Cglib2AopProxy$CglibMethodInvocation.invokeJoinpoint(Cglib2AopProxy.java:700)
	at
org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:149)
	at
org.springframework.aop.support.DelegatingIntroductionInterceptor.doProceed(DelegatingIntroductionInterceptor.java:131)
	at
org.springframework.aop.support.DelegatingIntroductionInterceptor.invoke(DelegatingIntroductionInterceptor.java:119)
	at
org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:171)
	at
org.springframework.aop.framework.Cglib2AopProxy$DynamicAdvisedInterceptor.intercept(Cglib2AopProxy.java:635)
	at
com.tp.server.persistence.internal.PersistenceSessionBean$$EnhancerByCGLIB$$108b16ca.login(<generated>)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
	at java.lang.reflect.Method.invoke(Unknown Source)
	at
org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:307)
	at
org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:182)
	at
org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:149)
	at
org.springframework.remoting.support.RemoteInvocationTraceInterceptor.invoke(RemoteInvocationTraceInterceptor.java:77)
	at
org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:171)
	at
org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:204)
	at $Proxy16.login(Unknown Source)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
	at java.lang.reflect.Method.invoke(Unknown Source)
	at
org.springframework.remoting.support.RemoteInvocation.invoke(RemoteInvocation.java:205)
	at
org.springframework.remoting.support.DefaultRemoteInvocationExecutor.invoke(DefaultRemoteInvocationExecutor.java:38)
	at
org.springframework.remoting.support.RemoteInvocationBasedExporter.invoke(RemoteInvocationBasedExporter.java:78)
	at
org.springframework.remoting.support.RemoteInvocationBasedExporter.invokeAndCreateResult(RemoteInvocationBasedExporter.java:114)
	at
org.springframework.remoting.httpinvoker.HttpInvokerServiceExporter.handleRequest(HttpInvokerServiceExporter.java:74)
	at
org.springframework.web.servlet.mvc.HttpRequestHandlerAdapter.handle(HttpRequestHandlerAdapter.java:49)
	at
org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:875)
	at
org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:807)
	at
org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:571)
	at
org.springframework.web.servlet.FrameworkServlet.doPost(FrameworkServlet.java:511)
	at javax.servlet.http.HttpServlet.service(HttpServlet.java:727)
	at javax.servlet.http.HttpServlet.service(HttpServlet.java:820)
	at
org.eclipse.equinox.http.servlet.internal.ServletRegistration.handleRequest(ServletRegistration.java:90)
	at
org.eclipse.equinox.http.servlet.internal.ProxyServlet.processAlias(ProxyServlet.java:111)
	at
org.eclipse.equinox.http.servlet.internal.ProxyServlet.service(ProxyServlet.java:67)
	at javax.servlet.http.HttpServlet.service(HttpServlet.java:820)
	at
org.eclipse.equinox.http.jetty.internal.HttpServerManager$InternalHttpServiceServlet.service(HttpServerManager.java:311)
	at org.mortbay.jetty.servlet.ServletHolder.handle(ServletHolder.java:502)
	at org.mortbay.jetty.servlet.ServletHandler.handle(ServletHandler.java:380)
	at org.mortbay.jetty.servlet.SessionHandler.handle(SessionHandler.java:181)
	at org.mortbay.jetty.handler.ContextHandler.handle(ContextHandler.java:765)
	at org.mortbay.jetty.handler.HandlerWrapper.handle(HandlerWrapper.java:152)
	at org.mortbay.jetty.Server.handle(Server.java:324)
	at org.mortbay.jetty.HttpConnection.handleRequest(HttpConnection.java:535)
	at
org.mortbay.jetty.HttpConnection$RequestHandler.content(HttpConnection.java:880)
	at org.mortbay.jetty.HttpParser.parseNext(HttpParser.java:747)
	at org.mortbay.jetty.HttpParser.parseAvailable(HttpParser.java:218)
	at org.mortbay.jetty.HttpConnection.handle(HttpConnection.java:404)
	at
org.mortbay.io.nio.SelectChannelEndPoint.run(SelectChannelEndPoint.java:409)
	at
org.mortbay.thread.QueuedThreadPool$PoolThread.run(QueuedThreadPool.java:520)
Caused by: Exception [EclipseLink-28018] (Eclipse Persistence Services -
1.1.2.v20090612-r4475):
org.eclipse.persistence.exceptions.EntityManagerSetupException
Exception Description: Predeployment of PersistenceUnit [tup_pu] failed.
Internal Exception: Exception [EclipseLink-7156] (Eclipse Persistence
Services - 1.1.2.v20090612-r4475):
org.eclipse.persistence.exceptions.ValidationException
Exception Description: Unable to find the class named
[com.tp.server.lisa.core.Company]. Ensure the class name/path is correct
and available to the classloader.
Internal Exception: java.lang.ClassNotFoundException:
com.tp.server.lisa.core.Company
	at
org.eclipse.persistence.exceptions.EntityManagerSetupException.predeployFailed(EntityManagerSetupException.java:210)
	... 70 more
Caused by: Exception [EclipseLink-7156] (Eclipse Persistence Services -
1.1.2.v20090612-r4475):
org.eclipse.persistence.exceptions.ValidationException
Exception Description: Unable to find the class named
[com.tp.server.lisa.core.Company]. Ensure the class name/path is correct
and available to the classloader.
Internal Exception: java.lang.ClassNotFoundException:
com.tp.server.lisa.core.Company
	at
org.eclipse.persistence.exceptions.ValidationException.unableToLoadClass(ValidationException.java:1821)
	at
org.eclipse.persistence.internal.jpa.metadata.xml.XMLEntityMappings.getClassForName(XMLEntityMappings.java:141)
	at
org.eclipse.persistence.internal.jpa.metadata.xml.XMLEntityMappings.getClassForName(XMLEntityMappings.java:175)
	at
org.eclipse.persistence.internal.jpa.metadata.xml.XMLEntityMappings.initPersistenceUnitClasses(XMLEntityMappings.java:415)
	at
org.eclipse.persistence.internal.jpa.metadata.MetadataProcessor.initPersistenceUnitClasses(MetadataProcessor.java:202)
	at
org.eclipse.persistence.internal.jpa.metadata.MetadataProcessor.processEntityMappings(MetadataProcessor.java:425)
	at
org.eclipse.persistence.internal.jpa.deployment.PersistenceUnitProcessor.processORMetadata(PersistenceUnitProcessor.java:299)
	at
org.eclipse.persistence.internal.jpa.EntityManagerSetupImpl.predeploy(EntityManagerSetupImpl.java:838)
	... 69 more
Caused by: java.lang.ClassNotFoundException: com.tp.server.lisa.core.Company
	at
org.eclipse.osgi.baseadaptor.loader.ClasspathManager.findLocalClassImpl(ClasspathManager.java:469)
	at
org.eclipse.osgi.baseadaptor.loader.ClasspathManager.findLocalClass_LockClassLoader(ClasspathManager.java:443)
	at
org.eclipse.osgi.baseadaptor.loader.ClasspathManager.findLocalClass(ClasspathManager.java:423)
	at
org.eclipse.osgi.internal.baseadaptor.DefaultClassLoader.findLocalClass(DefaultClassLoader.java:193)
	at
org.eclipse.persistence.internal.jpa.deployment.osgi.equinox.EquinoxInitializer$TempEquinoxEntityLoader.loadClass(EquinoxInitializer.java:200)
	at java.lang.ClassLoader.loadClass(Unknown Source)
	at java.lang.ClassLoader.loadClassInternal(Unknown Source)
	at java.lang.Class.forName0(Native Method)
	at java.lang.Class.forName(Unknown Source)
	at
org.eclipse.persistence.internal.security.PrivilegedAccessHelper.getClassForName(PrivilegedAccessHelper.java:86)
	at
org.eclipse.persistence.internal.jpa.metadata.xml.XMLEntityMappings.getClassForName(XMLEntityMappings.java:138)
	... 75 more

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


Thanks again,

Tom



Shaun Smith schrieb:
> Thomas Haskes wrote:
>> ...
>> Now when I start my application, I get a ClassNotFoundException on my
>> entity classes, but only when I start the fragments
>> org.eclipse.persistence.equinox and org.eclipse.equinox.weaving (which
>> are required to start to get lazy loading working as mentioned in [1]).
> 
> You don't have to start those fragments; I don't think you can really. 
> In the example you deploy those fragments and start the
> javax.persistence bundle and then the org.eclipse.persistence.jpa
> bundle.  Finally you start your client bundle.
> 
>> If I dont start those fragments, everything works, but then theres no
>> weaving at all(which is clear as the fragment are not started). It seems
>> that I have to configure some more Bundle-Requirements or
>> Buddy-Classloading directives, but I don't know where and what.
> 
> You don't have to use an Equinox specific buddy loading with
> EclipseLink.  If it works without weaving then your config is probably ok.
> 
> One of the key issues for weaving is the requirement that framework
> fragments be co-located with the org.eclipse.osgi bundle.  In the
> example [1], all the bundles are in the same folder so the fragment
> loads properly.  The way Equinox is launched is key to this working and
> the config I describe is critical to success.  If you're running inside
> PDE then you need to checkout the source for Equinox (org.eclipse.osgi)
> from CVS.  See the comments on the Adaptor Hook [2] page for details. 
> By having the Equinox source in your dev environment when you deploy
> org.eclipse.osgi and the framework extension fragment
> org.eclipse.persistence.equinox.weaving are in the same folder. 
> Luckily, PDE launches Equinox in such a way that the fragments are
> loaded correctly--when I went outside PDE I soon discovered that
> launching Equinox with "java -jar org.eclipse.osgi_<version>" did not
> work, the framework extensions are loaded after the Adapter Hook
> framework has looked for extensions!  So, as I said, *luckily* PDE
> launches Equinox in a way that works.
> 
>> Any Ideas?
> 
> I've thrown out a bunch of background and hopefully this helps.  In my
> experience, the most common problem is the weaving extension either not
> being attached to org.eclipse.osgi or being attached after the Adaptor
> Hook framework has looked for extensions.  Making sure you launch
> Equinox as described should solve these issues. If this doesn't help can
> you post your short status (ss) which will show if the fragments are
> properly attached?
> 
> --Shaun
> 
>> Tom
> 
>> [1]
>> http://wiki.eclipse.org/EclipseLink/Examples/OSGi/Equinox_Byte_Code_Weaving
>>
> [2] http://wiki.eclipse.org/Adaptor_Hooks
>