1 Reply Latest reply: May 23, 2013 6:03 AM by gimbal2 RSS

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

    Joseph Hwang
      I am using eclipse IDE and try to import a jar file in my JSP. With click of right button of my project, 'Properties' => 'Java Build Path' => 'Add External JARs' button in Libraries tab, I import org.apache.cxf.jaxws.JaxWsProxyFactoryBean.jar file
      This is my JSP file,

      <%@ page language="java" contentType="text/html; charset=EUC-KR" pageEncoding="EUC-KR"%>

      <%@ page import="com.aaa.ws.*" %>
      <%@ page import="org.apache.cxf.jaxws.JaxWsProxyFactoryBean" %> *==> This statement throws Exception.*

      <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
      <html>
      <head>
      <meta http-equiv="Content-Type" content="text/html; charset=EUC-KR">
      <title>JBoss JAAS와 JBoss Web Service</title>
      </head>
      <body>
      <%
           JaxWsProxyFactoryBean factory = new JaxWsProxyFactoryBean(); *==> This statement throws Exception.*
           factory.setServiceClass(SecureTestBean.class);
           factory.setAddress("http://localhost:8080/SecurityTestWS/SecureTestBean");
           factory.setUsername("joseph");
           factory.setPassword("joseph123");
           
           SecureTestBeanService service = (SecureTestBeanService)factory.create();
           ISecureTestPort port = service.getSecureTestBeanPort();
           out.println("Result : " + port.searchSecureData("test"));
      %>
      </body>
      </html>

      The Exception is like below

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

      An error occurred at line: 7 in the generated java file
      Only a type can be imported. org.apache.cxf.jaxws.JaxWsProxyFactoryBean resolves to a package

      An error occurred at line: 14 in the jsp file: /index.jsp
      JaxWsProxyFactoryBean cannot be resolved to a type
      11: </head>
      12: <body>
      13: <%
      14:      JaxWsProxyFactoryBean factory = new JaxWsProxyFactoryBean();
      15:      factory.setServiceClass(SecureTestBean.class);
      16:      factory.setAddress("http://localhost:8080/SecurityTestWS/SecureTestBean");
      17:      factory.setUsername("joseph");


      An error occurred at line: 14 in the jsp file: /index.jsp
      JaxWsProxyFactoryBean cannot be resolved to a type
      11: </head>
      12: <body>
      13: <%
      14:      JaxWsProxyFactoryBean factory = new JaxWsProxyFactoryBean();
      15:      factory.setServiceClass(SecureTestBean.class);
      16:      factory.setAddress("http://localhost:8080/SecurityTestWS/SecureTestBean");
      17:      factory.setUsername("joseph");


      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:446)
           org.apache.jasper.compiler.Compiler.compile(Compiler.java:362)
           org.apache.jasper.compiler.Compiler.compile(Compiler.java:340)
           org.apache.jasper.compiler.Compiler.compile(Compiler.java:327)
           org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:607)
           org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:312)
           org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:326)
           org.apache.jasper.servlet.JspServlet.service(JspServlet.java:253)
           javax.servlet.http.HttpServlet.service(HttpServlet.java:847)


      I am a beginner to JSP. I need your advice! Thanks in advanced.
        • 1. Re: org.apache.jasper.JasperException: Unable to compile class for JSP
          gimbal2
          Yeah great that you do things and stuff in Eclipse, but what is actually relevant is what is deployed to your server. Is the CXF jar actually deployed to the WEB-INF/lib folder of your web application?

          The error itself is incredibly odd and makes me believe the deployment is very wrong. Java is trying to tell you here that there is a directory 'org/apache/cxf/jaxws/JaxWsProxyFactoryBean' on your application's classpath. The truth is again in the deployed files in the server, so check what is there. It usually takes me a fair amount of fiddling before Eclipse deploys my application correctly.