Bug 98870 - Can't use DataObjects from a JSP
Summary: Can't use DataObjects from a JSP
Status: CLOSED WONTFIX
Alias: None
Product: Red Hat Enterprise CMS
Classification: Retired
Component: other
Version: nightly
Hardware: All
OS: Linux
medium
medium
Target Milestone: ---
Assignee: Archit Shah
QA Contact: Jon Orris
URL:
Whiteboard:
Keywords:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2003-07-09 17:52 UTC by Branimir Dolicki
Modified: 2007-04-18 16:55 UTC (History)
1 user (show)

(edit)
Clone Of:
(edit)
Last Closed: 2006-09-05 17:21:28 UTC


Attachments (Terms of Use)

Description Branimir Dolicki 2003-07-09 17:52:38 UTC
From Bugzilla Helper:
User-Agent: Mozilla/5.0 (Macintosh; U; PPC Mac OS X Mach-O; en-US; rv:1.4)
Gecko/20030624

Description of problem:

You create a servlet that extends com.arsdigita.web.BaseServlet and in its
doService method you do the following:

public void doService (HttpServletRequest req, HttpServletResponse resp)
throws ServletException, IOException
{

...

Category cat = new Category(new BigDecimal("147"));
req.setAttribute("category", cat);
req.getRequestDispatcher("/ccm/content/admin/cats/showcat.jsp").forward(req,resp);
}

You create a JSP like this:

<%@ page import="com.arsdigita.categorization.Category" %>

<% Category cat = (Category) request.getAttribute("category"); %>
<%= cat.getDisplayName() %>

You put this JSP into cms/web/packages/content-section/www/admin/cats
so that it gets ant-deployed to webapps/ccm/packages/content-section/www/admin/cats

However, that doesn't work. The following error message is thrown:

com.arsdigita.persistence.PersistenceException: This data object is not valid.
This usually results from using a data object that was retrieved during a
transaction that has been rolled back.
at com.arsdigita.persistence.GenericDataObject.validate(GenericDataObject.java:1058)
at com.arsdigita.persistence.GenericDataObject.validate(GenericDataObject.java:1048)
at com.arsdigita.persistence.GenericDataObject.get(GenericDataObject.java:419)
at com.arsdigita.domain.DomainObject.get(DomainObject.java:435)
at com.arsdigita.categorization.Category.getName(Category.java:453)
at com.arsdigita.categorization.Category.getDisplayName(Category.java:467)
at
_packages._content_22dsection._www._admin._cats._showcat__jsp._jspService(_showcat__jsp.java:30)
at com.caucho.jsp.JavaPage.service(JavaPage.java:75)
at com.caucho.jsp.Page.subservice(Page.java:485)
at com.caucho.server.http.FilterChainPage.doFilter(FilterChainPage.java:182)
at com.caucho.server.http.Invocation.service(Invocation.java:312)
at com.caucho.server.http.QRequestDispatcher.forward(QRequestDispatcher.java:213)
at com.caucho.server.http.QRequestDispatcher.forward(QRequestDispatcher.java:100)
at com.caucho.server.http.QRequestDispatcher.forward(QRequestDispatcher.java:77)
at
com.arsdigita.dispatcher.DispatcherHelper.forwardHelper(DispatcherHelper.java:163)
at
com.arsdigita.dispatcher.DispatcherHelper.forwardRequestByPath(DispatcherHelper.java:192)
at
com.arsdigita.dispatcher.DispatcherHelper.forwardRequestByPath(DispatcherHelper.java:205)
at
com.arsdigita.cms.dispatcher.FileDispatcher.chainedDispatch(FileDispatcher.java:61)
at com.arsdigita.dispatcher.DispatcherChain.dispatch(DispatcherChain.java:74)
at com.arsdigita.cms.ContentSectionServlet.doService(ContentSectionServlet.java:135)
at
com.arsdigita.web.BaseApplicationServlet$1.excurse(BaseApplicationServlet.java:119)
at com.arsdigita.kernel.KernelExcursion.run(KernelExcursion.java:57)
at
com.arsdigita.web.BaseApplicationServlet.doService(BaseApplicationServlet.java:113)
at com.arsdigita.web.BaseServlet$1.excurse(BaseServlet.java:128)
at com.arsdigita.kernel.KernelExcursion.run(KernelExcursion.java:57)
at com.arsdigita.web.BaseServlet.internalService(BaseServlet.java:104)
at com.arsdigita.web.BaseServlet.doGet(BaseServlet.java:205)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:126)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:103)
at com.caucho.server.http.FilterChainServlet.doFilter(FilterChainServlet.java:96)
at com.caucho.server.http.Invocation.service(Invocation.java:312)
at com.caucho.server.http.QRequestDispatcher.forward(QRequestDispatcher.java:213)
at com.caucho.server.http.QRequestDispatcher.forward(QRequestDispatcher.java:100)
at com.caucho.server.http.QRequestDispatcher.forward(QRequestDispatcher.java:77)
at com.arsdigita.web.BaseDispatcher.forward(BaseDispatcher.java:212)
at com.arsdigita.web.BaseDispatcher.forward(BaseDispatcher.java:198)
at com.arsdigita.web.BaseDispatcher.dispatch(BaseDispatcher.java:130)
at com.arsdigita.web.DispatcherServlet.service(DispatcherServlet.java:136)
at com.caucho.server.http.FilterChainServlet.doFilter(FilterChainServlet.java:96)
at com.caucho.server.http.Invocation.service(Invocation.java:312)
at com.caucho.server.http.QRequestDispatcher.forward(QRequestDispatcher.java:213)
at com.caucho.server.http.QRequestDispatcher.forward(QRequestDispatcher.java:100)
at com.caucho.server.http.QRequestDispatcher.forward(QRequestDispatcher.java:77)
at com.branimir.BranimirServlet.doService(BranimirServlet.java:34)
at com.arsdigita.web.BaseServlet$1.excurse(BaseServlet.java:128)
at com.arsdigita.kernel.KernelExcursion.run(KernelExcursion.java:57)
at com.arsdigita.web.BaseServlet.internalService(BaseServlet.java:104)
at com.arsdigita.web.BaseServlet.doGet(BaseServlet.java:205)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:126)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:103)
at com.caucho.server.http.FilterChainServlet.doFilter(FilterChainServlet.java:96)
at com.caucho.server.http.Invocation.service(Invocation.java:312)
at com.caucho.server.http.HttpRequest.handleRequest(HttpRequest.java:221)
at com.caucho.server.http.HttpRequest.handleConnection(HttpRequest.java:163)
at com.caucho.server.TcpConnection.run(TcpConnection.java:137)
at java.lang.Thread.run(Thread.java:479)


Version-Release number of selected component (if applicable):


How reproducible:
Always

Steps to Reproduce:
See above

Actual Results:  Exception

Additional info:

I didn't know this was a bug so I entered it to
http://sharenet.munich.redhat.com/o/129865

Comment 1 Vadim Nasardinov 2003-07-09 18:15:15 UTC
Branimir,

I have a very similar piece of code, except I forward by doing

getServletContext().getRequestDispatcher("foo.jsp").forward(req, resp)

instead of
  req.getRequestDispatcher("foo.jsp").forward(req,resp);

Although it be useful to get to the bottom of this, in the meantime,
could you change your code to do what mine does and see if this fixes
the problem by any chance?

See

//core-platform/dev/test/src/com/arsdigita/versioning/VersioningServlet.java
//core-platform/dev/test/src/com/arsdigita/versioning/ui/txns.jsp


Comment 2 Branimir Dolicki 2003-07-09 20:16:11 UTC
Vadim,

I've tried your variation and the result is identical.  As I originally dealt with this bug the error 
message was the one above.  Now with the Troika tip from a few days ago (with new persistence)
the error message looks like this (both with your and my variant)

[2003/07/09 22:02:02] can not write to disconnected data object: 
[com.arsdigita.categorization.Category:{id=147}]
com.arsdigita.persistence.PersistenceException: can not write to disconnected data object: 
[com.arsdigita.categorization.Category:{id=147}]
        at com.arsdigita.persistence.DataObjectImpl.validate(DataObjectImpl.java:318)
        at com.arsdigita.persistence.DataObjectImpl.set(DataObjectImpl.java:227)
        at com.arsdigita.domain.DomainObject.set(DomainObject.java:340)
        at com.arsdigita.categorization.Category.getDisplayName(Category.java:467)
        at 
_packages._content_22dsection._www._admin._showcat__jsp._jspService(_showcat__jsp.java:30)
        at com.caucho.jsp.JavaPage.service(JavaPage.java:75)
        at com.caucho.jsp.Page.subservice(Page.java:485)
        at com.caucho.server.http.FilterChainPage.doFilter(FilterChainPage.java:182)
        at com.caucho.server.http.Invocation.service(Invocation.java:312)
        at com.caucho.server.http.QRequestDispatcher.forward(QRequestDispatcher.java:213)
        at com.caucho.server.http.QRequestDispatcher.forward(QRequestDispatcher.java:100)
        at com.caucho.server.http.QRequestDispatcher.forward(QRequestDispatcher.java:77)
        at com.arsdigita.dispatcher.DispatcherHelper.forwardHelper(DispatcherHelper.java:174)
        at 
com.arsdigita.dispatcher.DispatcherHelper.forwardRequestByPath(DispatcherHelper.java:203)
        at 
