From: Stefan R. <Ste...@gm...> - 2016-07-07 22:08:28
|
<html><head></head><body><div style="font-family: Verdana;font-size: 12.0px;"><div style="font-family: Verdana;font-size: 12.0px;"> <div> <div>This looks like you placed a jar-file inside a jar-file.</div> <div>I never tried this, but I doubt that Jython (actually Java?) can handle such nesting of jars (maybe this feature was added and I am overlooking it, sorry in that case). According to <a href="http://www.jython.org/jythonbook/en/1.0/SimpleWebApps.html?highlight=explode#distributing-via-standalone-jar" target="_blank">http://www.jython.org/jythonbook/en/1.0/SimpleWebApps.html?highlight=explode#distributing-via-standalone-jar</a> (which is somewhat dated though) you should "explode" jython-standalone, add your code-files and then jar it again. I suppose you would have to do this with your other dependencies too or distribute them as separate files.</div> <div>(Maybe you better try this with a toy-example first, before re-packing all the jars).</div> <div>Looking at this, the need for some kind of deployment-tool that would automate such a process comes to my mind. You should maybe check, whether such a thing already exists (maybe for Java-apps in general).</div> <div> </div> <div>Best</div> <div> </div> <div>Stefan</div> <div> </div> <div> <div style="margin: 10.0px 5.0px 5.0px 10.0px;padding: 10.0px 0 10.0px 10.0px;border-left: 2.0px solid rgb(195,217,229);"> <div style="margin: 0 0 10.0px 0;"><b>Gesendet:</b> Dienstag, 05. Juli 2016 um 16:21 Uhr<br/> <b>Von:</b> "Ranga Babu Mandada" <Ran...@ip...><br/> <b>An:</b> "Stefan Richthofer" <Ste...@gm...><br/> <b>Cc:</b> "jyt...@li..." <jyt...@li...><br/> <b>Betreff:</b> Re: [Jython-users] ImportError: No module named re</div> <div> <div style="font-size: 12.0pt;color: rgb(0,0,0);background-color: rgb(255,255,255);font-family: Calibri , Arial , Helvetica , sans-serif;"> <p>Hello Stefan,</p> <p> </p> <p>I am packaging my application as a runnable jar ex: application.jar.</p> <p> </p> <p>It's contents are like below:</p> <p> </p> <p>when I run my application via IDE(Intellij IDEA) it's working properly.</p> <p>sys.path : </p> <p><span style="color: rgb(0,111,201);">['/home/rmandada/.m2/repository/org/python/jython-standalone/2.5.2/Lib', '/home/rmandada/.m2/repository/org/python/jython-standalone/2.5.2/jython-standalone-2.5.2.jar/Lib', '__classpath__', '__pyclasspath__/']</span></p> <p> </p> <p>But when I run the application from command line using <span style="color: rgb(0,111,201);"> java -jar application.jar</span> I am getting the above error.</p> <p>now sys.path is :</p> <p> </p> <p><span style="color: rgb(0,111,201);">['/home/rmandada/amelia-web.jar!/lib/Lib', '__classpath__', '__pyclasspath__/']​</span></p> <p> </p> <p>I tried to add the path like below code.</p> <p> </p> <div><span style="color: rgb(0,111,201);">PySystemState systemState = new PySystemState();</span></div> <div><span style="color: rgb(0,111,201);">systemState.path.append(Py.newString("lib/jython-standalone-2.5.2.jar/Lib"));</span></div> <div><span style="color: rgb(0,111,201);">Py.setSystemState(systemState);</span></div> <div><span style="color: rgb(0,111,201);">return new ScriptEngineManager().getEngineByName("python");</span></div> <div> </div> <div><span style="color: rgb(0,111,201);"><span style="color: rgb(0,0,0);">​But it's not working . Please tell me how to add the path of jython-standalone-2.5.2.jar​ which lies in lib folder of application.jar.</span></span></div> <p> </p> <p> </p> <p> </p> <div id="Signature"> <div style="font-family: Calibri , Arial , Helvetica , sans-serif;margin: 0;">Regards,<br/> Ranga Babu<br/> </div> </div> <div style="color: rgb(33,33,33);"> <hr style="display: inline-block;width: 98.0%;"/> <div id="divRplyFwdMsg"><font color="#000000" face="Calibri, sans-serif" style="font-size: 11.0pt;"><b>From:</b> Stefan Richthofer <Ste...@gm...><br/> <b>Sent:</b> Friday, June 24, 2016 4:58 PM<br/> <b>To:</b> Ranga Babu Mandada<br/> <b>Cc:</b> jyt...@li...<br/> <b>Subject:</b> Re: [Jython-users] ImportError: No module named re</font> <div> </div> </div> <div> <div style="font-family: Verdana;font-size: 12.0px;"> <div> <div>Hello Ranga,</div> <div> </div> <div>this looks like in your command-line Jython-launch cannot find its lib-folder/doesn't have Jython-path configured properly.</div> <div>You should first identify the location of Jython's lib-folder (the folder containing the .py-files making up the major</div> <div>part of the standard lib). Then</div> <div>- you can check via import sys; print sys.path whether that folder is on the path.</div> <div>- you can verify if the problem is cured by manually adding that path via sys.path.append</div> <div>- you can fix you Jython-path configuration by providing the environment variable JYTHONPATH to the jvm (see jython --help)</div> <div>- I guess things get easier or issue might be self-soved if you call Jython via its launcher rather than manually via java-command.</div> <div>- finally you can consider how to solve this for distribution, e.g. by distributing jython-standalone</div> <div>(which contains the lib folder) or by providing an installer or launcher that makes sure the path is configured correctly for the user</div> <div> </div> <div>Hope this somewhat helps.</div> <div>Best</div> <div> </div> <div>Stefan</div> <div> </div> <div> </div> <div> <div style="margin: 10.0px 5.0px 5.0px 10.0px;padding: 10.0px 0 10.0px 10.0px;border-left: 2.0px solid rgb(195,217,229);"> <div style="margin: 0 0 10.0px 0;"><b>Gesendet:</b> Freitag, 24. Juni 2016 um 12:17 Uhr<br/> <b>Von:</b> "Ranga Babu Mandada" <Ran...@ip...><br/> <b>An:</b> "jyt...@li..." <jyt...@li...><br/> <b>Betreff:</b> [Jython-users] ImportError: No module named re</div> <div> <div style="font-size: 12.0pt;color: rgb(0,0,0);background-color: rgb(255,255,255);font-family: Calibri , Arial , Helvetica , sans-serif;"> <p> </p> <div style="font-size: 12.0pt;color: rgb(0,0,0);background-color: rgb(255,255,255);font-family: Calibri , Arial , Helvetica , sans-serif;"><span style="font-size: 12.0pt;">Hello, </span> <div> <p> </p> <p>I am using Jython in java application to run python scripts. I am using <span style="font-size: 12.0pt;">j</span><span style="font-size: 12.0pt;">ython-standalone-2.5.2 as a dependency in pom.xml in maven project.</span></p> <p><span style="font-size: 12.0pt;">when I run the application in IDE the script is running without problems.</span></p> <p>But when I run the application from command line using<span style="color: rgb(255,0,0);"> java -jar application.jar <span style="color: rgb(0,0,0);">I get the following error</span></span></p> <p><span style="color: rgb(255,0,0);"><span style="color: rgb(0,0,0);">ImportError: No module named re​.</span></span></p> <p> </p> <p><span style="color: rgb(255,0,0);"><span style="color: rgb(0,0,0);">Please help me in fixing the issue.</span></span></p> <p> </p> <div id="Signature"> <div style="font-family: Calibri , Arial , Helvetica , sans-serif;margin: 0;">Regards,<br/> Ranga Babu<br/> </div> </div> </div> </div> ------------------------------------------------------------------------------ Attend Shape: An AT&T Tech Expo July 15-16. Meet us at AT&T Park in San Francisco, CA to explore cutting-edge tech and listen to tech luminaries present their vision of the future. This family event has something for everyone, including kids. Get more information and register today. <a href="http://sdm.link/attshape_______________________________________________" target="_blank"> http://sdm.link/attshape_______________________________________________</a> Jython-users mailing list Jyt...@li... <a href="https://lists.sourceforge.net/lists/listinfo/jython-users" target="_blank"> https://lists.sourceforge.net/lists/listinfo/jython-users</a></div> </div> </div> </div> </div> </div> </div> </div> </div> </div> </div> </div> </div> </div></div></body></html> |