The exception:
java.lang.reflect.InvocationTargetException
at sun.reflect.GeneratedMethodAccessor6.invoke(Unknown Source)
at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.drools.lang.RuleParserTest.execTreeParser(RuleParserTest.java:4071)
at org.drools.lang.RuleParserTest.newParser(RuleParserTest.java:4038)
at org.drools.lang.RuleParserTest.parse(RuleParserTest.java:3996)
at org.drools.lang.RuleParserTest.parseResource(RuleParserTest.java:4025)
at
org.drools.lang.RuleParserTest.testTypeDeclaration1(RuleParserTest.java:3762)
Caused by: java.lang.NullPointerException
at org.drools.lang.descr.DescrFactory.createTypeField(DescrFactory.java:401)
at org.drools.lang.DescrBuilderTree.decl_field(DescrBuilderTree.java:1758)
at
org.drools.lang.DescrBuilderTree.type_declaration(DescrBuilderTree.java:1592)
at org.drools.lang.DescrBuilderTree.statement(DescrBuilderTree.java:575)
at org.drools.lang.DescrBuilderTree.compilation_unit(DescrBuilderTree.java:222)
... 34 more
Here is the drl that causes it:
[declare_type_1.drl]
package org.drools;
declare NetworkNode
locElevation:
java.math.BigDecimal
name:
String @key
nodeClass:
String
locLongitude:
java.math.BigDecimal
nodeType:
String
locLatitude:
java.math.BigDecimal
end
declare NetworkConnection
id:
String @key
node1:
NetworkNode
node2:
NetworkNode
hops:
Integer
end
declare NetworkEvent
@role(
event )
@timestamp(
creationTime )
id:
String @key
locElevation:
java.math.BigDecimal
description:
String
sourceComponent:
NetworkNode
locLongitude:
java.math.BigDecimal
severity:
Integer
creationTime:
java.util.Date
locLatitude:
java.math.BigDecimal
end
the test function in RuleParserTest.java
you can use to replicate:
public void
testTypeDeclaration1() throws Exception {
parseResource( "compilation_unit",
"compilation_unit",
"declare_type_1.drl" );
final PackageDescr pack = walker.getPackageDescr();
final List<TypeDeclarationDescr> declarations =
pack.getTypeDeclarations();
assertEquals( 3,
declarations.size() );
}
I believe @key is the cause, I based my
code on the example from the documentation:
declare Person
@author( Bob )
@dateOfCreation(
01-Feb-2009 )
name : String @key
@maxLength( 30 )
dateOfBirth : Date
address : Address
end
Regards
--zoly