Unable to fetch module from resource error trying to restore serialized KieBase

334 views
Skip to first unread message

David Weir

unread,
Oct 13, 2015, 6:10:29 PM10/13/15
to Drools Usage
This might be a problem caused by going from 6.2.0 to 6.3.0, but code which was working in 6.2.0 is now not working.

I've serialised a kiebase using code (from examples):

rid = ks.newReleaseId("a","b","c");

InternalKieModule kieModule = (InternalKieModule) ks.getRepository().getKieModule(rid);

byte[] theModulesBytes = kieModule.getBytes();

synchronized(this) {

    String base = Base64.encodeBase64String(theModulesBytes);

    persist(base);

}


When I try  to recover the the base using

byte[] theBytes = Base64.decodeBase64(data);

Resource jarRes = ks.getResources().newByteArrayResource(theBytes);

KieRepository kr = ks.getRepository();

km = kr.addKieModule(jarRes);


the kr.addKieModule(jarRes) call throws a runtime exception: 

Unable to fetch module from resource: ByteArrayResource[bytes=[-84, -19, 0, 5, 119, 124, 10, 6, 8, 6, ...], encoding=null]


The cause is an NPE:

Caused by: java.lang.NullPointerException

at java.io.ByteArrayInputStream.<init>(ByteArrayInputStream.java:106)

at org.drools.compiler.kie.builder.impl.KieRepositoryImpl.getKieModule(KieRepositoryImpl.java:227)


with additional stack:

at org.drools.compiler.kie.builder.impl.KieRepositoryImpl.getKieModule(KieRepositoryImpl.java:236)

at org.drools.compiler.kie.builder.impl.KieRepositoryImpl.addKieModule(KieRepositoryImpl.java:192)


What do I need to do to stop this NPE?


David.

David Weir

unread,
Oct 13, 2015, 6:23:36 PM10/13/15
to Drools Usage
Whoops, trying to restore a base from a session's data.
Never mind...
Reply all
Reply to author
Forward
0 new messages