3 Replies Latest reply on Sep 11, 2012 5:43 AM by dcsdb

    StringIndexOutOfBoundsException hibernate4 getCacheRegionNames ?

    cstachris Newbie

      Hi - I've just been porting my app from glassfish3 to jboss-7.1.0.CR1 and now jboss-7.1.0.Final and in the last hour have been getting this exception on deployment - can anyone give me a hint as to where to look or how to fix it?

       

      22:03:05,981 ERROR [org.jboss.as.controller.management-operation] (HttpManagementService-threads - 3) JBAS014612: Operation ("deploy") failed - address: ([("deployment" => "earProject-1.0-SNAPSHOT.ear")]): java.lang.StringIndexOutOfBoundsException: String index out of range: -17

          at java.lang.String.substring(String.java:1937) [classes.jar:1.6.0_24]

          at java.lang.String.substring(String.java:1904) [classes.jar:1.6.0_24]

          at org.jboss.as.jpa.hibernate4.management.HibernateStatisticsResource.getCacheRegionNames(HibernateStatisticsResource.java:319)

          at org.jboss.as.jpa.hibernate4.management.HibernateStatisticsResource.getChildren(HibernateStatisticsResource.java:200)

          at org.jboss.as.controller.registry.BasicResource$DelegateResource.getChildren(BasicResource.java:294) [jboss-as-controller-7.1.0.Final.jar:7.1.0.Final]

          at org.jboss.as.controller.registry.Resource$Tools.readModel(Resource.java:245) [jboss-as-controller-7.1.0.Final.jar:7.1.0.Final]

          at org.jboss.as.controller.registry.Resource$Tools.readModel(Resource.java:232) [jboss-as-controller-7.1.0.Final.jar:7.1.0.Final]

          at org.jboss.as.controller.registry.Resource$Tools.readModel(Resource.java:219) [jboss-as-controller-7.1.0.Final.jar:7.1.0.Final]

          at org.jboss.as.controller.registry.Resource$Tools.readModel(Resource.java:247) [jboss-as-controller-7.1.0.Final.jar:7.1.0.Final]

          at org.jboss.as.controller.registry.Resource$Tools.readModel(Resource.java:232) [jboss-as-controller-7.1.0.Final.jar:7.1.0.Final]

          at org.jboss.as.controller.registry.Resource$Tools.readModel(Resource.java:219) [jboss-as-controller-7.1.0.Final.jar:7.1.0.Final]

          at org.jboss.as.controller.registry.Resource$Tools.readModel(Resource.java:247) [jboss-as-controller-7.1.0.Final.jar:7.1.0.Final]

          at org.jboss.as.controller.registry.Resource$Tools.readModel(Resource.java:232) [jboss-as-controller-7.1.0.Final.jar:7.1.0.Final]

          at org.jboss.as.controller.registry.Resource$Tools.readModel(Resource.java:219) [jboss-as-controller-7.1.0.Final.jar:7.1.0.Final]

          at org.jboss.as.controller.registry.Resource$Tools.readModel(Resource.java:247) [jboss-as-controller-7.1.0.Final.jar:7.1.0.Final]

          at org.jboss.as.controller.registry.Resource$Tools.readModel(Resource.java:232) [jboss-as-controller-7.1.0.Final.jar:7.1.0.Final]

          at org.jboss.as.controller.registry.Resource$Tools.readModel(Resource.java:219) [jboss-as-controller-7.1.0.Final.jar:7.1.0.Final]

          at org.jboss.as.controller.registry.Resource$Tools.readModel(Resource.java:247) [jboss-as-controller-7.1.0.Final.jar:7.1.0.Final]

          at org.jboss.as.controller.registry.Resource$Tools.readModel(Resource.java:232) [jboss-as-controller-7.1.0.Final.jar:7.1.0.Final]

          at org.jboss.as.controller.registry.Resource$Tools.readModel(Resource.java:219) [jboss-as-controller-7.1.0.Final.jar:7.1.0.Final]

          at org.jboss.as.controller.registry.Resource$Tools.readModel(Resource.java:208) [jboss-as-controller-7.1.0.Final.jar:7.1.0.Final]

          at org.jboss.as.controller.ModelControllerImpl.writeModel(ModelControllerImpl.java:382) [jboss-as-controller-7.1.0.Final.jar:7.1.0.Final]

          at org.jboss.as.controller.OperationContextImpl.createPersistenceResource(OperationContextImpl.java:158) [jboss-as-controller-7.1.0.Final.jar:7.1.0.Final]

          at org.jboss.as.controller.AbstractOperationContext.doCompleteStep(AbstractOperationContext.java:309) [jboss-as-controller-7.1.0.Final.jar:7.1.0.Final]

          at org.jboss.as.controller.AbstractOperationContext.completeStep(AbstractOperationContext.java:202) [jboss-as-controller-7.1.0.Final.jar:7.1.0.Final]

          at org.jboss.as.controller.AbstractOperationContext.finishStep(AbstractOperationContext.java:453) [jboss-as-controller-7.1.0.Final.jar:7.1.0.Final]

          at org.jboss.as.controller.AbstractOperationContext.executeStep(AbstractOperationContext.java:440) [jboss-as-controller-7.1.0.Final.jar:7.1.0.Final]

          at org.jboss.as.controller.AbstractOperationContext.doCompleteStep(AbstractOperationContext.java:274) [jboss-as-controller-7.1.0.Final.jar:7.1.0.Final]

          at org.jboss.as.controller.AbstractOperationContext.completeStep(AbstractOperationContext.java:202) [jboss-as-controller-7.1.0.Final.jar:7.1.0.Final]

          at org.jboss.as.server.deployment.DeploymentHandlerUtil$1.execute(DeploymentHandlerUtil.java:118) [jboss-as-server-7.1.0.Final.jar:7.1.0.Final]

          at org.jboss.as.controller.AbstractOperationContext.executeStep(AbstractOperationContext.java:387) [jboss-as-controller-7.1.0.Final.jar:7.1.0.Final]

          at org.jboss.as.controller.AbstractOperationContext.doCompleteStep(AbstractOperationContext.java:274) [jboss-as-controller-7.1.0.Final.jar:7.1.0.Final]

          at org.jboss.as.controller.AbstractOperationContext.completeStep(AbstractOperationContext.java:202) [jboss-as-controller-7.1.0.Final.jar:7.1.0.Final]

          at org.jboss.as.server.deployment.DeploymentDeployHandler.execute(DeploymentDeployHandler.java:73) [jboss-as-server-7.1.0.Final.jar:7.1.0.Final]

          at org.jboss.as.controller.AbstractOperationContext.executeStep(AbstractOperationContext.java:387) [jboss-as-controller-7.1.0.Final.jar:7.1.0.Final]

          at org.jboss.as.controller.AbstractOperationContext.doCompleteStep(AbstractOperationContext.java:274) [jboss-as-controller-7.1.0.Final.jar:7.1.0.Final]

          at org.jboss.as.controller.AbstractOperationContext.completeStep(AbstractOperationContext.java:202) [jboss-as-controller-7.1.0.Final.jar:7.1.0.Final]

          at org.jboss.as.controller.ModelControllerImpl$DefaultPrepareStepHandler.execute(ModelControllerImpl.java:461) [jboss-as-controller-7.1.0.Final.jar:7.1.0.Final]

          at org.jboss.as.controller.AbstractOperationContext.executeStep(AbstractOperationContext.java:387) [jboss-as-controller-7.1.0.Final.jar:7.1.0.Final]

          at org.jboss.as.controller.AbstractOperationContext.doCompleteStep(AbstractOperationContext.java:274) [jboss-as-controller-7.1.0.Final.jar:7.1.0.Final]

          at org.jboss.as.controller.AbstractOperationContext.completeStep(AbstractOperationContext.java:202) [jboss-as-controller-7.1.0.Final.jar:7.1.0.Final]

          at org.jboss.as.controller.ModelControllerImpl.execute(ModelControllerImpl.java:121) [jboss-as-controller-7.1.0.Final.jar:7.1.0.Final]

          at org.jboss.as.controller.ModelControllerImpl$1.execute(ModelControllerImpl.java:304) [jboss-as-controller-7.1.0.Final.jar:7.1.0.Final]

          at org.jboss.as.controller.ModelControllerImpl$1.execute(ModelControllerImpl.java:294) [jboss-as-controller-7.1.0.Final.jar:7.1.0.Final]

          at org.jboss.as.domain.http.server.DomainApiHandler.processRequest(DomainApiHandler.java:294) [jboss-as-domain-http-interface-7.1.0.Final.jar:7.1.0.Final]

          at org.jboss.as.domain.http.server.DomainApiHandler.doHandle(DomainApiHandler.java:201) [jboss-as-domain-http-interface-7.1.0.Final.jar:7.1.0.Final]

          at org.jboss.as.domain.http.server.DomainApiHandler.handle(DomainApiHandler.java:208) [jboss-as-domain-http-interface-7.1.0.Final.jar:7.1.0.Final]

          at org.jboss.as.domain.http.server.security.SubjectAssociationHandler.handle(SubjectAssociationHandler.java:51) [jboss-as-domain-http-interface-7.1.0.Final.jar:7.1.0.Final]

          at org.jboss.com.sun.net.httpserver.Filter$Chain.doFilter(Filter.java:78)

          at org.jboss.sun.net.httpserver.AuthFilter.doFilter(AuthFilter.java:69)

          at org.jboss.com.sun.net.httpserver.Filter$Chain.doFilter(Filter.java:81)

          at org.jboss.sun.net.httpserver.ServerImpl$Exchange$LinkHandler.handle(ServerImpl.java:710)

          at org.jboss.com.sun.net.httpserver.Filter$Chain.doFilter(Filter.java:78)

          at org.jboss.as.domain.http.server.RealmReadinessFilter.doFilter(RealmReadinessFilter.java:54) [jboss-as-domain-http-interface-7.1.0.Final.jar:7.1.0.Final]

          at org.jboss.com.sun.net.httpserver.Filter$Chain.doFilter(Filter.java:81)

          at org.jboss.sun.net.httpserver.ServerImpl$Exchange.run(ServerImpl.java:682)

          at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886) [classes.jar:1.6.0_24]

          at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908) [classes.jar:1.6.0_24]

          at java.lang.Thread.run(Thread.java:680) [classes.jar:1.6.0_24]

          at org.jboss.threads.JBossThread.run(JBossThread.java:122) [jboss-threads-2.0.0.GA.jar:2.0.0.GA]

       

       

      Attached is my persistence.xml

       

       

      Cheers

      Chris

        • 1. Re: StringIndexOutOfBoundsException hibernate4 getCacheRegionNames ?
          Scott Marlow Master

          Chris,

           

          Try commenting out the "hibernate.cache.region_prefix" property, I think that the bug is caused by your application setting it and the code mentioned above not expecting it to be set by the application.

           

          When you unset "hibernate.cache.region_prefix", it will be set internally to the fully application scoped persistence unit name.  The second level cache region names are expected to contain the fully scoped persistence unit name.  This is definitely a bug but I'm not yet sure of the fix (could be a change to not let the application override the "hibernate.cache.region_prefix" with a warning that it couldn't be changed).  An example of a fully scoped persistence unit name would look like "YourDeploymentFileName.jar#YourPersistenceUnitName".

           

          Question:  What would be the impact on your application, if AS7 didn't let you override the "hibernate.cache.region_prefix" setting? 

           

          After you verify that commenting out the "hibernate.cache.region_prefix" works around the problem, could you create a JPA issue that references this forum post.  The jira link is https://issues.jboss.org/browse/AS7.  There is not need to mention how the bug should be fixed, it would be helpful if you answer the above question here.

           

          Scott

          • 2. Re: StringIndexOutOfBoundsException hibernate4 getCacheRegionNames ?
            cstachris Newbie

            Scott you champion!  Thanks

             

            I've commented the value out and there's no exception.

            To answer your question, there would be no known impact on the application if I couldn't override the "hibernate.cache.region_prefix".  Not known because I have always had this setting in my persistence.xml

             

            Created a JIRA https://issues.jboss.org/browse/AS7-3858

             

            Cheers

            Chris

            • 3. Re: StringIndexOutOfBoundsException hibernate4 getCacheRegionNames ?
              dcsdb Newbie

              Hi Scott,

              we had the same problem (using JBoss AS 7.1.1) and, as a workaround, we have used a "hibernate.cache.region_prefix" longer than the name of our persistent unit (this workaround avoids the StringIndexOutOfBoundsException allowing the deploy).

               

              We have to do so because we have multiple deployments which, using a single PU, work on the same data. As a consequence our deployments must share cache regions to have a coherent view of shared data. To achieve this result we have overridden the default cache region prefix using the same value in each deployment.

               

              If you plan to disable such property, is there another way to obtain such result?

               

              Thank you.