Announcement Announcement Module
Collapse
No announcement yet.
spring mvc error Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • spring mvc error

    javax.servlet.ServletException: No adapter for handler [com.user.logindetails.LoginController@1b47bff]: Does your handler implement a supported interface like Controller?

    javax.servlet.ServletException: No adapter for handler [com.user.logindetails.LoginController@1b47bff]: Does your handler implement a supported interface like Controller?
    at org.springframework.web.servlet.DispatcherServlet. getHandlerAdapter(DispatcherServlet.java:1091)
    at org.springframework.web.servlet.DispatcherServlet. doDispatch(DispatcherServlet.java:874)
    at org.springframework.web.servlet.DispatcherServlet. doService(DispatcherServlet.java:809)
    at org.springframework.web.servlet.FrameworkServlet.p rocessRequest(FrameworkServlet.java:571)
    at org.springframework.web.servlet.FrameworkServlet.d oGet(FrameworkServlet.java:501)
    at javax.servlet.http.HttpServlet.service(HttpServlet .java:690)
    at javax.servlet.http.HttpServlet.service(HttpServlet .java:803)
    at org.apache.catalina.core.ApplicationFilterChain.in ternalDoFilter(ApplicationFilterChain.java:290)
    at org.apache.catalina.core.ApplicationFilterChain.do Filter(ApplicationFilterChain.java:206)
    at org.jboss.web.tomcat.filters.ReplyHeaderFilter.doF ilter(ReplyHeaderFilter.java:96)
    at org.apache.catalina.core.ApplicationFilterChain.in ternalDoFilter(ApplicationFilterChain.java:235)
    at org.apache.catalina.core.ApplicationFilterChain.do Filter(ApplicationFilterChain.java:206)
    at org.apache.catalina.core.StandardWrapperValve.invo ke(StandardWrapperValve.java:230)
    at org.apache.catalina.core.StandardContextValve.invo ke(StandardContextValve.java:175)
    at org.jboss.web.tomcat.security.SecurityAssociationV alve.invoke(SecurityAssociationValve.java:182)
    at org.jboss.web.tomcat.security.JaccContextValve.inv oke(JaccContextValve.java:84)
    at org.apache.catalina.core.StandardHostValve.invoke( StandardHostValve.java:127)
    at org.apache.catalina.valves.ErrorReportValve.invoke (ErrorReportValve.java:102)
    at org.jboss.web.tomcat.service.jca.CachedConnectionV alve.invoke(CachedConnectionValve.java:157)
    at org.apache.catalina.core.StandardEngineValve.invok e(StandardEngineValve.java:109)
    at org.apache.catalina.connector.CoyoteAdapter.servic e(CoyoteAdapter.java:262)
    at org.apache.coyote.http11.Http11Processor.process(H ttp11Processor.java:844)
    at org.apache.coyote.http11.Http11Protocol$Http11Conn ectionHandler.process(Http11Protocol.java:583)
    at org.apache.tomcat.util.net.JIoEndpoint$Worker.run( JIoEndpoint.java:446)
    at java.lang.Thread.run(Thread.java:662)

    below is dispatcher-servlet.xml
    <?xml version="1.0" encoding="UTF-8"?>
    <beans xmlns="http://www.springframework.org/schema/beans"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://www.springframework.org/schema/beans
    http://www.springframework.org/schema/beans/spring-beans-2.5.xsd"
    xmlns="http://www.springframework.org/schema/p">

    <bean id="viewResolver"
    class="org.springframework.web.servlet.view.Intern alResourceViewResolver">
    <property name="prefix">
    <value>/</value>
    </property>
    <property name="suffix">
    <value>.jsp</value>
    </property>
    </bean>
    <bean id="myurlMapping" class="org.springframework.web.servlet.handler.Sim pleUrlHandlerMapping">
    <property name="interceptors">
    <list>
    <ref local="localeChangeInterceptor" />
    </list>
    </property>
    <property name="mappings">
    <props>
    <prop key="/login.html">loginController</prop>
    </props>
    </property>
    </bean>

    <bean id="datasource" class="org.apache.commons.dbcp.BasicDataSource">
    <property name="driverClassName">
    <value>com.mysql.jdbc.Driver</value></property>
    <property name="url" value="jdbc:mysql://localhost:8080/hibernatetutorial"/>
    <property name="username" value="root"/>
    <property name="password" value="root"/>

    </bean>
    <bean id="jdbctemplate" class="org.springframework.jdbc.core.JdbcTemplate" >
    <constructor-arg>
    <ref local="datasource"/>
    </constructor-arg>
    </bean>
    <bean id="loginmodel" class="com.user.logindetails.LoginModel">
    <constructor-arg>
    <ref local="jdbctemplate"/>
    </constructor-arg>
    </bean>
    <bean id="loginController" class="com.user.logindetails.LoginController">

    <property name="loginmodel">
    <ref local="loginmodel"/>
    </property>
    <property name="commandName">
    <value>user</value>
    </property>
    <property name="commandClass">
    <value>com.user.logindetails.user</value>
    </property>

    </bean>

    <bean id="localeChangeInterceptor"
    class="org.springframework.web.servlet.i18n.Locale ChangeInterceptor">
    <property name="paramName" value="hl" />
    </bean>

    <bean id="localeResolver"
    class="org.springframework.web.servlet.i18n.Sessio nLocaleResolver" />
    </beans>

  • #2
    Please use [ code][/code ] tags when posting code, that way it remains readable.

    I also doubt it is the full configuration (either that or you are mixing spring versions ). So please post the Controller code and all relevant MVC configuration.

    Comment


    • #3
      i have sent the controller and mode java file and dispatcher-servlet.xml.please resolve my error
      Logincontroller.java
      package com.user.logindetails;
      import org.springframework.validation.BindException;
      import org.springframework.web.portlet.ModelAndView;
      import org.springframework.web.portlet.mvc.AbstractComman dController;
      import org.springframework.web.portlet.mvc.Controller;

      import javax.portlet.ActionRequest;
      import javax.portlet.ActionResponse;
      import javax.portlet.RenderRequest;
      import javax.portlet.RenderResponse;
      import javax.servlet.http.*;

      public class LoginController extends AbstractCommandController implements Controller{
      LoginModel loginmodel;


      public LoginModel getLoginmodel() {
      return loginmodel;
      }

      public void setLoginmodel(LoginModel loginmodel) {
      this.loginmodel = loginmodel;
      }

      protected ModelAndView handle(HttpServletRequest req,HttpServletResponse res, Object comand, BindException ex)
      throws Exception
      {
      String type=loginmodel.validate((user)comand);
      if(type==null)
      return new ModelAndView("/login.jsp");
      else if(type.equals("jitu"))
      return new ModelAndView("/success.jsp");
      else
      return new ModelAndView("/success.jsp");

      }


      protected void handleAction(ActionRequest arg0, ActionResponse arg1,
      Object arg2, BindException arg3) throws Exception {
      // TODO Auto-generated method stub

      }


      protected ModelAndView handleRender(RenderRequest arg0,
      RenderResponse arg1, Object arg2, BindException arg3)
      throws Exception {
      // TODO Auto-generated method stub
      return null;
      }



      }


      lloginmodel.java
      package com.user.logindetails;

      import org.springframework.jdbc.core.JdbcTemplate;

      public class LoginModel {

      private JdbcTemplate jdbctemplate;

      public LoginModel(JdbcTemplate jt) {
      super();
      // TODO Auto-generated constructor stub
      jdbctemplate=jt;

      }
      public String validate(user users)
      {
      try
      {
      return(String)jdbctemplate.queryForObject("select type from user where username=\'"+users.getUsername()+"\' and userpass=\'"+users.getPassword()+"\'", String.class);
      }catch(Exception e){System.out.println(e.getMessage());}
      return null;
      }


      }

      Comment


      • #4
        As mentioned before use [ code][/code ] tags when posting code, that way it remains readable!?

        1) Why does your controller extend AbstractCOmmandController AND implements an interface?
        2) Your controller appears to be a servlet.controller and a portlet.controller?!
        3) NEVER NEVER NEVER use string concat to construct a query this makes you vulnerable to sql injection (although not related to your problem)
        4) You are using a servlet HandlerMapping with a portlet controller... Not going to work.
        5a) I assume you want to use portlets you need the SimplePortletHandlerAdapterto be able to execute the controller
        5b) If it is a servlet you want change your controller

        Also what has this to do with spring workflow?!

        Comment

        Working...
        X