views:

43

answers:

2

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.catW3.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?

A: 

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.

CitizenForAnAwesomeTomorrow
<target name="build" description="Compile main source tree java files"> <mkdir dir="${build.dir}"/> <javac destdir="${build.dir}" source="1.5" target="1.5" debug="true" deprecation="false" optimize="false" failonerror="true"> <src path="${src.dir}"/> <classpath refid="master-classpath"/> </javac> </target>
josé
the destdir =$(build.dir) <property name="build.dir" value="${web.dir}/WEB-INF/classes"/>
josé
+1  A: 

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
Thierry-Dimitri Roy
but in my WEB-INF/Classes generate it, that is the contain my controller in WEB-INF/classes C:\Archivos de programa\Apache Software Foundation\Tomcat 5.5\webapps\branch_try_htmlModulo1\war\WEB-INF\classes\com\bamboo\catW3\business\impl\WelcomeController.java
josé
@josé: dont know if this spelling matters, your webapp is *branch_try_htmlModulo1* but your spring file is */WEB-INF/branch_try_htmlModulo-servlet.xml*. Is it looking under the correct WEB-INF for the class?
JoseK