• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 382
  • Last Modified:

JBoss standalone program does not use Classpath - why?

I am using JBoss 6.1.0 on RHEL to exchange messages from a JMS queue between 2 separate Java programs (sender and receiver).

The software works when I include all the necessary Jboss library jar files and properties files in my own Java application JAR file.

But when I pull out the Jboss jar files from my own application jar file, I get the java.lang.NoClassDefFoundError exceptions where the system complains about not finding the Jboss jar library files, even when I run the application using a Classpath argument:

java -cp /opt/jboss/client/*.jar:/opt/jboss/lib/*.jar:/opt/jboss/common/*.jar:/opt/jboss/comm-lang.jar:/jboss/server/default/deploy/*.jar -jar MyJossApplication.jar

The exception points back to a Class file to a JBoss library jar file that is included in the Classpath.

Any idea why my invocation method of Jboss is ignoring the Classpath?  Thanks.
0
rleelink
Asked:
rleelink
  • 6
  • 4
  • 3
1 Solution
 
for_yanCommented:
With -cp you need to mention all jars' explicitlly - you cannot say *.jat
0
 
for_yanCommented:

With -cp you need to mention all jars' explicitlly - you cannot say *.jar
0
 
for_yanCommented:
In Java ^ there is a way to refer to the whole folder of jars, let me see
0
Free learning courses: Active Directory Deep Dive

Get a firm grasp on your IT environment when you learn Active Directory best practices with Veeam! Watch all, or choose any amount, of this three-part webinar series to improve your skills. From the basics to virtualization and backup, we got you covered.

 
for_yanCommented:

In Java 6 there is a way to refer to the whole folder of jars, let me see
0
 
for_yanCommented:
java -Djava.ext.dirs=jarDirectory
0
 
for_yanCommented:
with omething like that in Java 6:

 -Djava.ext.dirs=/opt/jboss/client:/opt/jboss/lib:/opt/jboss/common

it shoudl pick up all jars in the folders.

0
 
CEHJCommented:
You need to prevent shell globbing through expansion
java -cp '/opt/jboss/client/*.jar:/opt/jboss/lib/*.jar:/opt/jboss/common/*.jar:/opt/jboss/comm-lang.jar:/jboss/server/default/deploy/*.jar' -jar MyJossApplication.jar

Open in new window

0
 
gordon_vt02Commented:
With JDK 6 and later, you can also just specify /some/dir/with/jars/* to load all JAR and ZIP files in that directory into the classpath.  Try:

java -cp /opt/jboss/client/*:/opt/jboss/lib/*:/opt/jboss/common/*:/opt/jboss/comm-lang.jar:/jboss/server/default/deploy/* -jar MyJossApplication.jar

Open in new window

0
 
gordon_vt02Commented:
More clarification on the wildcarding can be found here:

http://download.oracle.com/javase/6/docs/technotes/tools/windows/classpath.html

About 2/3 down the page.
0
 
CEHJCommented:
Gordon, the point is that the shell will get to that glob before java and that will confuse the issue. The (SINGLE) quoting is to prevent that happening
0
 
gordon_vt02Commented:
With or without the quotes, the cp should be specified without the '.jar', so the correct command line should be a combination of our responses:

java -cp '/opt/jboss/client/*:/opt/jboss/lib/*:/opt/jboss/common/*:/opt/jboss/comm-lang.jar:/jboss/server/default/deploy/*' -jar MyJossApplication.jar

Open in new window

0
 
CEHJCommented:
Actually it works fine for me with *.jar
0
 
CEHJCommented:
rleelink, I'm not sure why you saw fit to ignore my and Gordon't comments. Bear in mind the accepted answer will knock out any other ext jars
0

Featured Post

Important Lessons on Recovering from Petya

In their most recent webinar, Skyport Systems explores ways to isolate and protect critical databases to keep the core of your company safe from harm.

  • 6
  • 4
  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now