[rules-users] Run Drool Application From Command Prompt

Greg Barton greg_barton at yahoo.com
Tue Jul 28 02:32:28 EDT 2009


Well, there you go. :)  Just put drools into the regular classpath and not the bootstrap classpath.  Is that possible?

--- On Tue, 7/28/09, Pankaj.Jain at lntinfotech.com <Pankaj.Jain at lntinfotech.com> wrote:

> From: Pankaj.Jain at lntinfotech.com <Pankaj.Jain at lntinfotech.com>
> Subject: Re: [rules-users] Run Drool Application From Command Prompt
> To: "Rules Users List" <rules-users at lists.jboss.org>
> Date: Tuesday, July 28, 2009, 1:23 AM
> 
> 
> Hi 
> 
> 
> 
> you r right, When I run
> the application
> (integrated with OFBiz) from command prompt  I get the
> NPE: in line
> 
> 
> 
> getClass().getClassLoader().loadClass(
> "org.eclipse.jdt.internal.compiler.Compiler"
> );
> 
> 
> 
> When I run the
> application (ofcourse
> integrated with OFBiz)  from eclipse I don't get
> NPE exception.
> 
> 
> 
> 
> 
> In ofbiz we have a batch
> file named
> startofbiz.bat to run the application, inside this I
> configured the classpath
> by this
> 
> 
> 
> 
> 
> set
> VMARGS=-Xbootclasspath/p:applications\order\lib\antlr-runtime.jar
> 
> set
> VMARGS=-Xbootclasspath/p:applications\order\lib\drools-api.jar
> %VMARGS%
> 
> set
> VMARGS=-Xbootclasspath/p:applications\order\lib\drools-compiler.jar
> %VMARGS%
> 
> set
> VMARGS=-Xbootclasspath/p:applications\order\lib\drools-core.jar
> %VMARGS%
> 
> set
> VMARGS=-Xbootclasspath/p:applications\order\lib\drools-decisiontables.jar
> %VMARGS%
> 
> set
> VMARGS=-Xbootclasspath/p:applications\order\lib\drools-jsr94.jar
> %VMARGS%
> 
> set
> VMARGS=-Xbootclasspath/p:applications\order\lib\drools-templates.jar
> %VMARGS%
> 
> set
> VMARGS=-Xbootclasspath/p:applications\order\lib\joda-time.jar
> %VMARGS%
> 
> set
> VMARGS=-Xbootclasspath/p:applications\order\lib\jsr94.jar
> %VMARGS%
> 
> set
> VMARGS=-Xbootclasspath/p:applications\order\lib\jxl.jar
> %VMARGS%
> 
> set
> VMARGS=-Xbootclasspath/p:applications\order\lib\mvel2.jar
> %VMARGS%
> 
> set
> VMARGS=-Xbootclasspath/p:applications\order\lib\org.eclipse.jdt.core_3.4.4.v_894_R34x.jar
> %VMARGS%
> 
> set
> VMARGS=-Xbootclasspath/p:applications\order\lib\xpp3.jar
> %VMARGS%
> 
> set
> VMARGS=-Xbootclasspath/p:applications\order\lib\xpp3_min.jar
> %VMARGS%
> 
> set
> VMARGS=-Xbootclasspath/p:applications\order\lib\xstream.jar
> %VMARGS%
> 
> 
> 
> 
> 
> 
> 
> If i don't do this I
> get the class
> not found exception
> 
> 
> 
> Thanks & Regards:
> 
> 
> 
> Pankaj Jain | L&T infotech |Navi Mumbai
> 
> Mobile: +91 9920218945
> 
> Email : pankaj.jain at lntinfotech.com
> 
> www.Lntinfotech.com
> 
> 
> 
> "Whatever the mind of man can conceive & believe,
> it can achieve."
> 
> 
> 
> Larsen & Toubro Infotech Ltd.
> 
> www.Lntinfotech.com
> 
> 
> 
> This Document is classified as: 
> 
> 
> 
> L&T
> Infotech Proprietary   L&T
> Infotech Confidential   L&T
> Infotech Internal Use Only   L&T
> Infotech General Business   
> 
> 
> 
> This Email may contain confidential or privileged
> information for the intended
> recipient (s) If you are not the intended recipient, please
> do not use
> or disseminate the information, notify the sender and
> delete it from your
> system. 
> 
> 
> 
> 
> 
> 
> 
> 
> Greg
> Barton <greg_barton at yahoo.com>
> 
> 
> Sent by:
> rules-users-bounces at lists.jboss.org
> 07/28/2009 11:29
> AM
> 
> 
> 
> Please respond to
> 
> Rules Users List
> <rules-users at lists.jboss.org>
> 
> 
> 
> 
> 
> 
> To
> Rules Users List
> <rules-users at lists.jboss.org>
> 
> 
> cc
> 
> 
> 
> Subject
> Re: [rules-users]
> Run Drool Application
> >From Command Prompt
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> It's unclear from your post when you get the NPE: from
> the command line,
> from eclipse, or when integrated with OFBiz. (I assume
> you're referring
> to http://ofbiz.apache.org/)
> 
> 
> 
> It's undoubtedly a classpath issue.  Just peek at
> the source a bit.
>  I'm not sure what version you're using, but
> if you look at the source
> in the svn repo you'll see that line 92 of
> JavaDialectConfiguration is
> this:
> 
> 
> 
> getClass().getClassLoader().loadClass(
> "org.eclipse.jdt.internal.compiler.Compiler"
> );
> 
> 
> 
> See the javadoc for Class.getClassLoader() that says
> "Returns the
> class loader for the class. Some implementations may use
> null to represent
> the bootstrap class loader. This method will return null in
> such implementations
> if this class was loaded by the bootstrap class
> loader."
> 
> 
> 
> So, it looks probable that in the environment that's
> having problems, the
> JavaDialectConfiguration class is loaded by the bootstrap
> classloader.
>  What is the VM implementation you're using?
> 
> 
> 
> It might be best if
> Thread.currentThread().getContextClassLoader() was
> used instead of getClass().getClassLoader() in
> JavaDialectConfiguration
> and elsewhere.  Devs, have an opinion on that?
> 
> 
> 
> --- On Mon, 7/27/09, Pankaj.Jain at lntinfotech.com
> <Pankaj.Jain at lntinfotech.com>
> wrote:
> 
> 
> 
> > From: Pankaj.Jain at lntinfotech.com
> <Pankaj.Jain at lntinfotech.com>
> 
> > Subject: Re: [rules-users] Run Drool Application From
> Command Prompt
> 
> > To: rules-users at lists.jboss.org
> 
> > Date: Monday, July 27, 2009, 11:50 PM
> 
> > 
> 
> > 
> 
> > Hi
> 
> > 
> 
> > 
> 
> > 
> 
> > I still have not got any
> 
> > solution
> 
> > of my problem that I posted previously. I have
> included all
> 
> > required jar
> 
> > files and set proper class path .. Please do help ?
> 
> > 
> 
> > 
> 
> > 
> 
> > problem: 
> 
> > 
> 
> > 
> 
> > 
> 
> > 
> 
> > I am trying to
> 
> > integrate Drool with
> 
> > ofbiz and run application from command prompt. In one
> way I
> 
> > have integrated
> 
> > it properly and I am able to run it
> 
> > successfully.
> 
> > 
> 
> > 
> 
> > 
> 
> > 
> 
> > Code : Which I was using initially 
> 
> > 
> 
> > 
> 
> > 
> 
> > KnowledgeBuilder kbuilder =
> 
> > KnowledgeBuilderFactory.newKnowledgeBuilder();
> 
> > 
> 
> > 
> 
> > 
> 
> > 
> 
> > or 
> 
> > 
> 
> > 
> 
> > 
> 
> > PackageBuilderConfiguration cfg = new
> 
> > PackageBuilderConfiguration();
> 
> > 
> 
> > 
> 
> > KnowledgeBuilder kbuilder =
> 
> > KnowledgeBuilderFactory.newKnowledgeBuilder();
> 
> > 
> 
> > 
> 
> > 
> 
> > 
> 
> > Exception I got : 
> 
> > 
> 
> > 
> 
> > 
> 
> > org.drools.RuntimeDroolsException: Unable to load
> dialect
> 
> >
> 'org.drools.rule.builder.dialect.java.JavaDialectConfiguration:java
> 
> > 
> 
> > 
> 
> >
> :org.drools.rule.builder.dialect.java.JavaDialectConfiguration'
> 
> > 
> 
> > 
> 
> > at
> 
> >
> org.drools.compiler.PackageBuilderConfiguration.addDialect(PackageBuilderConfiguration.java:274)
> 
> > at
> 
> >
> org.drools.compiler.PackageBuilderConfiguration.buildDialectConfigurationMap(PackageBuilderConfiguration.java:259)
> 
> > 
> 
> > 
> 
> > 
> 
> > 
> 
> > at
> 
> >
> org.drools.compiler.PackageBuilderConfiguration.init(PackageBuilderConfiguration.java:176)
> 
> > at
> 
> >
> org.drools.compiler.PackageBuilderConfiguration.<init>(PackageBuilderConfiguration.java:153)
> 
> > at
> 
> >
> org.drools.compiler.PackageBuilder.<init>(PackageBuilder.java:242)
> 
> > 
> 
> > 
> 
> > . 
> 
> > 
> 
> > . 
> 
> > 
> 
> > . 
> 
> > 
> 
> > Caused by: java.lang.NullPointerException 
> 
> > 
> 
> > at
> 
> >
> org.drools.rule.builder.dialect.java.JavaDialectConfiguration.setCompiler(JavaDialectConfiguration.java:92)
> 
> > at
> 
> >
> org.drools.rule.builder.dialect.java.JavaDialectConfiguration.init(JavaDialectConfiguration.java:55)
> 
> > at
> 
> >
> org.drools.compiler.PackageBuilderConfiguration.addDialect(PackageBuilderConfiguration.java:270
> 
> > 
> 
> > 
> 
> > 
> 
> > 
> 
> > Problem I found : 
> 
> > 
> 
> > In the class JavaDialectConfiguration in jar file
> 
> > drools-compiler.jar there
> 
> > is a method named "setCompliler",  in
> this
> 
> > method Null Pointer
> 
> > Exception was coming. 
> 
> > 
> 
> > 
> 
> > 
> 
> > Solution I provided :
> 
> > 
> 
> > 
> 
> > In my application I created my custom class
> 
> > CustomJavaDialectConfiguration
> 
> > by extending to class JavaDialectConfiguration, In
> this
> 
> > class I overrided
> 
> > the method setCompiler. My method was exactly same as
> that
> 
> > of method setCompiler
> 
> > in JavaDialectConfiguration . To call my dialect class
> I
> 
> > also overrided
> 
> > the method "addDialect" of
> 
> > PackageBuilderConfiguration class
> 
> > . For that I created class
> 
> > CustomPackageBuilderConfiguration by extending
> 
> > to PackageBuilderConfiguration. 
> 
> > 
> 
> > after that I wrote the code: 
> 
> > 
> 
> > 
> 
> > 
> 
> > PackageBuilderConfiguration cfg = new
> 
> > CustomPackageBuilderConfiguration();
> 
> > 
> 
> > 
> 
> > KnowledgeBuilder kbuilder =
> 
> > KnowledgeBuilderFactory.newKnowledgeBuilder(cfg);
> 
> > 
> 
> > 
> 
> > 
> 
> > 
> 
> > 
> 
> > 
> 
> > Now application is running perfectly fine from both
> eclipse
> 
> > and command
> 
> > prompt without any exception. 
> 
> > 
> 
> > 
> 
> > 
> 
> > I want to know as my overrided method
> 
> > "setCompiler" was exactly
> 
> > same then why I had to override method, and In
> original
> 
> > code (ie in drools-compiler.jar
> 
> > file) why it was giving exception  ???  Was
> that
> 
> > due to class
> 
> > lader or something else ??  Please do help in
> this
> 
> > regard ....
> 
> > 
> 
> > 
> 
> > 
> 
> > 
> 
> >  
> 
> > 
> 
> > 
> 
> > 
> 
> > Thanks & Regards:
> 
> > 
> 
> > 
> 
> > 
> 
> > Pankaj Jain | L&T infotech |Navi Mumbai
> 
> > 
> 
> > Mobile: +91 9920218945
> 
> > 
> 
> > Email : pankaj.jain at lntinfotech.com
> 
> > 
> 
> > www.Lntinfotech.com
> 
> > 
> 
> > 
> 
> > 
> 
> > "Whatever the mind of man can conceive &
> believe,
> 
> > it can achieve."
> 
> > 
> 
> > 
> 
> > 
> 
> > Larsen & Toubro Infotech Ltd.
> 
> > 
> 
> > www.Lntinfotech.com
> 
> > 
> 
> > 
> 
> > 
> 
> > This Document is classified as: 
> 
> > 
> 
> > 
> 
> > 
> 
> > L&T
> 
> > Infotech Proprietary   L&T
> 
> > Infotech Confidential   L&T
> 
> > Infotech Internal Use Only   L&T
> 
> > Infotech General Business   
> 
> > 
> 
> > 
> 
> > 
> 
> > This Email may contain confidential or privileged
> 
> > information for the intended
> 
> > recipient (s) If you are not the intended recipient,
> please
> 
> > do not use
> 
> > or disseminate the information, notify the sender and
> 
> > delete it from your
> 
> > system. 
> 
> > 
> 
> > 
> 
> > 
> 
> >
> ______________________________________________________________________
> 
> > 
> 
> > 
> 
> > -----Inline Attachment Follows-----
> 
> > 
> 
> > _______________________________________________
> 
> > 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
> 
> 
> 
> ______________________________________________________________________
> 
> 
> 
> 
> 
> 
> 
> ______________________________________________________________________
> 
> 
> -----Inline Attachment Follows-----
> 
> _______________________________________________
> rules-users mailing list
> rules-users at lists.jboss.org
> https://lists.jboss.org/mailman/listinfo/rules-users
> 


      




More information about the rules-users mailing list