synyx GmbH & Co. KG Homepage Welcome Guest   | Login
  Search  
  Index  | Recent Threads  | Who's Online  | User List  | Register  | Search  | Help  | RSS feeds


Quick Go »
Thread Status: Normal
Total posts in this thread: 6
[Add To My Favorites] [Watch this Thread]
Author
Previous Thread This topic has been viewed 3902 times and has 5 replies Next Thread
Male The_Mario
Stranger


Deutschland (Germany)
Joined: Sep 21, 2009
Posts: 3
Status: Offline

confused   cannot be resolved to a type

Hello,

I tried to work through the book "OpenCms 7 Development" which is about building a page with OpenCms 7RC2.
Technicaly it is a Blog you build and after coding a template, a javaclass with logic for e.g. getting all blog entries of a month and a formular for the non-technical people working with this page you have to "connect" the template with your code by include the javaclass in the jsp-template.
<%@ page session="true" import="com.deepthoughts.templates.*"%>

After this import the jsp creates an instance of the class com.deepthoughts.templates.BlogJspTemplate.
<% 	
// create the bean
BlogJspTemplate blog = new BlogJspTemplate(pageContext, request, response);
// get all the blogs in the specified folder
blog.getBlogsInFolder();
// allow edit mode for offline previewing
blog.editable();
%>

This is where the error occurs.
 
An error occurred at line: 7 in the jsp file: /WEB-INF/jsp/offline/system/modules/com.deepthoughts.templates/templates/BlogHomepage.jsp BlogJspTemplate cannot be resolved to a typ

It seems that the import doesn't work at all.

More than this is not described in this book an googleing around doesn't work either worried .

The full message from the OpenCms log is:
 
21 Sep 2009 16:07:14,930 ERROR [ina.core.ApplicationDispatcher: 711] Servlet.service() for servlet jsp threw exception

org.apache.jasper.JasperException: Unable to compile class for JSP:

An error occurred at line: 7 in the jsp file: /WEB-INF/jsp/offline/system/modules/com.deepthoughts.templates/templates/BlogHomepage.jsp
BlogJspTemplate cannot be resolved to a type
4:
5: <%
6: // create the bean
7: BlogJspTemplate blog = new BlogJspTemplate(pageContext, request, response);
8: // get all the blogs in the specified folder
9: blog.getBlogsInFolder();
10: // allow edit mode for offline previewing


An error occurred at line: 7 in the jsp file: /WEB-INF/jsp/offline/system/modules/com.deepthoughts.templates/templates/BlogHomepage.jsp
BlogJspTemplate cannot be resolved to a type
4:
5: <%
6: // create the bean
7: BlogJspTemplate blog = new BlogJspTemplate(pageContext, request, response);
8: // get all the blogs in the specified folder
9: blog.getBlogsInFolder();
10: // allow edit mode for offline previewing


An error occurred at line: 50 in the jsp file: /WEB-INF/jsp/offline/system/modules/com.deepthoughts.templates/templates/BlogHomepage.jsp
BlogJspTemplate cannot be resolved
47: <td width="100%" class="blogHeadline"><%=blog.linkToCurrentItem(blog.getField("Title"))%><cms:editable mode="manual" /></td>
48: </tr>
49: <tr>
50: <td class="blogTimestamp"><%=BlogJspTemplate.formatDate(blog.getField("Date"), "dd.MM.yyyy")%></td>
51: </tr>
52: <tr>
53: <td class="bodyText" valign="top">


An error occurred at line: 56 in the jsp file: /WEB-INF/jsp/offline/system/modules/com.deepthoughts.templates/templates/BlogHomepage.jsp
BlogJspTemplate cannot be resolved
53: <td class="bodyText" valign="top">
54: <div class="photo">
55: <%=blog.getBlogImage(120)%>
56: <%=BlogJspTemplate.trimUp(blog.getField("BlogText"), 700)%>&nbsp;
57: <%=blog.linkToCurrentItem("more...")%>
58: </div>
59: </td>


Stacktrace:

at org.apache.jasper.compiler.DefaultErrorHandler.javacError(DefaultErrorHandler.java:93)

at org.apache.jasper.compiler.ErrorDispatcher.javacError(ErrorDispatcher.java:330)

at org.apache.jasper.compiler.JDTCompiler.generateClass(JDTCompiler.java:435)

at org.apache.jasper.compiler.Compiler.compile(Compiler.java:298)

at org.apache.jasper.compiler.Compiler.compile(Compiler.java:277)

at org.apache.jasper.compiler.Compiler.compile(Compiler.java:265)

at org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:564)

at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:302)

at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:329)

at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:265)

at javax.servlet.http.HttpServlet.service(HttpServlet.java:729)

at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:269)

at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:188)

at org.apache.catalina.core.ApplicationDispatcher.invoke(ApplicationDispatcher.java:679)

at org.apache.catalina.core.ApplicationDispatcher.doInclude(ApplicationDispatcher.java:584)

at org.apache.catalina.core.ApplicationDispatcher.include(ApplicationDispatcher.java:497)

