I have following Spring config and code. Keep getting 404 error when I hit
the URL

<!-- Restlet config -->
       <bean name="techRestResource"
class="webservice.rest.IssueRestResource" scope="prototype">
              <property name="techServiceImpl"><ref
bean="techServiceImpl"/></property>
       </bean>
       <bean name="restletRouter"
class="org.restlet.ext.spring.SpringRouter">
              <property name="attachments">
                     <map>
                           <entry key="/service/issue/">
                                  <bean
class="org.restlet.ext.spring.SpringFinder">
                                         <lookup-method
name="createResource" bean="techRestResource"/>
                                  </bean>
                           </entry>
                     </map>
              </property>
       </bean>

Where IssueRestResource is as follow

public class IssueRestResource extends Resource {
       private Log log = LogFactory.getLog(this.getClass().getName());
       private TechServiceImpl techServiceImpl;
       
       public IssueRestResource(){
             
       }
       public IssueRestResource(Context context, Request request, Response
response) {
        super(context, request, response);
        init(context, request, response);
    }

@Override
       public void init(Context context, Request request, Response
response){
              if(log.isDebugEnabled())
                     log.debug("Inside init");
              super.init(context, request, response);
              getVariants().add(new Variant(MediaType.TEXT_XML));
       }
       
         
    /**  
     * Returns a full representation for a given variant.  
     */  
    @Override  
    public Representation represent(Variant variant) throws
ResourceException {  
       if(log.isDebugEnabled())
              log.debug("Inside represent");
       IssueList issues = techServiceImpl.findAllIssues(1);
       if(log.isDebugEnabled()){
              log.debug("Issues "+issues);
              if(!issues.isEmpty())
……..

In web.xml
<context-param>  
      <param-name>org.restlet.application</param-name>  
      <param-value>  
        webservice.rest.TechRestlet  
      </param-value>  
   </context-param>

<!-- Restlet adapter -->  
   <servlet>  
      <servlet-name>RestletServlet</servlet-name>  
      <servlet-class>  
         com.noelios.restlet.ext.servlet.ServerServlet  
      </servlet-class>
   </servlet>  
 
   <!-- Catch all /service/issue requests -->  
   <servlet-mapping>  
      <servlet-name>RestletServlet</servlet-name>  
      <url-pattern>/service/issue</url-pattern>  
   </servlet-mapping>

Where TechRestlet code is nothing but returning Router from Spring context.

public class TechRestlet extends Application {
       private Log log = LogFactory.getLog(this.getClass().getName());
       
         
    @Override
    public Restlet createRoot(){
       if(log.isDebugEnabled()){
              log.debug("Inside createRoot");
       }
       return (SpringRouter)APPLICATION_CONTEXT.getBean("restletRouter");
             

    }

when I type in url http://localhost:8080/myapp/service/issue I keep getting
404 error. In the log I can see following

INFO: RestletServlet: [Noelios Restlet Engine] - Attaching application:
webservice.rest.techrest...@68ec7913 to URI: /myapp/service/issue

Mar 1, 2010 12:41:55 PM com.noelios.restlet.LogFilter afterHandle
INFO: 2010-03-01     12:41:55       GET       /myapp/service/issue     -     
404    330    -      8      

My debug statements from IssueTechResource’s init() & represent() methods
never get printed, which make s me believe Resource isn’t getting
initialized properly or something? 
-- 
View this message in context: 
http://n2.nabble.com/Spring-not-working-with-Restlet-tp4664881p4664881.html
Sent from the Restlet Discuss mailing list archive at Nabble.com.

------------------------------------------------------
http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447&dsMessageId=2454200

Reply via email to