我正在使用 openesb 运行 glassfish 2.1.1。我遇到的问题是,我的 Web 服务运行正常,但要求 Web 服务必须在 glassfish 管理控制台中注册。不幸的是,管理控制台没有显示我的任何网络服务。需要澄清的是,当在导航中选择“Web 服务”时,右侧 Pane 显示“未找到项目”,但服务运行良好。我完全不知道如何解决这个问题。我已经打开了最好的日志记录,但没有看到任何可以帮助我识别此问题的信息。我的项目是一个简单的 war 应用程序,我没有使用任何 ejb。
Web.xml
<?xml version="1.0" encoding="UTF-8"?>
<web-app version="2.5" 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_2_5.xsd">
<listener>
<listener-class>com.sun.xml.ws.transport.http.servlet.WSServletContextListener</listener-class>
</listener>
<servlet>
<servlet-name>ConsolidatedWS</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>ConsolidatedWS</servlet-name>
<url-pattern>/ConsolidatedWS</url-pattern>
</servlet-mapping>
<session-config>
<session-timeout>
30
</session-timeout>
</session-config>
</web-app>
网络服务
@SchemaValidation(handler= SchemaValidationHandler.class)
@WebService(serviceName = "ConsolidatedWS", targetNamespace = "http://consolidatedapi/1.0", endpointInterface = "com.ConsolidatedWS")
@HandlerChain(file="/META-INF/SoapHandlerChain.xml")
public class ConsolidatedWSImpl implements ConsolidatedWS {
@Override
public CreateConsolidatedOrderResponse createConsolidatedOrder(ConsolidatedOrder order) {
return new CreateConsolidatedOrderResponse();
}
}
sun-jaxws.xml
<?xml version="1.0" encoding="UTF-8"?>
<endpoints version="2.0" xmlns="http://java.sun.com/xml/ns/jax-ws/ri/runtime">
<endpoint implementation="com.ConsolidatedWSImpl" name="ConsolidatedWS" url-pattern="/ConsolidatedWS"/>
</endpoints>
最佳答案
我想我已经明白了,这是几件事的结合。感谢 Paul,因为我的 web.xml 现在没有监听器和 servlet。
我提供了 Metro webservices-rt,因为这可能会扰乱 Glassfish Metro 的实现。
<dependency> <groupId>org.glassfish.metro</groupId> <artifactId>webservices-rt</artifactId> <version>2.1</version> <scope>provided</scope> </dependency>
按照 Paul 的建议,我删除了 servlet 映射和监听器
web.xml
<?xml version="1.0" encoding="UTF-8"?>
<web-app version="2.5" 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_2_5.xsd">
<session-config>
<session-timeout>
30
</session-timeout>
</session-config>
</web-app>
sun-javaws.xml
<?xml version="1.0" encoding="UTF-8"?>
<endpoints version="2.0" xmlns="http://java.sun.com/xml/ns/jax-ws/ri/runtime">
</endpoints>
sun-web.xml
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE sun-web-app PUBLIC "-//Sun Microsystems, Inc.//DTD Application Server 8.1 Servlet 2.4//EN" "http://www.sun.com/software/appserver/dtds/sun-web-app_2_4-1.dtd">
<sun-web-app error-url="">
<context-root>/consolidated-api</context-root>
<class-loader delegate="true"/>
<jsp-config>
<property name="keepgenerated" value="true">
<description>Keep a copy of the generated servlet class' java code.</description>
</property>
</jsp-config>
</sun-web-app>
关于java - Glassfish 2.11 未在管理控制台中显示 Web 服务,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19816955/