问题
I have 2 maven projects set up like this:
-com.wuntee.rsaAuthenticationManager (jar) -com.wuntee.taac (pom) --taac-backend-gui (jar) --taac-web (war)
And 'com.wuntee.rsaAuthenticationManager' is a dep in 'taac-backend-gui'. When running a test case in taac-backend-gui, everything executes fine, but when trying to start the taac-web, I get the following ClassNotFoundException - the library that contains the class 'weblogic.security.SSL.TrustManager' is also in my local maven repository, and set as a dependency of com.wuntee.rsaAuthenticationManager. Does anyone know why I would be getting this error? I have also attempted to directly add the library containing TrustManager to the taac-web project, and still get the same Exception. Any ideas?
ERROR[com.wuntee.taac.business.TaacWorkshop][main] - couldnt create rsa dao:
com.rsa.common.SystemException: Command target (CommandAPIConnection) initialization failure
java.lang.NoClassDefFoundError: weblogic/security/SSL/TrustManager
at com.rsa.command.ConnectionFactory.getSpringBeanTarget(ConnectionFactory.java:212)
at com.rsa.command.ConnectionFactory.getTarget(ConnectionFactory.java:170)
at com.rsa.command.ConnectionFactory.getConnection(ConnectionFactory.java:246)
at com.wuntee.rsaAuthenticationManager.RsaAuthenticationManagerDao.init(RsaAuthenticationManagerDao.java:60)
at com.wuntee.taac.business.TaacWorkshop.<init>(TaacWorkshop.java:68)
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)
at java.lang.reflect.Constructor.newInstance(Constructor.java:501)
at org.springframework.beans.BeanUtils.instantiateClass(BeanUtils.java:126)
at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:72)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantiateBean(AbstractAutowireCapableBeanFactory.java:939)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:892)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:479)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:450)
at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:290)
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222)
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:287)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:189)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:562)
at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:871)
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:423)
at org.springframework.web.context.ContextLoader.createWebApplicationContext(ContextLoader.java:272)
at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:196)
at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:47)
at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:3972)
at org.apache.catalina.core.StandardContext.start(StandardContext.java:4467)
at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1045)
at org.apache.catalina.core.StandardHost.start(StandardHost.java:722)
at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1045)
at org.apache.catalina.core.StandardEngine.start(StandardEngine.java:443)
at org.apache.catalina.core.StandardService.start(StandardService.java:516)
at org.apache.catalina.core.StandardServer.start(StandardServer.java:710)
at org.apache.catalina.startup.Catalina.start(Catalina.java:593)
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:592)
at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:289)
at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:414)
Caused by: com.rsa.ims.components.NoSuchComponentException: Unable to locate bean CommandAPIConnection
at com.rsa.ims.components.spring.SpringComponentManagerImpl.getBean(SpringComponentManagerImpl.java:71)
at com.rsa.command.ConnectionFactory.getSpringBeanTarget(ConnectionFactory.java:209)
... 39 more
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'CacheableCommandTargetBasicAuth': FactoryBean threw exception on object creation; nested exception is java.lang.reflect.InvocationTargetException
at org.springframework.beans.factory.support.FactoryBeanRegistrySupport.doGetObjectFromFactoryBean(FactoryBeanRegistrySupport.java:150)
at org.springframework.beans.factory.support.FactoryBeanRegistrySupport.getObjectFromFactoryBean(FactoryBeanRegistrySupport.java:102)
at org.springframework.beans.factory.support.AbstractBeanFactory.getObjectForBeanInstance(AbstractBeanFactory.java:1387)
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:301)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:189)
at org.springframework.context.support.AbstractApplicationContext.getBean(AbstractApplicationContext.java:1044)
at com.rsa.ims.components.spring.SpringComponentManagerImpl.getBean(SpringComponentManagerImpl.java:69)
... 40 more
Caused by: java.lang.reflect.InvocationTargetException
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)
at java.lang.reflect.Constructor.newInstance(Constructor.java:501)
at com.rsa.command.RemoteCommandTargetFactoryBean.getObject(RemoteCommandTargetFactoryBean.java:273)
at org.springframework.beans.factory.support.FactoryBeanRegistrySupport.doGetObjectFromFactoryBean(FactoryBeanRegistrySupport.java:143)
... 46 more
Caused by: java.lang.NoClassDefFoundError: weblogic/security/SSL/TrustManager
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:164)
at com.rsa.command.InitialContextFactoryLocator.getInitialContextFactory(InitialContextFactoryLocator.java:72)
at com.rsa.command.EJBRemoteTarget.<init>(EJBRemoteTarget.java:189)
... 52 more
In the com.wuntee.rsaAuthenticationManager project, the dependancy that has the missing class is defined as:
<dependency>
<groupId>com.rsa</groupId>
<artifactId>wlfullclient</artifactId>
<version>1.0</version>
<type>jar</type>
<scope>compile</scope>
</dependency>
Note: This dep can also be added to the taac-web project, and I still get the same exception.
I have also confirmed that the .jar with the class is in the WEB-INF/lib/ directory of the tomcat web-root directory, and that the class does exist...:
./wlfullclient-1.0.jar
weblogic/security/SSL/TrustManager.class
weblogic/security/SSL/TrustManagerJSSE.class
回答1:
Maven dependencies are not always transitive. If taac-backend-gui declares its dependency on com.wuntee.rsaAuthenticationManager with scope="test"
or optional="true"
, com.wuntee.rsaAuthenticationManager won't automatically become a dependency of com.wuntee.taac
Either of these would be consistent with the symptoms you describe.
回答2:
Looking through all of the logs, I found this:
INFO: validateJarFile(/Users/wuntee/workspace/.metadata/.plugins/org.eclipse.wst.server.core/tmp1/wtpwebapps/taac-web/WEB-INF/lib/wlfullclient-1.0.jar) - jar not loaded. See Servlet Spec 2.3, section 9.7.2. Offending class: javax/servlet/Servlet.class
That will explain why the class cant be found...
来源:https://stackoverflow.com/questions/2822958/maven-spring-java-classnotfoundexception-but-i-know-class-is-there