Re: Glassfish and FilterRedirector
"Keith R. Davis" <[email protected]> Wed, 04 Jun 2008 18:53:42 -0600
| Newsgroups | gmane.comp.jakarta.cactus.user |
|---|---|
| Organization | ZuniSoft |
| Message-ID | <[email protected]> |
I think I found the culprit:
From the Cactus docs:
The Cactus test redirectors are automatically injected into the
deployment descriptor of the destination archive. By the way, the task
will examine the version of the *web-app DTD used in the source file,
which determines the servlet API version in use (if no |DOCTYPE|
declaration is found, it assumes servlet API 2.2)*. The filter test
redirector will only be inserted if the servlet API version is 2.3 (or
later).
The Glassfish web.xml uses schemas (xsd) not DOCTYPEs, so I think what
is happening is the Cactus ant tasks think my 2.5 web.xml is really a
2.2 application and therefore does not add the FilterRedirector. I
finally got a filter tests to work after forcing a filter into the
original web.xml. So my next question is, how to make it work...
I stuffed the following at the top of my web.xml:
<!DOCTYPE sun-web-app PUBLIC "-//Sun Microsystems, Inc.//DTD Application
Server 9.0 Servlet 2.5//EN"
"http://www.sun.com/software/appserver/dtds/sun-web-app_2_5-0.dtd">
Didn't work, no FilterRedirector, so taking a wild stab, I added a 2.3
DOCTYPE to the web.xml:
<!DOCTYPE web-app PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application
2.3//EN" "http://java.sun.com/dtd/web-app_2_3.dtd">
Everything works! But the app versions are mismatched 2.3 DOCTYPE with a
2.5 file, NOT good and I get nasty validation errors. This looks like a
bug.
My original web.xml:
<?xml version="1.0" encoding="UTF-8"?>
<web-app version="2.5" xmlns="http://java.sun.com/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee
http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd">
<display-name>openEPRS Services</display-name>
<filter>
<filter-name>LoginCheckFilter</filter-name>
<filter-class>com.zunisoft.openeprs.servlet.LoginCheckFilter</filter-class>
</filter>
<filter-mapping>
<filter-name>LoginCheckFilter</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
<filter>
<filter-name>WadlFormatFilter</filter-name>
<filter-class>com.zunisoft.openeprs.servlet.WadlFormatFilter</filter-class>
<init-param>
<param-name>xsltfile</param-name>
<param-value>/common/xsl/wadl_to_html.xsl</param-value>
</init-param>
</filter>
<filter-mapping>
<filter-name>WadlFormatFilter</filter-name>
<url-pattern>/resources/application.wadl</url-pattern>
</filter-mapping>
<servlet>
<servlet-name>ServletAdaptor</servlet-name>
<servlet-class>com.sun.ws.rest.impl.container.servlet.ServletAdaptor</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>ServletAdaptor</servlet-name>
<url-pattern>/resources/*</url-pattern>
</servlet-mapping>
<session-config>
<session-timeout>
30
</session-timeout>
</session-config>
<welcome-file-list>
<welcome-file>index.jsp</welcome-file>
</welcome-file-list>
<login-config>
<auth-method>BASIC</auth-method>
<realm-name>openeprs-realm</realm-name>
</login-config>
<security-constraint>
<display-name>Protected Resources</display-name>
<web-resource-collection>
<web-resource-name>Secure Web Services</web-resource-name>
<description/>
<url-pattern>/*</url-pattern>
<http-method>GET</http-method>
<http-method>POST</http-method>
<http-method>HEAD</http-method>
<http-method>PUT</http-method>
<http-method>OPTIONS</http-method>
<http-method>TRACE</http-method>
<http-method>DELETE</http-method>
</web-resource-collection>
<auth-constraint>
<description>Role Access</description>
<role-name>admin</role-name>
</auth-constraint>
</security-constraint>
<security-role>
<description>Administrator</description>
<role-name>admin</role-name>
</security-role>
</web-app>
Keith R. Davis wrote:
> I have a meeting so I won't be available this afternoon. What time zone are
> you on?
>
> On Wed, 4 Jun 2008 21:44:06 +0300, "Petar Tahchiev" <[email protected]>
> wrote:
>
>> Hi Keith,
>>
>> do you have some kind of AIM, Gtalk, Skype, ICQ.
>>
>> I want to help you so it would be best if I can talk to you
>> in person.
>>
>> Thanks, Petar.
>>
>> 2008/6/4, Keith R. Davis <[email protected]>:
>>
>>> I give up, tried linux and windows, downgraded to ant 1.6.5, tried the
>>> mergewebxml attribute with cactifywar, changed api levels in the web.xml
>>> and even forced a filterredirector into the original web.xml. The
>>>
>> closest I
>>
>>> get is a 404 not found error when running a filter test. The cactus
>>>
>> samples
>>
>>> fail as well. The environment is Netbeans 6.1 and Glassfish V2UR2. I
>>> couldn't find a way of adding the filter redirector through any cactus
>>> method that would work with this environment.
>>>
>>> Does anyone use alternative testing frameworks?
>>>
>>> On Wed, 04 Jun 2008 07:09:49 -0600, Keith R. Davis
>>>
>>> <[email protected]> wrote:
>>>
>>>> Petar,
>>>>
>>>> Thanks for the hints, I'll see what happens. One of the first things
>>>>
>> I
>>
>>>> did
>>>> check was the dtd version in the web.xml, it is 2.5. I forgot about
>>>> running
>>>> ant in verbose mode, that may give me a bit of insight as well as
>>>>
>> trying
>>
>>> a
>>>
>>>> different version of ant.
>>>>
>>>> Thanks again!
>>>>
>>>> On Wed, 4 Jun 2008 15:45:25 +0300, "Petar Tahchiev"
>>>> <[email protected]>
>>>> wrote:
>>>>
>>>>> Hi Keith,
>>>>>
>>>>> honestly I don't see any reason why this would not work.
>>>>> Everything seems OK. :-(
>>>>> I want to give you a few hints to try different stuff:
>>>>>
>>>>> 0) Your web.xml might follow the 2.2 dtd schema.
>>>>> If that is the case then filter redirectors will not get included in
>>>>>
>> the
>>
>>>>> web.xml.
>>>>> You can try to add the
>>>>> mergewebxml="${basedir}/src/main/webapp/WEB-INF/cactus-web.xml"
>>>>> parameter to your cactifywar task.
>>>>>
>>>>> 1) First try to execute ant in verbose mode: ant -v
>>>>> and see if the redirectors get added. You can also redirect the
>>>>>
>> output
>>
>>>>> with
>>>>>
>>>>>> to a file
>>>>>>
>>>>> and attach the output to your mail here.
>>>>>
>>>>> 2) I think there was some problem with Ant 1.7.0.
>>>>> If the first hint does not work you can try to downgrade to ant
>>>>>
>> 1.6.5,
>>
>>>> or
>>>>
>>>>> use ant 1.7.1 or
>>>>> Ant 1.8.0.
>>>>>
>>>>> 3) Also try to execute the sample tests that come with the source
>>>>> distribution.
>>>>> See how they work and follow their principles.
>>>>>
>>>>> Hope some of these help.
>>>>>
>>>>> Best of luck, Petar.
>>>>>
>>>>> 2008/6/4 Keith R. Davis <[email protected]>:
>>>>>
>>>>>
>>>>>> Let's try the build.xml part again:
>>>>>>
>>>>>> <!-- Cactify the WAR -->
>>>>>> <target name="cactify-war" depends="-copy-cactus-tests,dist">
>>>>>> <cactifywar destfile="${dist.dir}/${cactus.war}"
>>>>>> srcfile="${dist.war}">
>>>>>> <servletredirector/>
>>>>>> <servletredirector name="${cactus.servlet.redirector}"
>>>>>> mapping="/${cactus.servlet.redirector}" roles="test,admin"/>
>>>>>> <filterredirector
>>>>>> mapping="/${cactus.webapp.context}/${cactus.filter.redirector}"/>
>>>>>> <jspredirector
>>>>>> mapping="/${cactus.webapp.context}/${cactus.jsp.redirector}"/>
>>>>>> </cactifywar>
>>>>>> <delete failonerror="false" includeEmptyDirs="true">
>>>>>> <fileset dir="${basedir}" includes="cactus*"/>
>>>>>> </delete>
>>>>>> </target>
>>>>>>
>>>>>> On Wed, 04 Jun 2008 06:15:18 -0600, Keith R. Davis
>>>>>> <[email protected]> wrote:
>>>>>>
>>>>>>> Thanks for the quick response! See my answers below and here is
>>>>>>>
>> the
>>
>>>>>>> important bit of my build.xml and as I said before, the task never
>>>>>>> inserts the filterredirector:
>>>>>>>
>>>>>>> * * * *
>>>>>>>
>>>>> *
>>>>>
>>>>>> *
>>>>>>
>>>>>>> * * *
>>>>>>>
>>>>> *
>>>>>
>>>>>>> * *
>>>>>>> -- Begin properties for the above --
>>>>>>>
>>>>>>> cactus.host = http://localhost cactus.port = 8080
>>>>>>> cactus.webapp.context = openeprs-svcs cactus.service = RUN_TEST
>>>>>>> cactus.servlet.redirector = ServletRedirectorSecure
>>>>>>> cactus.jsp.redirector = JspRedirector cactus.filter.redirector =
>>>>>>> FilterRedirector cactus.war = cactus-test.war
>>>>>>>
>>>>>>> -- End properties for the above --
>>>>>>>
>>>>>>> What is your Cactus version that you use? 1.8.0 (binary dist from
>>>>>>> Apache)
>>>>>>> What version of Ant you use? 1.7.0
>>>>>>> What is your JVM version and operating System? Ubuntu Linux 8.04
>>>>>>> with JDK 1.6.0_06
>>>>>>> On Wed, 4 Jun 2008 09:41:25 +0300, "Petar Tahchiev" wrote: Hi
>>>>>>> Keith,
>>>>>>> the short answer is Yes. You
>>>>>>> should be able to test Filters with
>>>>>>> Servlet API 2.5.
>>>>>>> We do it in the sample projects that come with Cactus.
>>>>>>> What is your Cactus version that you use?
>>>>>>> What version of Ant you use?
>>>>>>> What is your JVM version and operating System?
>>>>>>> Please post your build.xml here to see what is wrong with it.
>>>>>>> Also have a look at the Cactus SVN repository - we have sample
>>>>>>> applications that execute filter tests, and they work.
>>>>>>> Thanks, Petar.
>>>>>>> 2008/6/4 Keith R. Davis :
>>>>>>> All,
>>>>>>> I am using Glassfish V2UR2 and my web application is using
>>>>>>>
>> version
>>
>>>>>>> 2.5 of the servlet API. I have basic Cactus servlet tests
>>>>>>>
>> working,
>>
>>>>>>> however I cannot get filter tests to work. I think this has to do
>>>>>>> with the cactifywar ant task not adding the filter redirector to
>>>>>>>
>> the
>>
>>>>>>> web.xml. I have one defined in the task, but it doesn't show up
>>>>>>>
>> when
>>
>>>>>>> the war is cactified.
>>>>>>> The short question, can I test filters with 2.5 of the servlet
>>>>>>>
>> API?
>>
>>>>>>> Everything else seems to work fine except filters. I did see
>>>>>>>
>> older
>>
>>>>>>> threads on the list that
>>>>>>> servlets using 2.4 and greater of the API
>>>>>>> were not supported. Has this been updated?
>>>>>>> Finally if I am being an idiot and it is not supported, is there
>>>>>>>
>> a
>>
>>>>>>> workaround or another tool that can test filters in container with
>>>>>>>
>>>> the
>>>>
>>>>>>> newest servlet APIs.
>>>>>>> Thanks!
>>>>>>>
>>>>>>>
>>>>>>>
>> ---------------------------------------------------------------------
>>
>>>>>>> To unsubscribe, e-mail:
>>>>>>>
>> [email protected]
>>
>>>>>>> [2]
>>>>>>> For additional commands, e-mail:
>>>>>>>
>>> [email protected]
>>>
>>>>>>> [3]
>>>>>>> --
>>>>>>> Regards, Petar!
>>>>>>> Karlovo, Bulgaria.
>>>>>>> - - - - - - - -
>>>>>>> | Author @ Manning Publications.
>>>>>>> | Technical Consultant @ HP
>>>>>>> | BGJUG-Bulgarian Java User Group Leader.
>>>>>>> | Apache Jakarta PMC member.
>>>>>>> | Jakarta Cactus Lead Developer.
>>>>>>> | Blogger: http://weblogs.java.net/blog/paranoiabla/ [4]
>>>>>>> - - - - - - - -
>>>>>>> Public PGP Key at:
>>>>>>>
>>>>>>>
>> https://keyserver1.pgp.com/vkd/DownloadKey.event?keyid=0x19658550C3110611
>>
>>>>>>> [5]
>>>>>>> Key Fingerprint: A369 A7EE 61BC 93A3 CDFF 55A5 1965 8550 C311
>>>>>>>
>> 0611
>>
>>>>>>>
>>>>>>> Links:
>>>>>>> ------
>>>>>>> [1]
>>>>>>> mailto:[email protected]
>>>>>>> [2] mailto:[email protected]
>>>>>>> [3] mailto:[email protected]
>>>>>>> [4] http://weblogs.java.net/blog/paranoiabla/
>>>>>>> [5]
>>>>>>>
>>>>>>>
>> https://keyserver1.pgp.com/vkd/DownloadKey.event?keyid=0x19658550C3110611
>>
>>>>>>
>>>>>>
>> ---------------------------------------------------------------------
>>
>>>>>> To unsubscribe, e-mail: [email protected]
>>>>>> For additional commands, e-mail: [email protected]
>>>>>>
>>>>>>
>>>>>>
>>>>> --
>>>>> Regards, Petar!
>>>>> Karlovo, Bulgaria.
>>>>> - - - - - - - -
>>>>> | Author @ Manning Publications.
>>>>> | Technical Consultant @ HP
>>>>> | BGJUG-Bulgarian Java User Group Leader.
>>>>> | Apache Jakarta PMC member.
>>>>> | Jakarta Cactus Lead Developer.
>>>>> | Blogger: http://weblogs.java.net/blog/paranoiabla/
>>>>> - - - - - - - -
>>>>> Public PGP Key at:
>>>>>
>>>>>
>> https://keyserver1.pgp.com/vkd/DownloadKey.event?keyid=0x19658550C3110611
>>
>>>>> Key Fingerprint: A369 A7EE 61BC 93A3 CDFF 55A5 1965 8550 C311 0611
>>>>>
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: [email protected]
>>> For additional commands, e-mail: [email protected]
>>>
>>>
>>>
>> --
>> Regards, Petar!
>> Karlovo, Bulgaria.
>> - - - - - - - -
>> | Author @ Manning Publications.
>> | Technical Consultant @ HP
>> | BGJUG-Bulgarian Java User Group Leader.
>> | Apache Jakarta PMC member.
>> | Jakarta Cactus Lead Developer.
>> | Blogger: http://weblogs.java.net/blog/paranoiabla/
>> - - - - - - - -
>> Public PGP Key at:
>> https://keyserver1.pgp.com/vkd/DownloadKey.event?keyid=0x19658550C3110611
>> Key Fingerprint: A369 A7EE 61BC 93A3 CDFF 55A5 1965 8550 C311 0611
>>