3

I have configured UGC for a JSP website and I am getting the following error in the generated DCP. It seems to be looking for HEADER_USER_ID.

org.apache.jasper.JasperException: An exception occurred processing JSP page /data/pub10/dcp/jsp/dcp295_4952.jsp at line 42
42:                     <ugc:Comments itemURI="tcm:10-4952">                    
43:                         <ol>
44:                             <ugc:ForEachComment>                            <li>

java.lang.NoSuchFieldError: HEADER_USER_ID
com.tridion.ugc.taglib.webservice.WebServiceClient.addHeaders(WebServiceClient.java:237)
com.tridion.ugc.taglib.webservice.WebServiceClient.getResponse(WebServiceClient.java:94)
com.tridion.ugc.taglib.webservice.CommentsRetriever.retrieveComments(CommentsRetriever.java:152)
com.tridion.ugc.taglib.UGCCommentsTag.doStartTag(UGCCommentsTag.java:97)
org.apache.jsp.data.pub10.dcp.jsp.dcp295_005f4952_jsp._jspx_meth_ugc_005fComments_005f0(dcp295_005f4952_jsp.java:171)
org.apache.jsp.data.pub10.dcp.jsp.dcp295_005f4952_jsp._jspService(dcp295_005f4952_jsp.java:147)
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
javax.servlet.http.HttpServlet.service(HttpServlet.java:722)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:432)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:390)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:334)
javax.servlet.http.HttpServlet.service(HttpServlet.java:722)
com.tridion.ambientdata.web.AmbientDataServletFilter.doFilter(AmbientDataServletFilter.java:255)

Below is the source of one of the published DCPs. UGC is working in the CMS GUI. I can view/add/edit comments on contents thru the Comments tab. However I am unable to get it to work on the presentation side.

<%@ page import="java.util.*, java.io.*, java.sql.*, utilClassesV3.*, adminV3.tridion.*, 
  jxl.*, jxl.write.*, admin.*, tags.*, com.tridion.linking.*, com.tridion.web.jsp.JSPPage,
  com.tridion.dynamiccontent.ComponentPresentationAssembler" %>  
<%@ page import="org.apache.lucene.analysis.*, org.apache.lucene.analysis.standard.StandardAnalyzer, org.apache.lucene.document.*, 
  org.apache.lucene.index.*, org.apache.lucene.search.*, org.apache.lucene.queryparser.analyzing.*, 
  java.net.URLEncoder, SiteSearch.*, org.apache.lucene.analysis.CachingTokenFilter, 
  org.apache.lucene.analysis.TokenStream, org.apache.lucene.index.memory.MemoryIndex, 
  org.apache.lucene.search.highlight.*, org.apache.lucene.store.FSDirectory, org.apache.lucene.store.Directory, 
  org.apache.lucene.store.SimpleFSDirectory" %> 
<%@ taglib uri="cbktags" prefix="CBK"%>
<%@ taglib uri="ugc" prefix="ugc"%>
<%@ taglib uri="jstltags" prefix="c"%>
<%@ taglib uri="tridiontags" prefix="tridion"%>
<%@ page contentType="text/html; charset=utf-8" language="java"%>

<%
  request.setCharacterEncoding("UTF-8");
  Link link = null;
  PageLink pageLink = new PageLink(10);
  BinaryLink binaryLink = null, rootBinaryLink = null;
  BinaryLink enBinaryLink = null, arBinaryLink = null, frBinaryLink = null;
  PageLink enPageLink = null, arPageLink = null, frPageLink = null;
  binaryLink = new BinaryLink(10);
  rootBinaryLink = new BinaryLink(9);
  enBinaryLink = new BinaryLink(10);
  enPageLink = new PageLink(10);
  arBinaryLink = new BinaryLink(11);
  arPageLink = new PageLink(11);
  ComponentLink componentLink = new ComponentLink(10);
  String linkAsString = "", tempString = "", strTCMPageId = "", siteLanguage="en";
  int publicationId=10;
  strTCMPageId = (String)session.getAttribute("TCMPageId");
  if (strTCMPageId == null || strTCMPageId.length() == 0)
    strTCMPageId = "";

  ComponentPresentationAssembler cpAssembler;
  cpAssembler = new ComponentPresentationAssembler(new JSPPage(pageContext, strTCMPageId)); 
