### nsjava project homepage

nsjava is a loadable c-module for aolserver that embeds a java virtual machine in process and takes advantage of aolservers adavanced features such as multi-threading and database connection pooling. The current module was recently merged with tclblend which allows complete access to the java api from within aolserver tcl scripts and adp pages.

Mo DeJong the lead developer of Tclblend has tenatively agreed to incorporate the aolserver support provided by nsjava into tclblend. If I get the time, it is likely that the current tclblend 1.3 development branch will be updated with these changes, and aolserver should be available on the tclblend 1.4 stable branch. In the meantime and until I merge these changes into TclBlend, I will be providing a seperate build here that incorporates Tclblend as a loadable c-module for aolserver.

### Features

- Create instances of Java objects from Tcl.
- Invoke instance methods on a Java object from Tcl.
- Invoke methods on array objects.
- Invoke static Java methods from Tcl.
- Get and Set Java Field values from Tcl.
- Determine if a Tcl object is an instance of a Java Class.
- Manipulate Java Bean properties from Tcl.
- Introspect Java Objects from Tcl.
- Load Tcl extensions defined in Java classes.
- Throw and Catch Java exceptions from Tcl.
- Import Java class names.

### Limitations

This module is currently limited to one tcl interpreter per aolserver thread. This is due to a work-around that was implemented to overcome a conflict between thread cleanup in aolserver and Tclblend.

### Motivation

najava is being used initially to support porting of the webmail module of the acs toolkit. In the original acs toolkit, or as some people have been calling it acs classic, the webmail module makes use of java inside of oracle to perform parsing of email messages using the JavaMail api. For openacs, the nsjava module in conjunction with the postgres database and aolerver will provide the equivalent JavaMail api for the parsing of email. It is anticipated that acs classic will make increasing use of java libraries to provide new functionality. The nsjava module should be capable of providing the needed functionality to openacs to allow the porting of these anticipated new modules from acs classic.

### Status

#### nsjavablend (nsjava + tclblend)

This version is the new development branch which will eventually be merged into the Tclblend distribution. This seperate distribution will be discontinued once aolserver support is added to Tclblend.

Alpha version nsjavablend-0.0.9.tar.gz is now available. Tested with Blackdown jdk1.1.8 on linux and Sun jdk1.1.8 on solaris. Both versions seem stable without segfaults however there does seem to be a memory leak associated with the java TclList splitlist method which is part of the tclblend distribution. Fixing this memory leak is at the head of my todo list for nsjavablend.

OS | JDK Vendor | JDK Version | Comments
--- | --- | --- | ---
Solaris 2.7 | Sun | 1.1.8 | o.k.
Linux 2.2.14 | Blackdown | 1.1.8 | o.k.

#### nsjava

This is the original nsjava distribution which has undergone much more testing and is considered to be quite stable. Once aolserver support is incorporated into Tclblend, this module will probably no longer be supported.

Alpha version nsjava-0.0.9.tar.gz is now available. Tested with Blackdown jdk1.1.8 and Blackdown jdk1.2.2-rc4 on linux, and Sun jdk1.1.8 and 1.2.2 on solaris. Both versions seem stable without segfaults however the Blackdown jdk1.2.2-rc4 seems to leak memory on linux. Limited testing with apache bench shows that the other jdk's hold up well when stressed. Near-term development will involve more elaborate testing with apache bench to see it holds up well under high load situations. Testing with IBM's jdk1.1.8 resulted in occasional segfaults which I tracked down to code associated with the JIT compiler. A glance at the release notices for this jdk indicate that there is still quite a bit of ongoing work related to the JIT compiler in the 1.1.8 version of IBM's jdk. For right now I recommend not using it with nsjava, but that could change in the near future. Sun's jdk1.2.2 seems to be completely broken on linux.

OS | JDK Vendor | JDK Version | Comments
--- | --- | --- | ---
Solaris 2.5.1 | Sun | 1.1.8 | o.k.
Solaris 2.5.1 | Sun | 1.2.2 | o.k.
Linux 2.2.14 | Blackdown | 1.1.8 | o.k.
Linux 2.2.14 | Blackdown | 1.2.2-rc4 | jdk memory leaks
Linux 2.2.14 | Sun | 1.2.2 | segfaults on thread detach
Linux 2.2.14 | IBM | 1.1.8 | segfaults on startup occasionally (JIT Compiler)

### CVS repository

The cvs repository is hosted on sourceforge at nsjava cvs

### TODO

- Fix memory leak in TclList splitlist method.
- Modify Tclblend test suite to work in aolserver environment.
- Test under high-load situations.
- Wrap as much of the aolserver api as possible.
- Implement jdbc interface on top of aolserver api

### Sourceforge

Many thanks to sourceforge for providing the resources to host this project. The nsjava project page is at SF Project page

### Documentation

Latest Documentation

### Related info

- This project was started to support porting of the acs toolkit. See openacs.org for more details.
- For more information on aolserver, see aolserver.com.
- For more information on the Tclblend project, see the project homepage
- For more information on the original acs toolkit, see photo.net.
- If python is your language, check out this aolserver module that embeds the python scripting language PyWX.
- For more information on the postgresql database, see postgresql.org
- Java Servlets can be run in aolserver using the nstomcat module, see nstomcat

danw@rtp.ericsson.se