com.arsdigita.dispatcher.DispatcherHelper.forwardRequestByPath(DispatcherHelper.java:216)
        at com.arsdigita.cms.dispatcher.FileDispatcher.chainedDispatch(FileDispatcher.java:61)
        at com.arsdigita.dispatcher.DispatcherChain.dispatch(DispatcherChain.java:74)
        at com.arsdigita.cms.ContentSectionServlet.doService(ContentSectionServlet.java:134)
        at com.arsdigita.web.BaseApplicationServlet$1.excurse(BaseApplicationServlet.java:119)
        at com.arsdigita.kernel.KernelExcursion.run(KernelExcursion.java:57)
        at com.arsdigita.web.BaseApplicationServlet.doService(BaseApplicationServlet.java:113)
        at com.arsdigita.web.BaseServlet$1.excurse(BaseServlet.java:127)
        at com.arsdigita.kernel.KernelExcursion.run(KernelExcursion.java:57)
        at com.arsdigita.web.BaseServlet.internalService(BaseServlet.java:102)
        at com.arsdigita.web.BaseServlet.doGet(BaseServlet.java:204)
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:126)
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:103)
        at com.caucho.server.http.FilterChainServlet.doFilter(FilterChainServlet.java:96)
        at com.caucho.server.http.Invocation.service(Invocation.java:312)
        at com.caucho.server.http.QRequestDispatcher.forward(QRequestDispatcher.java:213)
        at com.caucho.server.http.QRequestDispatcher.forward(QRequestDispatcher.java:100)
        at com.caucho.server.http.QRequestDispatcher.forward(QRequestDispatcher.java:77)
        at com.arsdigita.web.BaseDispatcher.forward(BaseDispatcher.java:212)
        at com.arsdigita.web.BaseDispatcher.forward(BaseDispatcher.java:198)
        at com.arsdigita.web.BaseDispatcher.dispatch(BaseDispatcher.java:130)
        at com.arsdigita.web.DispatcherServlet.service(DispatcherServlet.java:136)
        at com.caucho.server.http.FilterChainServlet.doFilter(FilterChainServlet.java:96)
        at com.caucho.server.http.Invocation.service(Invocation.java:312)
        at com.caucho.server.http.QRequestDispatcher.forward(QRequestDispatcher.java:213)
        at com.caucho.server.http.QRequestDispatcher.forward(QRequestDispatcher.java:100)
        at com.caucho.server.http.QRequestDispatcher.forward(QRequestDispatcher.java:77)
        at com.branimir.BranimirServlet.doService(BranimirServlet.java:34)
        at com.arsdigita.web.BaseServlet$1.excurse(BaseServlet.java:127)
        at com.arsdigita.kernel.KernelExcursion.run(KernelExcursion.java:57)
        at com.arsdigita.web.BaseServlet.internalService(BaseServlet.java:102)
        at com.arsdigita.web.BaseServlet.doGet(BaseServlet.java:204)
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:126)
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:103)
        at com.caucho.server.http.FilterChainServlet.doFilter(FilterChainServlet.java:96)
        at com.caucho.server.http.Invocation.service(Invocation.java:312)
        at com.caucho.server.http.HttpRequest.handleRequest(HttpRequest.java:221)
        at com.caucho.server.http.HttpRequest.handleConnection(HttpRequest.java:163)
        at com.caucho.server.TcpConnection.run(TcpConnection.java:137)
        at java.lang.Thread.run(Thread.java:479)

Comment 3 Vadim Nasardinov 2003-07-28 20:51:27 UTC
Branimir,

I forgot to add myself to the CC list last time around and I didn't
see your reply until today, after I decided to check on the status of
this ticket.

On the face of it, this latest stack trace does not seem to be related
to, or caused by, the fact that you are using a JSP.  The Category
object gets disconnected somewhere.  I don't know where, but if you
want to find out, you should override the disconnect() method in
Category.java to look like so:


    public void disconnect() {
        s_log.warn("disconnect() called", new Throwable());
        super.disconnect();
    }

What seems to be at the root of the problem is the fact the
getDisplayName() method calls the set(String,Object) method on the
underlying data object.  Since the data object has been disconnected,
this causes an exception.


    public String getDisplayName() {
        // The call to get("displayName") avoids a fringe condition
        // where calling get("diplayName") by ACSObject.beforeSave()
        // throws an error if the "retrieve" event does not return
        // any information
        set("displayName", getName());
        return getName();
    }


So, my guess is, if you don't call getDisplayName(), everything should
work fine.  The fact that the call to getDisplayName() leads to an
exception has nothing to do with the fact that you are using a JSP.

If you can track down where the Category object is being disconnected,
please post here.  If the use case for the use of disconnect() looks
legit, then the getDisplayName() method should be rewritten to *not*
call set(String,Object), because the latter cannot possible work, once
the data object has been disconnected.


Comment 4 Jon Orris 2003-08-05 15:51:01 UTC
Moved to final blockers

Comment 5 Justin Ross 2003-08-13 23:41:58 UTC
Fixed in perforce change 34630.

Comment 6 David Lawrence 2006-07-18 02:40:35 UTC
QA_READY has been deprecated in favor of ON_QA. Please use ON_QA in the future.
Moving to ON_QA.

Comment 7 Jon Orris 2006-09-05 17:21:28 UTC
Closing old tickets





Note You need to log in before you can comment on or make changes to this bug.