facebook

JasperException – unable to compile class for JSP

  1. MyEclipse Archived
  2.  > 
  3. Application Servers and Deployment
Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
    Posts
  • #307241 Reply

    Gerd W. Naschenweng
    Participant

    My webproject has been running fine for some weeks and since yesterday I get the error “org.apache.jasper.JasperException: Unable to compile class for JSP” on a few select JSPs which used to compile fine.

    I am running on Mac OS X 10.6.3 and MyEclipseIDE 8.5. I am also running against a JDK as the internal Tomcat server is able to compile all of the JSPs with the exception of JSPs referencing a specific class/import.

    The JSP error:

    
    An error occurred at line: 14 in the generated java file
    The import com.bidorbuy.bobe.search.predicate cannot be resolved
    
    An error occurred at line: 150 in the jsp file: /jsp/home/Home.jsp
    CustomPredicate cannot be resolved to a type
    147:     premiumTradeQuery.addPredicate(QueryTables.tradeTable.TYPE, QueryVerb.NOT_EQUALS, TradeType.PERSONAL_OFFER);
    148:   premiumTradeQuery.addPredicate(QueryTables.tradeTable.PREMIUMLISTING, QueryVerb.EQUALS, true);
    149:   premiumTradeQuery.addPredicate(QueryTables.tradeTable.THUMBNAILIMAGEID, QueryVerb.GREATER_THAN, 1);
    150:   premiumTradeQuery.addPredicate(new CustomPredicate(QueryTables.tradeTable, "tr.CloseTime >= (sysdate + 1/24)"));
    151:   premiumTradeQuery.addOrderBy(QueryTables.tradeTable.TRADEID, Query.ORDER_BY_RANDOM);
    152:   premiumTradeQuery.addFreeFormatOrderBy("floor((tr.closetime - sysdate) / 7)");
    153:   Collection premiumTrades = TradeSearchInterface.executeTradeQuery(userToken, premiumTradeQuery, PREMIUM_TRADES_TO_DISPLAY).getResultCollection();
    
    
    An error occurred at line: 189 in the jsp file: /jsp/home/Home.jsp
    CustomPredicate cannot be resolved to a type
    186:   homePageFeaturedTradeQuery.addPredicate(QueryTables.tradeTable.EITHERCATEGORYID, QueryVerb.IN_PERMITTED_CATEGORY_TREE, categoryId);
    187:   homePageFeaturedTradeQuery.addPredicate(QueryTables.tradeTable.HOMEPAGELISTING, QueryVerb.EQUALS, true);
    188:   homePageFeaturedTradeQuery.addPredicate(QueryTables.tradeTable.THUMBNAILIMAGEID, QueryVerb.GREATER_THAN, 1);
    189:   homePageFeaturedTradeQuery.addPredicate(new CustomPredicate(QueryTables.tradeTable, "tr.CloseTime >= (sysdate + 1/24)"));
    190:   homePageFeaturedTradeQuery.addOrderBy(QueryTables.tradeTable.TRADEID, Query.ORDER_BY_RANDOM);
    191:   homePageFeaturedTradeQuery.addFreeFormatOrderBy("floor((tr.closetime - sysdate) / 7)");
    192:   Collection homePageFeaturedTrades = TradeSearchInterface.executeTradeQuery(userToken, homePageFeaturedTradeQuery, HOME_PAGE_FEATURED_TRADES_TO_DISPLAY).getResultCollection();
    
    
    Stacktrace:
        at org.apache.jasper.compiler.DefaultErrorHandler.javacError(DefaultErrorHandler.java:92)
        at org.apache.jasper.compiler.ErrorDispatcher.javacError(ErrorDispatcher.java:330)
        at org.apache.jasper.compiler.JDTCompiler.generateClass(JDTCompiler.java:423)
        at org.apache.jasper.compiler.Compiler.compile(Compiler.java:308)
        at org.apache.jasper.compiler.Compiler.compile(Compiler.java:286)
        at org.apache.jasper.compiler.Compiler.compile(Compiler.java:273)
        at org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:566)
        at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:317)
        at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:320)
        at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:266)
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
        at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
        at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
        at org.tuckey.web.filters.urlrewrite.UrlRewriteFilter.doFilter(UrlRewriteFilter.java:738)
        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:230)
        at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:175)
        at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:128)
        at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:104)
        at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
        at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:261)
        at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:844)
        at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:581)
        at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:447)
        at java.lang.Thread.run(Thread.java:613)
    

    The code in question (the class CustomPredicate is causing the problem, but the import-statement “com.bidorbuy.bobe.search.predicate.*” references the package of that class):

    
    <%@ page errorPage="/jsp/error/ErrorPage.jsp"
    import="com.bidorbuy.bobe.category.*" 
    import="com.bidorbuy.bobe.enumlistitem.*" 
    import="com.bidorbuy.bobe.featuredtrade.*"
    import="com.bidorbuy.bobe.jspclient.*"
    import="com.bidorbuy.bobe.list.*"
    import="com.bidorbuy.bobe.permission.*"
    import="com.bidorbuy.bobe.search.*"
    import="com.bidorbuy.bobe.search.tradesearch.*"
    import="com.bidorbuy.bobe.search.predicate.*"
    import="com.bidorbuy.bobe.site.*"
    import="com.bidorbuy.bobe.text.*" 
    import="com.bidorbuy.bobe.utility.*" 
    import="java.util.*" %>
    <%@ taglib uri="/bobe.tld" prefix="bobe" %>
    <jsp:useBean id="userToken" scope="request" class="com.bidorbuy.bobe.jspclient.JSPUserToken">
        <% userToken.initialise(pageContext); %>
    </jsp:useBean>
    <%!
      private static final int PREMIUM_TRADES_TO_DISPLAY = 12;
      private static final int PREMIUM_TRADES_DISPLAY_COLUMNS = 2;
      private static final int HOME_PAGE_FEATURED_TRADES_TO_DISPLAY = 20;
    %>
    
    
    <% // Line 150 (excess code removed for readability)
    ...
      premiumTradeQuery.addPredicate(QueryTables.tradeTable.THUMBNAILIMAGEID, QueryVerb.GREATER_THAN, 1);
      premiumTradeQuery.addPredicate(new CustomPredicate(QueryTables.tradeTable, "tr.CloseTime >= (sysdate + 1/24)"));
      premiumTradeQuery.addOrderBy(QueryTables.tradeTable.TRADEID, Query.ORDER_BY_RANDOM);
    ...
    

    If I however remove the import statement and fully qualify the class, the code compiles:

    
    <%@ page errorPage="/jsp/error/ErrorPage.jsp"
    import="com.bidorbuy.bobe.category.*" 
    import="com.bidorbuy.bobe.enumlistitem.*" 
    import="com.bidorbuy.bobe.featuredtrade.*"
    import="com.bidorbuy.bobe.jspclient.*"
    import="com.bidorbuy.bobe.list.*"
    import="com.bidorbuy.bobe.permission.*"
    import="com.bidorbuy.bobe.search.*"
    import="com.bidorbuy.bobe.search.tradesearch.*"
    import="com.bidorbuy.bobe.site.*"
    import="com.bidorbuy.bobe.text.*" 
    import="com.bidorbuy.bobe.utility.*" 
    import="java.util.*" %>
    <%@ taglib uri="/bobe.tld" prefix="bobe" %>
    <jsp:useBean id="userToken" scope="request" class="com.bidorbuy.bobe.jspclient.JSPUserToken">
        <% userToken.initialise(pageContext); %>
    </jsp:useBean>
    <%!
      private static final int PREMIUM_TRADES_TO_DISPLAY = 12;
      private static final int PREMIUM_TRADES_DISPLAY_COLUMNS = 2;
      private static final int HOME_PAGE_FEATURED_TRADES_TO_DISPLAY = 20;
    %>
    
    
    <% // Line 150 (excess code removed for readability)
    ...
      premiumTradeQuery.addPredicate(QueryTables.tradeTable.THUMBNAILIMAGEID, QueryVerb.GREATER_THAN, 1);
      premiumTradeQuery.addPredicate(new com.bidorbuy.bobe.search.predicate.CustomPredicate(QueryTables.tradeTable, "tr.CloseTime >= (sysdate + 1/24)"));
      premiumTradeQuery.addOrderBy(QueryTables.tradeTable.TRADEID, Query.ORDER_BY_RANDOM);
    ...
    

    As said, other JSPs compile fine and it seems to be only related to the reference of the class CustomPredicate. I don’t have any compile errors in the workbench.

    I have deleted MyEclipseIDE as well as the workspace and reimported the projects from scratch and still have the issue. Other people in my team are able to execute those JSPs fine.

    I have also noticed that when I refresh the JSP in question several times, I will get it occasionally compiled but not consistently.

    #307243 Reply

    Gerd W. Naschenweng
    Participant

    Another oddity I found is that even a JSP with just the page-import, but no reference of the class will cause a JSP error:

    
    <%-- $Header: /srv/cvs/cvsroot/bobe/webapp/adminjsp/HomePageFeaturedItemEdit.jsp,v 1.19 2010/03/08 10:09:13 xmikek Exp $ --%>
    <%@ page errorPage="/adminjsp/AdminError.jsp" %>
    
    <%@ taglib uri="/bobe.tld" prefix="bobe" %>
    
    <%@ page import="com.bidorbuy.bobe.category.*" %>
    <%@ page import="com.bidorbuy.bobe.enumlistitem.*" %>
    <%@ page import="com.bidorbuy.bobe.jspclient.*" %>
    <%@ page import="com.bidorbuy.bobe.list.*" %>
    <%@ page import="com.bidorbuy.bobe.search.*" %>
    <%@ page import="com.bidorbuy.bobe.search.predicate.*" %>
    <%@ page import="com.bidorbuy.bobe.search.tradesearch.*" %>
    <%@ page import="com.bidorbuy.bobe.site.*" %>
    <%@ page import="com.bidorbuy.bobe.trading.*" %>
    <%@ page import="com.bidorbuy.bobe.user.*" %>
    <%@ page import="java.util.*" %>
    
    <jsp:useBean id="userToken" scope="request" class="com.bidorbuy.bobe.jspclient.JSPUserToken">
        <% userToken.initialise(pageContext); %>
    </jsp:useBean>
    

    Removing the line “<%@ page import=”com.bidorbuy.bobe.search.predicate.*” %>” will compile the JSP without an error.

    #307271 Reply

    Gerd W. Naschenweng
    Participant

    I managed to resolve the issue, although I am still uncertain how this relates to the Jasper-errors. Some time back I included the statement allowLinking=”true” into META-INF’s context.xml. As soon as I change allowLinking to false, the problem disappears. I am still uncertain how those are related and why it seems to only affect JSPs with that specific import statement.

    #307313 Reply

    Brian Fernandes
    Moderator

    It could have something to do with the source of that package. Are all these packages coming from the same JAR (or are they on your source path?) Also, are other members of your team using the same source for this class?

    #307317 Reply

    Gerd W. Naschenweng
    Participant

    @Support-Brian wrote:

    It could have something to do with the source of that package. Are all these packages coming from the same JAR (or are they on your source path?) Also, are other members of your team using the same source for this class?

    the project is not packaged as a JAR. All classes reside under WEB-INF/classes and the package in question as well as the class itself is there.

    #307352 Reply

    Brian Fernandes
    Moderator

    Very odd. Just to clarify – is this package on your source path – i.e. do you have the source for this package in your project or are you using compiled classes from elsewhere which you place in the classes folder?

    Something to look at is your project properties, go to the Java Compiler node and check the compliance level for the project (if workspace settings are used, go on and check the workspace compliance level)? Is the compliance level set to 1.5 or 1.6? What JDK is Tomcat being launched with?

    Finally, in case you have not already tried it, please clean your project using the Proejct > Clean option. When you deploy your app, please use the server view to browse to the deployment location and ensure that the classes are actually being deployed too?
    w.r.t. allowLinking = “true”, it appears to be something to do with symbolic links and allowing Tomcat to follow them- do you have any in your deployment area?

Viewing 6 posts - 1 through 6 (of 6 total)
Reply To: JasperException – unable to compile class for JSP

You must be logged in to post in the forum log in