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 Darren Hartford <dh...@ghsinc.com> on 2005/05/10 22:30:39 UTC

HttpServletRequestWrapper and getLocalName()

Hey all,
I have some Servlet code that retrieves the server called for the
request as well as the actual host server:

==========
String calledserver = request.getLocalName();
String hostserver = InetAddress.getLocalHost().getHostName();
=============

The reasoning is what someone calls the server via DNS resolution, it
may very well be different than the actual server that responds to the
request.  These work great in production and I'm logging this
information in case of issues to help identify the proper request and
which server there may have been an issue with.

My problem is the 'request.getLocalName()' uses HttpServletRequest, and
when trying to run cactus tests on this particular servlet I get an
error like this:

===========
[cactus]    Caused an ERROR

[cactus]
org.apache.cactus.server.HttpServletRequestWrapper.getLocalName()Ljava/l
ang/String;

[cactus] java.lang.AbstractMethodError:
org.apache.cactus.server.HttpServletRequestWrapper.getLocalName()Ljava/l
ang/String;
==========

Any recommendations on what I should about this problem?  It works fine
in production, but prevents testing.

Thanks,
-D

Re: HttpServletRequestWrapper and getLocalName()

Posted by Kazuhito SUGURI <su...@lab.ntt.co.jp>.
Hi Darren,

In article <3A...@GHSEXCH.ghsinc.com>,
Tue, 10 May 2005 16:30:39 -0400,
"Darren Hartford" <dh...@ghsinc.com> wrote: 
dhartford> My problem is the 'request.getLocalName()' uses HttpServletRequest, and
dhartford> when trying to run cactus tests on this particular servlet I get an
dhartford> error like this:
dhartford> 
dhartford> ===========
dhartford> [cactus]    Caused an ERROR
dhartford> 
dhartford> [cactus]
dhartford> org.apache.cactus.server.HttpServletRequestWrapper.getLocalName()Ljava/l
dhartford> ang/String;
dhartford> 
dhartford> [cactus] java.lang.AbstractMethodError:
dhartford> org.apache.cactus.server.HttpServletRequestWrapper.getLocalName()Ljava/l
dhartford> ang/String;
dhartford> ==========

As Sun's Servlet API document shows, getLocalName() is not method
of javax.servlet.ServletRequest or of javax.servert.http.HttpServletRequest.
Some of servlet containers, such as Tomcat and Jetty,
provide their own Servlet class library which has
javax.servlet.ServletRequest#getLocalName(), though...


I believe the java code of the servlet cannot be compiled
by using j2ee.jar provided by Sun.
# From API doc of java.lang.AbstractMethodError:
# Thrown when an application tries to call an abstract method.
# Normally, this error is caught by the compiler; this error can only occur
# at run time if the definition of some class has incompatibly changed
# since the currently executing method was last compiled.

Regards,
----
Kazuhito SUGURI