Neil-

It seems from your example like you are passing a string representation of the path to the Python modules.  That is one way of performing this task.  Another way is to place the modules somewhere in your sys.path and pass just the name of the module instead of the complete path.  You can take a look at an article submitted to Jython Monthly by Charlie Groves for more information:  http://wiki.python.org/jython/JythonMonthly/Articles/October2006/3 on this technique.  You'd have to modify your code a bit, but this may be one way to get around these errors. 

I am not exactly sure why you are receiving the errors unless the modules are not available to the web server in the designated path that you are sending to the factory.

Hope this gets you headed in the right direction for resolving the errors.

Josh Juneau
juneau001@gmail.com
http://jj-blogger.blogspot.com
Twitter ID:  javajuneau


On Mon, Jun 15, 2009 at 12:16 PM, Neil M. <nabber00@gmail.com> wrote:
Hi, I'm trying to run a Java Applet with a Java Swing GUI but using a
python library as a backed.  I've packed it all into a .jar that runs
fine as a standalone Java app.  When I move it to the webserver it seems
to be issuing HTTP requests (see attached log) for various imports and I
have no idea why.  Something with the classpath or pythonpath?  Any ideas?

Neil

--------------- modified jython factory ----------------------
  public static Object getJythonObject(String interfaceName,
                                       String pathToJythonModule){

      Object javaInt = null;
      PythonInterpreter interpreter = new PythonInterpreter();
      //interpreter.execfile(pathToJythonModule);
      interpreter.exec("import " + pathToJythonModule);
      //String tempName =
pathToJythonModule.substring(pathToJythonModule.lastIndexOf("/")+1);
      String tempName =
pathToJythonModule.substring(pathToJythonModule.lastIndexOf(".")+1);
      //tempName = tempName.substring(0, tempName.indexOf("."));
      //System.out.println(tempName);
      String instanceName = tempName.toLowerCase();
      String javaClassName = tempName.substring(0,1).toUpperCase() +
                          tempName.substring(1);
      //String objectDef = "=" + javaClassName + "()";
      String objectDef = "=" + pathToJythonModule + "." + javaClassName
+ "()";
      interpreter.exec(instanceName + objectDef);
      //System.out.println(instanceName + objectDef);
       try {
          Class JavaInterface = Class.forName(interfaceName);
          javaInt =
               interpreter.get(instanceName).__tojava__(JavaInterface);
       } catch (ClassNotFoundException ex) {
           ex.printStackTrace();  // Add logging here
       }

      return javaInt;
  }


-------------------- HTTP Log --------------------

[Sun Jun 14 18:50:40 2009] [error] [client X] File does not exist:
/download_test/stat$py.class

[Sun Jun 14 18:50:41 2009] [error] [client X] File does not exist:
/download_test/stat$py.class
[Sun Jun 14 18:50:42 2009] [error] [client X] File does not exist:
/download_test/java
[Sun Jun 14 18:50:45 2009] [error] [client X] File does not exist:
/download_test/java
[Sun Jun 14 18:50:46 2009] [error] [client X] File does not exist:
/download_test/java
[Sun Jun 14 18:50:46 2009] [error] [client X] File does not exist:
/download_test/java
[Sun Jun 14 18:50:47 2009] [error] [client X] File does not exist:
/download_test/org.class
[Sun Jun 14 18:50:47 2009] [error] [client X] File does not exist:
/download_test/org.class
[Sun Jun 14 18:50:48 2009] [error] [client X] File does not exist:
/download_test/org
[Sun Jun 14 18:50:48 2009] [error] [client X] File does not exist:
/download_test/org
[Sun Jun 14 18:50:49 2009] [error] [client X] File does not exist:
/download_test/org
[Sun Jun 14 18:50:50 2009] [error] [client X] File does not exist:
/download_test/org

------------------------------------------------------------------------------
Crystal Reports - New Free Runtime and 30 Day Trial
Check out the new simplified licensing option that enables unlimited
royalty-free distribution of the report engine for externally facing
server and web deployment.
http://p.sf.net/sfu/businessobjects
_______________________________________________
Jython-users mailing list
Jython-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/jython-users