gpt4 book ai didi

spring - java.lang.IllegalArgumentException : Prefix '' is already bound to '' 异常

转载 作者:行者123 更新时间:2023-12-04 05:27:54 27 4
gpt4 key购买 nike

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="ways.org.commerce.inventory.service.InventoryServiceImpl" name="InventoryServiceImpl" url-pattern="/services/InventoryServiceImpl"/>
</endpoints>

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">
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>classpath:applicationContext-Main.xml</param-value>
</context-param>
<listener>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>
<listener>
<listener-class>com.sun.xml.ws.transport.http.servlet.WSServletContextListener</listener-class>
</listener>
<servlet>
<servlet-name>InventoryServiceImpl</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>InventoryServiceImpl</servlet-name>
<url-pattern>/services/InventoryServiceImpl</url-pattern>
</servlet-mapping>
<session-config>
<session-timeout>
30
</session-timeout>
</session-config>
</web-app>

InventoryServiceImpl.java

@WebService(serviceName = "InventoryServiceImpl")
public class InventoryServiceImpl implements IFInventoryService {

private IFInventoryDAO inventoryDAO;

@WebMethod(exclude = true)
public IFInventoryDAO getInventoryDAO() {
return inventoryDAO;
}

@WebMethod(exclude = true)
public void setInventoryDAO(IFInventoryDAO inventoryDAO) {
this.inventoryDAO = inventoryDAO;
}

@WebMethod(operationName = "addProduct")
public void addProduct(
@WebParam(name = "product") ProductBean product) throws CommerceBaseException {
if (inventoryDAO.productExists(product.getProductUniqueCode())) {
throw new CommerceBaseException("Product Not Found", InventoryErrorCode.PRODUCT_NOT_FOUND_ERROR);
}
inventoryDAO.addProduct(product);
}

@WebMethod(operationName = "getProduct")
public ProductBean getProduct(
@WebParam(name = "productUniqueCode") String productUniqueCode) throws CommerceBaseException {
if (inventoryDAO.productExists(productUniqueCode)) {
throw new CommerceBaseException("Product Not Found", InventoryErrorCode.PRODUCT_NOT_FOUND_ERROR);
}
return inventoryDAO.getProduct(productUniqueCode);
}

@WebMethod(operationName = "productExists")
public boolean productExists(
@WebParam(name = "productUniqueCode") String productUniqueCode) {
return inventoryDAO.productExists(productUniqueCode);
}
}

我遇到以下异常

SEVERE: Exception sending context initialized event to listener instance of class com.sun.xml.ws.transport.http.servlet.WSServletContextListener
com.sun.xml.ws.transport.http.servlet.WSServletException: WSSERVLET11: failed to parse runtime descriptor: java.lang.IllegalArgumentException: Prefix '' is already bound to ''
at com.sun.xml.ws.transport.http.servlet.WSServletContextListener.contextInitialized(WSServletContextListener.java:139)
at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4681)
at org.apache.catalina.core.StandardContext$1.call(StandardContext.java:5184)
at org.apache.catalina.core.StandardContext$1.call(StandardContext.java:5179)
at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:303)
at java.util.concurrent.FutureTask.run(FutureTask.java:138)
at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
at java.lang.Thread.run(Thread.java:662)
Caused by: java.lang.IllegalArgumentException: Prefix '' is already bound to ''
at com.sun.xml.txw2.StartTag.addNamespaceDecl(StartTag.java:171)
at com.sun.xml.txw2.ContainerElement._namespace(ContainerElement.java:313)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at com.sun.xml.txw2.ContainerElement.invoke(ContainerElement.java:114)
at $Proxy179._namespace(Unknown Source)
at com.sun.xml.ws.wsdl.writer.WSDLGenerator.generateDocument(WSDLGenerator.java:339)
at com.sun.xml.ws.wsdl.writer.WSDLGenerator.doGeneration(WSDLGenerator.java:272)
at com.sun.xml.ws.server.EndpointFactory.generateWSDL(EndpointFactory.java:443)
at com.sun.xml.ws.server.EndpointFactory.createEndpoint(EndpointFactory.java:209)
at com.sun.xml.ws.api.server.WSEndpoint.create(WSEndpoint.java:505)
at com.sun.xml.ws.transport.http.DeploymentDescriptorParser.parseAdapters(DeploymentDescriptorParser.java:253)
at com.sun.xml.ws.transport.http.DeploymentDescriptorParser.parse(DeploymentDescriptorParser.java:147)
at com.sun.xml.ws.transport.http.servlet.WSServletContextListener.contextInitialized(WSServletContextListener.java:124)
... 8 more
20 Oct, 2012 11:17:18 PM org.apache.catalina.core.ApplicationContext log
INFO: Closing Spring root WebApplicationContext

请帮我找出我哪里做错了...

最佳答案

您的 web 服务库和 tomcat 的库之间存在冲突。

使用以下依赖项:

<dependency>
<groupId>com.sun.xml.ws</groupId>
<artifactId>jaxws-rt</artifactId>
<version>2.2.8</version>
<scope>provided</scope>
</dependency>

关于spring - java.lang.IllegalArgumentException : Prefix '' is already bound to '' 异常,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12991093/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com