Search code examples
javajsptomcatapache-axis

Why do axis2's jsps give compiler errors when running in tomcat6?


In Ubuntu, I'm running Tomcat 6, the Tomcat version on the bottom of the browser reads:

Apache Tomcat/6.0.28

I installed Tomcat via apt-get. I made some "hello world" servlets and confirmed that Tomcat 6 appears to be working correctly.

Since my end goal was to make a webservice, I went to look for axis2. I couldn't find any Ubuntu packages for axis2, so I next went and downloaded axis2 v 1.6.1 from here and unzipped it in my home directory. To get started, I pointed a symbolic link from /var/lib/tomcat6/webapps/axis2 -> /home/doug/.../axis2-1.6.1/webapp/ based on these instructions.

Browsing to http://localhost:8080/axis2/ I expect to see basic axis2 (admin?) pages. Instead I get a slew of errors complaining about failing to compile axis2's jsp:

Type Exception report

message

description The server encountered an internal error () that prevented it from fulfilling this request.

exception

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

An error occurred at line: 6 in the generated java file
Only a type can be imported. org.apache.axis2.Constants resolves to a package

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

An error occurred at line: 8 in the generated java file
Only a type can be imported. org.apache.axis2.description.Parameter resolves to a package

An error occurred at line: 9 in the generated java file
Only a type can be imported. org.apache.axis2.transport.http.AxisServlet resolves to a package

An error occurred at line: 10 in the generated java file
Only a type can be imported. org.apache.axis2.transport.TransportListener resolves to a package

An error occurred at line: 31 in the jsp file: /axis2-web/include/httpbase.jsp
ConfigurationContext cannot be resolved to a type
28: 
29:     public void jspInit() {
30:         ServletContext context = this.getServletConfig().getServletContext();
31:         ConfigurationContext configctx = (ConfigurationContext) context.getAttribute(AxisServlet.CONFIGURATION_CONTEXT);
32:         if (configctx != null) {
33:             Parameter parameter = configctx.getAxisConfiguration().getParameter(Constants.HTTP_FRONTEND_HOST_URL);
34:             if (parameter != null) {


An error occurred at line: 31 in the jsp file: /axis2-web/include/httpbase.jsp
ConfigurationContext cannot be resolved to a type
28: 
29:     public void jspInit() {
30:         ServletContext context = this.getServletConfig().getServletContext();
31:         ConfigurationContext configctx = (ConfigurationContext) context.getAttribute(AxisServlet.CONFIGURATION_CONTEXT);
32:         if (configctx != null) {
33:             Parameter parameter = configctx.getAxisConfiguration().getParameter(Constants.HTTP_FRONTEND_HOST_URL);
34:             if (parameter != null) {


An error occurred at line: 31 in the jsp file: /axis2-web/include/httpbase.jsp
AxisServlet.CONFIGURATION_CONTEXT cannot be resolved to a type
28: 
29:     public void jspInit() {
30:         ServletContext context = this.getServletConfig().getServletContext();
31:         ConfigurationContext configctx = (ConfigurationContext) context.getAttribute(AxisServlet.CONFIGURATION_CONTEXT);
32:         if (configctx != null) {
33:             Parameter parameter = configctx.getAxisConfiguration().getParameter(Constants.HTTP_FRONTEND_HOST_URL);
34:             if (parameter != null) {


An error occurred at line: 33 in the jsp file: /axis2-web/include/httpbase.jsp
Parameter cannot be resolved to a type
30:         ServletContext context = this.getServletConfig().getServletContext();
31:         ConfigurationContext configctx = (ConfigurationContext) context.getAttribute(AxisServlet.CONFIGURATION_CONTEXT);
32:         if (configctx != null) {
33:             Parameter parameter = configctx.getAxisConfiguration().getParameter(Constants.HTTP_FRONTEND_HOST_URL);
34:             if (parameter != null) {
35:                 frontendHostUrl = (String) parameter.getValue();
36:             }


An error occurred at line: 33 in the jsp file: /axis2-web/include/httpbase.jsp
Constants.HTTP_FRONTEND_HOST_URL cannot be resolved to a type
30:         ServletContext context = this.getServletConfig().getServletContext();
31:         ConfigurationContext configctx = (ConfigurationContext) context.getAttribute(AxisServlet.CONFIGURATION_CONTEXT);
32:         if (configctx != null) {
33:             Parameter parameter = configctx.getAxisConfiguration().getParameter(Constants.HTTP_FRONTEND_HOST_URL);
34:             if (parameter != null) {
35:                 frontendHostUrl = (String) parameter.getValue();
36:             }


An error occurred at line: 37 in the jsp file: /axis2-web/include/httpbase.jsp
Parameter cannot be resolved to a type
34:             if (parameter != null) {
35:                 frontendHostUrl = (String) parameter.getValue();
36:             }
37:             Parameter hostnameParam = configctx.getAxisConfiguration().getParameter(TransportListener.HOST_ADDRESS);
38:             if (hostnameParam != null) {
39:                 hostname = (String) hostnameParam.getValue();
40:             }


An error occurred at line: 37 in the jsp file: /axis2-web/include/httpbase.jsp
TransportListener.HOST_ADDRESS cannot be resolved to a type
34:             if (parameter != null) {
35:                 frontendHostUrl = (String) parameter.getValue();
36:             }
37:             Parameter hostnameParam = configctx.getAxisConfiguration().getParameter(TransportListener.HOST_ADDRESS);
38:             if (hostnameParam != null) {
39:                 hostname = (String) hostnameParam.getValue();
40:             }


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:439)
    org.apache.jasper.compiler.Compiler.compile(Compiler.java:349)
    org.apache.jasper.compiler.Compiler.compile(Compiler.java:327)
    org.apache.jasper.compiler.Compiler.compile(Compiler.java:314)
    org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:592)
    org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:317)
    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:717)
    org.apache.jasper.runtime.JspRuntimeLibrary.include(JspRuntimeLibrary.java:968)
    org.apache.jsp.axis2_002dweb.index_jsp._jspService(index_jsp.java:59)
    org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
    javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
    org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:377)
    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:717)

Should I not be trying the latest axis2 with Tomcat 6? Is there an Ubuntu package I should be using instead?


Solution

  • Those confusing JSP compilation errors are under the covers actually NoClassDefFoundErrors, which in your particular case in turn means that the Axis related libraries (JAR files) are not present in the webapp's runtime classpath. The webapp's /WEB-INF/lib folder is part of the webapp's runtime classpath, so put them in there.