%>
<ugc:Comments itemURI="tcm:10-4952">                    
  <ol>
    <ugc:ForEachComment>
      <li>
        <ugc:Choose>                                            
          <ugc:When test="ugcUser equals ugcComment.User.Id">
            <!-- If the user is the comment author, show a form to edit the comment -->
            <form method="post" id="editCommentForm">
              <input type="hidden" name="commentIdtcm:10-4952" value=""/>
              <textarea rows="4" cols="30" name="editCommenttcm:10-4952"></textarea><br/>
              <input type="submit" value="Save comment"/>
            </form>
          </ugc:When>
          <ugc:Otherwise> 
            <!-- If this visitor did not submit this comment, simply display it. -->
          </ugc:Otherwise> 
        </ugc:Choose>                                   
        <br/>               
      </li>
    </ugc:ForEachComment>                       
  </ol>
</ugc:Comments>             

As you see the generated DCP doesn't show code for comment.content or comment.id

Has anyone come across this?

UPDATE 21/1/2013

Okay, so the reason why I was getting the above error was because I used ugc_taglib.jar from hotfix #2 and the remaining jars from 2011 SP1. Once I replaced all the jars from the hotfix, the error is gone.

  • Can you supply a little more detail and information, like sources of published pages/DCPs and where this error exactly occurs? Also is this the only issue or is UGC not working all together? – Bart Koopman Jan 15 '14 at 16:35
  • Hi Bart, Please see updated query. – user858 Jan 16 '14 at 7:57
  • a little bit of formatting would have helped in making it more readable for everybody, please see what I edited so you can do the same in the future – Bart Koopman Jan 16 '14 at 9:19
  • to keep everything relevant, I suggest you answer this question with your update from 21/1/2013 and accept that answer. Then please ask your second question in a separate question, so it can be addressed separately, since it is a totally different question and it is confusing to have answers on different questions in the same location. – Bart Koopman Jan 21 '14 at 9:17
3

Okay, so the reason why I was getting the above error was because I used ugc_taglib.jar from hotfix #2 and the remaining jars from 2011 SP1. Once I replaced all the jars from the hotfix, the error is gone.

2

If you created your Component Template using a DWT Template Building Block, then the ${ syntax will have been stripped in there most likely.

To get the original output like this again:

<ugc:Choose>
  <ugc:When test="ugcUser equals ugcComment.User.Id">
    <!-- If the user is the comment author, show a form to edit the comment -->
    <form method="post" id="editCommentForm">
      <input type="hidden" name="commentIdtcm:10-4952" value="${ugcComment.id}"/>
      <textarea rows="4" cols="30" name="editCommenttcm:10-4952">${ugcComment.content}</textarea><br/>
      <input type="submit" value="Save comment"/>
    </form>
  </ugc:When>
  <ugc:Otherwise> 
    <!-- If this visitor did not submit this comment, simply display it. -->
    ${ugcComment.content}
  </ugc:Otherwise> 
</ugc:Choose>

You will have escape the ${ like this in your DWT TBB:

${'$'}{ugcComment.id}

or

@@'$'@@{ugcComment.id}

But be aware this only works correctly for Dynamic Component Templates or Page Templates. Since when you use this in an Embedded Component Template, the Page Template will resolve the ${ it sees again and you still end up with nothing in your output.

For Embedded Component Templates, you will have to escape it twice, like so:

${'$'}{'${'$'}'}{ugcComment.id}

or

@@'$'@@{'@@'$'@@'}{ugcComment.id}

However the error you are getting seems to be pointing to yet another issue, I don't know exactly but it looks like ugcUser is not initialized at all.

  • Hi Bart, Thanks for the update. We haven't used a DWT to get the UGC code but instead we are using a C# TBB to output the UGC code. I tried to escape the tag twice like you mentioned and this time, I was able to see the tag in the generated DCP. But when I access the DCP on a browser, it throws the same exception shown above at this line >> <ugc:Comments itemURI="tcm:10-4952"> and when UGCCommentsTag.doStartTag(). Is there something wrong with the syntax. – user858 Jan 19 '14 at 8:08
  • Please see update. – user858 Jan 21 '14 at 7:45

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.