我正在使用Jboss 5.0.1服务器并尝试在我们的应用程序中对其中一个EJB进行webservice JAX-RPC
调用。我下载并将以下三个罐子从JBOSS_HOME\server\default\lib
复制到JBOSS_HOME\lib\endorsed
当抛出此异常时,我无法进行Web服务客户端调用:
**11:54:33,995 ERROR [CommonClient] Exception caught while (preparing for) performing the invocation:
java.lang.StringIndexOutOfBoundsException: String index out of range: -1
at java.lang.String.substring(String.java:1937)
at org.jboss.ws.core.client.EndpointInfo.lowerCaseProtocol(EndpointInfo.java:114)
at org.jboss.ws.core.client.EndpointInfo.<init>(EndpointInfo.java:49)
at org.jboss.ws.core.CommonClient.invoke(CommonClient.java:335)
at org.jboss.ws.core.jaxrpc.client.CallImpl.invokeInternal(CallImpl.java:516)
at org.jboss.ws.core.jaxrpc.client.CallImpl.invoke(CallImpl.java:275)
at org.jboss.ws.core.jaxrpc.client.PortProxy.invoke(PortProxy.java:154)
at $Proxy106.checkPlanData(Unknown Source)
at org.apache.jsp.index_jsp._jspService(index_jsp.java:88)
at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:369)
at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:322)
at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:249)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:96)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:235)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
at org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(SecurityAssociationValve.java:190)
at org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValve.java:92)
at org.jboss.web.tomcat.security.SecurityContextEstablishmentValve.process(SecurityContextEstablishmentValve.java:126)
at org.jboss.web.tomcat.security.SecurityContextEstablishmentValve.invoke(SecurityContextEstablishmentValve.java:70)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
at org.jboss.web.tomcat.service.jca.CachedConnectionValve.invoke(CachedConnectionValve.java:158)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:330)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:829)
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:601)
at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:447)
at java.lang.Thread.run(Thread.java:662)
11:54:34,307 ERROR [STDERR] java.rmi.RemoteException: Call invocation failed; nested exception is:
java.lang.StringIndexOutOfBoundsException: String index out of range: -1
11:54:34,323 ERROR [STDERR] at org.jboss.ws.core.jaxrpc.client.CallImpl.invokeInternal(CallImpl.java:535)
11:54:34,323 ERROR [STDERR] at org.jboss.ws.core.jaxrpc.client.CallImpl.invoke(CallImpl.java:275)
11:54:34,338 ERROR [STDERR] at org.jboss.ws.core.jaxrpc.client.PortProxy.invoke(PortProxy.java:154)
11:54:34,338 ERROR [STDERR] at $Proxy106.checkPlanData(Unknown Source)
11:54:34,354 ERROR [STDERR] at org.apache.jsp.index_jsp._jspService(index_jsp.java:88)
11:54:34,354 ERROR [STDERR] at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
11:54:34,370 ERROR [STDERR] at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
11:54:34,370 ERROR [STDERR] at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:369)
11:54:34,385 ERROR [STDERR] at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:322)
11:54:34,401 ERROR [STDERR] at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:249)
11:54:34,401 ERROR [STDERR] at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
11:54:34,417 ERROR [STDERR] at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
11:54:34,417 ERROR [STDERR] at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
11:54:34,432 ERROR [STDERR] at org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:96)
11:54:34,432 ERROR [STDERR] at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
11:54:34,448 ERROR [STDERR] at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
11:54:34,448 ERROR [STDERR] at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:235)
11:54:34,463 ERROR [STDERR] at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
11:54:34,463 ERROR [STDERR] at org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(SecurityAssociationValve.java:190)
11:54:34,479 ERROR [STDERR] at org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValve.java:92)
11:54:34,495 ERROR [STDERR] at org.jboss.web.tomcat.security.SecurityContextEstablishmentValve.process(SecurityContextEstablishmentValve.java:126)
11:54:34,495 ERROR [STDERR] at org.jboss.web.tomcat.security.SecurityContextEstablishmentValve.invoke(SecurityContextEstablishmentValve.java:70)
11:54:34,510 ERROR [STDERR] at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
11:54:34,510 ERROR [STDERR] at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
11:54:34,526 ERROR [STDERR] at org.jboss.web.tomcat.service.jca.CachedConnectionValve.invoke(CachedConnectionValve.java:158)
11:54:34,526 ERROR [STDERR] at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
11:54:34,542 ERROR [STDERR] at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:330)
11:54:34,542 ERROR [STDERR] at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:829)
11:54:34,557 ERROR [STDERR] at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:601)
11:54:34,557 ERROR [STDERR] at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:447)
11:54:34,573 ERROR [STDERR] at java.lang.Thread.run(Thread.java:662)
11:54:34,588 ERROR [STDERR] Caused by: java.lang.StringIndexOutOfBoundsException: String index out of range: -1
11:54:34,588 ERROR [STDERR] at java.lang.String.substring(String.java:1937)
11:54:34,604 ERROR [STDERR] at org.jboss.ws.core.client.EndpointInfo.lowerCaseProtocol(EndpointInfo.java:114)
11:54:34,604 ERROR [STDERR] at org.jboss.ws.core.client.EndpointInfo.<init>(EndpointInfo.java:49)
11:54:34,620 ERROR [STDERR] at org.jboss.ws.core.CommonClient.invoke(CommonClient.java:335)
11:54:34,620 ERROR [STDERR] at org.jboss.ws.core.jaxrpc.client.CallImpl.invokeInternal(CallImpl.java:516)
11:54:34,635 ERROR [STDERR] ... 30 more**
我不知道可能是什么问题,请帮帮我客户端代码如下:
<%@page import="java.util.Hashtable"%>
<%@page import="javax.naming.*,com.test.*,javax.xml.rpc.*,stub.*"%>
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<html><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8"><title>JSP
Page</title></head><body>
<h1>Hello World!</h1>
<%
try{
InitialContext ic = new InitialContext( );
CarrierWS service = (CarrierWS)ic.lookup("java:comp/env/service/CarrierWS");
out.println("======================="+service.getCarrierWSSEIPort().checkPlanData("2007-01-01"));
}
catch(Exception e)
{
out.println("Exception occurred : " + e.getMessage());
e.printStackTrace();
}
%>
</body>
</html>
提前致谢
塞特希
答案 0 :(得分:2)
您是否正确配置了endpoint
?
方法EndpointInfo.lowerCaseProtocol
的内容表明你错了。
private String lowerCaseProtocol(String targetAddress) {
int colonIndex = targetAddress.indexOf(':');
String lowerCasedProtocol = targetAddress.substring(0, colonIndex).toLowerCase();
return lowerCasedProtocol + targetAddress.substring(colonIndex);
}
endpoint
中似乎没有“:”,这意味着endIndex
方法中的substring
小于beginIndex
,因此StringIndexOutOfBoundsException
检查您的配置,然后重试。
答案 1 :(得分:0)
您得到的错误:StringIndexOutOfBoundsException
表示代码中的某个地方您试图获取集合中的项目但该集合没有您想要获取的索引。
所以,例如:
//lets say myList contains 10 items
List myList = new ArrayList();
myList.get(10) // will throw StringIndexOutOfBoundsException since there is no index 10
因为在jsp代码中我没有看到任何使用集合,我猜测问题出在服务/ EJB本身。
答案 2 :(得分:0)
我遇到了这个问题,问题是我在背书文件夹中复制了错误的jars版本。
解决方案是复制
jboss-common-core.jar
jboss-logging-spi.jar
jbossws-native-jaxrpc.jar
jbossws-native-jaxws.jar
jbossws-native-jaxws-ext.jar
jbossws-native-saaj.jar
从\ client文件夹到背书文件夹。这解决了我的问题