Bug 756683

Summary: Attempt to rename package via REST results in a corrupted repository
Product: [JBoss] JBoss Enterprise BRMS Platform 5 Reporter: Lukáš Petrovický <lpetrovi>
Component: BRM (Guvnor)Assignee: Mark Proctor <mproctor>
Status: VERIFIED --- QA Contact: Lukáš Petrovický <lpetrovi>
Severity: urgent Docs Contact:
Priority: unspecified    
Version: BRMS 5.3.0.GACC: mproctor
Target Milestone: ---   
Target Release: BRMS 5.3.0.GA   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: Type: ---
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:

Description Lukáš Petrovický 2011-11-24 09:34:42 UTC
Updating package via Guvnor RESTful interface works just fine, except when you try to rename the package. After you attempt to do that, every other REST operation receives the following exception:

2011-11-24 10:31:24,683 INFO  [STDOUT] (http-127.0.0.1-8080-3) ERROR 24-11 10:31:24,680 (RulesRepository.java:loadPackage:436) 	 Unable to load a rule package. 
javax.jcr.PathNotFoundException: org.package.update
	at org.apache.jackrabbit.core.NodeImpl$8.perform(NodeImpl.java:2135)
	at org.apache.jackrabbit.core.NodeImpl$8.perform(NodeImpl.java:2129)
	at org.apache.jackrabbit.core.session.SessionState.perform(SessionState.java:200)
	at org.apache.jackrabbit.core.ItemImpl.perform(ItemImpl.java:91)
	at org.apache.jackrabbit.core.NodeImpl.getNode(NodeImpl.java:2129)
	at org.drools.repository.RulesRepository.loadPackage(RulesRepository.java:424)
	at org.drools.guvnor.server.jaxrs.PackageResource.deletePackage(PackageResource.java:385)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:616)
	at org.apache.cxf.service.invoker.AbstractInvoker.performInvocation(AbstractInvoker.java:173)
	at org.apache.cxf.service.invoker.AbstractInvoker.invoke(AbstractInvoker.java:89)
	at org.apache.cxf.jaxrs.JAXRSInvoker.invoke(JAXRSInvoker.java:164)
	at org.apache.cxf.jaxrs.JAXRSInvoker.invoke(JAXRSInvoker.java:91)
	at org.apache.cxf.interceptor.ServiceInvokerInterceptor$1.run(ServiceInvokerInterceptor.java:58)
	at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:471)
	at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:334)
	at java.util.concurrent.FutureTask.run(FutureTask.java:166)
	at org.apache.cxf.workqueue.SynchronousExecutor.execute(SynchronousExecutor.java:37)
	at org.apache.cxf.interceptor.ServiceInvokerInterceptor.handleMessage(ServiceInvokerInterceptor.java:106)
	at org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(PhaseInterceptorChain.java:263)
	at org.apache.cxf.transport.ChainInitiationObserver.onMessage(ChainInitiationObserver.java:118)
	at org.apache.cxf.transport.http.AbstractHTTPDestination.invoke(AbstractHTTPDestination.java:208)
	at org.apache.cxf.transport.servlet.ServletController.invokeDestination(ServletController.java:223)
	at org.apache.cxf.transport.servlet.ServletController.invoke(ServletController.java:166)
	at org.apache.cxf.transport.servlet.CXFNonSpringServlet.invoke(CXFNonSpringServlet.java:113)
	at org.apache.cxf.transport.servlet.AbstractHTTPServlet.handleRequest(AbstractHTTPServlet.java:184)
	at org.apache.cxf.transport.servlet.AbstractHTTPServlet.doDelete(AbstractHTTPServlet.java:118)
	at javax.servlet.http.HttpServlet.service(HttpServlet.java:643)
	at org.apache.cxf.transport.servlet.AbstractHTTPServlet.service(AbstractHTTPServlet.java:163)
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
	at org.jboss.seam.web.ContextFilter$1.process(ContextFilter.java:42)
	at org.jboss.seam.servlet.ContextualHttpServletRequest.run(ContextualHttpServletRequest.java:65)
	at org.jboss.seam.web.ContextFilter.doFilter(ContextFilter.java:37)
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
	at org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:96)
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
	at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:235)
	at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
	at org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(SecurityAssociationValve.java:183)
	at org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValve.java:95)
	at org.jboss.web.tomcat.security.SecurityContextEstablishmentValve.process(SecurityContextEstablishmentValve.java:126)
	at org.jboss.web.tomcat.security.SecurityContextEstablishmentValve.invoke(SecurityContextEstablishmentValve.java:70)
	at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
	at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
	at org.jboss.web.tomcat.service.jca.CachedConnectionValve.invoke(CachedConnectionValve.java:158)
	at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
	at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:330)
	at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:829)
	at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:599)
	at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:451)
	at java.lang.Thread.run(Thread.java:679)

If you delete the reposistent even if you restart the server. The only way to get rid of it is to delete the repository.

Comment 1 Lukáš Petrovický 2011-11-24 09:36:14 UTC
The last paragraph should have read: "The problem is persistent even if you restart the server. The only way to get rid of it is to delete the repository."

Comment 2 Jervis Liu 2011-12-07 06:05:39 UTC
Hi could you please paste the code you used to rename package? Renaming package through REST is not supported yet even on the master branch.

Thanks.

Comment 3 Lukáš Petrovický 2011-12-07 07:37:44 UTC
Hello Jervis,

the code is a little too complicated to paste here. But here's what I do:

1) Obtain a Package POJO from the RESTful API, ideally via XML as that's the most stable from my experience.
2) Change the title of the package in the POJO.
3) Send the POJO back via the RESTful API.
4) Observe the above exception.

I'll try to simplify my code to provide a reproducer.

Comment 4 Jervis Liu 2011-12-07 10:01:11 UTC
I think I've got the idea. I will let you know if I need the client code. At the moment, this information should be enough for me to move forward. 

One more thing, as a matter of fact, the REST interface via Atom is actually far more stable. The REST interface via json and XML part of code was contributed by community members originally, and are not very well tested and maintained.

Comment 5 Lukáš Petrovický 2011-12-07 11:07:26 UTC
(In reply to comment #4)
> One more thing, as a matter of fact, the REST interface via Atom is actually
> far more stable. The REST interface via json and XML part of code was
> contributed by community members originally, and are not very well tested and
> maintained.

My personal experience is different:
- the Atom API is missing some data that the XML one has. (bug 756671)
- and the JSON interface has some problems with collections, which I have yet to report. (After I am able to find the root cause.)

Comment 6 Jervis Liu 2012-01-31 05:19:28 UTC
Fixed on both 5.3.x and master branch. 

This test has some client example codes that we used to test the REST service: https://github.com/droolsjbpm/guvnor/blob/4acab88936d812aa62e0d218ab68cbf6322e5186/guvnor-webapp-drools/src/test/java/org/drools/guvnor/server/jaxrs/BasicPackageResourceTest.java

Comment 7 Ryan Zhang 2012-02-15 09:11:55 UTC
Please verify the issue on 5.3 ER4.

Comment 9 Lukáš Petrovický 2012-05-02 09:50:20 UTC
VERIFIED