You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by Johnny Kewl <jo...@kewlstuff.co.za> on 2007/11/01 06:42:19 UTC

Re: CLASSPATH, .jar files, packages, and so forth

---------------------------------------------------------------------------
HARBOR: http://coolharbor.100free.com/index.htm
Now Tomcat is also a cool pojo application server
---------------------------------------------------------------------------
----- Original Message ----- 
From: "Mann, Ivan H" <iv...@eds.com>
To: <us...@tomcat.apache.org>
Sent: Wednesday, October 31, 2007 10:25 PM
Subject: CLASSPATH, .jar files, packages, and so forth


----------------------------------------------------------------
Hi, I actually dont know where to start ;)

No... is probably a good place.

Why not try this, take the layout from a working web app with the packages 
manually installed...
    jar cvf webappname.WAR
Then to deploy, drop it into Tomcat.

There are so many differnet classloaders involved in what you doing that its 
just wrong...
WEB-INF/lib/ MUST NOT be in the Java classpath.
Yes it will work when you run from an external test program, but it will 
screw TC up nicely... never do that.

You seem to be using applets... those classes or Jars, are not in any class 
path... they in the web site and end up in the browsers classpath.
Makes no sense to put those in a class path in the server side...

Why fight the way its meant to be packaged.... why not just try get it into 
a war?

Good luck...


