logo       

[enhydra] help: bug? when using a default context in tomcat/enhydra: msg#00025

java.enhydra.general

Subject: [enhydra] help: bug? when using a default context in tomcat/enhydra

Hi,
we have a enhydra application which, on the dev environment, is "listening"
under the url http://localhost:8080/alpinPortal2/Portal.po

What i wanted to achieve is that this application will also
accept incoming requests of the type

http://localhost:8080/Portal.po

--- side note ---
(Actually, I want this application to grab "all" requests for whatever
url is coming in, since we will then have a Filter/HttpServletRequestWrapper
that will "rewrite" static urls into dynamic urls:

To register the Filter i have put the following into web.xml of the
application:

<filter>
<filter-name>URLRewritingFilter</filter-name>

<filter-class>it.alpin.portal.presentation.helpers.URLRewritingFilter</filte
r-class>
</filter>
<filter-mapping>
<filter-name>URLRewritingFilter</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>

Our UrlRewritingFilter will then call a ServletRequestWrapper to rewrite
the url. So far, so good. I get urls of the type
http://localhost:8080/alpinPortal2/foo/bar/whatever
and can rewrite the url so that Portal.po will be called with the correct
parameters.).
But, for now, simply forget about this filter. It just works.

--- end side note ---


Now, I would also like to get rid of the "alpinPortal2" part. So a call
to "http://localhost:8080/Portal.po"; should go to our application.
If I try to write such an url, tomcat will not forward the request to the
enhydra
application, since that resides under the "alpinPortal2" path.

I then tried to change the server.xml for tomcat such as to have a
"default context" definition:

<Context path="" docBase="alpinPortal2" debug="0" crossContext="true" />
or: <Context path="" docBase="alpinPortal2" debug="0" />

That kind of solved the issue: now, whatever url i type, it will be passed
on the the enhydra application, since i mapped path="" to
docBase="alpinPortal2".

But then i noticed a problem:
-----------------------------

our application is instantiated twice!!! The startup() method is called
twice
and i notice that i have two enhydra applications running! why?

One of them looks "normal", has a member variable contextMBean, so that i
can
call contextMBean.getAppContext() to see that the application is
"alpinPortal2".
I can also call contextMBean.getAppRealContext and see the local path on my
machine.

The second application instead, has a "null" contextMBean!!! Strange?

Strangely enough, whenever i call a url like
http://localhost:8080/Portal.po, it will be passed to the "first"
application. Everything ok. Even all the other calls, like
http://localhost:8080/foo/bar/whatever get passed to the "first"
application.
My filter works just fine.

When i call http://localhost:8080/alpinPortal2/Portal.po, this request
gets passed to the "second" application (the one with the "null"
contextMBean). It works, but the fact of not having a contextMBean is
irritating - and more than that, i cannot really accept having two
applications floating around and one of them catching some requests.


Does anybody have a clue as to why this is so?
Is there a better way to have tomcat pass all requests to a single enhydra
application? Why is using the context entry in server.xml instantiating
two applications?

I imagine that, in production environment, i will do this by a director
configuration or apache rewriting rule, but it's kind of necessary to
have the same feature on the standalone enhydra ide/tomcat suite that
we use for development.

Even though I spent a lot of debugging on this, i have no real insight
as to how to solve the issue.
Thanks for everybody that comes up with a helpful hint.

Regards
Christoph

--
http://www.alpin.it software, consulting & strategy

Christoph Moar Dipl. Inform. Univ.
alpin gmbh srl management & technology consultants
tel +39 0471 056007 fax +39 0471 056005 gsm +39 348 3057012
lanciastr. 8b via lancia 8b bozen 39100 bolzano italy
http://www.alpin.it christoph.moar@xxxxxxxx



--
You receive this message as a subscriber of the enhydra@xxxxxxxxxxxxx mailing
list.
To unsubscribe: mailto:enhydra-unsubscribe@xxxxxxxxxxxxx
For general help: mailto:sympa@xxxxxxxxxxxxx?subject=help
ObjectWeb mailing lists service home page: http://www.objectweb.org/wws
<Prev in Thread] Current Thread [Next in Thread>
Google Custom Search

News | FAQ | advertise