geronimo-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Kevan Miller <kevan.mil...@gmail.com>
Subject NoClassDefFoundError trying to use log4j SMTPAppender
Date Fri, 02 Mar 2012 15:02:21 GMT
On IRC, yesterday, a user reported a problem deploying their app on Geronimo 2.2.1. They had
an exception like the following:

ERROR Servlet /analytics threw load() exception
org.springframework.beans.PropertyBatchUpdateException; nested PropertyAccessException details
(1) are:
PropertyAccessException 1:
org.springframework.beans.MethodInvocationException: Property 'accountService' threw exception;
nested exception is java.lang.NoClassDefFoundError: javax/mail/Multipart
	at org.springframework.beans.BeanWrapperImpl.setPropertyValue(BeanWrapperImpl.java:1119)
	at org.springframework.beans.BeanWrapperImpl.setPropertyValue(BeanWrapperImpl.java:899)
	at org.springframework.beans.AbstractPropertyAccessor.setPropertyValues(AbstractPropertyAccessor.java:76)
	at org.springframework.beans.AbstractPropertyAccessor.setPropertyValues(AbstractPropertyAccessor.java:58)
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyPropertyValues(AbstractAutowireCapableBeanFactory.java:1350)
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1076)
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:517)
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:456)
	at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:291)
	at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222)
	at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:288)
	at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:190)
	at org.springframework.context.support.AbstractApplicationContext.getBean(AbstractApplicationContext.java:1075)
	at org.springframework.web.servlet.handler.AbstractUrlHandlerMapping.registerHandler(AbstractUrlHandlerMapping.java:383)
	at org.springframework.web.servlet.handler.AbstractUrlHandlerMapping.registerHandler(AbstractUrlHandlerMapping.java:362)
	at org.springframework.web.servlet.handler.AbstractDetectingUrlHandlerMapping.detectHandlers(AbstractDetectingUrlHandlerMapping.java:82)
	at org.springframework.web.servlet.handler.AbstractDetectingUrlHandlerMapping.initApplicationContext(AbstractDetectingUrlHandlerMapping.java:58)
	at org.springframework.context.support.ApplicationObjectSupport.initApplicationContext(ApplicationObjectSupport.java:119)
	at org.springframework.web.context.support.WebApplicationObjectSupport.initApplicationContext(WebApplicationObjectSupport.java:72)
	at org.springframework.context.support.ApplicationObjectSupport.setApplicationContext(ApplicationObjectSupport.java:73)
	at org.springframework.context.support.ApplicationContextAwareProcessor.invokeAwareInterfaces(ApplicationContextAwareProcessor.java:106)
	at org.springframework.context.support.ApplicationContextAwareProcessor.postProcessBeforeInitialization(ApplicationContextAwareProcessor.java:85)
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyBeanPostProcessorsBeforeInitialization(AbstractAutowireCapableBeanFactory.java:394)
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1405)
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:519)
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:456)
	at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:291)
	at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222)
	at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:288)
	at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:194)
	at org.springframework.beans.factory.support.DefaultListableBeanFactory.getBeansOfType(DefaultListableBeanFactory.java:398)
	at org.springframework.context.support.AbstractApplicationContext.getBeansOfType(AbstractApplicationContext.java:1146)
	at org.springframework.beans.factory.BeanFactoryUtils.beansOfTypeIncludingAncestors(BeanFactoryUtils.java:266)
	at org.springframework.beans.factory.BeanFactoryUtils.beansOfTypeIncludingAncestors(BeanFactoryUtils.java:270)
	at org.springframework.web.servlet.DispatcherServlet.initHandlerMappings(DispatcherServlet.java:424)
	at org.springframework.web.servlet.DispatcherServlet.initStrategies(DispatcherServlet.java:339)
	at org.springframework.web.servlet.DispatcherServlet.onRefresh(DispatcherServlet.java:328)
	at org.springframework.web.servlet.FrameworkServlet.onApplicationEvent(FrameworkServlet.java:523)
	at org.springframework.web.servlet.FrameworkServlet$ContextRefreshListener.onApplicationEvent(FrameworkServlet.java:749)
	at org.springframework.web.servlet.FrameworkServlet$ContextRefreshListener.onApplicationEvent(FrameworkServlet.java:1)
	at org.springframework.context.event.GenericApplicationListenerAdapter.onApplicationEvent(GenericApplicationListenerAdapter.java:51)
	at org.springframework.context.event.SourceFilteringListener.onApplicationEventInternal(SourceFilteringListener.java:97)
	at org.springframework.context.event.SourceFilteringListener.onApplicationEvent(SourceFilteringListener.java:68)
	at org.springframework.context.event.SimpleApplicationEventMulticaster.multicastEvent(SimpleApplicationEventMulticaster.java:97)
	at org.springframework.context.support.AbstractApplicationContext.publishEvent(AbstractApplicationContext.java:303)
	at org.springframework.context.support.AbstractApplicationContext.finishRefresh(AbstractApplicationContext.java:911)
	at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:428)
	at org.springframework.web.servlet.FrameworkServlet.createWebApplicationContext(FrameworkServlet.java:442)
	at org.springframework.web.servlet.FrameworkServlet.createWebApplicationContext(FrameworkServlet.java:458)
	at org.springframework.web.servlet.FrameworkServlet.initWebApplicationContext(FrameworkServlet.java:339)
	at org.springframework.web.servlet.FrameworkServlet.initServletBean(FrameworkServlet.java:306)
	at org.springframework.web.servlet.HttpServletBean.init(HttpServletBean.java:127)
	at javax.servlet.GenericServlet.init(GenericServlet.java:215)
	at org.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper.java:1065)
	at org.apache.catalina.core.StandardWrapper.load(StandardWrapper.java:967)
	at org.apache.catalina.core.StandardContext.loadOnStartup(StandardContext.java:4343)
	at org.apache.catalina.core.StandardContext.start(StandardContext.java:4649)
	at org.apache.geronimo.tomcat.GeronimoStandardContext.access$201(GeronimoStandardContext.java:64)
	at org.apache.geronimo.tomcat.GeronimoStandardContext$SystemMethodValve.invoke(GeronimoStandardContext.java:412)
	at org.apache.geronimo.tomcat.valve.GeronimoBeforeAfterValve.invoke(GeronimoBeforeAfterValve.java:47)
	at org.apache.geronimo.tomcat.GeronimoStandardContext.start(GeronimoStandardContext.java:264)
	at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:791)
	at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:771)
	at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:546)
	at org.apache.geronimo.tomcat.TomcatContainer.addContext(TomcatContainer.java:339)
	at org.apache.geronimo.tomcat.TomcatWebAppContext.doStart(TomcatWebAppContext.java:525)
	at org.apache.geronimo.gbean.runtime.GBeanInstance.createInstance(GBeanInstance.java:953)
	at org.apache.geronimo.gbean.runtime.GBeanInstanceState.attemptFullStart(GBeanInstanceState.java:269)
	at org.apache.geronimo.gbean.runtime.GBeanInstanceState.start(GBeanInstanceState.java:103)
	at org.apache.geronimo.gbean.runtime.GBeanInstance.start(GBeanInstance.java:525)
	at org.apache.geronimo.gbean.runtime.GBeanDependency.attemptFullStart(GBeanDependency.java:110)
	at org.apache.geronimo.gbean.runtime.GBeanDependency.addTarget(GBeanDependency.java:145)
	at org.apache.geronimo.gbean.runtime.GBeanDependency$1.running(GBeanDependency.java:119)
	at org.apache.geronimo.kernel.basic.BasicLifecycleMonitor.fireRunningEvent(BasicLifecycleMonitor.java:175)
	at org.apache.geronimo.kernel.basic.BasicLifecycleMonitor.access$300(BasicLifecycleMonitor.java:44)
	at org.apache.geronimo.kernel.basic.BasicLifecycleMonitor$RawLifecycleBroadcaster.fireRunningEvent(BasicLifecycleMonitor.java:253)
	at org.apache.geronimo.gbean.runtime.GBeanInstanceState.attemptFullStart(GBeanInstanceState.java:295)
	at org.apache.geronimo.gbean.runtime.GBeanInstanceState.start(GBeanInstanceState.java:103)
	at org.apache.geronimo.gbean.runtime.GBeanInstanceState.startRecursive(GBeanInstanceState.java:125)
	at org.apache.geronimo.gbean.runtime.GBeanInstance.startRecursive(GBeanInstance.java:539)
	at org.apache.geronimo.kernel.basic.BasicKernel.startRecursiveGBean(BasicKernel.java:377)
	at org.apache.geronimo.kernel.config.ConfigurationUtil.startConfigurationGBeans(ConfigurationUtil.java:456)
	at org.apache.geronimo.kernel.config.KernelConfigurationManager.start(KernelConfigurationManager.java:190)
	at org.apache.geronimo.kernel.config.SimpleConfigurationManager.startConfiguration(SimpleConfigurationManager.java:546)
	at sun.reflect.GeneratedMethodAccessor22.invoke(Unknown Source)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
	at java.lang.reflect.Method.invoke(Method.java:597)
	at org.apache.geronimo.gbean.runtime.ReflectionMethodInvoker.invoke(ReflectionMethodInvoker.java:34)
	at org.apache.geronimo.gbean.runtime.GBeanOperation.invoke(GBeanOperation.java:130)
	at org.apache.geronimo.gbean.runtime.GBeanInstance.invoke(GBeanInstance.java:816)
	at org.apache.geronimo.gbean.runtime.RawInvoker.invoke(RawInvoker.java:57)
	at org.apache.geronimo.kernel.basic.RawOperationInvoker.invoke(RawOperationInvoker.java:35)
	at org.apache.geronimo.kernel.basic.ProxyMethodInterceptor.intercept(ProxyMethodInterceptor.java:96)
	at org.apache.geronimo.gbean.GBeanLifecycle$$EnhancerByCGLIB$$badafacb.startConfiguration(<generated>)
	at org.apache.geronimo.system.main.EmbeddedDaemon.doStartup(EmbeddedDaemon.java:204)
	at org.apache.geronimo.system.main.EmbeddedDaemon.execute(EmbeddedDaemon.java:87)
	at org.apache.geronimo.kernel.util.MainConfigurationBootstrapper.main(MainConfigurationBootstrapper.java:45)
	at org.apache.geronimo.cli.AbstractCLI.executeMain(AbstractCLI.java:65)
	at org.apache.geronimo.cli.daemon.DaemonCLI.main(DaemonCLI.java:30)
