问题
I first start up my WebSphere Application Server 8.5.5.0 with no applications deployed to it, it starts up fine, text is below.
Launching defaultServer (WebSphere Application Server 8.5.5.0/wlp-1.0.3.20130510-0831) on Java HotSpot(TM) 64-Bit Server VM, version 1.7.0_51-b13 (en_US)
[AUDIT ] CWWKE0001I: The server defaultServer has been launched.
[INFO ] CWWKE0002I: The kernel started after 1.714 seconds
[INFO ] CWWKF0007I: Feature update started.
[AUDIT ] CWWKZ0058I: Monitoring dropins for applications.
[INFO ] CWWKF0008I: Feature update completed in 2.472 seconds.
[AUDIT ] CWWKF0011I: The server defaultServer is ready to run a smarter planet.
[INFO ] CWWKO0219I: TCP Channel defaultHttpEndpoint has been started and is now listening for requests on host 127.0.0.1 (IPv4: 127.0.0.1) port 9080.
While WebSphere is started up, I used Eclipse to Export my war file to Eclipse, it deploys into the plugins directory. This part is also successful, I get the additional output in the server log:
[INFO ] CWWKZ0018I: Starting application iaat.
[WARNING ] CWWJP9991W: openjpa.Runtime: Warn: An error occurred while registering a ClassTransformer with JPAPUnitInfo(PuId=iaat#iaat.war#DB2-Config)@3476b7f1. The error has been consumed. To see it, set your openjpa.Runtime log level to TRACE. Load-time class transformation will not be available.
[INFO ] CWWJP9990I: openjpa.Runtime: Info: OpenJPA dynamically loaded a validation provider.
[INFO ] SRVE0169I: Loading Web Module: iaat.
[INFO ] SRVE0250I: Web Module iaat has been bound to default_host.
[AUDIT ] CWWKT0016I: Web application available (default_host):
[AUDIT ] CWWKZ0001I: Application iaat started in 6.774 seconds.
My problem is when I attempt to bring up my application with the URL provided provided by WebSphere. While the page is coming up in Internet Explorer I get the following message in the WebSphere log. I did look at the generated War file and the class file that it complaining about is located at WEB-INF/classes/com/bah/iaat/model/data/Proposal
[INFO ] FFDC1015I: An FFDC Incident has been created: "org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'entityManagerFactory' defined in ServletContext resource [/WEB-INF/iaatadmin-servlet.xml]: Invocation of init method failed; nested exception is java.lang.NoClassDefFoundError: WEB-INF/classes/com/bah/iaat/model/data/Proposal (wrong name: com/bah/iaat/model/data/Proposal) com.ibm.ws.webcontainer.servlet.ServletWrapper.init 181" at ffdc_14.03.14_18.20.49.0.log
[ERROR ] Uncaught.init.exception.thrown.by.servlet
iaatadmin
iaat
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'entityManagerFactory' defined in ServletContext resource [/WEB-INF/iaatadmin-servlet.xml]: Invocation of init method failed; nested exception is java.lang.NoClassDefFoundError: WEB-INF/classes/com/bah/iaat/model/data/Proposal (wrong name: com/bah/iaat/model/data/Proposal)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1482)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:521)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:458)
at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:295)
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:223)
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:292)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:194)
at org.springframework.context.support.AbstractApplicationContext.getBean(AbstractApplicationContext.java:1117)
at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:922)
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:479)
at org.springframework.web.servlet.FrameworkServlet.configureAndRefreshWebApplicationContext(FrameworkServlet.java:651)
at org.springframework.web.servlet.FrameworkServlet.createWebApplicationContext(FrameworkServlet.java:599)
at org.springframework.web.servlet.FrameworkServlet.createWebApplicationContext(FrameworkServlet.java:665)
at org.springframework.web.servlet.FrameworkServlet.initWebApplicationContext(FrameworkServlet.java:518)
at org.springframework.web.servlet.FrameworkServlet.initServletBean(FrameworkServlet.java:459)
at org.springframework.web.servlet.HttpServletBean.init(HttpServletBean.java:136)
at javax.servlet.GenericServlet.init(GenericServlet.java:161)
at com.ibm.ws.webcontainer.servlet.ServletWrapper.init(ServletWrapper.java:322)
at [internal classes]
Caused by: java.lang.NoClassDefFoundError: WEB-INF/classes/com/bah/iaat/model/data/Proposal (wrong name: com/bah/iaat/model/data/Proposal)
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClass(ClassLoader.java:800)
at com.ibm.ws.classloading.internal.AppClassLoader.findClass(AppClassLoader.java:278)
at [internal classes]
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:190)
at org.hibernate.internal.util.ReflectHelper.classForName(ReflectHelper.java:192)
at org.hibernate.ejb.packaging.NativeScanner.getClassesInJar(NativeScanner.java:136)
at org.hibernate.ejb.Ejb3Configuration.addScannedEntries(Ejb3Configuration.java:485)
at org.hibernate.ejb.Ejb3Configuration.scanForClasses(Ejb3Configuration.java:852)
at org.hibernate.ejb.Ejb3Configuration.configure(Ejb3Configuration.java:597)
at org.hibernate.ejb.HibernatePersistence.createContainerEntityManagerFactory(HibernatePersistence.java:73)
at org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean.createNativeEntityManagerFactory(LocalContainerEntityManagerFactoryBean.java:288)
at org.springframework.orm.jpa.AbstractEntityManagerFactoryBean.afterPropertiesSet(AbstractEntityManagerFactoryBean.java:310)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1541)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1479)
... 18 more
回答1:
As for your ERROR (3rd snippet) - it appears to me you're missing a jar/class in your classpath.
As for you WARNING (2nd snippet) I have a similar problem and according to the openJPA site it can be safely ignored.
http://openjpa.apache.org/integration.html
Integrating with Spring:
It is not necessary to configure a Spring loadTimeWeaver when using OpenJPA build time enhancement. The following warning message will be logged by OpenJPA when creating an EntityManagerFactory but it can be safely ignored.
WARN [main] while registering a ClassTransformer with PersistenceUnitInfo: name 'PuName', root URL [file:/.../]. The error has been consumed. To see it, set your openjpa.Runtime log level to TRACE. Load-time class transformation will not be available.
Please see the Spring documentation for more information.
来源:https://stackoverflow.com/questions/22417002/java-web-application-error-cant-find-classes-that-are-located-in-web-inf-clas