Goat
Goat

Reputation: 179

Unable to compile class for JSP: x cannot be resolved to a type

I've looked through numerous similar posts and tried a number of solutions over the past couple days. None have worked.

I typically don't work with Java but the main Java guy on my team is out of the office for a couple weeks and I would like to finish a project during that time.

Here's the issue:

<%@page contentType="text/html" pageEncoding="UTF-8"%>
<%@page session="false"%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<%@page import="java.io.File" %>
<%@page import="java.io.FileInputStream" %>
<%@page import="java.util.Properties" %>

<%@page import="a.custom.package.path.FilterVO" %>
<%@page import="a.custom.package.path.CodeTypeSearchResultsDTO" %>
<%@page import="a.custom.package.path.CodeDTO" %>

<html>
    <head>
        <!-- Code in question begin ======================================== -->
        <%
            // Create filter.
            FilterVO filter = new FilterVO();
            filter.setActive(true);


            // Execute search.
            CodeSearchResultsDTO results = getMyClient().getSystemFacade().getSomePreferences(filter, new Range(1, 10), "");

            for (CodeDTO code : results.getCodes())
            {
                System.out.println("Some Preference: " + code);
            }
        %>
        <!-- Code in question end ========================================== -->



        <!-- Some CSS imports and JS imports are here. -->

        <%
            <!-- Some currently working java code here that references the first 3 java imports at the top of the page. -->
        %>

    </head>
   <body>

    </body>
</html>

Here is the errors:

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

An error occurred at line: 28 in the jsp file: /index.jsp
CodeSearchResultsDTO cannot be resolved to a type
25: 
26: 
27:             // Execute search.
28:             CodeSearchResultsDTO results = getMyClient().getSystemFacade().getSomePreferences(filter, new Range(1, 10), "");
29: 
30:             for (CodeDTO code : results.getCodes())
31:             {


An error occurred at line: 28 in the jsp file: /index.jsp
The method getMyClient() is undefined for the type index_jsp
25: 
26: 
27:             // Execute search.
28:             CodeSearchResultsDTO results = getMyClient().getSystemFacade().getSomePreferences(filter, new Range(1, 10), "");
29: 
30:             for (CodeDTO code : results.getCodes())
31:             {


An error occurred at line: 28 in the jsp file: /index.jsp
Range cannot be resolved to a type
25: 
26: 
27:             // Execute search.
28:             CodeSearchResultsDTO results = getMyClient().getSystemFacade().getSomePreferences(filter, new Range(1, 10), "");
29: 
30:             for (CodeDTO code : results.getCodes())
31:             {


Stacktrace:
    org.apache.jasper.compiler.DefaultErrorHandler.javacError(DefaultErrorHandler.java:92)
    org.apache.jasper.compiler.ErrorDispatcher.javacError(ErrorDispatcher.java:330)
    org.apache.jasper.compiler.JDTCompiler.generateClass(JDTCompiler.java:460)
    org.apache.jasper.compiler.Compiler.compile(Compiler.java:356)
    org.apache.jasper.compiler.Compiler.compile(Compiler.java:334)
    org.apache.jasper.compiler.Compiler.compile(Compiler.java:321)
    org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:592)
    org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:328)
    org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:313)
    org.apache.jasper.servlet.JspServlet.service(JspServlet.java:260)
    javax.servlet.http.HttpServlet.service(HttpServlet.java:723)

The classes are located in the WEB-INF/lib jar's, as in they are not missing. The path is correct. The casing is correct. I've tried to 'clean' my container by deleting the CATALINA_BASE/work/Catalina/localhost folder. I've tried to clean all browser cash because that was suggested for some reason (seemed like a long shot).

I'm leaning towards it being a container java dependency refresh issue, but again, Java and containers aren't exactly my MO.

I realize now I haven't imported the Range class, which I will add, but that wont stop the main issue of these imports not being found.

Any debugging advice would be greatly appreciated! Cheers!

Upvotes: 0

Views: 1573

Answers (1)

Angelo Oparah
Angelo Oparah

Reputation: 673

I believe something is wrong here.

This is what you import

<%@page import="a.custom.package.path.CodeTypeSearchResultsDTO" %>

This is what you call

CodeSearchResultsDTO

Could it be a Typ(e)o ??

Upvotes: 1

Related Questions