> I have an application  that consists of >150 classes, organized in
> several different packages.
>
> In the past I have installed the application in
> .../webapps/<appl>/<directories> where the directory tree corresponds
> to the package layout, and this has worked fine.
>
> I am trying to change this to using .jar files for a couple of
> reasons.  I took one package and created a jar file like this:
>
> cd webapps/<appl>/
> jar cvf schedule.jar applet/schedule/*.class
> mv schedule.jar WEB-INF/lib
> rm applet/schedule/*.class
>
> I modified setupclasspath.sh to read WEB-INF/lib and add all .jar
> files to the CLASSPATH before starting tomcat.  Now when I try to
> access one of the classes that I put into schedule.jar it throws a
> NoClassDefFoundError.
>
> If I run a test program with CLASSPATH pointing to the webapps/<appl>
> directory and WEB-INF/lib/schedule.jar it works fine.  In tomcat it
> doesn't find the class.  I would suspect that there an issue with the
> way I build the jar file, but I can't figure out why it works outside
> of tomcat but not inside.
>
> What I would really like is a cookbook document telling me how to
> distribute an application in jar files to the web.  I have Googled
> many combinations of words and can't find one.  If anybody has one of
> those I would really appreciate it.  I thing I am missing a step here,
> possibly making the manifest, but I just don't know what that missing
> step is.
>
> Thanks for the help.
>
> Ivan Mann
>
>


---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Re: CLASSPATH, .jar files, packages, and so forth

Posted by Gabe Wong <ga...@ngasi.com>.
Mann, Ivan H wrote:
> As we discovered earlier this morning, it is an applet question, not a
> servlet question.
>
> I looked in this spec and did not find any mention of applets, which is
> not surprising since it is the servlet spec.  
>
> Is there an applet spec?  
>   
Follow this link:
http://www.google.com/search?hl=en&q=java+applet+specification&btnG=Search

-- 
Regards

Gabe Wong
NGASI AppServer Manager
Application server installation and configuration AUTOMATION
http://www.ngasi.com


---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


RE: CLASSPATH, .jar files, packages, and so forth

Posted by "Mann, Ivan H" <iv...@eds.com>.
As we discovered earlier this morning, it is an applet question, not a
servlet question.

I looked in this spec and did not find any mention of applets, which is
not surprising since it is the servlet spec.  

Is there an applet spec?  

Ivan Mann 


 

-----Original Message-----
From: Caldarale, Charles R [mailto:Chuck.Caldarale@unisys.com] 
Sent: Thursday, November 01, 2007 10:21 AM
To: Tomcat Users List
Subject: RE: CLASSPATH, .jar files, packages, and so forth

> From: Mann, Ivan H [mailto:ivan.mann@eds.com]
> Subject: RE: CLASSPATH, .jar files, packages, and so forth
> 
> So, is there a link somewhere that tells the ways it's meant to be 
> packaged?

As we told you before - read the servlet spec:
http://jcp.org/aboutJava/communityprocess/mrel/jsr154/index.html

 - Chuck


THIS COMMUNICATION MAY CONTAIN CONFIDENTIAL AND/OR OTHERWISE PROPRIETARY
MATERIAL and is thus for use only by the intended recipient. If you
received this in error, please contact the sender and delete the e-mail
and its attachments from all computers.

---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org To unsubscribe,
e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


RE: CLASSPATH, .jar files, packages, and so forth

Posted by "Caldarale, Charles R" <Ch...@unisys.com>.
> From: Mann, Ivan H [mailto:ivan.mann@eds.com] 
> Subject: RE: CLASSPATH, .jar files, packages, and so forth
> 
> So, is there a link somewhere that tells the ways it's meant to be
> packaged?

As we told you before - read the servlet spec:
http://jcp.org/aboutJava/communityprocess/mrel/jsr154/index.html

 - Chuck


THIS COMMUNICATION MAY CONTAIN CONFIDENTIAL AND/OR OTHERWISE PROPRIETARY
MATERIAL and is thus for use only by the intended recipient. If you
received this in error, please contact the sender and delete the e-mail
and its attachments from all computers.

---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Re: CLASSPATH, .jar files, packages, and so forth

Posted by David Smith <dn...@cornell.edu>.
The servlet spec describes how webapps are supposed to be layed out.  
The general layout template in tomcat is

|<tomcat_home>
|  <webapps>
|    <webapp1>
|      WEB-INF (note this must be all caps and case IS important)
|        classes (where to put non-jarred class files)
|        lib (where to put webapp specific jar libraries)
|    <webapp2>
|      (see webapp1 for layout)
|    <webapp3>
|       (see webapp1 for layout)
|   

--David

Mann, Ivan H wrote:

>Yes, I am using applets.
>
>  
>
>>Why fight the way its meant to be packaged.... 
>>    
>>
>
>So, is there a link somewhere that tells the ways it's meant to be
>packaged?
>
>I took out all of the CLASSPATH setting that I done, I moved the .jar
>file to the webapps/<app> directory, and it still doesn't work.  How do
>I tell Tomcat when using applets to use a .jar file?
>
>Ivan Mann
>
>
>---------------------------------------------------------------------
>To start a new topic, e-mail: users@tomcat.apache.org
>To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
>For additional commands, e-mail: users-help@tomcat.apache.org
>
>  
>


---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


RE: CLASSPATH, .jar files, packages, and so forth

Posted by "Mann, Ivan H" <iv...@eds.com>.
Oops.  I mistyped one item.  Everything is in webapps/<appl>.

By now it doesn't matter, because it is working.

Thanks to whomever it was that provided the example.

Ivan Mann


 

-----Original Message-----
From: Christopher Schultz [mailto:chris@christopherschultz.net] 
Sent: Thursday, November 01, 2007 12:18 PM
To: Tomcat Users List
Subject: Re: CLASSPATH, .jar files, packages, and so forth

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Ivan,

Mann, Ivan H wrote:
> Not being able to find the class may mean that it can't find the jar 
> file and it may mean that it can find the jar file but the package and

> or directory is not done right.

Probably.

> The applet specified here appears in the web browser just fine.

> <applet codebase="." code="applet/DDSMenu.class"
>                   archive="schedule.jar"
> 		      width=600
>                     height=300>
> </applet>

Okay: that means that the JAR file itself is being loaded properly
(unless you happen to have class files laying around in the webapp's
deployment directory, outside of WEB-INF: make sure you aren't doing
that; I'm pretty sure that archive="...." indicates that all code should
come from the specified JAR and classes will not be requested from the
server directly).

> The
> applet tries to access the BuildSchedule class in response to a menu 
> item and the exception is not thrown until then.
>
> java.lang.NoClassDefFoundError: applet/schedule/BuildSchedule

What do you get when you run:

$ unzip -v webapps/schedule.jar

> The jar file is located in .../webapps/schedule.jar, which is where 
> the applet directory in the cod parameter is.

Unless you have written this incorrectly, scheduler.jar shouldn't be in
"webapps/scheduler.jar"... it should be in
webapps/[yourappname]/scheduler.jar. And your applet tag should look
like this:

<applet archive="<%= request.getContextPath() %>/scheduler.jar"

...since your JAR file is in the web root. If you relocate the page, you
want your URLs to work properly. Fully-qualified URLs always work
better.

- -chris
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.7 (MingW32)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iD8DBQFHKgkv9CaO5/Lv0PARAhz8AKCDi6WbYGHmWSMOwexrqivaOybKtgCgjtul
LjWnGhknf160oyRsjh8G4X4=
=LMdJ
-----END PGP SIGNATURE-----

---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org To unsubscribe,
e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Re: CLASSPATH, .jar files, packages, and so forth

Posted by Christopher Schultz <ch...@christopherschultz.net>.
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Ivan,

Mann, Ivan H wrote:
> Not being able to find the class may mean that it can't find the jar
> file and it may mean that it can find the jar file but the package and
> or directory is not done right.

Probably.

> The applet specified here appears in the web browser just fine.

> <applet codebase="." code="applet/DDSMenu.class"
>                   archive="schedule.jar"
> 		      width=600
>                     height=300>
> </applet>

Okay: that means that the JAR file itself is being loaded properly
(unless you happen to have class files laying around in the webapp's
deployment directory, outside of WEB-INF: make sure you aren't doing
that; I'm pretty sure that archive="...." indicates that all code should
come from the specified JAR and classes will not be requested from the
server directly).

> The
> applet tries to access the BuildSchedule class in response to a menu
> item and the exception is not thrown until then.
>
> java.lang.NoClassDefFoundError: applet/schedule/BuildSchedule

What do you get when you run:

$ unzip -v webapps/schedule.jar

> The jar file is located in .../webapps/schedule.jar, which is where the
> applet directory in the cod parameter is.

Unless you have written this incorrectly, scheduler.jar shouldn't be in
"webapps/scheduler.jar"... it should be in
webapps/[yourappname]/scheduler.jar. And your applet tag should look
like this:

<applet archive="<%= request.getContextPath() %>/scheduler.jar"

...since your JAR file is in the web root. If you relocate the page, you
want your URLs to work properly. Fully-qualified URLs always work better.

- -chris
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.7 (MingW32)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iD8DBQFHKgkv9CaO5/Lv0PARAhz8AKCDi6WbYGHmWSMOwexrqivaOybKtgCgjtul
LjWnGhknf160oyRsjh8G4X4=
=LMdJ
-----END PGP SIGNATURE-----

---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Re: CLASSPATH, .jar files, packages, and so forth

Posted by Christopher Schultz <ch...@christopherschultz.net>.
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Ivan,

(Not sure if this ever got sent; I found it in my drafts folder today)

Mann, Ivan H wrote:
> Not being able to find the class may mean that it can't find the jar
> file and it may mean that it can find the jar file but the package and
> or directory is not done right.

Probably.

> The applet specified here appears in the web browser just fine.

> <applet codebase="." code="applet/DDSMenu.class"
>                   archive="schedule.jar"
> 		      width=600
>                     height=300>
> </applet>

Okay: that means that the JAR file itself is being loaded properly
(unless you happen to have class files laying around in the webapp's
deployment directory, outside of WEB-INF: make sure you aren't doing
that; I'm pretty sure that archive="...." indicates that all code should
come from the specified JAR and classes will not be requested from the
server directly).

> The
> applet tries to access the BuildSchedule class in response to a menu
> item and the exception is not thrown until then.
>
> java.lang.NoClassDefFoundError: applet/schedule/BuildSchedule

What do you get when you run:

$ unzip -v webapps/schedule.jar

> The jar file is located in .../webapps/schedule.jar, which is where the
> applet directory in the cod parameter is.

Unless you have written this incorrectly, scheduler.jar shouldn't be in
"webapps/scheduler.jar"... it should be in
webapps/[yourappname]/scheduler.jar. And your applet tag should look
like this:

<applet archive="<%= request.getContextPath() %>/scheduler.jar"
   ...

...since your

> 
> The jar file is built from the same directory using this command:
> 	
> 	jar cvf schedule.jar applet/schedule/*.class
> 
> The message is 
> 
> 	Exception in thread "AWT-EventQueue-7"
> java.lang.NoClassDefFoundError: applet/schedule/BuildSchedule
> 	<stack trace>
> 
> 
> Ivan Mann
> 
> ---------------------------------------------------------------------
> To start a new topic, e-mail: users@tomcat.apache.org
> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
> For additional commands, e-mail: users-help@tomcat.apache.org
> 



-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.7 (MingW32)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iD8DBQFHK27f9CaO5/Lv0PARAmTxAJsFa2+UCgzSSq7RJJh/g+Pn1F3eMgCgnzaH
QiN82KmRMStbEIWP2TION7Y=
=FZWB
-----END PGP SIGNATURE-----

---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Re: CLASSPATH, .jar files, packages, and so forth

Posted by Christopher Schultz <ch...@christopherschultz.net>.
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Ivan,

Mann, Ivan H wrote:
> Not being able to find the class may mean that it can't find the jar
> file and it may mean that it can find the jar file but the package and
> or directory is not done right.

Probably.

> The applet specified here appears in the web browser just fine.

> <applet codebase="." code="applet/DDSMenu.class"
>                   archive="schedule.jar"
> 		      width=600
>                     height=300>
> </applet>

Okay: that means that the JAR file itself is being loaded properly
(unless you happen to have class files laying around in the webapp's
deployment directory, outside of WEB-INF: make sure you aren't doing
that; I'm pretty sure that archive="...." indicates that all code should
come from the specified JAR and classes will not be requested from the
server directly).

> The
> applet tries to access the BuildSchedule class in response to a menu
> item and the exception is not thrown until then.
>
> java.lang.NoClassDefFoundError: applet/schedule/BuildSchedule

What do you get when you run:

$ unzip -v webapps/schedule.jar

> The jar file is located in .../webapps/schedule.jar, which is where the
> applet directory in the cod parameter is.

Unless you have written this incorrectly, scheduler.jar shouldn't be in
"webapps/scheduler.jar"... it should be in
webapps/[yourappname]/scheduler.jar. And your applet tag should look
like this:

<applet archive="<%= request.getContextPath() %>/scheduler.jar"

...since your JAR file is in the web root. If you relocate the page, you
want your URLs to work properly. Fully-qualified URLs always work better.

- -chris
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.7 (MingW32)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iD8DBQFHKgkv9CaO5/Lv0PARAhz8AKCDi6WbYGHmWSMOwexrqivaOybKtgCgjtul
LjWnGhknf160oyRsjh8G4X4=
=LMdJ
-----END PGP SIGNATURE-----

---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


RE: CLASSPATH, .jar files, packages, and so forth

Posted by "Mann, Ivan H" <iv...@eds.com>.
Not being able to find the class may mean that it can't find the jar
file and it may mean that it can find the jar file but the package and
or directory is not done right.  The read/write permission on the jar
file is 777, so I know that it can read the jar file if it can find it. 

The applet specified here appears in the web browser just fine.  The
applet tries to access the BuildSchedule class in response to a menu
item and the exception is not thrown until then.

The applet tag is 

	<applet codebase="." code="applet/DDSMenu.class"
ARCHIVE="schedule.jar"  
		width=600 height=300></applet>

The jar file is located in .../webapps/schedule.jar, which is where the
applet directory in the cod parameter is.

The jar file is built from the same directory using this command:
	
	jar cvf schedule.jar applet/schedule/*.class

The message is 

	Exception in thread "AWT-EventQueue-7"
java.lang.NoClassDefFoundError: applet/schedule/BuildSchedule
	<stack trace>


Ivan Mann

---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Re: CLASSPATH, .jar files, packages, and so forth

Posted by Christopher Schultz <ch...@christopherschultz.net>.
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Ivan,

Mann, Ivan H wrote:
> Yes, I am using applets.
> 
>> Why fight the way its meant to be packaged.... 
> 
> So, is there a link somewhere that tells the ways it's meant to be
> packaged?

Applets ought to be packaged into a normal JAR file. Johnny is saying
that these classes do not need to be loaded by the server (because
applets run on the client, not the server), so they should neither be
put into the server's CLASSPATH (which is a no-no in general) nor into
the webapp's WEB-INF/lib directory.

> I took out all of the CLASSPATH setting that I done, I moved the .jar
> file to the webapps/<app> directory, and it still doesn't work.  How do
> I tell Tomcat when using applets to use a .jar file?

Tomcat doesn't care: the web browser does. Please post an example of the
<applet> or <object> or <embed> tag that you are using to load the
applet from the web browser.

- -chris

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.7 (MingW32)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iD8DBQFHKe/E9CaO5/Lv0PARAl8zAKCaxCgOQJYQvbBNvF9RUR9ZaDyUeQCePwhL
PLoDe4WkyVpMUxXvhBD5PE8=
=NA2Q
-----END PGP SIGNATURE-----

---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


RE: CLASSPATH, .jar files, packages, and so forth

Posted by "Mann, Ivan H" <iv...@eds.com>.
Yes, I am using applets.

> Why fight the way its meant to be packaged.... 

So, is there a link somewhere that tells the ways it's meant to be
packaged?

I took out all of the CLASSPATH setting that I done, I moved the .jar
file to the webapps/<app> directory, and it still doesn't work.  How do
I tell Tomcat when using applets to use a .jar file?

Ivan Mann


---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org