Using Kawa with Apache Tomcat

classic Classic list List threaded Threaded
7 messages Options
Reply | Threaded
Open this post in threaded view
|

Using Kawa with Apache Tomcat

Tony West
Hi.

I have been trying to get Kawa to work with Tomcat but so far I haven't succeeded.

At the moment, when I browse to the url, Firefox's console is showing [HTTP/1.1 200 OK 0ms] so I seem to be finding the file, but the screen comes back blank.

My web.xml is as follows:
<web-app>
  <display-name>My Application</display-name>

  <servlet>
    <servlet-name>MyHello</servlet-name>
    <servlet-class>hello</servlet-class>
  </servlet>

  <servlet-mapping>
    <servlet-name>MyHello</servlet-name>
    <url-pattern>/hello</url-pattern>
  </servlet-mapping>
</web-app>


My hello.scm is simply:
(require 'http)
(display (html:p "Hello world from Kawa"))


I have been compiling the file with:
java kawa.repl --servlet -C hello.scm

The file compiles ok and produces:
hello$frame.class
hello.class


I would be grateful if anyone could suggest what I am doing wrong.

Thanks.

Tony    
Reply | Threaded
Open this post in threaded view
|

Re: Using Kawa with Apache Tomcat

Per Bothner
On 06/14/2015 07:04 PM, Tony West wrote:
> I have been trying to get Kawa to work with Tomcat but so far I haven't succeeded.
>
> At the moment, when I browse to the url, Firefox's console is showing [HTTP/1.1 200 OK 0ms] so I seem to be finding the file, but the screen comes back blank.
> ...
> My hello.scm is simply:
> (require 'http)
> (display (html:p "Hello world from Kawa"))

Leave off the display call:

(require 'http)
(html:p "Hello world from Kawa")

In a Kawa servlet, you don't "print" the response.
It's like a REPL - the servlet is evaluated to a value
and *that* becomes the response.

Try copying the file in testsuite/info/+default+
to your hello.scm and you'll get a very detailed response,
--
        --Per Bothner
[hidden email]   http://per.bothner.com/
Reply | Threaded
Open this post in threaded view
|

RE: Using Kawa with Apache Tomcat

Tony West

----------------------------------------

> Date: Sun, 14 Jun 2015 19:45:57 -0700
> From: [hidden email]
> To: [hidden email]; [hidden email]
> Subject: Re: Using Kawa with Apache Tomcat
>
> On 06/14/2015 07:04 PM, Tony West wrote:
>> I have been trying to get Kawa to work with Tomcat but so far I haven't succeeded.
>>
>> At the moment, when I browse to the url, Firefox's console is showing [HTTP/1.1 200 OK 0ms] so I seem to be finding the file, but the screen comes back blank.
>> ...
>> My hello.scm is simply:
>> (require 'http)
>> (display (html:p "Hello world from Kawa"))
>
> Leave off the display call:
>
> (require 'http)
> (html:p "Hello world from Kawa")
>
> In a Kawa servlet, you don't "print" the response.
> It's like a REPL - the servlet is evaluated to a value
> and *that* becomes the response.
>
> Try copying the file in testsuite/info/+default+
> to your hello.scm and you'll get a very detailed response,
> --
> --Per Bothner
> [hidden email] http://per.bothner.com/

I made the above change to hello.scm but I still get a blank screen in the browser.

I downloaded the source (kawa-2.0.tar.gz) and found the testsuite directory, but I can't find /info/+default+ under it.

Puzzled.

Tony
     
Reply | Threaded
Open this post in threaded view
|

Re: Using Kawa with Apache Tomcat

Per Bothner

> I made the above change to hello.scm but I still get a blank screen in the browser.


What if the entire hello.scm is just the following

"Hello world\n"

> I downloaded the source (kawa-2.0.tar.gz) and found the testsuite directory, but I can't find /info/+default+ under it.

Sorry, it's actually testsuite/webtest/info/+default+

And it appears it's only in the Subversion sources, but doesn't
get included in the source tar-balls.

You can get it from here:
https://sourceware.org/viewvc/kawa/trunk/testsuite/webtest/info/+default+

Given that this file is mentioned in the documentation, I should fix the
tar-building script to includes this file.

Note I haven't actually tried your example configuration - I'll try tomorrow
if you can't get it to work with my suggestions.
--
        --Per Bothner
[hidden email]   http://per.bothner.com/
Reply | Threaded
Open this post in threaded view
|

RE: Using Kawa with Apache Tomcat

Tony West

----------------------------------------

> Date: Sun, 14 Jun 2015 21:36:47 -0700
> From: [hidden email]
> To: [hidden email]; [hidden email]
> Subject: Re: Using Kawa with Apache Tomcat
>
>
>> I made the above change to hello.scm but I still get a blank screen in the browser.
>
>
> What if the entire hello.scm is just the following
>
> "Hello world\n"
>
>> I downloaded the source (kawa-2.0.tar.gz) and found the testsuite directory, but I can't find /info/+default+ under it.
>
> Sorry, it's actually testsuite/webtest/info/+default+
>
> And it appears it's only in the Subversion sources, but doesn't
> get included in the source tar-balls.
>
> You can get it from here:
> https://sourceware.org/viewvc/kawa/trunk/testsuite/webtest/info/+default+
>
> Given that this file is mentioned in the documentation, I should fix the
> tar-building script to includes this file.
>
> Note I haven't actually tried your example configuration - I'll try tomorrow
> if you can't get it to work with my suggestions.
> --
> --Per Bothner
> [hidden email] http://per.bothner.com/

I have tried replacing the contents of hello.scm with just "Hello world\n", and also replacing it with the contents of +default+.

In both cases it continues to show a blank screen.

Some additional information about my setup if this helps:

Operating System: Windows 7 Pro x64 SP1
Tomcat version: 8.0.23 (running as a Windows service)
Java version: J2SE 8u45 x64 JDK
Kawa version: 2.0 (the precompiled jar file)

CLASSPATH=.;E:\Languages\Kawa\kawa-2.0.jar;C:\apache-tomcat-8.0.23\lib\servlet-api.jar

Thanks for your help with this by the way.

Tony
     
Reply | Threaded
Open this post in threaded view
|

Re: Using Kawa with Apache Tomcat

Per Bothner
Well, it works for me ...

Note that Tomcat doesn't seem to automatically re-load manually compiled classes.
So if you change something, I suggest running $CATALINA_HOME/shutdown.bat and then
$CATALINA_HOME/startup.bat.  There is probably some way to get Tomcat to
re-load classes without shutting it down, but I'm not a Tomcat expert.

Note if you use "self-configuring web page" feature (which is somewhat like JSP),
then you don't need to manually compile servlets, or stop/start the server.  See here:
http://www.gnu.org/software/kawa/Self-configuring-page-scripts.html

I'm assuming you have a copy of the kawa jar file as WEB-INF/lib/kawa.jar.
I'm also assuming your hello.class is WEB-INF/classes/hello.class.
--
        --Per Bothner
[hidden email]   http://per.bothner.com/
Reply | Threaded
Open this post in threaded view
|

RE: Using Kawa with Apache Tomcat

Tony West
----------------------------------------

> Date: Sun, 14 Jun 2015 23:44:17 -0700
> From: [hidden email]
> To: [hidden email]; [hidden email]
> Subject: Re: Using Kawa with Apache Tomcat
>
> Well, it works for me ...
>
> Note that Tomcat doesn't seem to automatically re-load manually compiled classes.
> So if you change something, I suggest running $CATALINA_HOME/shutdown.bat and then
> $CATALINA_HOME/startup.bat. There is probably some way to get Tomcat to
> re-load classes without shutting it down, but I'm not a Tomcat expert.
>
> Note if you use "self-configuring web page" feature (which is somewhat like JSP),
> then you don't need to manually compile servlets, or stop/start the server. See here:
> http://www.gnu.org/software/kawa/Self-configuring-page-scripts.html
>
> I'm assuming you have a copy of the kawa jar file as WEB-INF/lib/kawa.jar.
> I'm also assuming your hello.class is WEB-INF/classes/hello.class.
> --
> --Per Bothner
> [hidden email] http://per.bothner.com/

Good grief.

You are right.  Tomcat wasn't automatically reloading the classes.

Simply restarting it did the trick.

Thank you for all your help and sorry to bother you with such a silly problem.

Tony