[rules-users] execution using "java -jar x.jar ..." fails

Andrew Waterman awaterma at ecosur.mx
Wed Jun 23 15:39:24 EDT 2010


Maven should help you out with jar file packaging as well:

http://maven.apache.org/plugins/maven-assembly-plugin/

If you use the assembly plugin you can push all of your dependencies/scripts/etc. into one large archive.  It works nicely for doing small distributions.

A

On Jun 23, 2010, at 2:29 PM, Wolfgang Laun wrote:

> OK. thanks.
> 
> 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):
> 
> Manifest-Version: 1.0
> 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
> Main-Class: rss.aws.init.Main
> 
> Eclipse's support for creating a jar isn't really helpful - I'd say it's confusing. I simply called
>    jar -fm myappl.jar MANIFEST ... # dirs where class and rules files are 
> 
> Thanks for the help. (My son simply said, "Why didn't you ask me?" - That's how it goes...)
> 
> -W
> 
> 
> 2010/6/23 Greg Barton <greg_barton at yahoo.com>
> See http://java.sun.com/j2se/1.4.2/docs/tooldocs/windows/java.html
> 
> Key line' referring to the -jar option:
> 
> "When you use this option, the JAR file is the source of all user classes, and other user class path settings are ignored."
> 
> You can specify the path to external jars in the manifest of the standalone jar.  
> 
> GreG
> 
> On Jun 23, 2010, at 9:44 AM, Wolfgang Laun <wolfgang.laun at gmail.com> wrote:
> 
>> The application works fine in Eclipse.
>> 
>> In Eclipse, I created a jar file x.jar from the .class and a few .drl files, and copied x.jar to /tmp/x/
>> 
>> Now, in /tmp/x
>>    CP="droos/*:drools/lib/*"
>>    java -cp "$CP" -jar dpvt.jar par...
>> This fails on the first attempt to access any class from a drools jar file.
>> 
>> In /tmp/x, I unpack x.jar and call
>>    CP="droos/*:drools/lib/*:."
>>    java -cp "$CP" rss.aws.init.Main par...
>> AND THIS WORKS!
>> 
>> So, what is different when starting a Java program with java -jar as opposed
>> to java x.y.Main? 
>> 
>> The stack dump is not very informative:
>> 
>> java.lang.NoClassDefFoundError: org/drools/KnowledgeBaseFactory
>>     at rss.aws.engine.impl.DroolsEngine.setup(DroolsEngine.java:30)
>>     at rss.aws.init.Core.init(Core.java:51)
>>     at rss.aws.init.Core.getInstance(Core.java:16)
>>     at rss.aws.init.Main.<init>(Main.java:35)
>>     at rss.aws.init.Main.main(Main.java:191)
>> Caused by: java.lang.ClassNotFoundException: org.drools.KnowledgeBaseFactory
>>     at java.net.URLClassLoader$1.run(URLClassLoader.java:217)
>>     at java.security.AccessController.doPrivileged(Native Method)
>>     at java.net.URLClassLoader.findClass(URLClassLoader.java:205)
>>     at java.lang.ClassLoader.loadClass(ClassLoader.java:319)
>>     at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:294)
>>     at java.lang.ClassLoader.loadClass(ClassLoader.java:264)
>>     at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:332)
>>     ... 5 more
>> 
>>  Any ideas?
>> -W
>> _______________________________________________
>> rules-users mailing list
>> rules-users at lists.jboss.org
>> https://lists.jboss.org/mailman/listinfo/rules-users
> 
> 
> _______________________________________________
> rules-users mailing list
> rules-users at lists.jboss.org
> https://lists.jboss.org/mailman/listinfo/rules-users
> 
> 
> _______________________________________________
> rules-users mailing list
> rules-users at lists.jboss.org
> https://lists.jboss.org/mailman/listinfo/rules-users

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.jboss.org/pipermail/rules-users/attachments/20100623/af5d58a5/attachment.html 


More information about the rules-users mailing list