Unable to resolve classpath invoking a class from sleep script

2 views
Skip to first unread message

Alen

unread,
Sep 30, 2008, 6:38:10 AM9/30/08
to Sleep Developers
Hi,

I am facing some issues when trying to invoke a java method from a
sleep script.
This issue comes when the java method is in turn calling some other
method of some other class file.

Suppose I have a scipt A, which is invoking a method "meth1" of class
"Class1".
The method "meth1" of class "Class1" is calling method "meth2" of some
other class "Class2".

This method "meth2" is not getting called and I am not getting any
exception as well.

Below is the sample code snippet:

Sleep script - A
======================================================================
import class1 from: <jar_path>.jar;

$output = [Class1 meth1];

======================================================================


Class - Class1
****************************************************************************************************************
public static String meth1()
{
Class2.meth2();
}
****************************************************************************************************************


Class - Class2
################################################################################
public static String meth2()
{
// Method implementation
}
################################################################################

I guess it could be an issue with classpath of Class2 because of which
meth1 is not able to recognize the meth2 of class2.

Please provide your valuable comments.

Thanks in advance
- Alen

Andreas Ravnestad

unread,
Sep 30, 2008, 9:55:09 AM9/30/08
to sleep-de...@googlegroups.com
Hi!

Have you tried to import Class2 as well?

-Andreas

Raphael Mudge

unread,
Sep 30, 2008, 9:58:18 AM9/30/08
to sleep-de...@googlegroups.com
Hi Alen,
Are you using the latest version of Sleep? Sleep 2.1-pre update 2
used to use a separate classloader for each import from an external
jar file. This had the unfortunate side effect that classes from
separate jars could not call eachother. In update 2, I changed this
to use a reflection hack to build up the Java classpath at runtime.
The main purpose was to allow the use of import * from: somejar.jar
to include dependencies another jar used by Sleep might have.

Its a bit odd that you're not seeing an error as well. Use debug
(debug() | 8) to get a trace of what the script is doing to make sure
everything is executing as you'd expect. Feel free to come back to
this list with any additional info and we'll try to help you out.

-- Raphael

Reply all
Reply to author
Forward
0 new messages