aspose file tools*
The moose likes JBoss/WildFly and the fly likes Question Regarding ClassPath with Eclipse/JBoss Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Products » JBoss/WildFly
Bookmark "Question Regarding ClassPath with Eclipse/JBoss" Watch "Question Regarding ClassPath with Eclipse/JBoss" New topic
Author

Question Regarding ClassPath with Eclipse/JBoss

Michele Smith
Ranch Hand

Joined: Oct 27, 2010
Posts: 420
Hello I have a quick question ( not as hard as my usual questions ) regarding the .classpath in Eclipse.

My question is, during deployment, what happens to that file?

I noticed that when I got to the test server, that there is another file with a similar name, classpath.sh in the JBoss directory.

It does not have the classpathentry items on it at all.

Could someone let me know how the .classpath gets encapsulated into the .war file? Is it packaged?

If I am doing a deployment where I am directed to add classpath entries to a couple of jar files, how can I be sure that the .war file is going to point to the proper jars?

Do I need to re-package the entire workspace? I am not sure, this is why I am asking.

Normally, we ftp everything from the workspace to the test server. I am not sure if this methodology is widespread.

Thank you,
William P O'Sullivan
Ranch Hand

Joined: Mar 28, 2012
Posts: 859

.classpath is purely Eclipse and sits alongside .project

You should not need .classpath in JBoss at all.

All you should be ftping to the deploy folder (or equivalent) is the generated war archive, or exploded target/war.

WP
Michele Smith
Ranch Hand

Joined: Oct 27, 2010
Posts: 420
Is this mission critical if I have changed the .classpath on the development machine?

The reason why I ask is that up to and including this time point, I have just made changes to the servlets and xsl pages.

Thanks for clarifying,

Let me know,

Thank you,
William P O'Sullivan
Ranch Hand

Joined: Mar 28, 2012
Posts: 859

No. The local .classpath is the Eclipse Java Build path. Edit it and you'll see what I mean.

When deployed, the servlet container (JBoss) determines the classpath, WEB-INF/lib etc.

WP
Michele Smith
Ranch Hand

Joined: Oct 27, 2010
Posts: 420
I am sorry William I may not be asking the right question.

Should I build the entire .war file and redeposit it on the test server, if I have edited the .classpath?

the four (4) .jars that I have added to the project are as follows:
<classpathentry kind="lib" path="WebContent/WEB-INF/lib/esapi-2.0.1.jar"/>
<classpathentry kind="lib" path="WebContent/WEB-INF/lib/log4j-1.2.12.jar"/>
<classpathentry kind="lib" path="C:/jakarta-tomcat/lib/servlet.jar" sourcepath="C:/jakarta-tomcat/lib/servlet.jar"/>
<classpathentry kind="lib" path="C:/jakarta-tomcat/common/lib/servlet-api.jar"/>

Thank you,
Peter Johnson
author
Bartender

Joined: May 14, 2008
Posts: 5836
    
    7

Michele Smith wrote:Should I build the entire .war file and redeposit it on the test server, if I have edited the .classpath?

It depends.

Are you using different versions of the JARs that you referenced? If so, you want want to rebuild the WAR so that it includes the correct versions of the JARs.

If not, then you don't have to rebuild the WAR. Also, if you changes a reference to a JAR that doesn't get packaged with your WAR (such as the servlet.jar), then there is no need to rebuild the WAR.

So ask yourself - if you rebuild the WAR, will the contents be different? If yes, rebuild. If not, skip it.


JBoss In Action
Junilu Lacar
Bartender

Joined: Feb 26, 2001
Posts: 4714
    
    7

Michele, the .classpath file in Eclipse is totally irrelevant in JBoss. Even if you include the .classpath from Eclipse in the WAR that you deploy to JBoss, JBoss will never use it.

Putting JAR files that your application is dependent on in WEB-INF/lib usually takes care of the classpath issue. See: http://java.sun.com/j2ee/verified/packaging.html for more options


Junilu - [How to Ask Questions] [How to Answer Questions]
Jaikiran Pai
Marshal

Joined: Jul 20, 2005
Posts: 10202
    
166

To make it a bit more clear - when developing and deploying applications, there are multiple classpaths involved at various levels/stages. When you are developing an application you'll need compile/build time classpath references to various other libraries. If an IDE is involved it will have its own way of setting up this classpath. For Eclipse it's the .classpath file. If you aren't using an IDE then there will other build tools like Ant which have their own way of specifying classpath. All these classpaths are build/compile time classpaths and don't play a role when you deploy the application to a server like JBoss. So those .classpath files are of no relevance at that time.

The deployment/runtime classpath is determined by the packaging of your application. The Java EE spec has specific rules on how the dependent libraries should be packaged within the application and how they play a role in the runtime/deployment time classpath. For example, all jars in the .war/WEB-INF/lib of your application are available in the classpath of the application being deployed. There's also server specific ways of adding additional libraries to this classpath, but I won't go into those details since that's irrelevant.

[My Blog] [JavaRanch Journal]
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Question Regarding ClassPath with Eclipse/JBoss