4 Replies Latest reply on Apr 11, 2017 2:43 AM by Vincent Sourin

    Wildfly 10 - Infinispan cache & Naming external context

    Vincent Sourin Newbie

      Hello,

       

      I have a custom Infinispan replicated cache defined in my domain.xml :

       

      <subsystem xmlns="urn:jboss:domain:infinispan:4.0">
      [...]
      <cache-container name="bbj2as" default-cache="bbj2as-cache">
           <transport lock-timeout="60000"/>
           <replicated-cache name="bbj2as-cache" mode="SYNC">
                <transaction locking="OPTIMISTIC" mode="FULL_XA"/>
                <eviction strategy="LRU" max-entries="10000"/>
                <expiration max-idle="60000"/>
           </replicated-cache>
      </cache-container>
      [...]
      </subsystem>
      

       

      and I use it like that :

       

      @Resource(lookup = "java:jboss/infinispan/cache/bbj2as/default")
      private Cache<String, String> cache;
      

       

      Everything works fine until I add a new binding entry under naming subsystem.

      If I add that binding in domain.xml :

       

      <subsystem xmlns="urn:jboss:domain:naming:2.0">
           <bindings>
                <external-context name="java:global/remoteContext" module="org.apache.activemq.artemis" class="javax.naming.InitialContext">
                     <environment>
                          <property name="java.naming.factory.initial" value="org.apache.activemq.artemis.jndi.ActiveMQInitialContextFactory"/>
                          <property name="java.naming.provider.url" value="(tcp://X.X.X.X:61616)"/>
                          <property name="topic.t1" value="t1"/>
                     </environment>
                </external-context>
                <lookup name="java:/t1" lookup="java:global/remoteContext/t1"/>
           </bindings>
           <remote-naming/>
      </subsystem>
      

       

      I get that Exception when deploying my app :

       

       Caused by: javax.naming.NamingException: WFLYNAM0062: Failed to lookup env/corp.bae.bridgestone.websocket.CuringInformationEndpoint/cache [Root exception is java.lang.RuntimeException: WFLYNAM0059: Resource lookup for injection failed: java:jboss/infinispan/cache/bbj2as/default]
      [Server:test-as1]       at org.jboss.as.naming.ServiceBasedNamingStore.lookup(ServiceBasedNamingStore.java:159)
      [Server:test-as1]       at org.jboss.as.naming.ServiceBasedNamingStore.lookup(ServiceBasedNamingStore.java:83)
      [Server:test-as1]       at org.jboss.as.naming.NamingContext.lookup(NamingContext.java:207)
      [Server:test-as1]       at org.jboss.as.naming.NamingContext.lookup(NamingContext.java:193)
      [Server:test-as1]       at org.jboss.as.naming.NamingContext.lookup(NamingContext.java:189)
      [Server:test-as1]       at org.jboss.as.naming.deployment.ContextNames$BindInfo$1$1.getReference(ContextNames.java:316)
      [Server:test-as1]       ... 40 more
      [Server:test-as1] Caused by: java.lang.RuntimeException: WFLYNAM0059: Resource lookup for injection failed: java:jboss/infinispan/cache/bbj2as/default
      [Server:test-as1]       at org.jboss.as.naming.deployment.ContextNames$BindInfo$1$1.getReference(ContextNames.java:319)
      [Server:test-as1]       at org.jboss.as.naming.ServiceBasedNamingStore.lookup(ServiceBasedNamingStore.java:143)
      [Server:test-as1]       ... 45 more
      [Server:test-as1] Caused by: javax.naming.NameNotFoundException: infinispan/cache/bbj2as/default [Root exception is java.lang.IllegalStateException]
      [Server:test-as1]       at org.jboss.as.naming.ServiceBasedNamingStore.lookup(ServiceBasedNamingStore.java:153)
      [Server:test-as1]       at org.jboss.as.naming.ServiceBasedNamingStore.lookup(ServiceBasedNamingStore.java:83)
      [Server:test-as1]       at org.jboss.as.naming.NamingContext.lookup(NamingContext.java:207)
      [Server:test-as1]       at org.jboss.as.naming.NamingContext.lookup(NamingContext.java:193)
      [Server:test-as1]       at org.jboss.as.naming.NamingContext.lookup(NamingContext.java:189)
      [Server:test-as1]       at org.jboss.as.naming.deployment.ContextNames$BindInfo$1$1.getReference(ContextNames.java:316)
      [Server:test-as1]       ... 46 more
      [Server:test-as1] Caused by: java.lang.IllegalStateException
      [Server:test-as1]       at org.jboss.msc.value.InjectedValue.getValue(InjectedValue.java:47)
      [Server:test-as1]       at org.jboss.as.naming.service.BinderService.getValue(BinderService.java:142)
      [Server:test-as1]       at org.jboss.as.naming.service.BinderService.getValue(BinderService.java:46)
      [Server:test-as1]       at org.jboss.msc.service.ServiceControllerImpl.getValue(ServiceControllerImpl.java:1158)
      [Server:test-as1]       at org.jboss.as.naming.ServiceBasedNamingStore.lookup(ServiceBasedNamingStore.java:131)
      [Server:test-as1]       ... 51 more
      

       

      Can someone tell me what I am doing wrong ?

       

      Thanks.

       

      Vincent.

        • 1. Re: Wildfly 10 - Infinispan cache & Naming external context
          Paul Ferraro Master

          Have you tried injecting your Infinispan cache via a resource reference?

          Create a resource-ref in your deployment descriptor and inject the Cache via its res-ref-name.

          e.g.

          @Resource("cache/bbj2as")
          private Cache<String, String> cache;
          

          e.g.

          <resource-ref>
              <res-ref-name>cache/bbj2as</res-ref-name>
              <res-type>org.infinispan.Cache</res-type>
              <lookup-name>java:jboss/infinispan/cache/bbj2as/default</lookup-name>
          </resource-ref>
          
          • 2. Re: Wildfly 10 - Infinispan cache & Naming external context
            Vincent Sourin Newbie

            Hello Paul,

             

            I got the same kind of exception with a resource reference :

             

            [Server:test-as1] 14:11:54,478 ERROR [org.jboss.as.server] (ServerService Thread Pool -- 101) WFLYSRV0021: Deploy of deployment "BBj2AS-ear.ear" was rolled back with the following failure message:
            [Server:test-as1] {
            [Server:test-as1]    "WFLYCTL0080: Failed services" => {"jboss.deployment.subunit.\"BBj2AS-ear.ear\".\"IARDisplayPresses-1.0.1.war\".component.CuringInformationEndpoint.START" => "org.jboss.msc.service.StartException in service jboss.deployment.subunit.\"BBj2AS-ear.ear\".\"IARDisplayPresses-1.0.1.war\".component.CuringInformationEndpoint.START: java.lang.IllegalStateException: WFLYEE0042: Failed to construct component instance
            [Server:test-as1]    Caused by: java.lang.IllegalStateException: WFLYEE0042: Failed to construct component instance
            [Server:test-as1]    Caused by: javax.ejb.EJBException: java.lang.RuntimeException: WFLYNAM0059: Resource lookup for injection failed: env/corp.bae.bridgestone.websocket.CuringInformationEndpoint/cache
            [Server:test-as1]    Caused by: java.lang.RuntimeException: WFLYNAM0059: Resource lookup for injection failed: env/corp.bae.bridgestone.websocket.CuringInformationEndpoint/cache
            [Server:test-as1]    Caused by: java.lang.IllegalStateException: WFLYEE0042: Failed to construct component instance
            [Server:test-as1]    Caused by: javax.ejb.EJBException: java.lang.RuntimeException: WFLYNAM0059: Resource lookup for injection failed: env/corp.bae.bridgestone.websocket.CuringInformationEndpoint/cache
            [Server:test-as1]    Caused by: java.lang.RuntimeException: WFLYNAM0059: Resource lookup for injection failed: env/corp.bae.bridgestone.websocket.CuringInformationEndpoint/cache
            [Server:test-as1]    Caused by: javax.naming.NamingException: WFLYNAM0062: Failed to lookup env/corp.bae.bridgestone.websocket.CuringInformationEndpoint/cache [Root exception is java.lang.RuntimeException: WFLYNAM0059: Resource lookup for injection failed: env/cache/bbj2as]
            [Server:test-as1]    Caused by: java.lang.RuntimeException: WFLYNAM0059: Resource lookup for injection failed: env/cache/bbj2as
            [Server:test-as1]    Caused by: javax.naming.NamingException: WFLYNAM0062: Failed to lookup env/cache/bbj2as [Root exception is java.lang.RuntimeException: WFLYNAM0059: Resource lookup for injection failed: java:jboss/infinispan/cache/bbj2as/default]
            [Server:test-as1]    Caused by: java.lang.RuntimeException: WFLYNAM0059: Resource lookup for injection failed: java:jboss/infinispan/cache/bbj2as/default
            [Server:test-as1]    Caused by: java.lang.RuntimeException: WFLYNAM0059: Resource lookup for injection failed: env/cache/bbj2as
            [Server:test-as1]    Caused by: javax.naming.NamingException: WFLYNAM0062: Failed to lookup env/cache/bbj2as [Root exception is java.lang.RuntimeException: WFLYNAM0059: Resource lookup for injection failed: java:jboss/infinispan/cache/bbj2as/default]
            [Server:test-as1]    Caused by: java.lang.RuntimeException: WFLYNAM0059: Resource lookup for injection failed: java:jboss/infinispan/cache/bbj2as/default
            [Server:test-as1]    Caused by: javax.naming.NameNotFoundException: infinispan/cache/bbj2as/default [Root exception is java.lang.IllegalStateException]
            [Server:test-as1]    Caused by: java.lang.IllegalStateException"},
            [Server:test-as1]    "WFLYCTL0412: Required services that are not installed:" => ["jboss.deployment.subunit.\"BBj2AS-ear.ear\".\"IARDisplayPresses-1.0.1.war\".component.CuringInformationEndpoint.START"],
            [Server:test-as1]    "WFLYCTL0180: Services with missing/unavailable dependencies" => undefined
            [Server:test-as1] }
            [Server:test-as1]    Caused by: java.lang.IllegalStateException"},
            [Server:test-as1]    "WFLYCTL0412: Required services that are not installed:" => ["jboss.deployment.subunit.\"BBj2AS-ear.ear\".\"IARDisplayPresses-1.0.1.war\".component.CuringInformationEndpoint.START"],
            [Server:test-as1]    "WFLYCTL0180: Services with missing/unavailable dependencies" => undefined
            [Server:test-as1] }
            

             

            Exception which disappears as soon as I remove the <bindings> element in naming subsystem.

            • 3. Re: Wildfly 10 - Infinispan cache & Naming external context
              Paul Ferraro Master

              This is a bug.  I've opened [WFLY-8553] Adding external contexts breaks resolution of non-external on demand resources - JBoss Issue Tracker

              Strange as this sounds, you should be able to work around the issue by choosing a external context name that is lexicographically larger than "java:jboss/infinispan", e.g.

              <subsystem xmlns="urn:jboss:domain:naming:2.0"> 
                  <bindings> 
                        <external-context name="java:jboss/xternal/remoteContext" module="org.apache.activemq.artemis" class="javax.naming.InitialContext"> 
                            <environment> 
                                  <property name="java.naming.factory.initial" value="org.apache.activemq.artemis.jndi.ActiveMQInitialContextFactory"/> 
                                  <property name="java.naming.provider.url" value="(tcp://X.X.X.X:61616)"/> 
                                  <property name="topic.t1" value="t1"/> 
                            </environment> 
                        </external-context> 
                        <lookup name="java:/t1" lookup="java:jboss/xternal/remoteContext/t1"/> 
                  </bindings> 
                  <remote-naming/> 
              </subsystem>
              
              • 4. Re: Wildfly 10 - Infinispan cache & Naming external context
                Vincent Sourin Newbie

                Hello Paul,

                 

                Indeed the proposed work-around works for me.

                A big thank you for your time and help.

                 

                Vincent.