JWS and Java CommAPI: any working examples please?

Hi all,

(sorry for the length of this post, but I hope that the completeness will help)

I have tried for some time to get the Java Communications API to work with JWS,

but have failed in all my attempts.

First, I am hoping that someone posts a reply that he/she has a working configuration, and

is willing to share it.

Second, I will describe what I have tried so far, and hope that someone can point out

what I still can try differently.

As you may or may not know, the Comm API (2.0) requires three files to be `available' on the

client machine: a JAR (comm.jar), a DLL (win32com.dll - I have so far only tried this under NT4.0)

and a properties file (javax.comm.properties - containing the line Driver=com.sun.comm.Win32river)

For a "standard" install, not using JWS the JAR goes into JRE\lib, the DLL into JRE\bin and

the prop-file into JRE\lib as well. This works fine. I can then access the Chipcardreader on COM2

without problems.

Now comes JWS.

I deploy comm.jar in the usual way.

I pack win32com.dll into win32com.jar (in the `root' of this file

as the spec says about loading native libs. Then at first I decided that the prop-file should

in principle also not be pre-installed on the client machine, so at first I naively packed it

in the win32com.jar (either in the root or as lib/javax.comm.properties).

When I do this I get a "NullPointerException: name can't be null" the first time the

code tries to CommPortIdentifier.getPortIdentifier("COM2").

I studied this carefully and after some debugging decided that probably the properties

file was the problem. I came to this conclusion since my debugging code was able

to load the classes from comm.jar without problems (by using the classloader obtained

by this.getClass().getClassLoader), and to load the native library

win32com.dll as well (by calling System.loadLibrary("win32com")).

The next step was to put the properties file on the client, in JRE\lib. This dramatically changes

the message I got: "NullPointerException: name can't be null while loading

com.sun.comm.Win32Driver". Thus the properties file is found, but loading the driver

failes for some 'name' is still null.

Needless to say I attempted the same with a non-existent drivername, I then got

"ClassNotFoundException: while loading <name of driverclass>"

Another attempt was made where the DLL was in JRE\bin and not deployed thru JWS (only

comm.jar was in the comm.jnlp extension file), giving the exact same result as above where

the DLL is deployed in a JAR by JWS.

So: I have the properties file where the API reads it, I have comm.jar where the API

can find the com.sun.comm.Win32Driver.class (see the ClassNotFoundException if I change

the name of the driver) and I have the DLL in a place where a simple call to System.loadLibary()

can load it (changing the name yields an Exception, I tried) -- but still no success.

This describes the attempts. Some more context:

The app is deployed through a couple of signed JAR's (certificate signed by an official CA)

that are listed in one jnlp. I have tried deploying the Comm API in the same .jnlp file

and as an extension .jnlp file: no difference. (Probably no difference as all jar's are signed

by the same ceritificate, comm.jar from Sun is not signed so I sign it with our own cert.)

Any reasonable suggestions very much appreciated!

Paul

[3643 byte] By [pgl1606] at [2007-9-26 3:37:16]
# 1
I have solved this issue by using another implementationof the Java Comm API 2.0, viz SerialPort from serialio.com.Worked as an out-of-the-box replacement for Sun'simplementation, and does work with JWS.Paul
pgl1606 at 2007-6-29 12:09:33 > top of Java-index,Desktop,Deploying...
# 2
Congratulations!Do you have an example of the jnlp you used?I tried using what was in their help file andit failed.Their supports seem unfamiliar with JWS
garywesley at 2007-6-29 12:09:33 > top of Java-index,Desktop,Deploying...
# 3

I had successful results using Sun's comm.jar & win32com.dll with the following code:

System.setSecurityManager(null);

String driverName = "com.sun.comm.Win32Driver";

try{

javax.comm.CommDriver commDriver = (javax.comm.CommDriver)Class.forName( driverName ).newInstance();

commDriver.initialize();

}

catch (ClassNotFoundException e) { e.printStackTrace(); }

catch (InstantiationException e) { e.printStackTrace(); }

catch (IllegalAccessException e) { e.printStackTrace(); }

anonymousfu at 2007-6-29 12:09:33 > top of Java-index,Desktop,Deploying...