How do I set the classpath in sleep 2.0?

48 views
Skip to first unread message

Shashidhar Gaurav

unread,
Jan 5, 2013, 3:36:12 AM1/5/13
to sleep-de...@googlegroups.com
Hi,

I have a following libraries under /home/jboss/server/default/lib

1. commons-logging-1.1.jar
2. securityframework-4.1.0.jar

However when I am running my sleep script by executing the below command I am getting class not found exception.

java -Dsleep.classpath=$JBOSS_HOME/server/default/lib/ -jar $JBOSS_HOME/server/default/lib/sleep-2.0.jar $JBOSS_HOME/jobs/send_to_xdas.sl

Exception in thread "main" java.lang.NoClassDefFoundError: org/apache/commons/logging/LogFactory


Any idea, how this can be fixed? Not sure if I am doing something wrong. 

Thanks in advance
Shashi

Raphael Mudge

unread,
Jan 5, 2013, 12:15:05 PM1/5/13
to sleep-de...@googlegroups.com
Try this:

java -classpath $JBOSS_HOME/...:...:...:sleep.jar sleep.console.TextConsole $JBOSS_HOME/jobs/send_to_xdas.sl

-- Raphael

--
-----
To post to this group, send email to sleep-de...@googlegroups.com
To unsubscribe from this group, send email to sleep-develope...@googlegroups.com
For more options, visit this group at http://groups.google.com/group/sleep-developers?hl=en
 
The Sleep Scripting Project: http://sleep.dashnine.org/

Shashidhar Gaurav

unread,
Jan 7, 2013, 12:40:03 AM1/7/13
to sleep-de...@googlegroups.com
Thanks Raphael it's working. 

Shashidhar Gaurav

unread,
Jan 7, 2013, 8:51:28 AM1/7/13
to sleep-de...@googlegroups.com
Hi Raphael,

Sorry it's not working. I am using sleep 2.0

 java -classpath /home/jboss/server/default/lib/commons-logging-1.1.jar:/home/jboss/server/default/lib/securityframework-4.1.0.jar:/home/jboss/server/default/lib/bcprov-jdk15-135.jar:/home/jboss/server/default/lib/commons-lang-2.3.jar:/home/jboss/server/default/lib/sleep-2.0.jar sleep.console.TextConsole $JBOSS_HOME/jobs/send_to_xdas.sl
Error: jar file to import package from was not found! at line 1
       import org.apache.commons.logging.LogFactory from: commons-logging-1.1.jar
Error: jar file to import package from was not found! at line 2
       import org.bouncycastle.jce.provider.BouncyCastleProvider from: bcprov-jdk15-135.jar
Error: jar file to import package from was not found! at line 3

Thanks
Shashidhar

Ralph Becker

unread,
Jan 7, 2013, 9:36:59 AM1/7/13
to sleep-de...@googlegroups.com

Hi Shashidhar,

if you use Sleep 2.0 and add all necessary jars via java -classpath
you should not use the Sleep 2.1 syntax for importing from jars (import * from: foo.jar;)

If you use Sleep 2.1 you may add directories via -Dsleep.classpath and Sleep will
look for jar files specified by the from: part of an import statement in these directories.

Consider this case:
You have 2 jars in /home/user/mylibs: libA.jar, libB.jar
You can use classes from these jars if you use the -Dsleep.classpath option:
  java -Dsleep.classpath=/home/user/mylibs [...]
and import them by
  import foo.* from: libA.jar;
  import bar.* from: libB.jar;
in your script. Sleep 2.1 will look for libA.jar and libB.jar in /home/user/mylibs.

With Sleep 2.0 you have to use the java -classpath (or -cp) option
  java -classpath /home/user/mylibs/libA.jar:/home/user/mylibs/libB.jar
and import classes without a from: part
  import foo.*;
  import bar.*;

If you want to use classes from jars/directories specifiied at runime
you may use my classloader bridge:
http://www.ululatus.org/sleep_jircii/classloader/
There are versions for Sleep 2.0 and Sleep 2.1

Ralph

Shashidhar Gaurav

unread,
Jan 7, 2013, 11:57:12 PM1/7/13
to sleep-de...@googlegroups.com
Thanks a lot Raphael. It's clear as a crystal now :). I appreciate your quick response on support issues. 

Thanks
Shashidhar
Reply all
Reply to author
Forward
0 new messages