Yeah, this whole thing is strange. I was able to reproduce the issue
and added some tests for it in the itests along with the annotations
that use enums stuff that Manu added.
We clearly have issues if you skip annotations and not enums -- custom
annotations that use custom enums no longer work then.
But, if you skip both annotations and enums it seems then any bean
methods that return an enum will break as described in this thread.
If you skip nothing (i.e. not annotations and not enums) and just run
everything through the TempClassLoader then apparently something in
OpenJPA breaks.
I couldn't find enough details on exactly what does break in OpenJPA
when you don't do any "skipping" logic. I gave it a try and all our
tests pass and the itests had no issues in openejb-standalone or
openejb-tomcat. I suspect it may be related to the use of OpenJPA
specific annotations, but not sure.
The OPENJPA-646 issue gets into some pretty hairy details and even
mentions Kevin working with the IBM JDK team to try and figure it out
all with no luck.
As it isn't clear which set of problems is the right set (seems we
have three choices, all of them with limitations) I went ahead and
implemented all three; the old 'skip annotations' logic we had in 3.1
and 3.0, the new logic of skipping 'annotations and enums', and then
added a new 'skip nothing'. With the 'skip nothing' all tests passed
and everything seemed fine, so I made that the default. If this
OpenJPA issue surfaces (not sure what it is) people can either switch
to one of the other modes.
Here's the flag and the possible values:
The default:
openejb.tempclassloader.skip=none
The 3.1, 3.0 behavior:
openejb.tempclassloader.skip=annotations
The new behavior (OPENEJB-951,OPENJPA-646) that fixes allowing custom
annotations to use custom enums... but breaks the use of custom
annotations in method signatures:
openejb.tempclassloader.skip=annotations,enums
I know Kevin Sutter will be at JavaOne next week. Going to have to
track him down and pick his brain a bit on exactly what scenarios
"skip nothing" will and will not work with OpenJPA. Clearly it works
in the limited scenarios we have.
-David
On May 28, 2009, at 3:25 AM, Bharath Ganesh wrote:
Currency Type would only be found in the TempClassLoader's classpath
right?
And getClass().getClassLoader() being the system classloader, would
not be
able to find the EJB app classes.
Also I guess the problem would be existing even for user-defined
annotations
in the bean code. Is my understanding right?
On Thu, May 28, 2009 at 2:09 PM, Jean-Sébastien Scrève <
[email protected]> wrote:
Ok I looked at these issues. Seems to be tricky...
Here is the stack trace I get :
java.lang.reflect.InvocationTargetException
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at
sun
.reflect
.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at
sun
.reflect
.DelegatingMethodAccessorImpl
.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:
295)
at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:
433)
Caused by: java.lang.NoClassDefFoundError:
net/atos/xastory/csm/core/product/Currency
at java.lang.Class.getDeclaredMethods0(Native Method)
at java.lang.Class.privateGetDeclaredMethods(Class.java:2427)
at java.lang.Class.getDeclaredMethods(Class.java:1791)
at
org.apache.openejb.finder.ClassFinder.<init>(ClassFinder.java:164)
at
org.apache.openejb.finder.ClassFinder.<init>(ClassFinder.java:146)
at
org.apache.openejb.config.AnnotationDeployer
$ProcessAnnotatedBeans.deploy(AnnotationDeployer.java:786)
at
org.apache.openejb.config.AnnotationDeployer
$ProcessAnnotatedBeans.deploy(AnnotationDeployer.java:549)
at
org
.apache
.openejb.config.AnnotationDeployer.deploy(AnnotationDeployer.java:
184)
at
org.apache.openejb.config.ConfigurationFactory
$Chain.deploy(ConfigurationFactory.java:243)
at
org
.apache
.openejb
.config
.ConfigurationFactory
.configureApplication(ConfigurationFactory.java:597)
at
org
.apache
.openejb
.tomcat.catalina.TomcatWebAppBuilder.start(TomcatWebAppBuilder.java:
245)
at
org
.apache
.openejb
.tomcat
.catalina
.GlobalListenerSupport.lifecycleEvent(GlobalListenerSupport.java:58)
at
org
.apache
.catalina
.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:120)
at
org.apache.catalina.core.StandardContext.start(StandardContext.java:
4148)
at
org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1014)
at
org.apache.catalina.core.StandardHost.start(StandardHost.java:736)
at
org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1014)
at
org.apache.catalina.core.StandardEngine.start(StandardEngine.java:
443)
at
org.apache.catalina.core.StandardService.start(StandardService.java:
448)
at
org.apache.catalina.core.StandardServer.start(StandardServer.java:
700)
at org.apache.catalina.startup.Catalina.start(Catalina.java:
552)
... 6 more
Caused by: java.lang.ClassNotFoundException:
net.atos.xastory.csm.core.product.Currency
at java.net.URLClassLoader$1.run(URLClassLoader.java:200)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:188)
at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
at java.lang.ClassLoader.loadClass(ClassLoader.java:251)
at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:
319)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:247)
at
org
.apache.openejb.core.TempClassLoader.loadClass(TempClassLoader.java:
102)
at
org
.apache.openejb.core.TempClassLoader.loadClass(TempClassLoader.java:
50)
at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:
319)
... 27 more
Tomcat StandardClassLoader does not find the Currency type.
To be honest, I'm a bit lost with classloaders. TempClassLoader is in
charge
of loading sessions beans and entities while Tomcat class loader
loads all
what is in openejb/lib ? Is that correct ?
Still investigating...
Regards,
Jean-Sébastien Scrève.
David Blevins wrote:
Also looking at this info:
https://issues.apache.org/jira/browse/OPENJPA-646
Jean-Sébastien, if you have a stacktrace of the
ClassNotFoundException
that'd be great.
-David
On May 27, 2009, at 4:58 PM, David Blevins wrote:
Moving this to the dev list.
Still looking over the info but the svn revision for the isEnum
method pulls up this info:
http://svn.apache.org/viewvc?view=rev&revision=720223
http://issues.apache.org/jira/browse/OPENEJB-951
-David
On May 27, 2009, at 9:56 AM, Jean-Sébastien Scrève wrote:
Hi,
I have a pretty annoying problem with Enum types.
I have the following session bean implementation :
@WebService
@Stateless (name =
"net.atos.xastory.csm.contract.CatalogueStockManagementService")
@Local (CatalogueStockManagementService.class)
public class CatalogueStockManagementServiceImpl implements
net.atos.xastory.csm.contract.CatalogueStockManagementService {
public Price getPrice() {
return new Price();
}
private Currency getCurrency() {
return net.atos.xastory.csm.core.product.Currency.EUR;
}
}
Price is a POJO. Currency is an Enum type.
I have a Class Not Found exception on the Currency type at OpenEJB
startup.
(OpenEJB + Tomcat).
I dug into the problem and I think I found the problem.
In TempClassLoader I see the following change :
// Annotation classes must be loaded by the normal classloader
// So must Enum classes to prevent problems with the sun jdk.
if (isAnnotationClass(bytes) || isEnum(bytes)) {
return Class.forName(name, resolve,
getClass().getClassLoader());
}
isEnum was added recently and causes my problem. Was is the
problem
we want
to avoid with Jdk ?
Shouldn't we try loading from TempClassLoader first then do a
Class.forName() ?
I can fill up a JIRA if want to.
Regards,
Jean-Sébastien Scrève.
--
View this message in context:
http://www.nabble.com/Enum-class-loading-in-a-session-bean-tp23746554p23746554.html
Sent from the OpenEJB User mailing list archive at Nabble.com.
--
View this message in context:
http://www.nabble.com/Re%3A-Enum-class-loading-in-a-session-bean-tp23752987p23757608.html
Sent from the OpenEJB Dev mailing list archive at Nabble.com.