You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

GlassFish部署JAX-WS服务异常:无法识别服务并生成WSDL/端点

Hey there! Let's break down why your web service isn't being recognized by GlassFish and walk through the fixes step by step. Here are the most common issues to check:

1. Missing Critical Web Service Annotations

Java EE web services (JAX-WS) rely on annotations to signal the server to expose them as endpoints. Double-check your service class has the right tags:

  • If you're using a service endpoint interface (SEI), add @WebService to the interface.
  • For the implementation class, use @WebService(endpointInterface = "your.package.YourSEIName") (to link to the SEI) or just @WebService if you're defining the service directly in the class.
  • Quick example:
package com.yourcompany;

import javax.jws.WebService;

@WebService
public class GreetingService {
    public String greet(String name) {
        return "Hi " + name + "!";
    }
}
2. Incorrect web.xml Configuration

Your web.xml might be missing the servlet mapping that lets GlassFish handle web service requests. Add this section to your deployment descriptor:

<servlet>
    <servlet-name>GreetingService</servlet-name>
    <servlet-class>com.sun.xml.ws.transport.http.servlet.WSServlet</servlet-class>
    <load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
    <servlet-name>GreetingService</servlet-name>
    <url-pattern>/GreetingService</url-pattern>
</servlet-mapping>

Also, make sure you have the correct Java EE namespace declared at the top of web.xml:

<web-app xmlns="http://java.sun.com/xml/ns/javaee"
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd"
         version="3.0">
3. Missing JAX-WS Libraries (for non-Java EE projects)

If your dynamic web project isn't configured to use Java EE (e.g., it's a plain Servlet project), you might be missing the required JAX-WS jars. GlassFish provides these, but sometimes Eclipse doesn't pull them into your build path automatically:

  • Right-click your project → Properties → Targeted Runtimes → Ensure GlassFish is checked. This should add all necessary Java EE libraries.
  • If that fails, manually copy jaxws-api.jar and jaxws-rt.jar from your GlassFish modules folder into your project's WEB-INF/lib directory.
4. War Packaging Mistakes

When generating your WAR file, confirm all essential files are included:

  • Compiled service class files in WEB-INF/classes.
  • Any required libraries in WEB-INF/lib.
  • The correct web.xml in the WEB-INF folder.
  • If you're using an SEI, the interface class must also be present in WEB-INF/classes.
5. Check GlassFish Server Logs

Even if deployment says "success", there might be hidden warnings or errors preventing the web service from registering. Open the GlassFish logs (located at glassfish/domains/domain1/logs/server.log) and search for keywords like "JAX-WS", "endpoint", or "WSDL" to spot issues.

6. Eclipse Project Setup Issues

When creating your dynamic web project, make sure you:

  • Selected Dynamic Web Project and chose GlassFish as the target runtime.
  • Enabled the correct project facets: Java (matching your GlassFish version) and Dynamic Web Module. For Java EE 6+, you don't need to manually enable web service facets if using annotations, but double-check the JAX-WS facet is enabled if it appears in the list.

Once you fix these, redeploy your WAR to GlassFish. You should be able to access the WSDL at http://localhost:8080/YourProjectName/GreetingService?wsdl (replace with your actual project and service names).

内容的提问来源于stack exchange,提问作者ronak_11

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.22 09:52:49