开发者

Spring-MVC bean class cannot be found

In my build.xml, I set the attribute scr.dir:

<property name="src.dir" value="${backend.dir}/java-src/catw/src"/>

My dispatcher-servlet.xml:

<bean name="/welcome.htm" class="com.bamboo.catW3.business.impl.WelcomeController"/>

My view WEB-INF/jsp:

welcome.jsp

My controller:

com.bamboo.catW3.business.impl.WelcomeController.java

I run the project and show me this message:

org.springframework.beans.factory.CannotLoadBeanClassException:
Cannot find class [com.bamboo.catW3.business.impl.WelcomeController] for bean
with name '/welcome.htm' defined in ServletContext resource
[/WEB-INF/branch_try_htmlModulo-servlet.xml]; nested exception is
java.lang.ClassNotFoundException: com.bamboo.catW开发者_JAVA技巧3.business.impl.WelcomeController
    org.springframework.beans.factory.support.AbstractBeanFactory.resolveBeanClass(AbstractBeanFactory.java:1076)

I don't know how to fix this error, can anyone help me please?


In your build, your output directory is not pointing to the correct location (as specified by the destdir attribute. A ClassNotFoundException means that the application looks for the compiled WelcomeController, but cannot find it. Usually web application expects compiled class files to be under:

/WEB-INF/classes

So make sure that you build output points to this directory. After a successful build, you should see:

/WEB-INF/classes/com/bamboo/catW3/business/impl/WelcomeController.class


Double check that the destdir attribute of your tag (or tag) in your ant build script is set to the correct class directory for your application server (ie: Tomcat). You could also just look for the class file in your build directory.


May be many of u r getting problem with springhelloworld project.I have recently faced that problem as from eclipse when i am running it,it's working fine..but from browser it is showing error like class not found exception.So,I have found solution for that...it is a problem of class file....

Solution:

Just put your classes folder from build/classes to your WEB-INF directory...and your problem will be solved...

I hope this will help you...

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