java/spring- getting NoClassDefFoundError at org.springframework.context.support.AbstractApplicationContext

*爱你&永不变心* 提交于 2019-12-20 05:31:20

问题


I am trying to initialise an RMI client for which I have used Spring.

Now, the application's RMI context is stored in file= rmiClientAppContext.xml

The relevant code for using the above file is given below--

 //RMI Client Application Context is started...
     ApplicationContext context = new ClassPathXmlApplicationContext("rmiClientAppContext.xml");

However, when I try and run the program, this is the error I am getting--

Exception in thread "main" java.lang.NoClassDefFoundError: org/apache/commons/logging/LogFactory
at org.springframework.context.support.AbstractApplicationContext.<init>(AbstractApplicationContext.java:164)
at org.springframework.context.support.AbstractRefreshableApplicationContext.<init>(AbstractRefreshableApplicationContext.java:90)
at org.springframework.context.support.AbstractRefreshableConfigApplicationContext.<init>(AbstractRefreshableConfigApplicationContext.java:59)
at org.springframework.context.support.AbstractXmlApplicationContext.<init>(AbstractXmlApplicationContext.java:61)
at org.springframework.context.support.ClassPathXmlApplicationContext.<init>(ClassPathXmlApplicationContext.java:136)
at org.springframework.context.support.ClassPathXmlApplicationContext.<init>(ClassPathXmlApplicationContext.java:83)

On further investigation of the first line of error message above, I found that

"164 is not a valid line number in org.springframework.context.support.AbstractApplicationContext"

What have i done wrong here? I am using Spring v3.1.3 How do I resolve the above error? Also, exactly which JARs do I have to include for the RMI client? And is there any specific order in which those JARs should be added to Java build path in Eclipse?


回答1:


In this particular case you should include commons-logging-1.1.1.jar in your client classpath. Spring-Core depends on it.

In general I suggest you to use Maven or similar tool to manage your dependencies.




回答2:


Sounds like you are missing very important spring-web jar file. Add this to your pom file to fix this issue.

     <dependency>
        <groupId>org.springframework</groupId>
        <artifactId>spring-web</artifactId>
        <version>3.2.6.RELEASE</version>
    </dependency>


来源:https://stackoverflow.com/questions/14021208/java-spring-getting-noclassdeffounderror-at-org-springframework-context-support

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!