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> |
From: Michael C. <chi...@mi...> - 2016-07-07 23:28:07
|
On 7/7/2016 6:08 PM, Stefan Richthofer wrote: > This looks like you placed a jar-file inside a jar-file. > 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). It's possible; spring-boot does it [1]. I guess with the ability to write custom classloaders, the sky's the limit :) According to > http://www.jython.org/jythonbook/en/1.0/SimpleWebApps.html?highlight=explode#distributing-via-standalone-jar > (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. > (Maybe you better try this with a toy-example first, before re-packing all the > jars). That's sometimes referred to as a "shaded" jar. [1] mentions that approach too. > 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). I know Maven has a plugin for it [2]. Other build tools might too. I don't know if this is helpful for Ranga's actual problem, but from the quoted email, I thought it would be of interest. Andy 1. http://docs.spring.io/spring-boot/docs/current-SNAPSHOT/reference/htmlsingle/#executable-jar 2. http://maven.apache.org/plugins/maven-shade-plugin/ |
From: magicalne <mag...@gm...> - 2016-12-29 07:13:53
|
Hi all, I have been through this issue for almost 2 days. I think I have figured it out. I use jsr223(groovy, jython) in my spring boot web project. I can execute groovy script, but not jython script. It looks like jython script want to import some modules from "Lib". But it cannot locate the right path to the "Lib". I think jython is a little guilty on this issue. The most simple way to get it work is to use : *springBoot { requiresUnpack = ['org.jruby:jruby-complete'] }* You can find it in spring boot doc: http://docs.spring.io/spring-boot/docs/current/reference/html/howto-build.html#howto-extract-specific-libraries-when-an-executable-jar-runs <http://docs.spring.io/spring-boot/docs/current/reference/html/howto-build.html#howto-extract-specific-libraries-when-an-executable-jar-runs> And it explains how it works. -- View this message in context: http://python.6.x6.nabble.com/Re-ImportError-No-module-named-re-tp5194446p5206030.html Sent from the jython-users mailing list archive at Nabble.com. |
From: Curtis R. <ctr...@wi...> - 2016-12-29 15:36:00
|
Hi Chandler, > It looks like jython script want to import some modules from "Lib". > But it cannot locate the right path to the "Lib". The Lib files are only present in jython-standalone, not jython base: $ jar tf ~/.m2/repository/org/python/jython/2.7.0/jython-2.7.0.jar|grep ^Lib|wc -l 0 $ jar tf ~/.m2/repository/org/python/jython-standalone/2.7.0/ jython-standalone-2.7.0.jar|grep ^Lib|wc -l 1226 I'm not sure how JRuby relates to this issue though, except that Jython and JRuby are rather incompatible with one another on the same classpath, unless you take special measures [1]. Regards, Curtis [1] https://github.com/scijava/jython-shaded -- Curtis Rueden LOCI software architect - http://loci.wisc.edu/software ImageJ2 lead, Fiji maintainer - http://imagej.net/User:Rueden On Thu, Dec 29, 2016 at 1:13 AM, magicalne <mag...@gm...> wrote: > Hi all, > > I have been through this issue for almost 2 days. I think I have figured it > out. > > I use jsr223(groovy, jython) in my spring boot web project. I can execute > groovy script, but not jython script. > > It looks like jython script want to import some modules from "Lib". But it > cannot locate the right path to the "Lib". > > I think jython is a little guilty on this issue. > > The most simple way to get it work is to use : > *springBoot { requiresUnpack = ['org.jruby:jruby-complete'] }* > > You can find it in spring boot doc: > http://docs.spring.io/spring-boot/docs/current/reference/htm > l/howto-build.html#howto-extract-specific-libraries-when-an- > executable-jar-runs > <http://docs.spring.io/spring-boot/docs/current/reference/ht > ml/howto-build.html#howto-extract-specific-libraries-when- > an-executable-jar-runs> > > And it explains how it works. > > > > > -- > View this message in context: http://python.6.x6.nabble.com/ > Re-ImportError-No-module-named-re-tp5194446p5206030.html > Sent from the jython-users mailing list archive at Nabble.com. > > ------------------------------------------------------------ > ------------------ > Check out the vibrant tech community on one of the world's most > engaging tech sites, SlashDot.org! http://sdm.link/slashdot > _______________________________________________ > Jython-users mailing list > Jyt...@li... > https://lists.sourceforge.net/lists/listinfo/jython-users > |