Using aTLS with java.nio (work-around included)

"Eric Wall" <[email protected]> Mon, 14 Jul 2003 13:57:03 -0400
Newsgroups gmane.comp.java.seda.user
Message-ID <050c01c34a31$551ea330$8481000a@aolg4fq5tjngkz>
I'm using SEDA and SEDA's aTLS implementation for an internal project here
at work.  When I tried to use the aTLS library with NIO this exception was
thrown at connect time:

    java.lang.NoClassDefFoundError: seda/nbio/NonblockingInputStream
        . . .
        (complete stack trace at bottom)

I was confused as to why it was trying to load an NBIO class at all, and my
first thought was that there was a different config element that had to be
set so that aTLS would also use NIO.  However, after some investigation I
found an alternate explanation.  It turns out that there is a direct
dependency on an NBIO class in the aTLS library.

The seda.sandStorm.lib.aTLS.aTLSPacketReader class uses
seda.sandStorm.lib.aSocket.aSocketInputStream.

The seda.sandStorm.lib.aSocket.aSocketInputStream class extends
seda.sandStorm.lib.util.MultiByteArrayInputStream which in turn extends
seda.nbio.NonblockingInputStream.

So you have a class in the aTLS library indirectly extending an NBIO class.
This makes NBIO a requirement for aTLS.  You at least have to have that
NonblockingInputStream class around to make the compiler happy. There is a
better (IMHO) work around than including pieces of the seda.nbio package in
your project.

Notice that the MultiByteArrayInputStream class overrides each and every
method from NonblockingInputStream.  This means that the
MultiByteArrayInputStream class can stand on its own, it does not need to
extend NonblockingInputStream.

So, as a work around you can simply remove the 'extends
NonblockingInputStream' text from the MultiByteArrayInputStream class source
and re-compile.  Alternatively, if you'd like MultiByteArrayInputStream to
still be an InputStream, you can make it extend java.io.InputStream directly
(note that NonblockingInputStream extends java.io.InputStream).

I chose the latter solution, and now I can use version of SEDA with zero
dependencies on NBIO for my project.

If the developers approve I will submit this as a patch.

Are patches to SEDA still being accepted?

What's the deal with the seda2 frame work taking shape in the CVS tree?  Are
the developers in a major re-design re-write phase of the project?

I know NBIO influenced NIO in Java 1.4, will the rest of the SEDA framework
make an appearance in the core Java libraries any time soon?  Perhaps in
1.5?

--
Eric Wall <[email protected]>

--- Begin Stack Trace ----------------------------------------------
aTLSRecordStage: Creating an aTLSConnection.
java.lang.NoClassDefFoundError: seda/nbio/NonblockingInputStream
at java.lang.ClassLoader.defineClass0(Native Method)
at java.lang.ClassLoader.defineClass(ClassLoader.java:502)
at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:123)
at java.net.URLClassLoader.defineClass(URLClassLoader.java:250)
at java.net.URLClassLoader.access$100(URLClassLoader.java:54)
at java.net.URLClassLoader$1.run(URLClassLoader.java:193)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:186)
at java.lang.ClassLoader.loadClass(ClassLoader.java:299)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:265)
at java.lang.ClassLoader.loadClass(ClassLoader.java:255)
at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:315)
at java.lang.ClassLoader.defineClass0(Native Method)
at java.lang.ClassLoader.defineClass(ClassLoader.java:502)
at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:123)
at java.net.URLClassLoader.defineClass(URLClassLoader.java:250)
at java.net.URLClassLoader.access$100(URLClassLoader.java:54)
at java.net.URLClassLoader$1.run(URLClassLoader.java:193)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:186)
at java.lang.ClassLoader.loadClass(ClassLoader.java:299)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:265)
at java.lang.ClassLoader.loadClass(ClassLoader.java:255)
at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:315)
at seda.sandStorm.lib.aTLS.aTLSPacketReader.<init>(aTLSPacketReader.java:76)
at seda.sandStorm.lib.aTLS.aTLSConnection.<init>(aTLSConnection.java:153)
at seda.sandStorm.lib.aTLS.aTLSConnection.<init>(aTLSConnection.java:92)
at
seda.sandStorm.lib.aTLS.aTLSRecordStage.handleEvent(aTLSRecordStage.java:167
)
at
seda.sandStorm.lib.aTLS.aTLSRecordStage.handleEvents(aTLSRecordStage.java:29
9)
at
seda.sandStorm.internal.TPSThreadManager$stageRunnable.run(TPSThreadManager.
java:215)
at java.lang.Thread.run(Thread.java:536)
--- End Stack Trace ----------------------------------------------



-------------------------------------------------------
This SF.Net email sponsored by: Parasoft
Error proof Web apps, automate testing & more.
Download & eval WebKing and get a free book.
www.parasoft.com/bulletproofapps1