at org.opencms.flex.CmsFlexRequestDispatcher.includeExternal(CmsFlexRequestDispatcher.java:193)

at org.opencms.flex.CmsFlexRequestDispatcher.include(CmsFlexRequestDispatcher.java:169)

at org.opencms.loader.CmsJspLoader.service(CmsJspLoader.java:439)

at org.opencms.flex.CmsFlexRequestDispatcher.includeInternalWithCache(CmsFlexRequestDispatcher.java:422)

at org.opencms.flex.CmsFlexRequestDispatcher.include(CmsFlexRequestDispatcher.java:173)

at org.opencms.loader.CmsJspLoader.dispatchJsp(CmsJspLoader.java:473)

at org.opencms.loader.CmsJspLoader.load(CmsJspLoader.java:418)

at org.opencms.loader.A_CmsXmlDocumentLoader.load(A_CmsXmlDocumentLoader.java:232)

at org.opencms.loader.CmsResourceManager.loadResource(CmsResourceManager.java:799)

at org.opencms.main.OpenCmsCore.showResource(OpenCmsCore.java:1485)

at org.opencms.main.OpenCmsServlet.doGet(OpenCmsServlet.java:171)

at javax.servlet.http.HttpServlet.service(HttpServlet.java:627)

at javax.servlet.http.HttpServlet.service(HttpServlet.java:729)

at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:269)

at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:188)

at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:213)

at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:172)

at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)

at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:117)

at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:108)

at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:174)

at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:875)

at org.apache.coyote.http11.Http11BaseProtocol$Http11ConnectionHandler.processConnection(Http11BaseProtocol.java:665)

at org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:528)

at org.apache.tomcat.util.net.LeaderFollowerWorkerThread.runIt(LeaderFollowerWorkerThread.java:81)

at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:689)

at java.lang.Thread.run(Unknown Source)


It would be more than nice if someone could help me to solve my problem.

Regards
The_Mario
[Sep 21, 2009 4:58:08 PM] Show Printable Version of Post     [Link] Report threatening or abusive post: please login first  Go to top 
Male JoeS
Stranger



Joined: Sep 22, 2009
Posts: 4
Status: Offline

Re: cannot be resolved to a type

Hello Mario,

do you solved the problem? I have the same...

Regards
JoeS
[Sep 22, 2009 1:52:40 PM] Show Printable Version of Post     [Link] Report threatening or abusive post: please login first  Go to top 
Male The_Mario
Stranger


Deutschland (Germany)
Joined: Sep 21, 2009
Posts: 3
Status: Offline

Re: cannot be resolved to a type

No, i still hope for some helpful tips.

Regards
The_Mario
[Sep 22, 2009 2:11:36 PM] Show Printable Version of Post     [Link] Report threatening or abusive post: please login first  Go to top 
Male JoeS
Stranger



Joined: Sep 22, 2009
Posts: 4
Status: Offline

Re: cannot be resolved to a type

You have to add the deepthoughts.jar into the lib folder of opencms (e.g. youre module). Then restart tomcat and it should work...
Regards
JoeS
[Sep 22, 2009 3:03:29 PM] Show Printable Version of Post     [Link] Report threatening or abusive post: please login first  Go to top 
Male The_Mario
Stranger


Deutschland (Germany)
Joined: Sep 21, 2009
Posts: 3
Status: Offline

Re: cannot be resolved to a type

At first thanks for the tip,
but i already tried it and importing the BlogJspTemplate.class in the /system/modules/my.module.name/classes folder doesn't work either.
[Sep 22, 2009 3:31:23 PM] Show Printable Version of Post     [Link] Report threatening or abusive post: please login first  Go to top 
Male ibigfoot
Stranger



Joined: Sep 26, 2009
Posts: 2
Status: Offline

Re: cannot be resolved to a type

Hi Mario,

Not sure how "java" you are so will assume little and apologise if incorrect :-)

The problem here is that the jsp, when it is being compiled, cannot find the Java class that you are wanting to import.

I am working through this book myself, just at the start, and find it isn't very clear on this. Like most java books, it leaves some stuff out.

The import statement

<%@ page session="true" import="com.deepthoughts.templates.*"%>

suggests you have your class in a package com.deepthoughts.templates

The first line in your java file should also read

package com.deepthoughts.templates;

and when you compile (if compiles to a jar) you should be able to open that jar file and see the following file structure

<jarfile>/com/deepthoughts/templates/BlogJspTemplate.class

If you are going to manually copy the class file into the classes directory it should also be in this file path. i.e.

/system/modules/my.module.name/classes/com/deepthoughts/templates/BlogJspTemplate.class

Note that if you do not have this package statement at the top of java class (you should btw) then the class can go into the classes directory but your import statement in the jsp would need to change to (i think this would work, not sure.. I always use package names!)

<%@ page session="true"%>

Hope this helps. Tomorrow, I should be able to get further into this book and perhaps up to where you seem to be stuck and might have some further tips if you need.

Cheers,
Troy
[Sep 26, 2009 11:41:15 AM] Show Printable Version of Post        Hidden to Guest [Link] Report threatening or abusive post: please login first  Go to top 
[Show Printable Version of Thread]