Caused by: java.lang.NoClassDefFoundError: javax/mail/Multipart
	at com.vistracks.tracking.web.controller.AccountController.setAccountService(AccountController.java:48)
	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.springframework.beans.BeanWrapperImpl.setPropertyValue(BeanWrapperImpl.java:1106)
	... 98 more
Caused by: java.lang.ClassNotFoundException: javax.mail.Multipart
	at java.net.URLClassLoader$1.run(URLClassLoader.java:202)
	at java.security.AccessController.doPrivileged(Native Method)
	at java.net.URLClassLoader.findClass(URLClassLoader.java:190)
	at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
	at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
	at java.lang.ClassLoader.loadClass(ClassLoader.java:247)
	... 104 more

The problem was caused by their use of org.apache.log4j.net.SMTPAppender (actually they were
using com.tgerm.log4j.appender.GmailSMTPAppender, which extends SMTPAppender).

log4j was being loaded from the Geronimo root classloader (log4j is packaged in our lib).
The root classloader does not include the javamail spec api classes. And thus we end up with
a confusing NoClassDefFoundError.

Their app included log4j. So, adding:

                <dep:hidden-classes>
                        <dep:filter>org.apache.log4j</dep:filter>
                </dep:hidden-classes>

to their deployment plan fixed the problem. If the app didn't include log4j, you could add
a dependency for the log4j jar in their deployment plan…

You should probably also review docs on application specific logging -- https://cwiki.apache.org/GMOxDOC22/configuring-application-specific-logging-with-log4j.html

--kevan
Mime
View raw message