cancel
Showing results for 
Search instead for 
Did you mean: 

Problems using Templates in WCM

marcus_cps
Champ in-the-making
Champ in-the-making
Hi,

I´m trying create a content based on a template, but I´m having trouble with classes needed.

I´ve installed Alfresco and WCM (it worked fine).
(uncompressed, set to MySQL and moved bootstrap to the right location).
After that, I got a template from the website (thumbs.ftl) and put it in /shared/templates folder (virtual-apache).
Added html_basic.tld and repo.tld to a new project (tld folder) and to tle tld folder at virtual-tomcat/shared.
I added main.jsp to the project:

– main.jsp:
<%@ taglib uri="/tld/html_basic.tld" prefix="h" %>
<%@ taglib uri="/tld/repo.tld" prefix="r" %>

<html>
<body>

<f:view>
   <h:form>
     <r:template template="/shared/templates/thumbs.ftl" />
   </h:form>
</f:view>

</body>
</html>

But when I try to preview it, a lot of error occur.
I´ve tryed to add a lot of .class files to the shared/classes folder of virtual-tomcat but it still not working. Everytime it complains about something, I grab it from javax or servlet lib and put it there.
Is there something wrong? I cant even imagine what else to do.

Thank you very much.
4 REPLIES 4

marcus_cps
Champ in-the-making
Champ in-the-making
I´ve posted a new topic, much simpler than this.
But you can still help me here!
Thank you.

kevinr
Star Contributor
Star Contributor
The UITemplate componet will load templates from the classpath - but is that folder you mention on the classpath? In tomcat it would be:
\apache-tomcat\shared\classes
and if you created a folder in that called "templates" and added your file "thumbs.ftl" to that folder, then the component ref would look like this:

<r:template template="/templates/thumbs.ftl" />

Does that help?

Kevin

marcus_cps
Champ in-the-making
Champ in-the-making
Hi, thank you very much for your answer.
But it didn´t worked. I believe the problem happens before this point.
I´ll tell you step by step what i´ve done… hope you have some patience because its kind a big post.


Phase 1: Alfresco basic:

1) Installed Java JDK (jdk-6u2-windows-i586-p.exe)
2) Extracted alfresco-community-tomcat-2.1.0.zip to C:\alfresco
3) Set these two files described in Readme-MySql and set dir.root to C:/alfresco/alf_data
4) Started tomcat and everything seems to be ok (When open http://localhost:8080/alfresco, it shows up).


Phase 2: Alfresco + WCM:

1) Extracted alfresco-community-wcm-2.1.0.zip to c:\alfresco
2) Moved wcm-bootstrap-context.xml to C:\alfresco\tomcat\shared\classes\alfresco\extension
3) Started tomcat and tomcat virtual and everything seems to be fine (WCM patch is ok and Web Projects is visible in Company´s home space).


Phase 3: Templates

1) Created a new Web Project called MyTest (just typed the name and hit next up to hit finish).
2) Added a new content to Staging Sandbox. The file is called HelloWorld0.jsp. This is its content:

<html>
<body>
   <f:view>
       Hello world 0!
   </f:view>
</body>
</html>

It looks ok in my preview (I click on PREVIEW button).

3) Added a new content (again). The file is called HelloWorld1.jsp and its content follows:

 <%@ taglib uri="http://java.sun.com/jsf/html" prefix="h" %>
<%@ taglib uri="http://java.sun.com/jsf/core" prefix="f" %>
<%@ taglib uri="/WEB-INF/repo.tld" prefix="r" %>

<html>
  <body>
 
  <f:view>
    <h:form>
       Hello world 1!
    </h:form>
  </f:view>
 
  </body>
</html>

The preview CRASHED:

