Ok, I now set up my code like following:

<code>
      URL robotURL = robotJar.toURI().toURL();
      URL jythonURL = jythonJar.toURI().toURL();
      ClassLoader currentClassLoder = Thread.currentThread().getContextClassLoader();
      URLClassLoader jythonAwareClassLoader =
          new URLClassLoader(new URL[]{ robotURL, jythonURL }, currentClassLoder);
      Thread.currentThread().setContextClassLoader(jythonAwareClassLoader);
      try
      {
        JarRunner.run(commandLine);
      }
      finally
      {
        Thread.currentThread().setContextClassLoader(currentClassLoder);
      }
</code>

This results in jython JarRunner starting the __run__, which finds and starts to initialize the module robot, which then fails:

[INFO] Trace
Traceback (most recent call last):
  File "__pyclasspath__/__run__.py", line 308, in <module>
  File "__pyclasspath__/robot/__init__.py", line 24, in <module>
  File "__pyclasspath__/robot/output/__init__$py.class", line 16, in <module>
  File "__pyclasspath__/robot/output/output$py.class", line 18, in <module>
  File "__pyclasspath__/robot/common/__init__$py.class", line 16, in <module>
  File "__pyclasspath__/robot/common/model$py.class", line 16, in <module>
ImportError: No module named random

As this is not working maybe the classloader idea was wrong and I need to modify the classpath property instead? Does that work within the same thread?

Cheers,
Kai

2010/2/25 Kai Hackemesser <kai.hackemesser@gmail.com>
2010/2/25 Frank Wierzbicki <fwierzbicki@gmail.com>

2010/2/24 Alex Grönholm <alex.gronholm@nextday.fi>:
> See if other stdlib modules can be imported. This problem is beyond me.
> Also, please reply to the mailing list, not to me personally.
Hi Kai,

It is necessary on this list to "reply to all" for it to get to the
main list (historical reasons).


Sorry for the email confusion, sometimes gmail does it right, sometimes not. (I think that depends on the mailing list settings that could inject an "answer to" header to the mails...)

 
Since you mention a __run__ I'm assuming you are following directions
like this one:

http://wiki.python.org/jython/JythonFaq/DistributingJythonScripts

Or this one:

http://stackoverflow.com/questions/1252965/distributing-my-python-scripts-as-jars-with-jython/1255113#1255113

The stackoverflow example mentions a class that is new as of Jython
2.5.1: JarRunner.  If you haven't tried using JarRunner that might be
a good place to start if you are jarring apps together, at least
that's what it sounds like you are doing.  If not please do tell us
more about your setup.


That's true, but I prefer not to have a single customised jython-standalone-app, but a one jar for plain jython-standalone and one for the additional modules required here.

I will test with the JarRunner now. I suppose I have to have both jars then in the classpath, right? a -jar option is then not longer required.

Is it enough to have a custom URLClassloader being aware of the jars wenn calling the JarRunner? After all my target is still to not need to fork the process.

Cheers,
Kai