tomee-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Romain Manni-Bucau <rmannibu...@gmail.com>
Subject Re: AW: Class loading problem in TomEE 1.5.1
Date Wed, 20 Feb 2013 19:44:10 GMT
sad to say you didn't reproduce it completely but i got the issue.

first i don't think it is linked to tomcat (if you use tomcat clustering
classes you'll not get it).

the fix is simply to not use an ObjectInputStream but this child (in dirty
mode):

in = new ObjectInputStream(inputStream) {
                @Override
                protected Class<?> resolveClass(ObjectStreamClass desc)
                        throws IOException, ClassNotFoundException {
                    return
Thread.currentThread().getContextClassLoader().loadClass(desc.getName());
                }
            };

if you update your sample with this code it will work fine.

Tomcat more or less does it automatically.

I don't have time to go further right now but i think somebody else is
serializing without respecting the TCCL.

*Romain Manni-Bucau*
*Twitter: @rmannibucau <https://twitter.com/rmannibucau>*
*Blog: **http://rmannibucau.wordpress.com/*<http://rmannibucau.wordpress.com/>
*LinkedIn: **http://fr.linkedin.com/in/rmannibucau*
*Github: https://github.com/rmannibucau*



2013/2/20 <dmitry.volkov@eiskonzept.com>

> Hi,
>
> I have just reproduced an issue which I have in my Application.
> Steps to reproduce:
>
> *Checkout project from https://github.com/eiskonzept/tomee/
> *Start TomEE maven plugin with node1 profile
> *Open in browser: /<application_context_root>/index.xhtml
> *Press submit button.
> *Following code will be executed:
>         ByteArrayOutputStream byteArrayOutputStream = new
> ByteArrayOutputStream();
>         SerializationUtils.serialize(new DefaultRequestTypeResolver(),
> byteArrayOutputStream);
>         byte[] bytes = byteArrayOutputStream.toByteArray();
>         try {
>             byteArrayOutputStream.close();
>         } catch (IOException e) {
>             e.printStackTrace();        }
>         Object deserialize = SerializationUtils.deserialize(bytes);
>
> Exception:
> org.apache.commons.lang.SerializationException:
> java.lang.ClassNotFoundException:
> org.apache.myfaces.extensions.cdi.jsf2.impl.request.DefaultRequestTypeResolver
>
> org.apache.commons.lang.SerializationUtils.deserialize(SerializationUtils.java:166)
>
> org.apache.commons.lang.SerializationUtils.deserialize(SerializationUtils.java:193)
>
> de.test.PassivationCapableBean.submit(PassivationCapableBean.java:55)
>         sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
>
> sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
>
> sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
>         java.lang.reflect.Method.invoke(Method.java:601)
>
> org.apache.webbeans.intercept.InterceptorHandler.invoke(InterceptorHandler.java:322)
>
> org.apache.webbeans.intercept.NormalScopedBeanInterceptorHandler.invoke(NormalScopedBeanInterceptorHandler.java:117)
>
> org.apache.webbeans.intercept.NormalScopedBeanInterceptorHandler.invoke(NormalScopedBeanInterceptorHandler.java:108)
>
> de.test.PassivationCapableBean_$$_javassist_27.submit(PassivationCapableBean_$$_javassist_27.java)
>         sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
>
> sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
>
> sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
>         java.lang.reflect.Method.invoke(Method.java:601)
>         org.apache.el.parser.AstValue.invoke(AstValue.java:278)
>
> org.apache.el.MethodExpressionImpl.invoke(MethodExpressionImpl.java:274)
>
> org.apache.myfaces.view.facelets.el.ContextAwareTagMethodExpression.invoke(ContextAwareTagMethodExpression.java:96)
>
> org.apache.myfaces.application.ActionListenerImpl.processAction(ActionListenerImpl.java:68)
>
> org.apache.myfaces.extensions.cdi.jsf.impl.security.SecurityViolationAwareActionListener.processAction(SecurityViolationAwareActionListener.java:56)
>
> org.apache.myfaces.extensions.cdi.jsf.impl.config.view.ViewControllerActionListener.processAction(ViewControllerActionListener.java:68)
>
> org.apache.myfaces.extensions.cdi.jsf.impl.listener.action.CodiActionListener.processAction(CodiActionListener.java:58)
>         javax.faces.component.UICommand.broadcast(UICommand.java:120)
>
> javax.faces.component.UIViewRoot._broadcastAll(UIViewRoot.java:1028)
>
> javax.faces.component.UIViewRoot.broadcastEvents(UIViewRoot.java:286)
>         javax.faces.component.UIViewRoot._process(UIViewRoot.java:1375)
>
> javax.faces.component.UIViewRoot.processApplication(UIViewRoot.java:752)
>
> org.apache.myfaces.lifecycle.InvokeApplicationExecutor.execute(InvokeApplicationExecutor.java:38)
>
> org.apache.myfaces.lifecycle.LifecycleImpl.executePhase(LifecycleImpl.java:170)
>
> org.apache.myfaces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:117)
>
> org.apache.myfaces.extensions.cdi.jsf2.impl.listener.phase.CodiLifecycleWrapper.execute(CodiLifecycleWrapper.java:95)
>         javax.faces.webapp.FacesServlet.service(FacesServlet.java:197)
>
>
> -----Ursprüngliche Nachricht-----
> Von: Romain Manni-Bucau [mailto:rmannibucau@gmail.com]
> Gesendet: Mittwoch, 6. Februar 2013 14:42
> An: users@tomee.apache.org
> Betreff: Re: AW: Class loading problem in TomEE 1.5.1
>
> yep, i just commited it today so it will be available tomorrow
>
> *Romain Manni-Bucau*
> *Twitter: @rmannibucau <https://twitter.com/rmannibucau>*
> *Blog: **http://rmannibucau.wordpress.com/*<
> http://rmannibucau.wordpress.com/>
> *LinkedIn: **http://fr.linkedin.com/in/rmannibucau*
> *Github: https://github.com/rmannibucau*
>
>
>
> 2013/2/6 <dmitry.volkov@eiskonzept.com>
>
> > What should I rebuild from sources? :) I just replaced as proposed:
> >
> > org.apache.commons.logging.Log=org.apache.commons.logging.impl.Log4JLo
> > gger
> > by
> > org.apache.commons.logging.Log=org.apache.openejb.log.commonslogging.L
> > og4J4AppOpenEJB4ContainerLog
> >
> > in my commons-logging.properties.
> > Or I got you wrong and this workaround will work only in future builds?
> >
> > -----Ursprüngliche Nachricht-----
> > Von: Romain Manni-Bucau [mailto:rmannibucau@gmail.com]
> > Gesendet: Mittwoch, 6. Februar 2013 12:09
> > An: users@tomee.apache.org
> > Betreff: Re: AW: Class loading problem in TomEE 1.5.1
> >
> > you rebuilt it from sources?
> >
> > *Romain Manni-Bucau*
> > *Twitter: @rmannibucau <https://twitter.com/rmannibucau>*
> > *Blog: **http://rmannibucau.wordpress.com/*<
> > http://rmannibucau.wordpress.com/>
> > *LinkedIn: **http://fr.linkedin.com/in/rmannibucau*
> > *Github: https://github.com/rmannibucau*
> >
> >
> >
> > 2013/2/6 <dmitry.volkov@eiskonzept.com>
> >
> > > Just tried proposed workaround and got exception:
> > >
> > > Error configuring application listener of class
> > > com.opensymphony.webwork.lifecycle.SessionLifecycleListener
> > > java.lang.ExceptionInInitializerError
> > >         at
> > > sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native
> > > Method)
> > >         at
> > >
> > sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructo
> > rAccessorImpl.java:57)
> > >         at
> > >
> > sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingCo
> > nstructorAccessorImpl.java:45)
> > >         at
> > java.lang.reflect.Constructor.newInstance(Constructor.java:525)
> > >         at
> > >
> > org.apache.webbeans.inject.InjectableConstructor.doInjection(Injectabl
> > eConstructor.java:89)
> > >         at
> > >
> > org.apache.openejb.cdi.ConstructorInjectionBean.createInstance(Constru
> > ctorInjectionBean.java:77)
> > >         at
> > >
> > org.apache.webbeans.component.AbstractOwbBean.create(AbstractOwbBean.j
> > ava:186)
> > >         at
> > > org.apache.openejb.core.WebContext.newInstance(WebContext.java:107)
> > >         at
> > >
> > org.apache.tomee.catalina.JavaeeInstanceManager.newInstance(JavaeeInst
> > anceManager.java:55)
> > >         at
> > >
> > org.apache.tomee.catalina.JavaeeInstanceManager.newInstance(JavaeeInst
> > anceManager.java:48)
> > >         at
> > >
> > org.apache.catalina.core.StandardContext.listenerStart(StandardContext
> > .java:4727)
> > >         at
> > >
> > org.apache.catalina.core.StandardContext.startInternal(StandardContext
> > .java:5285)
> > >         at
> > > org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
> > >         at
> > >
> > org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.
> > java:901)
> > >         at
> > > org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:877)
> > >         at
> > > org.apache.catalina.core.StandardHost.addChild(StandardHost.java:633)
> > >         at
> > >
> > org.apache.catalina.startup.HostConfig.deployDescriptor(HostConfig.jav
> > a:657)
> > >         at
> > >
> > org.apache.catalina.startup.HostConfig$DeployDescriptor.run(HostConfig
> > .java:1637)
> > >         at
> > > java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:471)
> > >         at
> > > java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:334)
> > >         at java.util.concurrent.FutureTask.run(FutureTask.java:166)
> > >         at
> > >
> > java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.j
> > ava:1110)
> > >         at
> > >
> > java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.
> > java:603)
> > >         at java.lang.Thread.run(Thread.java:722)
> > > Caused by: org.apache.commons.logging.LogConfigurationException:
> > > User-specified log class
> > > 'org.apache.openejb.log.commonslogging.Log4J4AppOpenEJB4ContainerLog'
> > > cannot be found or is not useable.
> > >         at
> > >
> > org.apache.commons.logging.impl.LogFactoryImpl.discoverLogImplementati
> > on(LogFactoryImpl.java:874)
> > >         at
> > >
> > org.apache.commons.logging.impl.LogFactoryImpl.newInstance(LogFactoryI
> > mpl.java:604)
> > >         at
> > >
> > org.apache.commons.logging.impl.LogFactoryImpl.getInstance(LogFactoryI
> > mpl.java:336)
> > >         at
> > >
> > org.apache.commons.logging.impl.LogFactoryImpl.getInstance(LogFactoryI
> > mpl.java:310)
> > >         at
> > > org.apache.commons.logging.LogFactory.getLog(LogFactory.java:685)
> > >         at
> > >
> > com.opensymphony.webwork.lifecycle.SessionLifecycleListener.<clinit>(S
> > essionLifecycleListener.java:28)
> > >         ... 24 more
> > >
> > > -----Ursprüngliche Nachricht-----
> > > Von: Romain Manni-Bucau [mailto:rmannibucau@gmail.com]
> > > Gesendet: Mittwoch, 6. Februar 2013 11:21
> > > An: users@tomee.apache.org
> > > Betreff: Re: AW: Class loading problem in TomEE 1.5.1
> > >
> > > that's more or less a bug in commons-logging which respects
> > > classloading but uses the current class loader configuration even
> > > when instantiating classes from upper classloader.
> > >
> > > It means it works for your app but not for the container part
> > > (myfaces) which will reuse your config but the parent classloader.
> > >
> > > The workaround i added is the following one:
> > >
> > > replace
> > > org.apache.commons.logging.Log=org.apache.commons.logging.impl.Log4J
> > > Lo
> > > gger
> > > by
> > > org.apache.commons.logging.Log=org.apache.openejb.log.commonslogging.
> > > Log4J4AppOpenEJB4ContainerLog
> > >
> > > i opened https://issues.apache.org/jira/browse/TOMEE-758 about it
> > >
> > > PS: you can implement any other facade you'd like to match your need
> > >
> > > *Romain Manni-Bucau*
> > > *Twitter: @rmannibucau <https://twitter.com/rmannibucau>*
> > > *Blog: **http://rmannibucau.wordpress.com/*<
> > > http://rmannibucau.wordpress.com/>
> > > *LinkedIn: **http://fr.linkedin.com/in/rmannibucau*
> > > *Github: https://github.com/rmannibucau*
> > >
> > >
> > >
> > > 2013/2/5 <dmitry.volkov@eiskonzept.com>
> > >
> > > > just have reproduced not exactly the same issue, but very similar,
> > > > in my test project:  https://github.com/eiskonzept/tomee
> > > > Just package the app and start tomee-plugin with node1 profile.
> > > >
> > > > Explanation:
> > > > I have two dependencies in my project: commons-logging and log4j.
> > > > If I package both libraries in my webapp I become:
> > > > "LogConfigurationException: User-specified log class
> > > > 'org.apache.commons.logging.impl.Log4JLogger' cannot be found or
> > > > is not useable"
> > > > which means that commons-logging can't find Log4JLogger class.
> > > >
> > > > When I put log4j.jar in tomee's lib folder it works just fine. But
> > > > I can't do this with other libraries in real Project, because we
> > > > use some special versions of libraries(quartz for example) which
> > > > are
> > > provided by tomee too.
> > > >
> > > > is there any possibility to use my own versions of libraries which
> > > > already provided by tomee?
> > > >
> > > > -----Ursprüngliche Nachricht-----
> > > > Von: dmitry.volkov@eiskonzept.com
> > > > [mailto:dmitry.volkov@eiskonzept.com]
> > > > Gesendet: Montag, 4. Februar 2013 13:12
> > > > An: users@tomee.apache.org
> > > > Betreff: AW: AW: Class loading problem in TomEE 1.5.1
> > > >
> > > > I got further by copying log4j.jar in CATALINA_BASE/lib folder,
> > > > but then I got next NoClassDefFoundError.
> > > > Most confusing is that the same application deployed in TomEE
> > > > Version 1.5.0 works perfectly.
> > > > I believe it is some kind of class loader issue. Are there some
> > > > significant class loader changes between version 1.5.0 and 1.5.1?
> > > > It looks like that container is loading some classes from
> > > > container provided commons-logging.jar first, and then can't find
> > > > some classes in WEB-APP/lib which needed by commons-logging.
> > > >
> > > > -----Ursprüngliche Nachricht-----
> > > > Von: Romain Manni-Bucau [mailto:rmannibucau@gmail.com]
> > > > Gesendet: Montag, 4. Februar 2013 12:13
> > > > An: users@tomee.apache.org
> > > > Betreff: Re: AW: Class loading problem in TomEE 1.5.1
> > > >
> > > > Hard to help since we dont "see" the issue
> > > >
> > > > You probably have some conflict in your app.
> > > >
> > > > Check your deps maybe
> > > > Le 4 févr. 2013 12:11, <dmitry.volkov@eiskonzept.com> a écrit
:
> > > >
> > > > > I have tried both: with commons-logging in my war file and without.
> > > > > With same result(exception) in both cases.
> > > > > I have tried to isolate the issue in small sample app, but
> > > > > without success. Unfortunately I can't provide full application
> > > > > for
> > > reproduction.
> > > > > Could you give some hints, how can I help you to reproduce the
> > > > > problem on your side or solve the issue by myself?
> > > > >
> > > > >
> > > > > > Note: did you put commons-logging in your app too?
> > > > >
> > > > > > can you reproduce it in a sample webapp?
> > > > >
> > > >
> > >
> >
>

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message