users@glassfish.java.net

RE: AppClient/JWS/Derby/Security problems

From: Martin, Ray <armart3_at_tycho.ncsc.mil>
Date: Tue, 26 Sep 2006 15:15:48 -0400

Find attached:
javaws32575.trace
MANIFEST.MF
build.xml
kart.Main.java
 
The .trace file shows that the last line of my code in the stack trace is
Main at line 49.
 
MANIFEST.MF shows that there is a lib directory that has nothing to do with
the application jar file (KART.jar)
 
But, most importantly (and not shown via any of the attached files) is that
my additions to build.xml do not add (or bundle) jar files within KART.jar.
So, I stated this incorrectly and want to make sure that everyone
understands that there are no jar files within KART.jar. What REALLY
happens is that Netbeans placed the classes of each jar that is specified in
build.xml between the 'target name="-post-jar" tag into KART.jar This is
the reason that pastry.jar classes can be 'seen' at runtime.
 
And, as can be seen from build.xml, derby.jar is added in the same manner as
pastry.jar - that is, all classes from derby.jar including package are
placed directly into KART.jar
 
If KART.jar is incorrect in having the classes with package structure placed
into KART.jar, then I need to learn to construct build.xml differently. Is
it more correct to actually place jars into KART.jar or are the package and
class acceptable?
 
So, the question is: Is it the manner in which I am building and deploying
the app that is causing appclient/JWS not to be able to 'see' the derby
classes?

-----Original Message-----
From: Timothy.Quinn_at_Sun.COM [mailto:Timothy.Quinn_at_Sun.COM]
Sent: Tuesday, September 26, 2006 2:17 PM
To: users_at_glassfish.dev.java.net
Subject: Re: AppClient/JWS/Derby/Security problems


Hi, Martin.

Martin, Ray wrote:

First, I need to apologize. You are gonna get a little frustrated with my
stupidity.
 
I don't know what an 'app client jar' is.
 
My understanding is that I create a J2SE application that I want to run on
the client's desktop. I can go around and load every user's desktop with
this desktop application. And so far this is not an 'app client' - just a
desktop application. Then I say this is too cumbersome going around loading
everyone's desktop. And I say "ah, look. If I deploy this desktop
application to Glassfish and select the Java Web Start checkbox, I will get
out of the business of loading every user's machine with my application".
My understanding is that at the point in time when I deploy to Glassfish,
the application now becomes an 'app client'. But, I had not read anywhere
(or, if I did, it totally went over my head) that I needed to do anything
but deploy my application to Glassfish (I use the admin console at port 4848
and choose App Client Modules). So, this is the way that I have been
running for months. After having done a "Clean and Build" in Netbeans, I
use the Glassfish console and I select (using the browse button) the jar
file from the dist directory that Netbeans has created.

I may have added unnecessarily to the confusion. Yes, what you are doing
works.



 
When you say, "...reran my very simple test in which I bundled a JAR into an
app client JAR, ..." - I do not know what 'bundled' means - this is very
embarrassing and I had to scrape deep to admit this.

Just different words to describe what you describe below about including an
additional JAR into the application's JAR.


 
The only thing that I know how to do is include third party jar files into
my application jar file using build.xml. I need pastry.jar (along with
others) for the application to run. I just went and verified that I had not
inadvertently placed pastry.jar into Glassfish's lib directory. So, after
deploying the desktop application to Glassfish, I go to a web page, poke the
hyperlink, Java Web Start whirs, the application is visible on the client's
desktop. If I go to a second machine, get to the same web page, poke the
hyperlink, Java Web Start does its thing, the application is visible on the
second machine. On both machine's using the desktop application, I select
my ChatAddon, and I can communicate between the two instances of the
application.

Do your build.xml customizations add the pastry.jar to the application JAR
so that its path as stored in the application JAR is lib/pastry.jar? (I
suspect strongly that the answer is yes but I want to verify that.)


 
In my small understanding, I never created an app client jar. In my
understanding, Glassfish provides an 'App Client container' - which I have
come to think of in some way as a Spring container or a JADE container.
But, I never do anything special. My understanding was that I merely
plunked my desktop application into Glassfish, the magic happens, and I run
my application from any machine on the network. And this is exactly what
happened for me on the Chat thingie. After the magic of Glassfish, I could
chat between several machines (using my app) - and some of those machines
(certainly not including my development machine) have never had this code
loaded- which said to me that pastry.jar was available because it was
contained in the application jar file.

Yes, I agree. The key is that the extra JAR must not only be present in the
application JAR but the manifest must also refer to it in the Class-Path
attribute using the correct path. My NetBeans (5.5 beta 2) added a
Class-Path entry for my extra JAR as lib/extra.jar. In my earlier
experiments my extra.jar was added at the "top level" of the application
JAR. I made sure that it was added to the app JAR as lib/extra.jar and my
test was able to load resources from that extra.jar.


 
Everything is going gggreat - then I add persistence - and things go
downhill from there. Don't forget that you guys have gotten me past all
roadblocks to the point where running appclient from the commandline is also
gggreat including persistence.

So to make sure I recall correctly, at this point are you adding derby.jar
to your application in the same way you are adding pastry.jar? And the only
thing that is not working at this point is adding persistence into the mix
and launching that from Java Web Start?

Can you - once more - send along the error messages and stack trace you get
during the attempted Java Web Start launch?

Thanks.

- Tim