当我将多弹簧Spring应用程序从Spring 4.1.8升级到4.2.3时,我在websphere应用程序服务器(版本8.5.5)中得到一个奇怪的ClassNotFoundException
。类加载器找不到的类位于类路径中,并且在以前版本的Spring中找到。
[11.12.15 10:04:27:536 CET] 0000004f FfdcProvider W com.ibm.ws.ffdc.impl.FfdcProvider logIncident FFDC1003I: FFDC Incident emitted on D:\devsbb\websphere\was8_5\IBM\WebSphere\AppServer\profiles\AppSrv01\logs\ffdc\server1_bc0c2481_15.12.11_10.04.27.4771875357035970693584.txt com.ibm.ws.webcontainer.webapp.WebApp.notifyServletContextCreated 1341
[11.12.15 10:04:27:536 CET] 0000004f webapp E com.ibm.ws.webcontainer.webapp.WebApp notifyServletContextCreated SRVE0283E: Exception caught while initializing context: {0}
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'showCaseViewModel' defined in BeanDefinition defined in file [D:\devsbb\websphere\was8_5\IBM\WebSphere\AppServer\profiles\AppSrv01\installedApps\localhostNode01Cell\template-ear-4.0.3-SNAPSHOT.ear\template-web-jsf.war\WEB-INF\classes\ch\sbb\myapp\presentation\ShowCaseViewModel.class]: Initialization of bean failed; nested exception is org.springframework.aop.framework.AopConfigException: Unexpected AOP exception; nested exception is java.lang.RuntimeException: java.lang.ClassNotFoundException: ch.sbb.myapp.presentation.exception.SampleTranslateableFileCopyException
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:553)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:482)
at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:306)
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:230)
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:302)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:197)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:753)
at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:838)
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:537)
at org.springframework.web.context.ContextLoader.configureAndRefreshWebApplicationContext(ContextLoader.java:446)
at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:328)
at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:107)
at com.ibm.ws.webcontainer.webapp.WebApp.notifyServletContextCreated(WebApp.java:1689)
at com.ibm.ws.webcontainer.webapp.WebAppImpl.initialize(WebAppImpl.java:414)
at com.ibm.ws.webcontainer.webapp.WebGroupImpl.addWebApplication(WebGroupImpl.java:88)
at com.ibm.ws.webcontainer.VirtualHostImpl.addWebApplication(VirtualHostImpl.java:169)
at com.ibm.ws.webcontainer.WSWebContainer.addWebApp(WSWebContainer.java:749)
at com.ibm.ws.webcontainer.WSWebContainer.addWebApplication(WSWebContainer.java:634)
at com.ibm.ws.webcontainer.component.WebContainerImpl.install(WebContainerImpl.java:426)
at com.ibm.ws.webcontainer.component.WebContainerImpl.start(WebContainerImpl.java:718)
at com.ibm.ws.runtime.component.ApplicationMgrImpl.start(ApplicationMgrImpl.java:1177)
at com.ibm.ws.runtime.component.DeployedApplicationImpl.fireDeployedObjectStart(DeployedApplicationImpl.java:1370)
at com.ibm.ws.runtime.component.DeployedModuleImpl.start(DeployedModuleImpl.java:639)
at com.ibm.ws.runtime.component.DeployedApplicationImpl.start(DeployedApplicationImpl.java:968)
at com.ibm.ws.runtime.component.ApplicationMgrImpl.startApplication(ApplicationMgrImpl.java:776)
at com.ibm.ws.runtime.component.ApplicationMgrImpl$5.run(ApplicationMgrImpl.java:2195)
at com.ibm.ws.security.auth.ContextManagerImpl.runAs(ContextManagerImpl.java:5474)
at com.ibm.ws.security.auth.ContextManagerImpl.runAsSystem(ContextManagerImpl.java:5600)
at com.ibm.ws.security.core.SecurityContext.runAsSystem(SecurityContext.java:255)
at com.ibm.ws.runtime.component.ApplicationMgrImpl.start(ApplicationMgrImpl.java:2200)
at com.ibm.ws.runtime.component.CompositionUnitMgrImpl.start(CompositionUnitMgrImpl.java:389)
at com.ibm.ws.runtime.component.CompositionUnitImpl.start(CompositionUnitImpl.java:123)
at com.ibm.ws.runtime.component.CompositionUnitMgrImpl.start(CompositionUnitMgrImpl.java:332)
at com.ibm.ws.runtime.component.CompositionUnitMgrImpl.access$500(CompositionUnitMgrImpl.java:119)
at com.ibm.ws.runtime.component.CompositionUnitMgrImpl$CUInitializer.run(CompositionUnitMgrImpl.java:938)
at com.ibm.wsspi.runtime.component.WsComponentImpl$_AsynchInitializer.run(WsComponentImpl.java:502)
at com.ibm.ws.util.ThreadPool$Worker.run(ThreadPool.java:1864)
Caused by: org.springframework.aop.framework.AopConfigException: Unexpected AOP exception; nested exception is java.lang.RuntimeException: java.lang.ClassNotFoundException: ch.sbb.myapp.presentation.exception.SampleTranslateableFileCopyException
at org.springframework.aop.framework.CglibAopProxy.getProxy(CglibAopProxy.java:218)
at org.springframework.aop.framework.ProxyFactory.getProxy(ProxyFactory.java:109)
at org.springframework.aop.scope.ScopedProxyFactoryBean.setBeanFactory(ScopedProxyFactoryBean.java:111)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeAwareMethods(AbstractAutowireCapableBeanFactory.java:1597)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1565)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:545)
... 36 more
Caused by: java.lang.RuntimeException: java.lang.ClassNotFoundException: ch.sbb.myapp.presentation.exception.SampleTranslateableFileCopyException
at org.springframework.asm.ClassWriter.getCommonSuperClass(ClassWriter.java:1684)
at org.springframework.asm.ClassWriter.getMergedType(ClassWriter.java:1654)
at org.springframework.asm.Frame.merge(Frame.java:1426)
at org.springframework.asm.Frame.merge(Frame.java:1337)
at org.springframework.asm.MethodWriter.visitMaxs(MethodWriter.java:1475)
at org.springframework.cglib.core.CodeEmitter.visitMaxs(CodeEmitter.java:842)
at org.springframework.cglib.transform.impl.UndeclaredThrowableTransformer$1.visitMaxs(UndeclaredThrowableTransformer.java:56)
at org.springframework.cglib.core.CodeEmitter.visitMaxs(CodeEmitter.java:842)
at org.springframework.cglib.core.CodeEmitter.end_method(CodeEmitter.java:138)
at org.springframework.cglib.proxy.MethodInterceptorGenerator.generate(MethodInterceptorGenerator.java:131)
at org.springframework.cglib.proxy.Enhancer.emitMethods(Enhancer.java:1005)
at org.springframework.cglib.proxy.Enhancer.generateClass(Enhancer.java:509)
at org.springframework.cglib.transform.TransformingClassGenerator.generateClass(TransformingClassGenerator.java:33)
at org.springframework.cglib.core.DefaultGeneratorStrategy.generate(DefaultGeneratorStrategy.java:25)
at org.springframework.cglib.core.AbstractClassGenerator.create(AbstractClassGenerator.java:231)
at org.springframework.cglib.proxy.Enhancer.createHelper(Enhancer.java:378)
at org.springframework.cglib.proxy.Enhancer.createClass(Enhancer.java:318)
at org.springframework.aop.framework.ObjenesisCglibAopProxy.createProxyClassAndInstance(ObjenesisCglibAopProxy.java:55)
at org.springframework.aop.framework.CglibAopProxy.getProxy(CglibAopProxy.java:202)
... 41 more
这是我的班级:
package ch.sbb.myapp.presentation;
import java.util.HashSet;
import java.util.Set;
import javax.validation.ConstraintViolation;
import javax.validation.ConstraintViolationException;
import javax.validation.Validation;
import javax.validation.Validator;
import javax.validation.ValidatorFactory;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import ch.sbb.esta.core.stereotype.Scope;
import ch.sbb.esta.core.stereotype.web.EstaViewModel;
import ch.sbb.esta.core.type.Email;
import ch.sbb.myapp.exception.TemplateErrorCode;
import ch.sbb.myapp.model.Customer;
import ch.sbb.myapp.model.CustomerStatus;
import ch.sbb.myapp.model.i18n.I18nMessageKey;
import ch.sbb.myapp.presentation.exception.SampleTranslateableFileCopyException;
/**
* ViewModel für den Primefaces Showcase.
*/
@EstaViewModel(scope = Scope.REQUEST)
public class ShowCaseViewModel {
private static final Logger LOGGER = LoggerFactory.getLogger(ShowCaseViewModel.class);
public boolean isMcaIntegrationInClasspath() {
try {
this.getClass().getClassLoader().loadClass("ch.sbb.myapp.presentation.McaDemoViewModel");
return true;
} catch (ClassNotFoundException e) { // NOSONAR: is just a check whether MCA integration is on the classpath
return false;
}
}
public CustomerStatus getCustomerStatusNull() {
return null;
}
public void setCustomerStatusNull(CustomerStatus t) {
}
public CustomerStatus getCustomerStatus() {
return CustomerStatus.VIP;
}
public void throwEstaException() throws SampleTranslateableFileCopyException {
throw new SampleTranslateableFileCopyException(I18nMessageKey.ERROR_WHILE_CALLING_SERVICE,
TemplateErrorCode.FILE_COPY_ERROR_CODE, "fileA", "fileB");
}
public void logValidationException() {
Customer wrongCustomer = new Customer("fi", "la", new Email("bla@sbb.ch"));
ValidatorFactory factory = Validation.buildDefaultValidatorFactory();
Validator validator = factory.getValidator();
Set<ConstraintViolation<Customer>> violations = validator.validate(wrongCustomer);
Set<ConstraintViolation<?>> violationsWithoutType = new HashSet<>();
violationsWithoutType.addAll(violations);
LOGGER.warn("violated exception", new ConstraintViolationException("bla", violationsWithoutType));
}
}
注释@EstaViewModel
被声明为一个简单的@Component:
@Inherited
@Component
@Retention(RetentionPolicy.RUNTIME)
@Target({ ElementType.TYPE })
public @interface EstaViewModel {
String value() default "";
Scope scope() default Scope.REQUEST;
}
所有其他具有@EstaViewModel
注释的类都会初始化而没有任何问题。
有什么想法吗?