Open GoogleCodeExporter opened 9 years ago
========================
SOLUTION
========================
In this case what appears to have happened is the instructions to run a maven
build
may not have been followed.
These general 're-setup project from the start' may resolve other compile
issues as well
1) Make sure you have Maven installed
2) Download and unzip the chapter 8 samples (links on the right of the home
page)
3) Open a terminal/ command window/dos prompt in the folder where the chapter 8
samples are- it should contain a pom.xml file
4) type the command 'mvn eclipse:eclipse'
5) Maven will download all the required libraries - including logging.
6) Refresh the eclipse project (right click on project name in eclipse, select
'refresh'
Original comment by paul.m.browne
on 15 Apr 2009 at 7:20
After this update it is still possible that the follow error may happen in
Eclipse
(this could be the original error reported by user)
- 'log cannot be resolved'
- 'unbound classpath variable'
See attached screenshot
Original comment by paul.m.browne
on 15 Apr 2009 at 7:28
Attachments:
=========================================================================
This an extract from Chapter 2 of the book - JBoss Drools Business Rules
http://www.packtpub.com/jboss-drools-business-rules/book
=========================================================================
The problem is caused by the fact that Maven has now downloaded the files, but
Eclipse doesn't know where Maven has stored them. To solve this, you you will
need to
tell eclipse where Maven stores it's files.
(The book has screenshots. For obvious reasons -I'm the author- I'm going to
suggest
that if you need the illustrations, that you buy the thing and follow the
instructions there)
In Eclipse, from the toolbar at the top, select Windows..Preferences..
In the Dialog box that appears, select Java... BuildPath ... Classpath
variables.
You should see a screen similar to that below.
Click on the 'New Tab' on the right hand side. In the dialog box that appears,
enter
the Name (M2_Repo) and the path to where Maven stores its files.
On Windows XP machines, this is likely to be in the format
C:\Documents and Settings\Administrator\.m2\repository
Replace 'Administrator' with your user name
On Windows Vista machines, this is likely to be in the format
C:\Users\Administrator\.m2\repository
On Linux (Ubuntu) this is likely to be in the format
/home/administrator/.m2/repository/
Replace 'Administrator' with your user name
If in doubt, open windows explorer and try to navigate to the files.
Alternatively,
use the search facility in windows explorer to find the .m2 folder on your
machine.
Best to search all files under C: - takes longer, but better chance of find it.
Back in Eclipse, when you're finished entering the variable name / value click
ok.
You will be asked if you want to do a full build. Click yes
After a couple of seconds, the red crosses should disappear, and you should see
the
project setup as per the screenshot in the previous step.
This will resolve the - 'log cannot be resolved' and 'unbound classpath
variable'
issues
Original comment by paul.m.browne
on 15 Apr 2009 at 8:02
Original comment by paul.m.browne
on 10 Jul 2009 at 8:00
Original comment by paul.m.browne
on 10 Jul 2009 at 8:00
i'm having error which log cannot be resolved, while when running the
ExcelDataRulesExample.java i'm getting the following in the console
log4j:WARN No appenders could be found for logger
(net.firstpartners.chap8.ExcelDataRulesExample).
log4j:WARN Please initialize the log4j system properly.
Exception in thread "main" java.lang.NullPointerException
at org.drools.reteoo.ReteooBuilder.removeRule(ReteooBuilder.java:224)
at org.drools.reteoo.ReteooRuleBase.removeRule(ReteooRuleBase.java:270)
at org.drools.common.AbstractRuleBase.removeRule(AbstractRuleBase.java:656)
at org.drools.common.AbstractRuleBase.mergePackage(AbstractRuleBase.java:519)
at org.drools.common.AbstractRuleBase.addPackage(AbstractRuleBase.java:409)
at net.firstpartners.drools.RuleRunner.loadRules(RuleRunner.java:55)
at net.firstpartners.drools.RuleRunner.runStatelessRules(RuleRunner.java:167)
at net.firstpartners.chap8.ExcelDataRulesExample.main
(ExcelDataRulesExample.java:81)
kindly help me here
Original comment by mobile...@gmail.com
on 17 Aug 2009 at 3:45
Attachments:
I did everything as suggested, however I get the same error as posted by
mobileset.
(I was able to get rid of log4j warning), but the main problem is still. It is
kind
of bad for a book this new to have an example that does not work
Original comment by dbsp...@gmail.com
on 12 Sep 2009 at 3:16
I too have followed all the steps outlined in this post and have the same issue
as
mobileset and dbspace. There is a reference to 'log' that can't be located in
TradingRules.xls that's causing the following error in eclipse :
'log cannot be resolved'.
I was able to get the mvn clean package to execute successfully after changing
the
pom.xml to resolve the xpp3 issue (changed the lower case 'o' to upper case 'O'
in
<groupId>xpp3</groupId>
<artifactId>xpp3</artifactId>
<version>1.1.3.4.O</version>
and it built successfully. And I even ran the mvn eclipse:eclipse and the build
was
successful. However, the project has the above error when I open it in Eclipse.
Please help with a resolution as soon as possible.
Original comment by gurvinde...@gmail.com
on 8 Nov 2009 at 4:25
I see the same null pointer exception stack trace. I've used the debugger and it
seems when adding the second package (tradingpartner.xls) to the drools
localrule
base invokes merging rules. In the merging there is a null that is being
removed and
this apparently upsets the apple cart - throwing the null pointer exception.
I'm not
sure I really want to build the drools jars from source to trace down the exact
location.
I, too, see all 298 compilation errors as they relate to the xls and drools
files but
ignore them to my apparent peril.
As for the log4j error in mobileset's post - the apache logger will still work
despite the warning, just logger gets to decide the level and the message
format.
Original comment by kite...@verizon.net
on 27 Dec 2009 at 7:59
I've been working on this issue - I've resolved the compilation errors and the
log
file not found. Still working on the nullpointer issue:
Compilation errors
In log-rules.drl - add ; to end of line import net.firstpartners.drools.log.ILogger;
In log-rules.dslr - do same
In log-then-modify-rules.dlr - do same
In rulesflow-rules.drl - do same
In tradingrules.xls , row 5 column c - add , to end of line -
net.firstpartners.excel.Cell, net.firstpartners.excel.Range,
Saved all files
Delete the project you imported for chapter 8 Steps:
1. Right click on project name
2. Select Delete
3. Make sure that the "Delete project contents on disk" check box is NOT CHECKED
(e.g. blank)
4. press okay button
Exit eclipse
Go to directory location where you unzipped the source.
Locate the directory named target (may be down one level)
Delete directory named target (the entire directory and contents).
Restart eclipse
Reimport the project
Clean the project : Project > Clean
Build the project if you don't have automatic build set : Project > Build
Project
This at least removes the compilation errors
Fix log4j errors
In the source package directory(where you find all of the java packages listed)
in
the Package explorer file src/main/java
In the Package Explorer under the current project - there is a directory called
src/main/java. When you expand it, you will
see a bunch of brown boxes (packages) - below the last package, there is a file
called log4j.properties.
Right click on the log4j.properties file.
Select copy
Scroll down in the package explorer, eventually you see some files called
licence.txt or pom.xml.
Move the cursor down to this area.
Right click
Select paste.
Now you should see log4j.properties listed with the pom.xml and licence.txt
files.
Original comment by kite...@verizon.net
on 30 Dec 2009 at 10:54
Did somebody solve this problem:
Exception in thread "main" org.drools.rule.InvalidRulePackage:
net.firstpartners.excelCellRule Compilation error : [Rule name=Evaluate the Sell
Trades that we are interested in_51, agendaGroup=MAIN, salience=0,
no-loop=false]
net/firstpartners/chap8/Rule_Evaluate_the_Sell_Trades_that_we_are_interested_in_51_0.java (2:41) : Only a type can be imported. net.firstpartners.excelCell resolves to a package
Rule Compilation error : [Rule name=Evaluate the Buy Trades that we are
interested
in_18, agendaGroup=MAIN, salience=0, no-loop=false]
net/firstpartners/chap8/Rule_Evaluate_the_Buy_Trades_that_we_are_interested_in_18_0.java (2:41) : Only a type can be imported. net.firstpartners.excelCell resolves to a package
Rule Compilation error : [Rule name=Evaluate the Buy Trades that we are
interested
in_21, agendaGroup=MAIN, salience=0, no-loop=false]
net/firstpartners/chap8/Rule_Evaluate_the_Buy_Trades_that_we_are_interested_in_21_0.java (2:41) : Only a type can be imported. net.firstpartners.excelCell resolves to a package
Rule Compilation error : [Rule name=Execute the Buy Trades_33, agendaGroup=MAIN,
salience=0, no-loop=false]
net/firstpartners/chap8/Rule_Execute_the_Buy_Trades_33_0.java (2:41) : Only a type
can be imported. net.firstpartners.excelCell resolves to a package
Rule Compilation error : [Rule name=Evaluate the Sell Trades that we are
interested
in_47, agendaGroup=MAIN, salience=0, no-loop=false]
net/firstpartners/chap8/Rule_Evaluate_the_Sell_Trades_that_we_are_interested_in_47_0.java (2:41) : Only a type can be imported. net.firstpartners.excelCell resolves to a package
Rule Compilation error : [Rule name=Evaluate the Buy Trades that we are
interested
in_19, agendaGroup=MAIN, salience=0, no-loop=false]
net/firstpartners/chap8/Rule_Evaluate_the_Buy_Trades_that_we_are_interested_in_19_0.java (2:41) : Only a type can be imported. net.firstpartners.excelCell resolves to a package
Rule Compilation error : [Rule name=Evaluate the Buy Trades that we are
interested
in_24, agendaGroup=MAIN, salience=0, no-loop=false]
net/firstpartners/chap8/Rule_Evaluate_the_Buy_Trades_that_we_are_interested_in_24_0.java (2:41) : Only a type can be imported. net.firstpartners.excelCell resolves to a package
Rule Compilation error : [Rule name=Evaluate the Sell Trades that we are
interested
in_46, agendaGroup=MAIN, salience=0, no-loop=false]
net/firstpartners/chap8/Rule_Evaluate_the_Sell_Trades_that_we_are_interested_in_46_0.java (2:41) : Only a type can be imported. net.firstpartners.excelCell resolves to a package
Rule Compilation error : [Rule name=Evaluate the Sell Trades that we are
interested
in_43, agendaGroup=MAIN, salience=0, no-loop=false]
net/firstpartners/chap8/Rule_Evaluate_the_Sell_Trades_that_we_are_interested_in_43_0.java (2:41) : Only a type can be imported. net.firstpartners.excelCell resolves to a package
Rule Compilation error : [Rule name=Evaluate the Buy Trades that we are
interested
in_16, agendaGroup=MAIN, salience=0, no-loop=false]
net/firstpartners/chap8/Rule_Evaluate_the_Buy_Trades_that_we_are_interested_in_16_0.java (2:41) : Only a type can be imported. net.firstpartners.excelCell resolves to a package
Rule Compilation error : [Rule name=Evaluate the Sell Trades that we are
interested
in_44, agendaGroup=MAIN, salience=0, no-loop=false]
net/firstpartners/chap8/Rule_Evaluate_the_Sell_Trades_that_we_are_interested_in_44_0.java (2:41) : Only a type can be imported. net.firstpartners.excelCell resolves to a package
Rule Compilation error : [Rule name=Evaluate the Sell Trades that we are
interested
in_53, agendaGroup=MAIN, salience=0, no-loop=false]
net/firstpartners/chap8/Rule_Evaluate_the_Sell_Trades_that_we_are_interested_in_53_0.java (2:41) : Only a type can be imported. net.firstpartners.excelCell resolves to a package
Rule Compilation error : [Rule name=Execute the Sell Trades_61,
agendaGroup=MAIN,
salience=0, no-loop=false]
net/firstpartners/chap8/Rule_Execute_the_Sell_Trades_61_0.java (2:41) : Only a type
can be imported. net.firstpartners.excelCell resolves to a package
Rule Compilation error : [Rule name=Evaluate the Buy Trades that we are
interested
in_15, agendaGroup=MAIN, salience=0, no-loop=false]
net/firstpartners/chap8/Rule_Evaluate_the_Buy_Trades_that_we_are_interested_in_15_0.java (2:41) : Only a type can be imported. net.firstpartners.excelCell resolves to a package
Rule Compilation error : [Rule name=Evaluate the Sell Trades that we are
interested
in_52, agendaGroup=MAIN, salience=0, no-loop=false]
net/firstpartners/chap8/Rule_Evaluate_the_Sell_Trades_that_we_are_interested_in_52_0.java (2:41) : Only a type can be imported. net.firstpartners.excelCell resolves to a package
Rule Compilation error : [Rule name=Evaluate the Buy Trades that we are
interested
in_13, agendaGroup=MAIN, salience=0, no-loop=false]
net/firstpartners/chap8/Rule_Evaluate_the_Buy_Trades_that_we_are_interested_in_13_0.java (2:41) : Only a type can be imported. net.firstpartners.excelCell resolves to a package
Rule Compilation error : [Rule name=Evaluate the Buy Trades that we are
interested
in_22, agendaGroup=MAIN, salience=0, no-loop=false]
net/firstpartners/chap8/Rule_Evaluate_the_Buy_Trades_that_we_are_interested_in_22_0.java (2:41) : Only a type can be imported. net.firstpartners.excelCell resolves to a package
Rule Compilation error : [Rule name=Evaluate the Sell Trades that we are
interested
in_42, agendaGroup=MAIN, salience=0, no-loop=false]
net/firstpartners/chap8/Rule_Evaluate_the_Sell_Trades_that_we_are_interested_in_42_0.java (2:41) : Only a type can be imported. net.firstpartners.excelCell resolves to a package
Rule Compilation error : [Rule name=Evaluate the Buy Trades that we are
interested
in_17, agendaGroup=MAIN, salience=0, no-loop=false]
net/firstpartners/chap8/Rule_Evaluate_the_Buy_Trades_that_we_are_interested_in_17_0.java (2:41) : Only a type can be imported. net.firstpartners.excelCell resolves to a package
Rule Compilation error : [Rule name=Evaluate the Buy Trades that we are
interested
in_14, agendaGroup=MAIN, salience=0, no-loop=false]
net/firstpartners/chap8/Rule_Evaluate_the_Buy_Trades_that_we_are_interested_in_14_0.java (2:41) : Only a type can be imported. net.firstpartners.excelCell resolves to a package
Rule Compilation error : [Rule name=Evaluate the Buy Trades that we are
interested
in_20, agendaGroup=MAIN, salience=0, no-loop=false]
net/firstpartners/chap8/Rule_Evaluate_the_Buy_Trades_that_we_are_interested_in_20_0.java (2:41) : Only a type can be imported. net.firstpartners.excelCell resolves to a package
Rule Compilation error : [Rule name=Evaluate the Sell Trades that we are
interested
in_50, agendaGroup=MAIN, salience=0, no-loop=false]
net/firstpartners/chap8/Rule_Evaluate_the_Sell_Trades_that_we_are_interested_in_50_0.java (2:41) : Only a type can be imported. net.firstpartners.excelCell resolves to a package
Rule Compilation error : [Rule name=Evaluate the Buy Trades that we are
interested
in_23, agendaGroup=MAIN, salience=0, no-loop=false]
net/firstpartners/chap8/Rule_Evaluate_the_Buy_Trades_that_we_are_interested_in_23_0.java (2:41) : Only a type can be imported. net.firstpartners.excelCell resolves to a package
Rule Compilation error : [Rule name=Evaluate the Sell Trades that we are
interested
in_48, agendaGroup=MAIN, salience=0, no-loop=false]
net/firstpartners/chap8/Rule_Evaluate_the_Sell_Trades_that_we_are_interested_in_48_0.java (2:41) : Only a type can be imported. net.firstpartners.excelCell resolves to a package
Rule Compilation error : [Rule name=Evaluate the Sell Trades that we are
interested
in_45, agendaGroup=MAIN, salience=0, no-loop=false]
net/firstpartners/chap8/Rule_Evaluate_the_Sell_Trades_that_we_are_interested_in_45_0.java (2:41) : Only a type can be imported. net.firstpartners.excelCell resolves to a package
Rule Compilation error : [Rule name=Evaluate the Buy Trades that we are
interested
in_25, agendaGroup=MAIN, salience=0, no-loop=false]
net/firstpartners/chap8/Rule_Evaluate_the_Buy_Trades_that_we_are_interested_in_25_0.java (2:41) : Only a type can be imported. net.firstpartners.excelCell resolves to a package
Rule Compilation error : [Rule name=Evaluate the Sell Trades that we are
interested
in_41, agendaGroup=MAIN, salience=0, no-loop=false]
net/firstpartners/chap8/Rule_Evaluate_the_Sell_Trades_that_we_are_interested_in_41_0.java (2:41) : Only a type can be imported. net.firstpartners.excelCell resolves to a package
Rule Compilation error : [Rule name=Evaluate the Sell Trades that we are
interested
in_49, agendaGroup=MAIN, salience=0, no-loop=false]
net/firstpartners/chap8/Rule_Evaluate_the_Sell_Trades_that_we_are_interested_in_49_0.java (2:41) : Only a type can be imported. net.firstpartners.excelCell resolves to a package
at org.drools.rule.Package.checkValidity(Package.java:424)
at org.drools.common.AbstractRuleBase.addPackage(AbstractRuleBase.java:394)
at net.firstpartners.drools.RuleRunner.loadRules(RuleRunner.java:55)
at net.firstpartners.drools.RuleRunner.runStatelessRules(RuleRunner.java:167)
at net.firstpartners.chap8.ExcelDataRulesExample.main(ExcelDataRulesExample.java:81)
Original comment by sylweste...@gmail.com
on 27 Feb 2010 at 8:45
Still have error 'log cannot be resolved', I do as comment of (omment 10 by
kite...@verizon.net, Dec 30, 2009), but still not working !!! How can i fix it?
've been working on this issue - I've resolved the compilation errors and the
log
file not found. Still working on the nullpointer issue:
Compilation errors
In log-rules.drl - add ; to end of line import net.firstpartners.drools.log.ILogger;
In log-rules.dslr - do same
In log-then-modify-rules.dlr - do same
In rulesflow-rules.drl - do same
In tradingrules.xls , row 5 column c - add , to end of line -
net.firstpartners.excel.Cell, net.firstpartners.excel.Range,
Original comment by sigma...@gmail.com
on 1 Apr 2010 at 3:15
'log cannot be resolved' errors are resolved by adding a global variable
declaration of "log" on the Tables sheet.
C6 -> Variables
D6 -> net.firstpartners.drools.log.ILogger log
The log global variable is already declared in log-rules.drl and without
additional declaration on the excel sheet I could run ExcelDataRulesExample
without errors, so I suspect it is a problem of drools builder (used by eclipse
plug-in) rather than of the book sample.
Original comment by ryoasa...@gmail.com
on 8 Apr 2010 at 6:43
After I downloaded the samples from here, I did a few things to make it work:
1) mvn clean package
2) Modify the path for "xpp3-1.1.3.4.O.jar" so that it can downloaded
3) Modify the "TradingRules.xls" file
- add "net.firstpartners.drools.log.ILogger" into the import statement
- add a "Variables" section with the "ILogger log" variable.
With the above changes, I also ran into the NullPointerException:
Exception in thread "main" java.lang.NullPointerException
at org.drools.reteoo.ReteooBuilder.removeRule(ReteooBuilder.java:224)
at org.drools.reteoo.ReteooRuleBase.removeRule(ReteooRuleBase.java:270)
at org.drools.common.AbstractRuleBase.removeRule(AbstractRuleBase.java:656)
at org.drools.common.AbstractRuleBase.mergePackage(AbstractRuleBase.java:519)
at org.drools.common.AbstractRuleBase.addPackage(AbstractRuleBase.java:409)
at net.firstpartners.drools.RuleRunner.loadRules(RuleRunner.java:57)
at net.firstpartners.drools.RuleRunner.runStatelessRules(RuleRunner.java:169)
at net.firstpartners.chap8.ExcelDataRulesExample.main(ExcelDataRulesExample.java:84)
After some troubleshooting, I discovered that this error is because
log-rules.drl and TradingRules.xls are being loaded at the same time and Drools
is trying to merge the rules because they are defined within the same package.
I made it work by removing log-rules.drl from the RULES_FILES list.
Hope it helps.
Original comment by xude...@gmail.com
on 8 Aug 2010 at 8:40
Original comment by paul.m.browne
on 26 Jan 2011 at 11:20
Original comment by paul.m.browne
on 26 Jan 2011 at 11:42
Original comment by paul.m.browne
on 26 Jan 2011 at 11:43
Original comment by paul.m.browne
on 26 Jan 2011 at 11:44
Original comment by paul.m.browne
on 26 Jan 2011 at 11:48
if you change the code of the RuleRunner.java inside the method loadRules to
this the log-rules.drl kann remain:
//Check the type of rule file, then load it
if(ruleFile.endsWith(XLS_FILE_EXTENSION)){
loadExcelRules(ruleFile,builder);
Package pkg = builder.getPackage();
localRuleBase.addPackage( pkg );
} else {
loadRuleFile(ruleFile,dslFileName,ruleFlowFileName,builder);
}
Original comment by reinhard...@gmail.com
on 28 Feb 2011 at 1:59
I was able to get this working. I tried everything that was in this stream. I
got it to work. When I updated the loadRules method inside RuleRunner.java. I
moved the following lines out side of the for loop.
Package pkg = builder.getPackage();
localRuleBase.addPackage( pkg );
Original comment by KDMCCARR...@gmail.com
on 11 Mar 2011 at 7:21
Original issue reported on code.google.com by
paul.m.browne
on 15 Apr 2009 at 7:06