Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 916905
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T18:07:25+00:00 2026-05-15T18:07:25+00:00

I am using JBoss 4.0 for creating a simple Web Service using the @WebService

  • 0

I am using JBoss 4.0 for creating a simple Web Service using the @WebService annotation as described in http://www.jtraining.com/blogs/java-web-services-getting-started.html. However, when I hit the service as if it is a servlet (as per the instructions in this article), I am getting a ClassCastException stating that my annotated webservice class cannot be cast to javax.servlet.Servlet.

Where am I going wrong?

The classes are given below:

//SimpleServiceWS.java    
import javax.jws.WebService;

@WebService()
public interface SimpleServiceWS {
    public String simpleMethod();
}

//SimpleServiceImpl.java
import javax.jws.WebService;

@WebService( serviceName="SimpleService", portName="SimpleServicePort", endpointInterface="edu.shyam.ws.SimpleServiceWS")
public class SimpleServiceImpl implements SimpleServiceWS {

    public String simpleMethod() {
        return "Simple response";
    }
}

<?xml version="1.0" encoding="UTF-8"?>
<web-app id="WebApp_ID" version="2.4" xmlns="http://java.sun.com/xml/ns/j2ee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd">
    <display-name>Service</display-name>
    <welcome-file-list>
        <welcome-file>/SimpleServiceWS</welcome-file>
    </welcome-file-list>
    <servlet>
        <servlet-name>SimpleServiceWS</servlet-name>
        <servlet-class>edu.shyam.ws.SimpleServiceWS</servlet-class>
    </servlet>
    <servlet-mapping>
        <servlet-name>SimpleServiceWS</servlet-name>
        <url-pattern>/SimpleService</url-pattern>
    </servlet-mapping>
</web-app>

The stacktrace is as follows:

java.lang.ClassCastException: SimpleServiceImpl cannot be cast to javax.servlet.Servlet
    at org.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper.java:1048)
    at org.apache.catalina.core.StandardWrapper.allocate(StandardWrapper.java:750)
    at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:130)
    at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:178)
    at org.jboss.web.tomcat.security.CustomPrincipalValve.invoke(CustomPrincipalValve.java:39)
    at org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(SecurityAssociationValve.java:159)
    at org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValve.java:59)
    at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:126)
    at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:105)
    at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:107)
    at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:148)
    at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:856)
    at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.processConnection(Http11Protocol.java:744)
    at org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:527)
    at org.apache.tomcat.util.net.MasterSlaveWorkerThread.run(MasterSlaveWorkerThread.java:112)
    at java.lang.Thread.run(Unknown Source)
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-15T18:07:26+00:00Added an answer on May 15, 2026 at 6:07 pm

    It looks like JBoss 4.0 is not enough to run web services you way you are trying to run them. Out of the box, JBoss 4.0.5 (latest 4.0 version) has an old implementation of JBossWS. You need newer version of JBossWS that will work with annotations on JDK 1.5 and above.

    Note: Both, interface and the class work in Jboss 5.1.0 and in 4.2.3. It might be easier for you to just get another version of JBoss AS.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm using JBoss Seam Framework, but it's seems to me isn't very popular among
I am using UrlRewrite in a JSP project over JBoss . I have configured
I want to monitor my application running inside JBoss version 3.2.5 using JVisualVM. I
We are using JBoss 4.2 GA, and need use a newest version in some
I am using jboss 5.1.0 GA and am connecting to a postgresql DB from
We're using Jboss, but we are really only using its JMS stuff. So, is
I know how I'd do this using JBoss: create a *-ds.xml file, and drop
I'm trying to test my code, written using JBoss Seam and Hibernate. What I'd
Running JBoss 4.2.3.GA and trying to deploy a WAR that is using Spring/Hibernate/JPA. I'm
Using online interfaces to a version control system is a nice way to have

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.