I have been trying to get Shale Remoting working using shale v 1.03

I first tried to follow the guide at:
http://shale.apache.org/features-remoting.html

I corrected the example to the following:

First adding methods to be called by client-side Ajax to the "welcome" bean
(WelcomeBean.java), registered in faces-config.xml with request scope :

package org.apache.shale.blank;
import java.io.IOException;
import java.util.Date;

import javax.faces.context.FacesContext;
import javax.faces.context.ResponseWriter;

import org.apache.shale.remoting.faces.ResponseFactory;
import org.apache.shale.view.AbstractViewController;

public class WelcomeBean extends AbstractViewController {
...

    public void validateUsername() {
        FacesContext context = FacesContext.getCurrentInstance();
        String username = (String)context
            .getExternalContext()
            .getRequestParameterMap().get("username");

        if( ! "Joe".equals(username))
            writeResponse(context, "Sorry, that's an unathorized username");
    }

    private void writeResponse(FacesContext context, String text) {
        ResponseWriter writer =
            (new ResponseFactory()).getResponseWriter(context,
"text/plain");
        try {
            writer.writeText(text, null);
            writer.close();
            context.responseComplete();
        } catch (IOException e) {
            e.printStackTrace();
        }
    }

The method was refactored a bit, closing the writer and calling
reponseComplete() as recommended in
http://shale.apache.org/shale-remoting/apidocs/index.html

For a text response, acquire a ResponseWriter instance and use its methods,
just as a Renderer would:

    FacesContext context = FacesContext.getCurrentInstance();
    ResponseWriter writer = (new
ResponseFactory()).getResponseWriter(context, "text/xml");
    writer.startDocument();
    ...
    writer.endDocument();
    writer.close();
            
Before returning, the dynamic logic should call responseComplete() on the
FacesContext instance for the current request, to bypass the remaining
phases of the JavaServer Faces request processing lifecycle.

I then went on to configure web.xml with appropriate mappings after the
Welcome File List entry:


  
    org.apache.shale.remoting.CLASS_RESOURCES
  
  
    /static/*:org.apache.shale.remoting.impl.ClassResourceProcessor
  



  
    org.apache.shale.remoting.DYNAMIC_RESOURCES
  
  
    /dynamic/*:org.apache.shale.remoting.impl.MethodBindingProcessor
  



  
    org.apache.shale.remoting.WEBAPP_RESOURCES
  
  
    /webapp/*:org.apache.shale.remoting.impl.WebResourceProcessor
  


I then changed welcome.jsp to the following, to try different URL patterns
for grabbing a resource:

<%@ taglib prefix="f" uri="http://java.sun.com/jsf/core"; %>
<%@ taglib prefix="h" uri="http://java.sun.com/jsf/html"; %>


  <[EMAIL PROTECTED]                  file="messages.jspf"%>



  
    
    
    
  

  
    

      Hello World
      
      
        
      
    

            

              

              

              

              


              

              

              

              
                

              

            
  






The result :(

running mvn deploy on the application and deploying the myShaleApp.war on
Tomcat 5.5.17

Prefixing the URL with http://localhost:8081/myShaleApp/ : getStaticRes(),
getWebAppRes() and the dynamic validateUsername(..)

HTTP 500 - The server encountered an internal error () that prevented it
from fulfilling this request.



Without the prefix: getStaticRes2(), getWebAppRes2()

HTTP 404 - The requested resource (/static/resource/hello.txt.faces) is not
available.

Any ideas about what I have missed in my configuration? How can I turn on
debugging/logging to determine and fix such problems in the future?

Kristian
-- 
View this message in context: 
http://www.nabble.com/Shale-Remoting-Troubles-tf2252936.html#a6248433
Sent from the Shale - Dev forum at Nabble.com.

Reply via email to