wood burning stoves 2.0*
The moose likes JBoss/WildFly and the fly likes Library Files Referencing Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Products » JBoss/WildFly
Bookmark "Library Files Referencing" Watch "Library Files Referencing" New topic
Author

Library Files Referencing

Wai Meng Ng
Greenhorn

Joined: Feb 17, 2003
Posts: 22
Hi All,

I am still figuring how to use JBoss and need some help in referencing Library Files for a WAR deployment. My current WAR file has the necessary library files (incl third party jars, spring jars etc) inside the 'WEB-INF\lib'. However, when I deploy this WAR file, all manner of exceptions show up (due to the inability for JBoss to reference them).

However, when I put these same jar files into "%JBOSS_HOME%server\default\lib", all the referencing error goes away and the WAR application can be deployed. I was hoping that the WAR file can be 'self-contained'; in other words, there is no need to copy any jar files to the JBoss folder. Could someone give me some advice as to how this can be done?

I was thinking of changing the JBOSS_CLASSPATH in the run.bat to include the reference to the 'WEB-INF\lib' folder in the WAR file but am not sure how do I do this (as in how to i reference a path in a WAR file) or if this is even the right approach.

Many thanks in advance!


Cheers,
Wai Meng
Peter Johnson
author
Bartender

Joined: May 14, 2008
Posts: 5812
    
    7

Most likely you are including in WEB-INF/lib some JAR files that are already present in JBoss AS, and this is causing classloader issues. But this is just a guess because you did not provide the stack traces showing the errors.


JBoss In Action
Wai Meng Ng
Greenhorn

Joined: Feb 17, 2003
Posts: 22
Peter Johnson wrote:Most likely you are including in WEB-INF/lib some JAR files that are already present in JBoss AS, and this is causing classloader issues. But this is just a guess because you did not provide the stack traces showing the errors.


Thank you for your reply. Actually, I have resolved the issue by putting the jars in the "%JBOSS_HOME%server\default\lib" folder. Whether the jars are included in the WAR's "WEB-INF\lib" or not does not cause the stack trace error. Only when the jars are not included in the "%JBOSS_HOME%server\default\lib" folder does the errors come up. So based on this, I reckon that JBoss only looks up and references jar files not from the WEB-INF/lib in my War file but rather solely on the jars found in "%JBOSS_HOME%server\default\lib".

Therefore my question is, how can i tell JBoss, to reference the jars found in my WAR (WEB-INF/lib folder) and not depend on those jars that i put into "%JBOSS_HOME%server\default\lib"?

Thank you
Peter Johnson
author
Bartender

Joined: May 14, 2008
Posts: 5812
    
    7

Please post the list of JAR files, and the stack trace you are seeing. That might give us some clue. Other than that we would juts be guessing.
Wai Meng Ng
Greenhorn

Joined: Feb 17, 2003
Posts: 22
Peter Johnson wrote:Please post the list of JAR files, and the stack trace you are seeing. That might give us some clue. Other than that we would juts be guessing.


Hi Peter,

Please find the stacktrace.




It is strange, now most of the errors are not appearing after removing all the jar files from the "%JBOSS_HOME%server\default\lib" folder. However, if i exclude the ojdbc14.jar file, the errors in the stack trace appears. Including this jar file back removes the errors.

I have confirmed that this jar file is in the 'WEB-INF/lib' folder of my WAR file (please see attached image).

Thank you.




[Thumbnail for library list.jpg]

Jaikiran Pai
Marshal

Joined: Jul 20, 2005
Posts: 9947
    
160

Actually, I have resolved the issue by putting the jars in the "%JBOSS_HOME%server\default\lib" folder. Whether the jars are included in the WAR's "WEB-INF\lib" or not does not cause the stack trace error. Only when the jars are not included in the "%JBOSS_HOME%server\default\lib" folder does the errors come up. So based on this, I reckon that JBoss only looks up and references jar files not from the WEB-INF/lib in my War file but rather solely on the jars found in "%JBOSS_HOME%server\default\lib".


However, if i exclude the ojdbc14.jar file, the errors in the stack trace appears


As suspected this jar is a JDBC driver jar. And a JDBC driver jar must be placed in the %JBOSS_HOME%/server/< serverName>/lib folder. See this for details.

[My Blog] [JavaRanch Journal]
Peter Johnson
author
Bartender

Joined: May 14, 2008
Posts: 5812
    
    7

And you also need to correct the connection URL:



You need to replace <IPADDR> and <TNSNAME> with the values for your system.
Wai Meng Ng
Greenhorn

Joined: Feb 17, 2003
Posts: 22
Peter Johnson wrote:And you also need to correct the connection URL:



You need to replace <IPADDR> and <TNSNAME> with the values for your system.


I know, i deliberately 'censored' that out ;)
Wai Meng Ng
Greenhorn

Joined: Feb 17, 2003
Posts: 22
Jaikiran Pai wrote:
Actually, I have resolved the issue by putting the jars in the "%JBOSS_HOME%server\default\lib" folder. Whether the jars are included in the WAR's "WEB-INF\lib" or not does not cause the stack trace error. Only when the jars are not included in the "%JBOSS_HOME%server\default\lib" folder does the errors come up. So based on this, I reckon that JBoss only looks up and references jar files not from the WEB-INF/lib in my War file but rather solely on the jars found in "%JBOSS_HOME%server\default\lib".


However, if i exclude the ojdbc14.jar file, the errors in the stack trace appears


As suspected this jar is a JDBC driver jar. And a JDBC driver jar must be placed in the %JBOSS_HOME%/server/< serverName>/lib folder. See this for details.


Thanks for the reply, i never knew this. So all the other jars should not cause the problem then
Peter Johnson
author
Bartender

Joined: May 14, 2008
Posts: 5812
    
    7

You still need to correct the URL:



The Oracle driver does not like the URL you gave it.
Wai Meng Ng
Greenhorn

Joined: Feb 17, 2003
Posts: 22
Peter Johnson wrote:You still need to correct the URL:



The Oracle driver does not like the URL you gave it.


Sorry Peter, I do not quite get you. After adding the ojdbc14.jar file to the %JBOSS_HOME%/server/< serverName>/lib folder, there are no more errors. The error only appears when I did not copy the ojdbc14.jar file to the %JBOSS_HOME%/server/< serverName>/lib folder.
Peter Johnson
author
Bartender

Joined: May 14, 2008
Posts: 5812
    
    7

Sorry, I though the you had already provided the ojdbc14.jar file and were getting the error, in which case the error means that the Oracle driver didn't like the URL.
Wai Meng Ng
Greenhorn

Joined: Feb 17, 2003
Posts: 22
Peter Johnson wrote:Sorry, I though the you had already provided the ojdbc14.jar file and were getting the error, in which case the error means that the Oracle driver didn't like the URL.


No worries. Thanks for the great help Peter!
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Library Files Referencing
 
Similar Threads
WEB-INF/classes contents be JAR?
Sharing External Jar files between projects
migrating from Jboss4.0 to websphere 6.0
JBoss class loading and reading .properties files
how to move the jar from the war web-inf directory?