[rules-users] Create package in Guvnor via REST API fail (Missing package name)

Magic magicboo at gmail.com
Sun Apr 21 03:21:32 EDT 2013


Hi,

I am trying to operate my local 5.5.0 Guvnor through RESTful API and have
some trouble.

For example, below is my code to create a package through a InputStream DRL.
The DRL string is copied from
org.drools.guvnor.server.util.FileManagerUtilsTest.java

=====================================================================
String content = "package testClassicDRLImport\n import blah \n rule 'ola'
\n when \n then \n end \n rule 'hola' \n when \n then \n end";
HttpClient client = new DefaultHttpClient();
HttpPost httpPost = new HttpPost(baseURL + "/rest/packages");
httpPost.addHeader("Authorization", securityToken);
httpPost.addHeader("Accept", MediaType.APPLICATION_JSON);
httpPost.addHeader("Content-Type", MediaType.APPLICATION_OCTET_STREAM);
        
InputStreamEntity entity = new
InputStreamEntity(IOUtils.toInputStream(comment), comment.length(),
ContentType.APPLICATION_OCTET_STREAM);
httpPost.setEntity(entity);
HttpResponse response = client.execute(httpPost);
=====================================================================

But, I still got an error that told me "Missing package name":

Caused by: java.lang.IllegalArgumentException: Missing package name.
        at
org.drools.guvnor.server.files.FileManagerService.importClassicDRL(FileManagerService.java:313)
[guvnor-webap
p-core-5.5.0.Final.jar:5.5.0.Final]
        at
org.drools.guvnor.server.files.FileManagerService$Proxy$_$$_WeldClientProxy.importClassicDRL(FileManagerServi
ce$Proxy$_$$_WeldClientProxy.java)
[guvnor-webapp-core-5.5.0.Final.jar:5.5.0.Final]
        at
org.drools.guvnor.server.jaxrs.PackageResource.createPackageFromDRLAndReturnAsJaxB(PackageResource.java:172)
[guvnor-webapp-core-5.5.0.Final.jar:5.5.0.Final]

I really don't know what's wrong and any help is really appreciate!



--
View this message in context: http://drools.46999.n3.nabble.com/Create-package-in-Guvnor-via-REST-API-fail-Missing-package-name-tp4023469.html
Sent from the Drools: User forum mailing list archive at Nabble.com.


More information about the rules-users mailing list