You are viewing a plain text version of this content. The canonical link for it is here.
Posted to cactus-user@jakarta.apache.org by Keith Irwin <ke...@keithirwin.com> on 2004/01/03 03:03:15 UTC

maven plugin help

Folks--

I'm using maven and can't seem to test my struts actions with struts
test case.

Figured I'd bypass it and just use ServletTestCase instead but keep
getting a nullpointer exception.


public void beginTest(WebRequest request) {
   request.setURL("localhost:8080", "/public", "/home.do", null, null);
}

public void testTest() {
   WPAActionServlet servlet = new WPAActionServlet();
   try {
      servlet.config();
      servlet.service(request, response);
   }

   catch (Exception e) {
    "...."
   }
}

I get a NullPointerException every time.  (WPAActionServlet is an
extension of the ActionServlet).

Is testing Struts actions with ServletTestCase a bit less trivial than
the above suggests?  (The WPAActionServlet seems to work in that I can
tell from logs that it's loading all its plugins.)

Keith


RE: maven plugin help

Posted by Vincent Massol <vm...@pivolis.com>.
Hi Keith,

> -----Original Message-----
> From: Keith Irwin [mailto:keith@keithirwin.com]
> Sent: 03 January 2004 03:34
> To: Cactus Users List
> Subject: Re: maven plugin help
> 
> Hm.  This might be a problem with web.xml.
> 
> If I deploy app-cactus.war to my app server (jboss, for instance), I
can
> click through links, but the pages are blank, as if the jsp pages were
> throwing exceptions.

You can check your server logs to see what errors there were.

> 
> However, if I rename the war file to app.war (remove -cactus), I can
> click around the application just fine.

It probably means paths are hardcoded in JSPs or somewhere else. Not a
good practice... :-)

> 
> I also note that a colleague has added a <displayname> element to the
> web.xml file.  Commenting that out hasn't solved the problem, yet.

The displayname is not meant for that.

> 
> Is there any way to make the maven task use a different name of the
war
> file (just for debugging, since I don't knowingly require any
particular
> context)?

Hmm.. Not really. Brian Topping has suggested fixing this too (see
http://nagoya.apache.org/bugzilla/show_bug.cgi?id=25859).

A simpler way is simply to introduce a property in the Cactus plugin for
Maven so that the name of the cactified war can be defined by the user.
ATM, inside the Cactus plugin there is this line:

    <j:set var="cactus.war" value="${pom.artifactId}-cactus.war"/>

What you could do (it's a hack!), is create a postGoal of cactus:init
and redefine the cactus.war property to whatever you wish. It should
work (untested though). Another hack is simply to edit the Cactus plugin
and change the above line.

Or better, fix the reasons why you cannot click through the JSP pages...
:-) 

Actually, maybe Cactus is just trying to tell you that there is indeed a
bug in your application in that it is dependent on the war name... ;-)

Thanks
-Vincent

> 
> Keith
> 
> On Fri, 2004-01-02 at 18:03, Keith Irwin wrote:
> > Folks--
> >
> > I'm using maven and can't seem to test my struts actions with struts
> > test case.
> >
> > Figured I'd bypass it and just use ServletTestCase instead but keep
> > getting a nullpointer exception.
> >
> >
> > public void beginTest(WebRequest request) {
> >    request.setURL("localhost:8080", "/public", "/home.do", null,
null);
> > }
> >
> > public void testTest() {
> >    WPAActionServlet servlet = new WPAActionServlet();
> >    try {
> >       servlet.config();
> >       servlet.service(request, response);
> >    }
> >
> >    catch (Exception e) {
> >     "...."
> >    }
> > }
> >
> > I get a NullPointerException every time.  (WPAActionServlet is an
> > extension of the ActionServlet).
> >
> > Is testing Struts actions with ServletTestCase a bit less trivial
than
> > the above suggests?  (The WPAActionServlet seems to work in that I
can
> > tell from logs that it's loading all its plugins.)
> >
> > Keith
> >
> >
> >
---------------------------------------------------------------------
> > To unsubscribe, e-mail: cactus-user-unsubscribe@jakarta.apache.org
> > For additional commands, e-mail: cactus-user-help@jakarta.apache.org
> >
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: cactus-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: cactus-user-help@jakarta.apache.org



Re: maven plugin help

Posted by Keith Irwin <ke...@keithirwin.com>.
Hm.  This might be a problem with web.xml.

If I deploy app-cactus.war to my app server (jboss, for instance), I can
click through links, but the pages are blank, as if the jsp pages were
throwing exceptions.

However, if I rename the war file to app.war (remove -cactus), I can
click around the application just fine.

I also note that a colleague has added a <displayname> element to the
web.xml file.  Commenting that out hasn't solved the problem, yet.

Is there any way to make the maven task use a different name of the war
file (just for debugging, since I don't knowingly require any particular
context)?

Keith

On Fri, 2004-01-02 at 18:03, Keith Irwin wrote:
> Folks--
> 
> I'm using maven and can't seem to test my struts actions with struts
> test case.
> 
> Figured I'd bypass it and just use ServletTestCase instead but keep
> getting a nullpointer exception.
> 
> 
> public void beginTest(WebRequest request) {
>    request.setURL("localhost:8080", "/public", "/home.do", null, null);
> }
> 
> public void testTest() {
>    WPAActionServlet servlet = new WPAActionServlet();
>    try {
>       servlet.config();
>       servlet.service(request, response);
>    }
> 
>    catch (Exception e) {
>     "...."
>    }
> }
> 
> I get a NullPointerException every time.  (WPAActionServlet is an
> extension of the ActionServlet).
> 
> Is testing Struts actions with ServletTestCase a bit less trivial than
> the above suggests?  (The WPAActionServlet seems to work in that I can
> tell from logs that it's loading all its plugins.)
> 
> Keith
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: cactus-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: cactus-user-help@jakarta.apache.org
>