This week's book giveaway is in the OCPJP forum.
We're giving away four copies of OCA/OCP Java SE 7 Programmer I & II Study Guide and have Kathy Sierra & Bert Bates on-line!
See this thread for details.
The moose likes Web Component Certification (SCWCD/OCPJWCD) and the fly likes the class is on the container's classpath Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCA/OCP Java SE 7 Programmer I & II Study Guide this week in the OCPJP forum!
JavaRanch » Java Forums » Certification » Web Component Certification (SCWCD/OCPJWCD)
Bookmark "the class is on the container Watch "the class is on the container New topic
Author

the class is on the container's classpath

A. Aka
Ranch Hand

Joined: Sep 08, 2012
Posts: 50
Hi,

what does it mean ? the class is on the container's classpath ?
where is the location of container's classpath

can I please have an example of a class which is on the container's classpath and also an example of class which is not ?

regards,


source :HFJS : page 628 (speaking about exception-type in web.xml
"as long as the checked exception class is on the container's classpath"

Frits Walraven
Creator of Enthuware JWS+ V6
Bartender

Joined: Apr 07, 2010
Posts: 1700
    
  25

can I please have an example of a class which is on the container's classpath and also an example of class which is not ?

Did you do SCJP? or OCPJ6?

If so, then you better have a look at the last chapter again (Java 6 Study Guide - Katherine Sierra and Bert Bates, Chapter 12 Development)

You will find the answer there.

Regards,
Frits
A. Aka
Ranch Hand

Joined: Sep 08, 2012
Posts: 50
@Frits, I think I understand the concept of classpath in java 6 (-classpath dir1:dir2), however I do not get what it means classpath's container!
how do I know that a class is not in classpath's container? is it when compiling my servlet, it cannot find the specific class ?

if it is the same concept as in java, why not say classpath instead of classpath's container ?
K. Tsang
Bartender

Joined: Sep 13, 2007
Posts: 2563
    
    9

Are you using any IDE like Eclipse or Netbeans? Because what "classpath container" for these IDEs is that place where you define any jar files or libraries your project may use.

Yet if you are talking about the application server's classpath container, then I reckon it's those jar that comes with Java EE plus those jars you deploy with your WAR or EAR or JAR.


K. Tsang JavaRanch SCJP5 SCJD/OCM-JD OCPJP7 OCPWCD5 OCPBCD5
Frits Walraven
Creator of Enthuware JWS+ V6
Bartender

Joined: Apr 07, 2010
Posts: 1700
    
  25

@Frits, I think I understand the concept of classpath in java 6 (-classpath dir1:dir2), however I do not get what it means classpath's container!

Ok, sorry, then I didn't understand your question well.

if it is the same concept as in java, why not say classpath instead of classpath's container ?

Yes, the concept is the same, the classpath of a container consists of a number of classes (packaged in jars, e.g. the Servlet implementation class) that are needed during compilation of your web components (but remember they are also needed at runtime) Apart from that you will have to put your classes in the right directory otherwise the container won't be able to load them (and execute them)

Just have a quick look at the following document: HowToCreateWebApplicationWithoutAnIDE.

A web application consists of a standard prescribed structure (Servlet 3.0 ch 10.5 Directory Structure):

10.5 Directory Structure
A Web application exists as a structured hierarchy of directories. The root of this hierarchy serves as the document root for files that are part of the application
...
A special directory exists within the application hierarchy named "WEB-INF".

The contents of the WEB-INF directory are:
- The /WEB-INF/web.xml deployment descriptor.
- The /WEB-INF/classes/ directory for servlet and utility classes. The classes in this directory must be available to the application class loader.
- The /WEB-INF/lib/*.jar area for Java ARchive files. These files contain servlets beans, static resources and JSPs packaged in a JAR file and other utility classes useful to the Web application. The Web application class loader must be able to load classes from any of these archive files.

...

The Web application class loader must load classes from the WEB-INF/classes directory first, and then from library JARs in the WEB-INF/lib directory.


Does this make things clearer?

Regards,
Frits
James Boswell
Bartender

Joined: Nov 09, 2011
Posts: 1030
    
    5

Yet if you are talking about the application server's classpath container, then I reckon it's those jar that comes with Java EE plus those jars you deploy with your WAR or EAR or JAR.


Not exactly. Additional JARs can be added to an application server's classpath by placing them in defined locations (for example, in JBoss, the lib folder which sits alongside the deploy folder).

There are particular libraries which due to licensing, will forbid you from including its JARs in your deployed artifact. In these cases, you would have to add it to the server's classpath using the aforementioned location.
 
jQuery in Action, 2nd edition
 
subject: the class is on the container's classpath