Menu

can i run a java servlet with jpype?

Feedback
ACM
2009-06-11
2013-04-25
  • ACM

    ACM - 2009-06-11

    Hi guys,

        I would like to know if I can inter-operate servlets written in java with ZK with  python through jpype. I've just learned about jpype and I am doing some kind of "hello world" programs but my final goal would be use ZK and python, do you think it would be possible?

    BR/

    Waster

     
    • Steve Menard

      Steve Menard - 2009-06-12

      Nothing prevents it. Python has to be the "host" though, so you'll essentially have to "embed" the servlet container in python by using jpype. After that, if you want the servlets to call python code you'll have to figure out a way to give references to the python object to the servlets.

      All in all not an easy task. But if you can get it done (say, using tomcat?) I am sure many other would love to reuse your work. I would gladly put it in as some kind of official jpype "addon".

       
    • ACM

      ACM - 2009-07-03

      Hi, I have done some proof of concept to know how complex it would be. First I  did  several python-java integration with openJMS without any problem, but i run into some difficulties when i tried to embed tomcat into python. Finally I have tomcat runnig into python and I am able to delegate the implementation of the java servlet to python, almost...
           I am using a factory to pass the implementation from python to java,  in java, the factory return interfaces and the implementation of this factory in python return jproxies. Every thing went fine until i started to have some python runtime exceptions in the invocation of some interfaces from java that are implemente in python. I  mean, some java interfaces invocation go well but other caused an exceptions,

      this is trace for one ok.

      INFO: calling python factory
      .............................received callback from java
      Jul 3, 2009 3:57:39 PM jpype.JPypeInvocationHandler hostInvoke
      INFO: Creating formCmp...
      created form......................
      Creating DropComponentEventListener
      adding event listener..................
      returning formCmp componente

      and this whit an exception
      ..
      ...
      Jul 3, 2009 3:57:42 PM org.zkoss.zk.ui.impl.UiEngineImpl handleError:1128
      SEVERE: >>java.lang.RuntimeException: Python exception thrown
      >>      at jpype.JPypeInvocationHandler.hostInvoke(Native Method)
      >>      at jpype.JPypeInvocationHandler.invoke(JPypeInvocationHandler.java:10)
      >>      at $Proxy1.hashCode(Unknown Source)
      >>      at java.util.HashMap.put(HashMap.java:372)
      >>      at java.util.HashSet.add(HashSet.java:200)
      >>      at org.zkoss.zk.ui.impl.EventProcessor.process0(EventProcessor.java:195)
      >>      at org.zkoss.zk.ui.impl.EventProcessor.process(EventProcessor.java:141)
      >>      at org.zkoss.zk.ui.impl.EventProcessingThreadImpl.process0(EventProcessingThreadImpl.java:488)
      >>...

      I I suppose I have made a little mistake in python, but with this information in the stack trace I can't see anything.

      could you give any guide? do you have any suggestion?

      thx

      waster.

       
  • Anonymous

    Anonymous - 2009-11-04

    Why dont you use jetty instead of tomcat. We have done setting up jetty with jpype to run solr, an it works fine.

     

Log in to post a comment.