public inbox for kawa@sourceware.org
 help / color / mirror / Atom feed
* Re: Using html namespace in a servlet
@ 2016-02-19  7:00 Per Bothner
  0 siblings, 0 replies; only message in thread
From: Per Bothner @ 2016-02-19  7:00 UTC (permalink / raw)
  To: Kawa mailing list, Sunder Swaminathan

I received this message:

> I’m new to Kawa and loving every bit of it so far! I’m playing around writing servlets but can’t seem to get the built in html namespace to generate some html output. Any ideas what might be going on? I’ve pasted the code and the exception below. Thank you for any help!
>
>
> —servlets.scm—
>
> (define-alias HttpServlet javax.servlet.http.HttpServlet)
> (define-alias HttpServletRequest javax.servlet.http.HttpServletRequest)
> (define-alias HttpServletResponse javax.servlet.http.HttpServletResponse)
>
> (define-simple-class <a.Foo> (HttpServlet)
> ((service (r :: HttpServletRequest) (w :: HttpServletResponse))
> ; ((w:getWriter):write "OK"))) ;this works fine
> ((w:getWriter):write (*:toString (html:p "here"))))) ;but this fails
>
>
>
>
> And the exception I’m seeing (while running under Tomcat 9.0.0.M1)
>
>
> HTTP Status 500 - Servlet execution threw an exception
>
> *type* Exception report
>
> *message* _Servlet execution threw an exception_
>
> *description* _The server encountered an internal error that prevented it from fulfilling this request._
>
> *exception*
>
> javax.servlet.ServletException: Servlet execution threw an exception
> org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:53)
>
> *root cause*
>
> java.lang.IllegalAccessError: tried to access field servlets.Lit0 from class a.Foo
> a.Foo.service(servlets.scm:26)
> javax.servlet.http.HttpServlet.service(HttpServlet.java:729)
> org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:53)

I don't know how you "deployed" your servlet - you should normaly
show the command-line or compilation options you used, as well ins how
you stalled something

However, I'm guessing the problem is almost certainly confusion between
the explicit class a.Foo vs the "module class" generated from the entire source file.
The following has more detail than you need, but it explains the idea of module classes:

http://www.gnu.org/software/kawa/Module-classes.html

It is possible to have a module class and an explicit class (defined by define-simple-class)
be the same class, as described in the above link.

Alternatively, follow the guide in:
http://www.gnu.org/software/kawa/Server-side-scripts.html
http://www.gnu.org/software/kawa/Self-configuring-page-scripts.html
http://www.gnu.org/software/kawa/Servlets.html
-- 
	--Per Bothner
per@bothner.com   http://per.bothner.com/

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2016-02-19  7:00 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-02-19  7:00 Using html namespace in a servlet Per Bothner

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).