getting error of java.lang.noclassdeffounderror while executing submit button, compilation successfull , build/class/
error
------- info: pre-instantiating singletons in org.springframework.beans.factory.support.defaultlistablebeanfactory@31809212: defining beans [crunchifyhelloworld,org.springframework.context.annotation.internalconfigurationannotationprocessor,org.springframework.context.annotation.internalautowiredannotationprocessor,org.springframework.context.annotation.internalrequiredannotationprocessor,org.springframework.context.annotation.internalcommonannotationprocessor,viewresolver,org.springframework.context.annotation.configurationclasspostprocessor.importawareprocessor]; root of factory hierarchy jul 17, 2015 2:09:59 pm org.apache.catalina.core.applicationcontext log severe: standardwrapper.throwable java.lang.noclassdeffounderror: com/crunchify/controller/passwordcheck @ java.lang.class.getdeclaredmethods0(native method) @ java.lang.class.privategetdeclaredmethods(class.java:2531) @ java.lang.class.getdeclaredmethods(class.java:1855) src/com/crunchify/controller/crunchifyhelloworld.java
package com.crunchify.controller; import com.crunchify.controller.passwordcheck; import org.springframework.stereotype.controller; import org.springframework.web.bind.annotation.requestmapping; import org.springframework.web.bind.annotation.requestmethod; import org.springframework.web.bind.annotation.requestparam; import org.springframework.web.bind.annotation.modelattribute; import org.springframework.validation.*; import org.springframework.web.servlet.modelandview; /* * author: crunchify.com * */ @controller public class crunchifyhelloworld { @requestmapping("/welcome") public modelandview helloworld() { string message = "<br><div style='text-align:center;'>" + "<h3>********** welcome ldo support landing page **********<h3> </div><br><br>"; return new modelandview("welcome", "message", message); } @requestmapping(value = "/logincheck", method = requestmethod.get) public modelandview addcontact(@modelattribute("index") com.crunchify.controller.passwordcheck passcheck, bindingresult result) { system.out.println("userid:" + passcheck.getuser_id() + "password:" + passcheck.getpassword()); //return "redirect:contacts.html"; string message = "<br><div style='text-align:center;'>" + "<h3>********** welcome ldo support landing page **********<h3> </div><br><br>"; return new modelandview("welcome", "message", message); } } src/com/crunchify/controller/passwordcheck.java
package com.crunchify.controller; public class passwordcheck { private string user_id; private string password; public string getuser_id() { return user_id; } public void setuser_id(string user_id) { this.user_id = user_id; } public string getpassword() { return password; } public void setpassword(string password) { this.password = password; } }
since spring, should annotate passwordcheck @service or @component , make available in controller via @resource.
should make available, since controller being instantiated while context loads, component scan not have detected passwordcheck-class @ time.
so, should this:
@service public class passwordcheck { // code omitted } and
@controller public class crunchifyhelloworld { @resource private passwordcheck passwordcheck; and use bean name "passwordcheck" in method.
Comments
Post a Comment