Uploaded image for project: 'JBoss Transaction Manager'
  1. JBoss Transaction Manager
  2. JBTM-3206

StringIndexOutOfBoundsException in Spring Boot JAX-RS

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Done
    • Icon: Major Major
    • 5.10.1.Final
    • None
    • LRA
    • None

      I have two same services (flight from the lra quickstart). One is original, another is Spring Boot with JAX-RS endpoint.
      The service is sitting on the root path

       http://localhost:8083 

      When I run the Spring Boot application and call the endpoint, the error is thrown:

      2019-10-02 10:21:02.944 ERROR 8482 --- [nio-8083-exec-4] o.a.c.c.C.[.[.[.[.m.t.f.JerseyConfig]    : Servlet.service() for servlet [org.mkralik.testing.flight.JerseyConfig] in context with path [] threw exception [java.lang.StringIndexOutOfBoundsException: String index out of range: -1] with root cause
      
      java.lang.StringIndexOutOfBoundsException: String index out of range: -1
      	at java.lang.String.substring(String.java:1967) ~[na:1.8.0_222]
      	at io.narayana.lra.client.NarayanaLRAClient.getTerminationUris(NarayanaLRAClient.java:398) ~[lra-client-5.9.6.Final.jar!/:5.9.6.Final]
      	at io.narayana.lra.filter.ServerLRAFilter.filter(ServerLRAFilter.java:301) ~[lra-filters-5.9.6.Final.jar!/:5.9.6.Final]
      	at org.glassfish.jersey.server.ContainerFilteringStage.apply(ContainerFilteringStage.java:132) ~[jersey-server-2.27.jar!/:na]
      	at org.glassfish.jersey.server.ContainerFilteringStage.apply(ContainerFilteringStage.java:68) ~[jersey-server-2.27.jar!/:na]
      	at org.glassfish.jersey.process.internal.Stages.process(Stages.java:197) ~[jersey-common-2.27.jar!/:na]
      	at org.glassfish.jersey.server.ServerRuntime$1.run(ServerRuntime.java:269) ~[jersey-server-2.27.jar!/:na]
      	at org.glassfish.jersey.internal.Errors$1.call(Errors.java:272) ~[jersey-common-2.27.jar!/:na]
      	at org.glassfish.jersey.internal.Errors$1.call(Errors.java:268) ~[jersey-common-2.27.jar!/:na]
      	at org.glassfish.jersey.internal.Errors.process(Errors.java:316) ~[jersey-common-2.27.jar!/:na]
      	at org.glassfish.jersey.internal.Errors.process(Errors.java:298) ~[jersey-common-2.27.jar!/:na]
      	at org.glassfish.jersey.internal.Errors.process(Errors.java:268) ~[jersey-common-2.27.jar!/:na]
      	at org.glassfish.jersey.process.internal.RequestScope.runInScope(RequestScope.java:289) ~[jersey-common-2.27.jar!/:na]
      	at org.glassfish.jersey.server.ServerRuntime.process(ServerRuntime.java:256) ~[jersey-server-2.27.jar!/:na]
      	at org.glassfish.jersey.server.ApplicationHandler.handle(ApplicationHandler.java:703) ~[jersey-server-2.27.jar!/:na]
      	at org.glassfish.jersey.servlet.WebComponent.serviceImpl(WebComponent.java:416) ~[jersey-container-servlet-core-2.27.jar!/:na]
      	at org.glassfish.jersey.servlet.WebComponent.service(WebComponent.java:370) ~[jersey-container-servlet-core-2.27.jar!/:na]
      	at org.glassfish.jersey.servlet.ServletContainer.service(ServletContainer.java:389) ~[jersey-container-servlet-core-2.27.jar!/:na]
      	at org.glassfish.jersey.servlet.ServletContainer.service(ServletContainer.java:342) ~[jersey-container-servlet-core-2.27.jar!/:na]
      	at org.glassfish.jersey.servlet.ServletContainer.service(ServletContainer.java:229) ~[jersey-container-servlet-core-2.27.jar!/:na]
      	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:231) ~[tomcat-embed-core-9.0.21.jar!/:9.0.21]
      	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166) ~[tomcat-embed-core-9.0.21.jar!/:9.0.21]
      	at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:53) ~[tomcat-embed-websocket-9.0.21.jar!/:9.0.21]
      	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193) ~[tomcat-embed-core-9.0.21.jar!/:9.0.21]
      	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166) ~[tomcat-embed-core-9.0.21.jar!/:9.0.21]
      	at org.springframework.web.filter.RequestContextFilter.doFilterInternal(RequestContextFilter.java:99) ~[spring-web-5.1.8.RELEASE.jar!/:5.1.8.RELEASE]
      	at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:109) ~[spring-web-5.1.8.RELEASE.jar!/:5.1.8.RELEASE]
      	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193) ~[tomcat-embed-core-9.0.21.jar!/:9.0.21]
      	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166) ~[tomcat-embed-core-9.0.21.jar!/:9.0.21]
      	at org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:200) ~[spring-web-5.1.8.RELEASE.jar!/:5.1.8.RELEASE]
      	at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:109) ~[spring-web-5.1.8.RELEASE.jar!/:5.1.8.RELEASE]
      	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193) ~[tomcat-embed-core-9.0.21.jar!/:9.0.21]
      	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166) ~[tomcat-embed-core-9.0.21.jar!/:9.0.21]
      	at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:202) ~[tomcat-embed-core-9.0.21.jar!/:9.0.21]
      	at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:96) [tomcat-embed-core-9.0.21.jar!/:9.0.21]
      	at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:490) [tomcat-embed-core-9.0.21.jar!/:9.0.21]
      	at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:139) [tomcat-embed-core-9.0.21.jar!/:9.0.21]
      	at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:92) [tomcat-embed-core-9.0.21.jar!/:9.0.21]
      	at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:74) [tomcat-embed-core-9.0.21.jar!/:9.0.21]
      	at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:343) [tomcat-embed-core-9.0.21.jar!/:9.0.21]
      	at org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:408) [tomcat-embed-core-9.0.21.jar!/:9.0.21]
      	at org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:66) [tomcat-embed-core-9.0.21.jar!/:9.0.21]
      	at org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:853) [tomcat-embed-core-9.0.21.jar!/:9.0.21]
      	at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1587) [tomcat-embed-core-9.0.21.jar!/:9.0.21]
      	at org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:49) [tomcat-embed-core-9.0.21.jar!/:9.0.21]
      	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149) [na:1.8.0_222]
      	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624) [na:1.8.0_222]
      	at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61) [tomcat-embed-core-9.0.21.jar!/:9.0.21]
      	at java.lang.Thread.run(Thread.java:748) [na:1.8.0_222]
      

      I noticed that when I call the endpoint the method containerRequestContext.getUriInfo().getPath() returns:

      • For original Thorntail service : "/"
      • For service in Attachment SpringBoot + JAX RS: ""

      That causes that with empty string, the getTerminationUris method fail on StringIndexOutOfBoundsException.

      I attached the project with Narayana 5.9.6 due to JBTM-3161

            rhn-engineering-mmusgrov Michael Musgrove
            mkralik@redhat.com Matej Kralik
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: