<table cellspacing="0" cellpadding="0" border="0" ><tr><td valign="top" style="font: inherit;">Yep, I know what you mean about building that jar. I usually use the maven jar plugin in a maven build to do that:<br><br><plugin><br> <groupId>org.apache.maven.plugins</groupId><br> <artifactId>maven-jar-plugin</artifactId><br> <configuration><br> <archive><br> <manifest><br> <mainClass>foo.bar.Bas</mainClass><br> <addClasspath>true</addClasspath><br> </manifest><br>
</archive><br> </configuration><br></plugin><br><br>The "addClasspath" bit is keen. That along with the maven dependency plugin gathers all the jars you need for the app. (Sample pom.xml attached.)<br><br><br>--- On <b>Wed, 6/23/10, Wolfgang Laun <i><wolfgang.laun@gmail.com></i></b> wrote:<br><blockquote style="border-left: 2px solid rgb(16, 16, 255); margin-left: 5px; padding-left: 5px;"><br>From: Wolfgang Laun <wolfgang.laun@gmail.com><br>Subject: Re: [rules-users] execution using "java -jar x.jar ..." fails<br>To: "Rules Users List" <rules-users@lists.jboss.org>, "Edson Tirelli" <ed.tirelli@gmail.com><br>Date: Wednesday, June 23, 2010, 2:29 PM<br><br><div id="yiv1964555394">OK. thanks.<br><br>Here is a sample MANIFEST, to be included in the application jar, with the jars I've found essential for running a plain Expert application (without XML rules or
commands):<br><br>Manifest-Version: 1.0<br>
Class-Path: /extra/drools-5.1.0.M2/drools-api-5.1.0.M2.jar /extra/drools-5.1.0.M2/drools-compiler-5.1.0.M2.jar /extra/drools-5.1.0.M2/drools-core-5.1.0.M2.jar /extra/drools-5.1.0.M2/lib/mvel2-2.0.16.jar /extra/drools-5.1.0.M2/lib/antlr-runtime-3.1.3.jar /usr/local/eclipse/plugins/org.eclipse.jdt.core_3.4.4.v_894_R34x.jar<br>
Main-Class: rss.aws.init.Main<br><br>Eclipse's support for creating a jar isn't really helpful - I'd say it's confusing. I simply called<br> jar -fm myappl.jar MANIFEST ... # dirs where class and rules files are <br>
<br>Thanks for the help. (My son simply said, "Why didn't you ask me?" - That's how it goes...)<br><br>-W<br><br><br><div class="gmail_quote">2010/6/23 Greg Barton <span dir="ltr"><<a rel="nofollow" ymailto="mailto:greg_barton@yahoo.com" target="_blank" href="/mc/compose?to=greg_barton@yahoo.com">greg_barton@yahoo.com</a>></span><br>
<blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;"><div><div>See <a rel="nofollow" target="_blank" href="http://java.sun.com/j2se/1.4.2/docs/tooldocs/windows/java.html"></a><a rel="nofollow" target="_blank" href="http://java.sun.com/j2se/1.4.2/docs/tooldocs/windows/java.html">http://java.sun.com/j2se/1.4.2/docs/tooldocs/windows/java.html</a></div>
<div><br></div><div>Key line' referring to the -jar option:</div><div class="im"><div><br></div><div>"<span style="font-family: Times; font-size: medium;">When you use this option, the JAR file is the source of all user classes, and other user class path settings are ignored."</span><br>
<br></div></div><div>You can specify the path to external jars in the manifest of the standalone jar. </div><div><br><font color="#888888">GreG</font></div><div><div></div><div class="h5"><div><br>On Jun 23, 2010, at 9:44 AM, Wolfgang Laun <<a rel="nofollow" ymailto="mailto:wolfgang.laun@gmail.com" target="_blank" href="/mc/compose?to=wolfgang.laun@gmail.com">wolfgang.laun@gmail.com</a>> wrote:<br>
<br></div><div></div><blockquote type="cite"><div>The application works fine in Eclipse.<br><br>In Eclipse, I created a jar file x.jar from the .class and a few .drl files, and copied x.jar to /tmp/x/<br><br>Now, in /tmp/x<br>
CP="droos/*:drools/lib/*"<br> java -cp "$CP" -jar dpvt.jar par...<br>
This fails on the first attempt to access any class from a drools jar file.<br><br>In /tmp/x, I unpack x.jar and call<br> CP="droos/*:drools/lib/*:."<br> java -cp "$CP" rss.aws.init.Main par...<br>
AND THIS WORKS!<br><br>So, what is different when starting a Java program with java -jar as opposed<br>to java x.y.Main? <br><br>The stack dump is not very informative:<br><br>java.lang.NoClassDefFoundError: org/drools/KnowledgeBaseFactory<br>
at rss.aws.engine.impl.DroolsEngine.setup(DroolsEngine.java:30)<br> at rss.aws.init.Core.init(Core.java:51)<br> at rss.aws.init.Core.getInstance(Core.java:16)<br> at rss.aws.init.Main.<init>(Main.java:35)<br>
at rss.aws.init.Main.main(Main.java:191)<br>Caused by: java.lang.ClassNotFoundException: org.drools.KnowledgeBaseFactory<br> at java.net.URLClassLoader$1.run(URLClassLoader.java:217)<br> at java.security.AccessController.doPrivileged(Native Method)<br>
at java.net.URLClassLoader.findClass(URLClassLoader.java:205)<br> at java.lang.ClassLoader.loadClass(ClassLoader.java:319)<br> at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:294)<br> at java.lang.ClassLoader.loadClass(ClassLoader.java:264)<br>
at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:332)<br> ... 5 more<br><br> Any ideas?<br>-W<br>
</div></blockquote><blockquote type="cite"><div><span>_______________________________________________</span><br><span>rules-users mailing list</span><br><span><a rel="nofollow" ymailto="mailto:rules-users@lists.jboss.org" target="_blank" href="/mc/compose?to=rules-users@lists.jboss.org">rules-users@lists.jboss.org</a></span><br>
<span><a rel="nofollow" target="_blank" href="https://lists.jboss.org/mailman/listinfo/rules-users">https://lists.jboss.org/mailman/listinfo/rules-users</a></span><br></div></blockquote><br>
</div></div></div><br>_______________________________________________<br>
rules-users mailing list<br>
<a rel="nofollow" ymailto="mailto:rules-users@lists.jboss.org" target="_blank" href="/mc/compose?to=rules-users@lists.jboss.org">rules-users@lists.jboss.org</a><br>
<a rel="nofollow" target="_blank" href="https://lists.jboss.org/mailman/listinfo/rules-users">https://lists.jboss.org/mailman/listinfo/rules-users</a><br>
<br></blockquote></div><br>
</div><br>-----Inline Attachment Follows-----<br><br><div class="plainMail">_______________________________________________<br>rules-users mailing list<br><a ymailto="mailto:rules-users@lists.jboss.org" href="/mc/compose?to=rules-users@lists.jboss.org">rules-users@lists.jboss.org</a><br><a href="https://lists.jboss.org/mailman/listinfo/rules-users" target="_blank">https://lists.jboss.org/mailman/listinfo/rules-users</a><br></div></blockquote></td></tr></table><br>