0

我正在使用 Jboss 5.0.1 服务器并尝试对JAX-RPC我们应用程序中的 EJB 之一进行 Web 服务调用。我下载并复制了以下三个罐子JBOSS_HOME\server\default\libJBOSS_HOME\lib\endorsed

  • jboss-jaxrpc.jar
  • jboss-jaxws.jar
  • jboss-saaj.jar

我无法进行 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>

提前致谢

森提尔

4

3 回答 3

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这意味着您endIndexsubstring方法小于您的beginIndex,因此StringIndexOutOfBoundsException

检查您的配置,然后重试。

于 2012-07-05T10:45:44.793 回答
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 本身。

于 2012-07-05T08:03:08.390 回答
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 文件夹到背书文件夹。这解决了我的问题

于 2012-08-22T11:23:04.567 回答