org.apache.jasper.JasperException: The absolute uri: http://java.sun.com/jsf/html cannot be resolved in either web.xml or the jar files deployed with this application
   org.apache.jasper.compiler.DefaultErrorHandler.jspError(DefaultErrorHandler.java:51)
   org.apache.jasper.compiler.ErrorDispatcher.dispatch(ErrorDispatcher.java:409)
   org.apache.jasper.compiler.ErrorDispatcher.jspError(ErrorDispatcher.java:116)
   org.apache.jasper.compiler.TagLibraryInfoImpl.generateTLDLocation(TagLibraryInfoImpl.java:317)
   org.apache.jasper.compiler.TagLibraryInfoImpl.<init>(TagLibraryInfoImpl.java:148)
   org.apache.jasper.compiler.Parser.parseTaglibDirective(Parser.java:424)
   org.apache.jasper.compiler.Parser.parseDirective(Parser.java:493)
   org.apache.jasper.compiler.Parser.parseElements(Parser.java:1557)
   org.apache.jasper.compiler.Parser.parse(Parser.java:127)
   org.apache.jasper.compiler.ParserController.doParse(ParserController.java:212)
   org.apache.jasper.compiler.ParserController.parse(ParserController.java:101)
   org.apache.jasper.compiler.Compiler.generateJava(Compiler.java:156)
   org.apache.jasper.compiler.Compiler.compile(Compiler.java:296)
   org.apache.jasper.compiler.Compiler.compile(Compiler.java:277)
   org.apache.jasper.compiler.Compiler.compile(Compiler.java:265)
   org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:564)
   org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:299)
   org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:315)
   org.apache.jasper.servlet.JspServlet.service(JspServlet.java:265)
   javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
   org.alfresco.filter.CacheControlFilter.doFilter(CacheControlFilter.java:187)


4) So I extracted jsf-1_1_01.zip lib content to C:\alfresco\tomcat\shared\lib and C:\alfresco\virtual-tomcat\shared\lib. The files:

commons-beanutils.jar
commons-collections.jar
commons-digester.jar
commons-logging.jar
html_basic.tld
jsf-api.jar
jsf-impl.jar
jsf_core.tld

Copied jsf_core.tld and html_basic.tld to C:\alfresco\tomcat\shared\tld and C:\alfresco\virtual-tomcat\shared\tld.
Copied repo.tld from C:\alfresco\tomcat\webapps\alfresco\WEB-INF to these folders too.

Created a folder named tld inside MyTest project and added these same 3 files.

And changed the source to:

 <%@ taglib uri="/tld/html_basic.tld" prefix="h" %>
<%@ taglib uri="/tld/jsf_core.tld" prefix="f" %>
<%@ taglib uri="/tld/repo.tld" prefix="r" %>

<html>
  <body>
 
  <f:view>
    <h:form>
       Hello world 1!
    </h:form>
  </f:view>
 
  </body>
</html>

The preview CRASHED again:

exception

org.apache.jasper.JasperException: Exception in JSP: /HelloWorld1.jsp:8

5:  <html>
6:   <body>
7:  
8:   <f:view>
9:     <h:form>
10:        Hello world 1!
11:     </h:form>


Stacktrace:
   org.apache.jasper.servlet.JspServletWrapper.handleJspException(JspServletWrapper.java:467)
   org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:371)
   org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:315)
   org.apache.jasper.servlet.JspServlet.service(JspServlet.java:265)
   javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
   org.alfresco.filter.CacheControlFilter.doFilter(CacheControlFilter.java:187)

root cause

javax.servlet.ServletException: Cannot find FacesContext
   org.apache.jasper.runtime.PageContextImpl.doHandlePageException(PageContextImpl.java:846)
   org.apache.jasper.runtime.PageContextImpl.handlePageException(PageContextImpl.java:779)
   org.apache.jsp.HelloWorld1_jsp._jspService(HelloWorld1_jsp.java:81)
   org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:98)
   javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
   org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:328)
   org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:315)
   org.apache.jasper.servlet.JspServlet.service(JspServlet.java:265)
   javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
   org.alfresco.filter.CacheControlFilter.doFilter(CacheControlFilter.java:187)

root cause

javax.servlet.jsp.JspException: Cannot find FacesContext
   javax.faces.webapp.UIComponentTag.doStartTag(UIComponentTag.java:405)
   com.sun.faces.taglib.jsf_core.ViewTag.doStartTag(ViewTag.java:105)
   org.apache.jsp.HelloWorld1_jsp._jspx_meth_f_005fview_005f0(HelloWorld1_jsp.java:96)
   org.apache.jsp.HelloWorld1_jsp._jspService(HelloWorld1_jsp.java:70)
   org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:98)
   javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
   org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:328)
   org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:315)
   org.apache.jasper.servlet.JspServlet.service(JspServlet.java:265)
   javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
   org.alfresco.filter.CacheControlFilter.doFilter(CacheControlFilter.java:187)

