DWR and Struts2

View: New views
3 Messages — Rating Filter:   Alert me  

DWR and Struts2

by Rafael Rech :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi,
I´m trying to make integrate DWR to Struts2. I took a look in the DWR to Web Work integration and did some similar setup, but something is not working properly.
Following is what I accomplished so far and following is the error I´m getting. Let´s see if somebody could help me.
web.xml
----------
        <display-name>StrutsWeb</display-name>
        <filter>
                <filter-name>struts2</filter-name>
                <filter-class>
                        org.apache.struts2.dispatcher.FilterDispatcher
                </filter-class>
        </filter>
        <filter-mapping>
                <filter-name>struts2</filter-name>
                <url-pattern>/*</url-pattern>
        </filter-mapping>
        <servlet>
                <display-name>DWR Servlet</display-name>
                <servlet-name>dwr-invoker</servlet-name>
                <servlet-class>
                        org.directwebremoting.servlet.DwrServlet
                </servlet-class>
                <init-param>
                        <param-name>debug</param-name>
                        <param-value>true</param-value>
                </init-param>
                <init-param>
                        <param-name>exposeInternals</param-name>
                        <param-value>true</param-value>
                </init-param>
        </servlet>
        <servlet-mapping>
                <servlet-name>dwr-invoker</servlet-name>
                <url-pattern>/dwr/*</url-pattern>
        </servlet-mapping>

dwr.xml
----------
<dwr>
        <allow>
                <create creator="none" javascript="DWRAction">
                       
                        <include method="execute" />
                </create>
                <convert converter="bean" match="org.directwebremoting.webwork.ActionDefinition">
                       
                </convert>
                <convert converter="bean" match="org.directwebremoting.webwork.AjaxResult" />
        </allow>
</dwr>

struts.xml
------------
        <package name="default" extends="struts-default">
                <action name="AreaSistema" class="test.AreaSistemaAction" method="list">
                        <result>combo.jsp</result>
                </action>
                <action name="*">
                        <result>{1}.jsp</result>
                </action>
        </package>

JSP
----
<%@ page language="java" contentType="text/html" pageEncoding="ISO-8859-1"%>
<%@ taglib prefix="s" uri="/struts-tags" %>
<html>
<head>
        <script type="text/javascript" src='./dwr/engine.js'></script>
        <script type="text/javascript" src='./dwr/util.js'></script>
        <script type="text/javascript" src='./dwr/interface/DWRAction.js'></script>
        <script type="text/javascript" src='./scripts/DWRActionUtil.js'></script>
        <script language="JavaScript" type="text/javascript">
                var cbf = function done(data)
                {
                        alert('came here');
                }
                function doValidate() {
                        DWRActionUtil.execute({
                  namespace:'default',
          action:'AreaSistema',
          method:'list',
          executeResult:'false'
                                                        }, {}, cbf);
                        alert('OH YEAH BABE');
                }
        </script>
</head>
<body>
        <button onclick="doValidate()">BTN</button>
</body>
</html>

AreaSistemaAction.java
-----------------------------
public class AreaSistemaAction extends ActionSupport
{

    public String list()
    {
        System.out.println("AreaSistemaAction.list()");
        try
        {
                        // some code here
        }
        catch(Exception ignore)
        {
            ignore.printStackTrace();
            return ERROR;
        }
        System.out.println("AreaSistemaAction.list() 6");
        return SUCCESS;
    }

    public String execute() throws Exception
    {
        System.out.println("AreaSistemaAction.execute()");
        return list();
    }

}

--------
Unfortunately what is being executed is the DWRAction.execute() method, not the AreaSistemaAction.list() and I´m getting the following stack:
16:06:46,421 INFO  [DefaultRemoter] Exec: DWRAction.execute()
16:06:46,421 WARN  [DefaultRemoter] Method execution failed:
java.lang.NoClassDefFoundError: com/opensymphony/webwork/dispatcher/DispatcherUtils
        at org.directwebremoting.webwork.DWRAction.<init>(DWRAction.java:53)
        at org.directwebremoting.webwork.DWRAction.initialize(DWRAction.java:226)
        at org.directwebremoting.webwork.DWRAction.execute(DWRAction.java:72)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
        at java.lang.reflect.Method.invoke(Method.java:585)
        at org.directwebremoting.impl.ExecuteAjaxFilter.doFilter(ExecuteAjaxFilter.java:34)
        at org.directwebremoting.impl.DefaultRemoter$1.doFilter(DefaultRemoter.java:428)
        at org.directwebremoting.impl.DefaultRemoter.execute(DefaultRemoter.java:431)
        at org.directwebremoting.impl.DefaultRemoter.execute(DefaultRemoter.java:283)
        at org.directwebremoting.servlet.PlainCallHandler.handle(PlainCallHandler.java:52)
        at org.directwebremoting.servlet.UrlProcessor.handle(UrlProcessor.java:101)
        at org.directwebremoting.servlet.DwrServlet.doPost(DwrServlet.java:146)
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:710)
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
        at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
        at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
        at org.apache.struts2.dispatcher.FilterDispatcher.doFilter(FilterDispatcher.java:413)
        at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
        at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
        at org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:96)
        at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
        at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
        at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:230)
        at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:175)
        at org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(SecurityAssociationValve.java:179)
        at org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValve.java:84)
        at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:128)
        at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:104)
        at org.jboss.web.tomcat.service.jca.CachedConnectionValve.invoke(CachedConnectionValve.java:157)
        at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
        at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:241)
        at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:844)
        at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:580)
        at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:447)
        at java.lang.Thread.run(Thread.java:595)
16:06:46,421 WARN  [BaseCallMarshaller] --Erroring: batchId[1] message[java.lang.NoClassDefFoundError: com/opensymphony/webwork/dispatcher/DispatcherUtils]

Re: DWR and Struts2

by Rafael Rech :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Simplifying the description...

DWRAction uses some classes from WebWorks. Problem is theses classes are not in Struts 2. I think this integration is not as simple as just using the step of integration to WW.

Any comments?

Rafael.

Re: DWR and Struts2

by Joe Walker-3 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


That's certainly correct. You could probably check out the source to the integration from CVS and change the import statements, to create a S2 integration. Not sure how easy this would be.

Joe.

On 11/1/07, Rafael Rech <rafael.rech@...> wrote:

Simplifying the description...

DWRAction uses some classes from WebWorks. Problem is theses classes are not
in Struts 2. I think this integration is not as simple as just using the
step of integration to WW.

Any comments?

Rafael.

--
View this message in context: http://www.nabble.com/DWR-and-Struts2-tf4733247.html#a13536182
Sent from the DWR - Dev mailing list archive at Nabble.com.

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@...
For additional commands, e-mail: dev-help@...