Spring : java.lang.ClassNotFoundException: java/lang.Class
-
13-11-2019 - |
문제
I'm creating beans with the following property
<property name="classe">
<value type="java.lang.Class">foo.bar.SomeClass</value>
</property>
The property "classe" is of type Class.
just like someone hinted on the following question : Spring syntax for setting a Class object?
The problem is that I'm having this exception when deploying my application :
java.lang.ClassNotFoundException: java/lang.Class
at weblogic.utils.classloaders.GenericClassLoader.findLocalClass(GenericClassLoader.java:280)
at weblogic.utils.classloaders.GenericClassLoader.findClass(GenericClassLoader.java:253)
at java.lang.ClassLoader.loadClass(ClassLoader.java:307)
at java.lang.ClassLoader.loadClass(ClassLoader.java:248)
at weblogic.utils.classloaders.GenericClassLoader.loadClass(GenericClassLoader.java:177)
at org.springframework.util.ClassUtils.forName(ClassUtils.java:229)
at org.springframework.beans.factory.config.TypedStringValue.resolveTargetType(TypedStringValue.java:154)
at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveTargetType(BeanDefinitionValueResolver.java:196)
at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveValueIfNecessary(BeanDefinitionValueResolver.java:163)
It looks like Steve B. in the question I linked had the same problem and it was related to some spring configuration. I'm very new to spring and dont really know how to fix this.
Thanks in advance for your answers.
해결책
What about simply:
<property name="classe" value="foo.bar.SomeClass"/>
Spring should figure out the correct type based on classe
property type, which is java.lang.Class
. I just successfully tested it with Spring 3.1, but I'm pretty sure it works with Spring 3.0/2.5.x as well.
제휴하지 않습니다 StackOverflow