Can you tell me whats wrong? I don´t know what to do…

Thank you very much.

marcus_cps
Champ in-the-making
Champ in-the-making
Just another note:
I tryed to remove from lib (tomcat\shared\lib and virtual-tomcat\shared\lib) all those files from jsf implementation.

I still crashed:
exception

org.apache.jasper.JasperException: Failed to load or instantiate TagLibraryValidator class: com.sun.faces.taglib.html_basic.HtmlBasicValidator
   org.apache.jasper.compiler.DefaultErrorHandler.jspError(DefaultErrorHandler.java:51)
   org.apache.jasper.compiler.ErrorDispatcher.dispatch(ErrorDispatcher.java:409)
   org.apache.jasper.compiler.ErrorDispatcher.jspError(ErrorDispatcher.java:281)
   org.apache.jasper.compiler.TagLibraryInfoImpl.createValidator(TagLibraryInfoImpl.java:662)
   org.apache.jasper.compiler.TagLibraryInfoImpl.parseTLD(TagLibraryInfoImpl.java:247)
   org.apache.jasper.compiler.TagLibraryInfoImpl.<init>(TagLibraryInfoImpl.java:163)
   org.apache.jasper.compiler.Parser.parseTaglibDirective(Parser.java:424)
   org.apache.jasper.compiler.Parser.parseDirective(Parser.java:493)
   org.apache.jasper.compiler.Parser.parseElements(Parser.java:1557)
   org.apache.jasper.compiler.Parser.parse(Parser.java:127)
   org.apache.jasper.compiler.ParserController.doParse(ParserController.java:212)
   org.apache.jasper.compiler.ParserController.parse(ParserController.java:101)
   org.apache.jasper.compiler.Compiler.generateJava(Compiler.java:156)
   org.apache.jasper.compiler.Compiler.compile(Compiler.java:296)
   org.apache.jasper.compiler.Compiler.compile(Compiler.java:277)
   org.apache.jasper.compiler.Compiler.compile(Compiler.java:265)
   org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:564)
   org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:299)
   org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:315)
   org.apache.jasper.servlet.JspServlet.service(JspServlet.java:265)
   javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
   org.alfresco.filter.CacheControlFilter.doFilter(CacheControlFilter.java:187)

root cause

java.lang.ClassNotFoundException: com.sun.faces.taglib.html_basic.HtmlBasicValidator
   org.alfresco.catalina.loader.AVMWebappClassLoader.loadClass(AVMWebappClassLoader.java:1394)
   org.alfresco.catalina.loader.AVMWebappClassLoader.loadClass(AVMWebappClassLoader.java:1240)
   org.apache.jasper.compiler.TagLibraryInfoImpl.createValidator(TagLibraryInfoImpl.java:658)
   org.apache.jasper.compiler.TagLibraryInfoImpl.parseTLD(TagLibraryInfoImpl.java:247)
   org.apache.jasper.compiler.TagLibraryInfoImpl.<init>(TagLibraryInfoImpl.java:163)
   org.apache.jasper.compiler.Parser.parseTaglibDirective(Parser.java:424)
   org.apache.jasper.compiler.Parser.parseDirective(Parser.java:493)
   org.apache.jasper.compiler.Parser.parseElements(Parser.java:1557)
   org.apache.jasper.compiler.Parser.parse(Parser.java:127)
   org.apache.jasper.compiler.ParserController.doParse(ParserController.java:212)
   org.apache.jasper.compiler.ParserController.parse(ParserController.java:101)
   org.apache.jasper.compiler.Compiler.generateJava(Compiler.java:156)
   org.apache.jasper.compiler.Compiler.compile(Compiler.java:296)
   org.apache.jasper.compiler.Compiler.compile(Compiler.java:277)
   org.apache.jasper.compiler.Compiler.compile(Compiler.java:265)
   org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:564)
   org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:299)
   org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:315)
   org.apache.jasper.servlet.JspServlet.service(JspServlet.java:265)
   javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
   org.alfresco.filter.CacheControlFilter.doFilter(CacheControlFilter.java:187)