This posting is a bit long and not completely relevant to Jetspeed development,
so if you're a bit pushed for time, just skip it.
OK, I've done a bit more work on the debugging JetSpeed with Jbuilder gig and
suprise suprise I've hit a few problems. The basic idea behind documenting this
stuff was to keep the process simple because simple is beautiful.
The debugging environment essentially consists of a java web server running
under the jbuilder debugger and jbuilder kicks off the web server from a simple
class with a main function. The server is configured to run JetSpeed, all the
required libraries are packaged into the Jbuilder tool, then all JetSpeed source
is added to the Jbuilder project via effectively a single mouse click, you hit
build, then run, point your browser at localhost:8080/servlet/jetspeed, and hey
presto, instant gratification.
However life's not that simple for a number of reasons. Firstly I started off
using the Java Server Web Development Kit 1.01 which uses the servlet 2.0 api.
It worked OK, but required that you removed the jetspeed.utils.servlet subtree
from the build. Probably not a good idea, but it got things moving again, and
appeared to work.
Then there was the strange case of the JetspeedResources class. When
Jetspeed is first started, the JetspeedLayout class is instantiated, and the
TOP and BOTTOM members are initialised by the JetspeedResources singleton.
Within JetspeedResources.init() there's the following bit of code:-
synchronised (JetspeedResources.class) {
try {
instance = new JetspeedResources(filename);
instance.setSingletonHandle( SINGLETON_HANDLE);
SingletonHolder.put( instance );
} catch (IOException ioe) {
Log.error( ioe );
return null;
}
}
instance.setInitialized( true );
When Jbuilder hit this piece of code, the 'try' block would execute fine
without throwing an exception but then the Jbuilder debugger would jump to the
'return null' line, skipping 'Log.error' and exit the function. I attempted a
number of fixes including disabling the JIT, and tweaking various Jbuilder
compile and runtime settings to no effect.
In the end I simply hard code the values of TOP and BOTTOM in the
JetspeedLayout class, again just to get things moving. The only other value
obtained from JetspeedResources that appeared to suffer was the
MAX_THREAD_COUNT in the BulkDownloader class. My JVM typically blew up when the
thread count reached around 40. Again a simple manual edit worked round this
problem so I set the count to the more reasonable value of 15.
Anyway, Jetspeed now functioned under the debugger, and by simply changing my
class output path to the webserver servlet directory, I could step through the
code as it executed.
However, this wasn't enough! What I wanted now was to run tomcat under the
debugger with jetspeed running under that. That way I'd not have to throw away
the jetspeed.util.servlet subtree 'cos I'd be using the 2.2 servlet api. So I
packaged up the relevant classes, examined the tomcat startup code, configured
tomat into my project as the main application class, setup my TOMCAT_HOME
environment variable, dragged the snoop servlet into my project for something
to debug, set a couple of breakpoints in snoop and fired up the debugger.
I was able to access and run the tomcat samples, and the snoop servlet produced
the expected output. However there was a problem. I could set breakpoints in
the snoop servlet, but single stepping resulted in a random number of lines
being executed which typically resulted in the function under examination
returning. Not one for giving up easily, I consulted the tomcats dev docs and
was met with the following comment "Using a debugger on servlets and JSP pages
is currently outside the scope of this document. Enhancements to describe these
procedures is requested."
Oh well back to the good old turbine logger (Kevin was right :-))
I did get most of the way through a FAQ for the JSWK 1.01 setup, so I've tagged
it onto the end of this email (mainly so I don't feel like I've completely
wasted my time!).
Julian.
--------- JetSpeed Jbuilder debugging FAQ v0.1 ----------------------
Prerequisites. The prerequisites are the tools I used, they aren't the only
options but they're what I got working!
===
Jbuilder 3.5 foundation
http://www.inprise.com/
Sun Java JDK 1.2
http://www.javasoft.com/products/jdk/1.2/
Sun Java Server Web Development Kit 1.01
http://java.sun.com/products/jsp/download.html
JetSpeed and Turbine CVS snapshots
http://www.working-dogs.com/daily/
I'm using the snapshot from ApacheJetspeed-20000429.tar.gz,
Jbuilder Multifile extension
http://www.javabuilders.com/opentools
===
Install Sun JDK 1.2, Jbuilder, expand the Java Server Web development kit 1.01
to a directory of your choice. To install the Jbuilder Multifile extension,
copy the multifile.jar file to the jbuilde35/lib/ext directory.
Expand the Apache-Jetspeed.tar.gz you got from the working-dogs daily
snapshot directory to a path of your choice. For this document I expand
everything under /usr/src which basically means expanding the .tar.gz
to /usr/src and renaming the Apache-Jetspeed- directory name to jetspeed to
ease typing.
So now you've got /usr/src/jetspeed containing all the jetspeed files and
directories. Jbuilder and JDK 1.2 setup, the JSWDK 1.01 files installed and the
multifile jbuilder extension.
Create a directory WEB-INF under /usr/src/jetspeed/src and copy the contents of
the path-to-jswdk/webpages/WEB-INF directory here along with the servlets
subdirectory and its contents.
Start Jbuilder, create a new project, set the project file to
/usr/src/jetspeed/src/java/jetspeed.jpr
Click finish.
Within your jetspeed project set the output path for class files.
Project Menu ->Project Properties-> "Paths Tab" -> Output Path
/usr/src/jetspeed/src/WEB-INF/servlets
This makes all your class files available to the web server.
Make /usr/src/jetspeed/src/java, the only entry in your project source paths
listbox. (Project->Project Properties->"Source Tab").
Create a Jbuider Library to hold the web server jar files.
Project->Project Properties->"Required Libraries tab" -> Add ->
New -> Add.
Give it the name "JSWDK_1.01" then add the following jar files.
path-to-jwsdk/webserver.jar
path-to-jwsdk/lib/servlet.jar
Click "OK" three times to close all the dialogs and add the library to your
project.
Copy the SimpleStartup.java file for path-to-jwsdk/etc/SimpleStartup.java to
/usr/src/jetspeed/src/java. Then add SimpleStartup.java to your jetspeed
project.(Project->Add to Project->Add files).
Change line 20 of SimpleStartup.java to the following:
URL url = resolveURL("/usr/src/jetspeed/src");
Hit Make project.
Set the project main application class to SimpleStartup.
Project->Project Properties->"Run Tab"->"Application Tab"->
Main Class->Set
Hit Run Project.
At this point you should be able to point your web browser at
http://localhost:8080 and see a listing of the files in
/usr/src/jetspeed/src. You should also be able to run the url
http://localhost:8080/servlet/snoop, provided that you copied the
SnoopServlet.class file over to the jetspeed/src/WEB-INF/servlets directory
from path-to-jswdk/webpages/WEB-INF/servlets.
Part 2.
The next part is to simply setup up JetspeedResources.properties and
TurbineResource.properties to recognise that their running
from /usr/src/jetspeed/src. I'm assuming here that you've setup tmp directories
and configured jdbcdrivers where appropriate.
--- JetspeedResources.properties ---
public.cache.directory=/usr/src/jetspeed/src/jetspeed-cache
(you have to create the jetspeed-cache directory).
xmlportletcontroller.stylesheet=/usr/src/jetspeed/src/content/xml/defaultstyle.xsl
cocoon.properties.file=/usr/src/jetspeed/src/config/cocoon.properties
--- TurbineResources.properties
jetspeed.properties=/usr/src/jetspeed/src/config/JetspeedResources.properties
Create a jbuilder library for the jetspeed libs and add it to your project.
You need all the jar files in /usr/src/jetspeed/src/lib.
Create a jbilder library for you jdbc drivers and add it to your project.
Modify your /usr/src/jetspeed/src/WEB-INF/servlets.properties file so it looks
like the following:-
----- servlets.properties ------------
# Define servlets here
# <servletname>.code=<servletclass>
# <servletname>.initparams=<name=value>,<name=value>
snoop.code=SnoopServlet
snoop.initparams=initarg1=foo,initarg2=bar
jetspeed.code=Turbine
jetspeed.initparms=properties=/usr/src/jetspeed/src/config/TurbineResources.properties
jsp.code=com.sun.jsp.runtime.JspServlet
--------------------------------------
Add the jetspeed source files to your project.
Select Add to Project->Add Files, then select the org directory in the folders
windows from /usr/src/jetspeed/src/java. Check the "Recurse Directories"
checkbox. Click on OK, making sure that the name "org" appears in the "Enter
filename" field on the bottom of this dialog box.
Do a "Rebuild All".
You'll get a number of "Deprecated warnings" which I presume you can ignore.
You'll also get errors from things in the jetspeed.util.servlet subtree. I just
removed the subtree from the project, to get the compile going. Its probably
something to do with the servlet.jar file from JSWDK1.01, but the aim here is
simply to get a working environment!
Now try and run it ...
-------
--
--------------------------------------------------------------
Please read the FAQ! <http://java.apache.org/faq/>
To subscribe: [EMAIL PROTECTED]
To unsubscribe: [EMAIL PROTECTED]
Archives and Other: <http://java.apache.org/main/mail.html>
Problems?: [EMAIL PROTECTED]