0
votes

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?

3
Never seen that, but I'd really recommend just getting your own Tomcat and putting it in one of your own directories, and copying the axis webapp into it. You have much more control over the entire process this way.Dave Newton
By the way, why the choice for Axis+JSP which is pretty old fashioned? Why not JAX-WS/RS? Webservices were standardized in Java EE since Java EE 5 with the JAX-WS API and since Java EE 6 also with the awesome RESTful JAX-RS API. For JAX-WS, see metro.java.net/guide and for JAX-RS see jersey.java.net/nonav/documentation/latest/user-guide.htmlBalusC

3 Answers

2
votes

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.

1
votes

The quick start guide you are referring to doesn't say that you should create a "symbolic link from /var/lib/tomcat6/webapps/axis2 -> /home/doug/.../axis2-1.6.1/webapp/". It says the you should "Copy the axis2.war file to the webapps directory of your servlet engine". There are two ways to get the axis2.war file:

  • Download the WAR distribution.
  • Download the binary distribution and execute the Ant script in the webapp folder.
0
votes

I have downloaded axis2-1.6.2-bin.zip and added it in eclipse using Window -> Preferences -> Web Services -> Axis2 Preferences ->Axis2 Runtime

Then created webservice from java class.

Using axis2-1.6.2-bin instead of axis2-1.7.3-bin resolved the issue.