本文介绍了Maven / Spring / Java:ClassNotFoundException - 但我知道类在那里的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

限时删除!!

我有2个maven项目设置如下:

而'com.wuntee.rsaAuthenticationManager'是'taac-backend-鬼。当在taac-backend-gui中运行测试用例时,一切都执行正常,但是当尝试启动taac-web时,我得到以下ClassNotFoundException - 包含类weblogic.security.SSL.TrustManager的库也在我的本地maven仓库,并设置为com.wuntee.rsaAuthenticationManager的依赖项。有谁知道为什么会得到这个错误?我也试图直接将包含TrustManager的库添加到taac-web项目中,并且仍然得到相同的异常。任何想法?

 错误[com.wuntee.taac.business.TaacWorkshop] [主]  - 无法创建rsa dao:
com.rsa.common.SystemException:命令目标(CommandAPIConnection)初始化失败
java.lang.NoClassDefFoundError:weblogic / security / SSL / TrustManager
在com.rsa.command.ConnectionFactory.getSpringBeanTarget(ConnectionFactory .java:212)
在com.rsa.command.ConnectionFactory.getTarget(ConnectionFactory.java:170)
在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.DelegatingConstructorAccessorIm pl.newInstance(DelegatingConstructorAccessorImpl.java:27)
在java.lang.reflect.Constructor.newInstance(Constructor.java:501)
在org.springframework.beans.BeanUtils.instantiateClass(BeanUtils.java: 126)
在org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:72)
在org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantiateBean(AbstractAutowireCapableBeanFactory.java: 939)
在org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:892)
在org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java: 479)
在org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:450)
在org.springframework.beans.factory.support.A bstractBeanFactory $ 1.getObject(AbstractBeanFactory.java:290)
在org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222)
在org.springframework.beans.factory.support .AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:287)
在org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:189)
在org.springframework.beans.factory.support .DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:562)
在org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:871)
在org.springframework.context.support.AbstractApplicationContext.refresh (AbstractApplicationContext.java:423)
在org.springframework.web.context.ContextLoader.createWebApplicationContext(ContextLoader.java:272)
在org.springframework.web.context.ContextLoader.ini tWebApplicationContext(ContextLoader.java:196)
在org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:47)
在org.apache.catalina.core.StandardContext.listenerStart(StandardContext。 java:3972)
在org.apache.catalina.core.StandardContext.start(StandardContext.java:4467)
在org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1045)
在org.apache.catalina.core.StandardHost.start(StandardHost.java:722)
在org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1045)
在org.apache.catalina.core.StandardEngine.start(StandardEngine.java:443)
在org.apache.catalina.core.StandardService.start(StandardService.java:516)
在org.apache .catalina.core.StandardServer.start(StandardServer.java:710)
在org.apache.catalina.startup.Catalina.start(Catalina.java:593)
at sun.reflect.NativeMethodAccessorImpl.invoke0 (Native Method)
at sun.r eflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
在java.lang.reflect.Method.invoke(Method.java: 592)
在org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:289)
在org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:414)
导致:com.rsa.ims.components.NoSuchComponentException:无法找到bean CommandAPIConnection
在com.rsa.ims.components.spring.SpringComponentManagerImpl.getBean(SpringComponentManagerImpl.java:71)
在com.rsa.command.ConnectionFactory.getSpringBeanTarget(ConnectionFactory.java:209)
... 39更多
导致:org.springframework.beans.factory.BeanCreationException:创建名称为CacheableCommandTargetBasicAuth的bean时出错:FactoryBean抛出异常创建对象;嵌套异常是org.springframework.beans.factory.support.FactoryBeanRegistrySupport.doGetObjectFromFactoryBean(FactoryBeanRegistrySupport.java:150)上的java.lang.reflect.InvocationTargetException
$ org.springframework.beans.factory.support上的
。 FactoryBeanRegistrySupport.getObjectFromFactoryBean(FactoryBeanRegistrySupport.java:102)
在org.springframework.beans.factory.support.AbstractBeanFactory.getObjectForBeanInstance(AbstractBeanFactory.java:1387)
在org.springframework.beans.factory.support。 AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:301)
在org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:189)
在org.springframework.context.support.AbstractApplicationContext。 getBean(AbstractApplicationContext.java:1044)
在com.rsa.ims.components.spring.SpringComponentManagerImpl.getBean(SpringComponentManagerImpl.java:69)
... 40更多
导致:java .lang.reflect.Inv ocationTargetException
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl .java:27)
在java.lang.reflect.Constructor.newInstance(Constructor.java:501)
在com.rsa.command.RemoteCommandTargetFactoryBean.getObject(RemoteCommandTargetFactoryBean.java:273)
在org.springframework.beans.factory.support.FactoryBeanRegistrySupport.doGetObjectFromFactoryBean(FactoryBeanRegistrySupport.java:143)
... 46更多
导致:java.lang.NoClassDefFoundError:weblogic / security / SSL / TrustManager
在java.lang.Class.forName0(本机方法)
在java.lang.Class.forName(Class.java:164)
在com.rsa.command.InitialContextFactoryLocator.getInitialContextFactory (InitialContextFactoryLocator.java:72)
在com.rs a.command.EJBRemoteTarget。< init>(EJBRemoteTarget.java:189)
... 52更多

在com.wuntee.rsaAuthenticationManager项目中,缺少类的依赖关系定义为:

  ;依赖性> 
< groupId> com.rsa< / groupId>
< artifactId> wlfullclient< / artifactId>
< version> 1.0< / version>
< type> jar< / type>
< scope> compile< / scope>
< / dependency>

注意:此dep也可以添加到taac-web项目中,我仍然得到相同例外。



我也确认,该类的.jar位于tomcat web-root目录的WEB-INF / lib /目录中,该类确实存在...:

  ./ wlfullclient-1.0.jar 
weblogic / security / SSL / TrustManager.class
weblogic / security / SSL / TrustManagerJSSE.class


解决方案

p> Maven依赖不总是传递的。如果taac-backend-gui使用 scope =test optional =true,com.wuntee.rsaAuthenticationManager不会自动成为com.wuntee.taac的依赖项。



其中之一与您所描述的症状一致。 / p>

I have 2 maven projects set up like this:

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
解决方案

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.

这篇关于Maven / Spring / Java:ClassNotFoundException - 但我知道类在那里的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

1403页,肝出来的..

09-07 13:55