0 Replies Latest reply on Mar 2, 2008 11:16 AM by hansolo chui

    error on accessing a web-service

    hansolo chui Newbie

      Hello, i have an ejb which contains following java-class "JBossEJBWS.java"

      package org.me.ejbwss;

      import javax.jws.WebMethod;
      import javax.jws.WebService;
      import javax.ejb.Stateless;

      @Stateless
      @WebService
      public class JBossEJBWS {
      private String message = new String("Hello, ");

      @WebMethod
      public String greet(String name) {
      return message + name + ".";
      }
      }






      when i deploy it, i can access the wsdl-file:
      http://localhost:8080/WSEJBModule/JBossEJBWS?wsdl


      Now i want to create a war-file which contains a jsp-file, which executes the method "greet"
      For this i created web.xml in WEB-INF:

      <?xml version="1.0" encoding="UTF-8"?>
      <web-app
      xmlns="http://java.sun.com/xml/ns/javaee"
      version="2.5"
      xmlns:xsi="http://www.w3.org/2001/XMLSchema"
      xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd">
      <display-name>webclient</display-name>

      <display-name>greeting</display-name>
      <servlet-name>greeting</servlet-name>
      <jsp-file>/index.jsp</jsp-file>

      <servlet-mapping>
      <servlet-name>greeting</servlet-name>
      <url-pattern>/greeting</url-pattern>
      </servlet-mapping>
      <service-ref>
      <service-ref-name>services/JBossEJBWS</service-ref-name>
      <service-interface>javax.xml.ws.Service</service-interface>
      <wsdl-file>WEB-INF/wsdl/JBossEJBWS.wsdl</wsdl-file>
      <port-component-ref>
      <service-endpoint-interface>org.me.ejbwss.JBossEJBWS</service-endpoint-interface>
      </port-component-ref>
      </service-ref>
      </web-app>


      And this is the jsp-file:

      <%@page contentType="text/html"%>
      <%@page pageEncoding="UTF-8"%>
      <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
      "http://www.w3.org/TR/html4/loose.dtd">
      <%@ page language="java" import="java.util.*" %>
      <%@ page import="java.io.*,javax.naming.InitialContext,javax.xml.ws.Service,org.me.ejbwss.JBossEJBWS"%>


      <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
      JSP Page


      <h1>JSP Page</h1>

      <%
      try {out.println("ole");
      InitialContext ctx = new InitialContext();
      Service service = (Service)ctx.lookup("java:comp/env/services/JBossEJBWS");
      JBossEJBWS port = (JBossEJBWS) service.getPort(JBossEJBWS.class);
      } catch (Exception e) {
      out.println("Error: " + e.getMessage());
      }
      String text = port.greet("Fugee");
      out.println(text);
      %>






      The Problem is, when i open the URL (http://localhost:8080/WSCWebModule/) in a webbrowser, i get the following error:

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

      An error occurred at line: 23 in the jsp file: /index.jsp
      port cannot be resolved
      20: } catch (Exception e) {
      21: out.println("Error: " + e.getMessage());
      22: }
      23: String text = port.greet("Fugee");
      24: out.println(text);
      25: %>
      26:


      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:415)
      org.apache.jasper.compiler.Compiler.compile(Compiler.java:308)
      org.apache.jasper.compiler.Compiler.compile(Compiler.java:286)
      org.apache.jasper.compiler.Compiler.compile(Compiler.java:273)
      org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:566)
      org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:316)
      org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:336)
      org.apache.jasper.servlet.JspServlet.service(JspServlet.java:265)
      javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
      org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:96)


      can someone tell me what i have done wrong ??