A WebLogic data source is configured in spring, then the load applicationcontext.xml is initialized directly in the JUnit Test class when the spring Framework initializes the data source , you receive the following exception message:
Org.springframework.beans.factory.BeanCreationException:Error creating Bean with Name ' DataSource ' defined in URL [file :.. /portalweb/webcontent/web-inf/applicationcontext.xml]: Invocation of Init method failed; Nested exception is Java.lang.noclassdeffounderror:weblogic/security/subject/abstractsubject
caused By:java.lang.noclassdeffounderror:weblogic/security/subject/abstractsubject
At Weblogic.jndi.WLInitialContextFactory.getInitialContext (wlinitialcontextfactory.java:117)
At Javax.naming.spi.NamingManager.getInitialContext (namingmanager.java:667)
At Javax.naming.InitialContext.getDefaultInitCtx (initialcontext.java:247)
At Javax.naming.InitialContext.init (initialcontext.java:223)
At Javax.naming.initialcontext.<init> (initialcontext.java:197)
At Org.springframework.jndi.JndiTemplate.createInitialContext (jnditemplate.java:106)
At Org.springframework.jndi.JndiTemplate.execute (jnditemplate.java:84)
At Org.springframework.jndi.JndiTemplate.lookup (jnditemplate.java:122)
At Org.springframework.jndi.JndiTemplate.lookup (jnditemplate.java:147)
At Org.springframework.jndi.JndiLocatorSupport.lookup (jndilocatorsupport.java:90)
At Org.springframework.jndi.JndiObjectLocator.lookup (jndiobjectlocator.java:101)
At Org.springframework.jndi.JndiObjectFactoryBean.lookupWithFallback (jndiobjectfactorybean.java:164)
At Org.springframework.jndi.JndiObjectFactoryBean.afterPropertiesSet (jndiobjectfactorybean.java:151)
At Org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods ( abstractautowirecapablebeanfactory.java:1057)
At Org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean ( abstractautowirecapablebeanfactory.java:1024)
At Org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean ( abstractautowirecapablebeanfactory.java:421)
At Org.springframework.beans.factory.support.abstractbeanfactory$1.getobject (abstractbeanfactory.java:245)
At Org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton ( defaultsingletonbeanregistry.java:140)
At Org.springframework.beans.factory.support.AbstractBeanFactory.getBean (abstractbeanfactory.java:242)
At Org.springframework.beans.factory.support.AbstractBeanFactory.getBean (abstractbeanfactory.java:156)
At Org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons ( defaultlistablebeanfactory.java:270)
At Org.springframework.context.support.AbstractApplicationContext.refresh (abstractapplicationcontext.java:346)
At Org.springframework.context.support.classpathxmlapplicationcontext.<init> ( classpathxmlapplicationcontext.java:92)
At Org.springframework.context.support.classpathxmlapplicationcontext.<init> ( classpathxmlapplicationcontext.java:77)
At Org.springframework.test.AbstractSpringContextTests.loadContextLocations (abstractspringcontexttests.java:130 )
At Org.springframework.test.AbstractDependencyInjectionSpringContextTests.loadContextLocations ( abstractdependencyinjectionspringcontexttests.java:224)
At Org.springframework.test.AbstractSpringContextTests.getContext (abstractspringcontexttests.java:110)
At Org.springframework.test.AbstractDependencyInjectionSpringContextTests.setUp ( abstractdependencyinjectionspringcontexttests.java:192)
At Junit.framework.TestCase.runBare (testcase.java:125)
At Org.springframework.test.ConditionalTestCase.runBare (conditionaltestcase.java:69)
At Junit.framework.testresult$1.protect (testresult.java:106)
After looking at the analysis, we learned that the Abstractsubject class exists in the Server/lib/weblogic.jar file of WebLogic Server, so you first add it directly to the current project's build path, and then run the JUnit Test, everything works.
Then remove the jar package from build path, run the current project directly, and find that everything is OK.
This shows that the Weblogc.jar file is only available when JUnit Test, so it is not necessary to place it in the Lib directory of project.
Note: The current development environment is WebLogic's workshop (Eclipse).
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.