1 Reply Latest reply on Aug 2, 2012 10:00 AM by pferraro

    infinispan jndi problem

    akhuting

      Hi.

      I use the domain model deployed two JBoss Cluster,

       

      I want to use distributed cache in the cluster and add a this cache container configuration to the full-ha profile:

       

      <cache-container name="jboss-as7-quickstart" default-cache="jboss-as7-quickstart-cache">
          <transport lock-timeout="60000"/>
          <distributed-cache owners="1" mode="SYNC" name="jboss-as7-quickstart-cache" start="EAGER"/>
      </cache-container>

       

      Jndi error when I use spring mvc :

       

       

      @RequestMapping("/demo")
          public String demo() {
                  Context ctx = new InitialContext(   );
                  CacheContainer container = (CacheContainer) ctx.lookup("java:jboss/infinispan/container/jboss-as7-quickstart");
              return "success";
          }
      

       

      error:

       

      01:25:39,063 INFO  [org.jboss.as.ejb3.deployment.processors.EjbJndiBindingsDeploymentUnitProcessor] (MSC service thread 1-1) JNDI bindings for session bean named Resources in deployment unit deployment "spring.war" are as follows:
      
          java:global/spring/Resources!org.infinispan.quickstart.jbossas7.Resources
          java:app/spring/Resources!org.infinispan.quickstart.jbossas7.Resources
          java:module/Resources!org.infinispan.quickstart.jbossas7.Resources
          java:global/spring/Resources
          java:app/spring/Resources
          java:module/Resources
      
      01:25:39,536 INFO  [org.jboss.weld.deployer] (MSC service thread 1-1) JBAS016005: Starting Services for CDI deployment: spring.war
      01:25:39,896 INFO  [org.jboss.weld.deployer] (MSC service thread 1-1) JBAS016008: Starting weld service for deployment spring.war
      01:25:40,394 INFO  [org.infinispan.cdi.InfinispanExtension] (MSC service thread 1-1) ISPN017001: Infinispan CDI extension version: 5.1.4.FINAL
      01:25:40,438 INFO  [org.jboss.solder.config.xml.bootstrap.XmlConfigExtension] (MSC service thread 1-1) Solder Config XML provider starting...
      01:25:40,459 INFO  [org.jboss.solder.config.xml.bootstrap.XmlConfigExtension] (MSC service thread 1-1) Loading XmlDocumentProvider: org.jboss.solder.config.xml.bootstrap.ResourceLoaderXmlDocumentProvider
      01:25:40,537 INFO  [org.jboss.solder.config.xml.bootstrap.XmlConfigExtension] (MSC service thread 1-1) Reading XML file: vfs:/content/spring.war/WEB-INF/lib/infinispan-cdi-5.1.4.FINAL.jar/META-INF/beans.xml
      01:25:40,603 INFO  [org.jboss.solder.Version] (MSC service thread 1-1) Solder 3.1.0.Final (build id: 3.1.0.Final)
      01:25:47,811 INFO  [org.jboss.solder.bean.defaultbean.DefaultBeanExtension] (MSC service thread 1-2) Preventing install of default bean Producer Method [EmbeddedCacheManager] with qualifiers [@Any @Synthetic] declared as [[method] @Produces @ApplicationScoped @DefaultBean public org.infinispan.cdi.DefaultEmbeddedCacheManagerProducer.getDefaultEmbeddedCacheManager(Instance<EmbeddedCacheManager>, Configuration)]
      01:25:48,621 INFO  [org.jboss.solder.bean.defaultbean.DefaultBeanExtension] (MSC service thread 1-1) Preventing install of default bean Producer Method [EmbeddedCacheManager] with qualifiers [@Any @Synthetic] declared as [[method] @Produces @ApplicationScoped @DefaultBean public org.infinispan.cdi.DefaultEmbeddedCacheManagerProducer.getDefaultEmbeddedCacheManager(Instance<EmbeddedCacheManager>, Configuration)]
      01:25:48,772 信息    [javax.enterprise.resource.webcontainer.jsf.config] (MSC service thread 1-2) 初始化上下文 '/infinispan-jboss-as7' 的 Mojarra 2.1.7-jbossorg-1 (20120227-1401)
      01:25:50,359 INFO  [org.apache.catalina.core.ContainerBase.[jboss.web].[default-host].[/spring]] (MSC service thread 1-1) Initializing Spring root WebApplicationContext
      01:25:50,371 INFO  [org.springframework.web.context.ContextLoader] (MSC service thread 1-1) Root WebApplicationContext: initialization started
      01:25:50,611 INFO  [org.springframework.web.context.support.XmlWebApplicationContext] (MSC service thread 1-1) Refreshing Root WebApplicationContext: startup date [Fri Jul 27 01:25:50 CST 2012]; root of context hierarchy
      01:25:50,917 INFO  [org.springframework.beans.factory.xml.XmlBeanDefinitionReader] (MSC service thread 1-1) Loading XML bean definitions from class path resource [conf/applicationContext.xml]
      01:25:51,568 INFO  [org.springframework.context.annotation.ClassPathBeanDefinitionScanner] (MSC service thread 1-1) JSR-250 'javax.annotation.ManagedBean' found and supported for component scanning
      01:25:51,573 INFO  [org.springframework.context.annotation.ClassPathBeanDefinitionScanner] (MSC service thread 1-1) JSR-330 'javax.inject.Named' annotation found and supported for component scanning
      01:25:53,859 INFO  [org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor] (MSC service thread 1-1) JSR-330 'javax.inject.Inject' annotation found and supported for autowiring
      01:25:53,936 INFO  [org.springframework.beans.factory.support.DefaultListableBeanFactory] (MSC service thread 1-1) Pre-instantiating singletons in org.springframework.beans.factory.support.DefaultListableBeanFactory@17b218b: defining beans [userService,org.springframework.context.annotation.internalConfigurationAnnotationProcessor,org.springframework.context.annotation.internalAutowiredAnnotationProcessor,org.springframework.context.annotation.internalRequiredAnnotationProcessor,org.springframework.context.annotation.internalCommonAnnotationProcessor]; root of factory hierarchy
      01:25:54,059 INFO  [org.springframework.web.context.ContextLoader] (MSC service thread 1-1) Root WebApplicationContext: initialization completed in 3679 ms
      01:25:54,226 INFO  [solder-servlet] (MSC service thread 1-1) Catch Integration for Servlets enabled
      01:25:54,252 INFO  [org.apache.catalina.core.ContainerBase.[jboss.web].[default-host].[/spring]] (MSC service thread 1-1) Initializing Spring FrameworkServlet 'springServlet'
      01:25:54,254 INFO  [org.springframework.web.servlet.DispatcherServlet] (MSC service thread 1-1) FrameworkServlet 'springServlet': initialization started
      01:25:54,300 INFO  [org.springframework.web.context.support.XmlWebApplicationContext] (MSC service thread 1-1) Refreshing WebApplicationContext for namespace 'springServlet-servlet': startup date [Fri Jul 27 01:25:54 CST 2012]; parent: Root WebApplicationContext
      01:25:54,332 INFO  [org.springframework.beans.factory.xml.XmlBeanDefinitionReader] (MSC service thread 1-1) Loading XML bean definitions from ServletContext resource [/WEB-INF/springServlet-servlet.xml]
      01:25:55,155 INFO  [org.springframework.context.annotation.ClassPathBeanDefinitionScanner] (MSC service thread 1-1) JSR-250 'javax.annotation.ManagedBean' found and supported for component scanning
      01:25:55,181 INFO  [org.springframework.context.annotation.ClassPathBeanDefinitionScanner] (MSC service thread 1-1) JSR-330 'javax.inject.Named' annotation found and supported for component scanning
      01:25:55,912 INFO  [org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor] (MSC service thread 1-1) JSR-330 'javax.inject.Inject' annotation found and supported for autowiring
      01:25:56,404 INFO  [org.springframework.beans.factory.support.DefaultListableBeanFactory] (MSC service thread 1-1) Pre-instantiating singletons in org.springframework.beans.factory.support.DefaultListableBeanFactory@1d05cdb: defining beans [myHandlerExceptionResolver,userController,org.springframework.context.annotation.internalConfigurationAnnotationProcessor,org.springframework.context.annotation.internalAutowiredAnnotationProcessor,org.springframework.context.annotation.internalRequiredAnnotationProcessor,org.springframework.context.annotation.internalCommonAnnotationProcessor,org.springframework.web.servlet.view.InternalResourceViewResolver#0,org.springframework.web.servlet.mvc.annotation.DefaultAnnotationHandlerMapping#0,org.springframework.validation.beanvalidation.LocalValidatorFactoryBean#0,org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter#0,org.springframework.web.servlet.handler.MappedInterceptor#0,messageSource,conversionService,org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter#1,messageConverters,xmlMarshaller,org.springframework.web.servlet.view.freemarker.FreeMarkerConfigurer#0,org.springframework.web.servlet.view.freemarker.FreeMarkerViewResolver#0,org.springframework.web.servlet.view.XmlViewResolver#0,org.springframework.web.servlet.view.ResourceBundleViewResolver#0,org.springframework.web.servlet.view.ContentNegotiatingViewResolver#0,localeResolver,org.springframework.web.servlet.handler.MappedInterceptor#1,multipartResolver,org.springframework.web.servlet.mvc.HttpRequestHandlerAdapter,org.springframework.web.servlet.resource.DefaultServletHttpRequestHandler#0,org.springframework.web.servlet.handler.SimpleUrlHandlerMapping#0,rpe,org.springframework.web.servlet.resource.ResourceHttpRequestHandler#0,org.springframework.web.servlet.handler.SimpleUrlHandlerMapping#1]; parent: org.springframework.beans.factory.support.DefaultListableBeanFactory@17b218b
      01:25:58,832 INFO  [solder-servlet] (MSC service thread 1-2) Catch Integration for Servlets enabled
      01:25:58,859 INFO  [org.jboss.web] (MSC service thread 1-2) JBAS018210: Registering web context: /infinispan-jboss-as7
      01:26:01,805 INFO  [org.springframework.web.servlet.view.freemarker.FreeMarkerConfigurer] (MSC service thread 1-1) ClassTemplateLoader for Spring macros added to FreeMarker configuration
      01:26:01,867 INFO  [org.springframework.beans.factory.xml.XmlBeanDefinitionReader] (MSC service thread 1-1) Loading XML bean definitions from ServletContext resource [/WEB-INF/views/baobaotao-views.xml]
      01:26:01,957 INFO  [org.springframework.web.context.support.GenericWebApplicationContext] (MSC service thread 1-1) Refreshing org.springframework.web.context.support.GenericWebApplicationContext@154e317: startup date [Fri Jul 27 01:26:01 CST 2012]; parent: WebApplicationContext for namespace 'springServlet-servlet'
      01:26:01,976 INFO  [org.springframework.beans.factory.support.DefaultListableBeanFactory] (MSC service thread 1-1) Pre-instantiating singletons in org.springframework.beans.factory.support.DefaultListableBeanFactory@a3cf94: defining beans [userListJson1,userListExcel1,userListPdf1]; parent: org.springframework.beans.factory.support.DefaultListableBeanFactory@1d05cdb
      01:26:02,198 INFO  [org.springframework.web.servlet.handler.SimpleUrlHandlerMapping] (MSC service thread 1-1) Mapped URL path [/**] onto handler 'org.springframework.web.servlet.resource.DefaultServletHttpRequestHandler#0'
      01:26:02,358 INFO  [org.springframework.web.servlet.handler.SimpleUrlHandlerMapping] (MSC service thread 1-1) Mapped URL path [/resources-1.2.1/**] onto handler 'org.springframework.web.servlet.resource.ResourceHttpRequestHandler#0'
      01:26:02,641 INFO  [org.springframework.web.servlet.DispatcherServlet] (MSC service thread 1-1) FrameworkServlet 'springServlet': initialization completed in 8361 ms
      01:26:02,663 INFO  [org.jboss.web] (MSC service thread 1-1) JBAS018210: Registering web context: /spring
      01:26:02,768 INFO  [org.jboss.as.server] (Controller Boot Thread) JBAS018559: Deployed "spring.war"
      01:26:02,787 INFO  [org.jboss.as.server] (Controller Boot Thread) JBAS018559: Deployed "infinispan-jboss-as7.war"
      01:26:02,788 INFO  [org.jboss.as.server] (Controller Boot Thread) JBAS018559: Deployed "demo.war"
      01:26:02,841 INFO  [org.jboss.as] (Controller Boot Thread) JBAS015874: JBoss AS 7.1.1.Final "Brontes" started in 62267ms - Started 706 of 845 services (138 services are passive or on-demand)
      01:26:17,586 INFO  [stdout] (http-172.16.146.79-172.16.146.79-8330-1) -----------------------------------------------------------------------
      01:26:17,595 ERROR [stderr] (http-172.16.146.79-172.16.146.79-8330-1) java.lang.ClassCastException: org.jboss.as.clustering.infinispan.DefaultEmbeddedCacheManager cannot be cast to org.infinispan.manager.CacheContainer
      01:26:17,598 ERROR [stderr] (http-172.16.146.79-172.16.146.79-8330-1)     at com.baobaotao.web.UserController.demo(UserController.java:596)
      01:26:17,603 ERROR [stderr] (http-172.16.146.79-172.16.146.79-8330-1)     at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      01:26:17,605 ERROR [stderr] (http-172.16.146.79-172.16.146.79-8330-1)     at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
      01:26:17,611 ERROR [stderr] (http-172.16.146.79-172.16.146.79-8330-1)     at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
      01:26:17,616 ERROR [stderr] (http-172.16.146.79-172.16.146.79-8330-1)     at java.lang.reflect.Method.invoke(Method.java:597)
      01:26:17,617 ERROR [stderr] (http-172.16.146.79-172.16.146.79-8330-1)     at org.springframework.web.bind.annotation.support.HandlerMethodInvoker.invokeHandlerMethod(HandlerMethodInvoker.java:176)
      01:26:17,623 ERROR [stderr] (http-172.16.146.79-172.16.146.79-8330-1)     at org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter.invokeHandlerMethod(AnnotationMethodHandlerAdapter.java:426)
      01:26:17,625 ERROR [stderr] (http-172.16.146.79-172.16.146.79-8330-1)     at org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter.handle(AnnotationMethodHandlerAdapter.java:414)
      01:26:17,635 ERROR [stderr] (http-172.16.146.79-172.16.146.79-8330-1)     at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:790)
      01:26:17,637 ERROR [stderr] (http-172.16.146.79-172.16.146.79-8330-1)     at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:719)
      01:26:17,642 ERROR [stderr] (http-172.16.146.79-172.16.146.79-8330-1)     at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:644)
      01:26:17,645 ERROR [stderr] (http-172.16.146.79-172.16.146.79-8330-1)     at org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:549)
      01:26:17,646 ERROR [stderr] (http-172.16.146.79-172.16.146.79-8330-1)     at javax.servlet.http.HttpServlet.service(HttpServlet.java:734)
      01:26:17,649 ERROR [stderr] (http-172.16.146.79-172.16.146.79-8330-1)     at javax.servlet.http.HttpServlet.service(HttpServlet.java:847)
      01:26:17,656 ERROR [stderr] (http-172.16.146.79-172.16.146.79-8330-1)     at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:329)
      01:26:17,658 ERROR [stderr] (http-172.16.146.79-172.16.146.79-8330-1)     at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:248)
      01:26:17,663 ERROR [stderr] (http-172.16.146.79-172.16.146.79-8330-1)     at org.springframework.web.filter.HiddenHttpMethodFilter.doFilterInternal(HiddenHttpMethodFilter.java:77)
      01:26:17,669 ERROR [stderr] (http-172.16.146.79-172.16.146.79-8330-1)     at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:76)
      01:26:17,675 ERROR [stderr] (http-172.16.146.79-172.16.146.79-8330-1)     at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:280)
      01:26:17,678 ERROR [stderr] (http-172.16.146.79-172.16.146.79-8330-1)     at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:248)
      01:26:17,684 ERROR [stderr] (http-172.16.146.79-172.16.146.79-8330-1)     at org.jboss.weld.servlet.ConversationPropagationFilter.doFilter(ConversationPropagationFilter.java:62)
      01:26:17,685 ERROR [stderr] (http-172.16.146.79-172.16.146.79-8330-1)     at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:280)
      01:26:17,690 ERROR [stderr] (http-172.16.146.79-172.16.146.79-8330-1)     at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:248)
      01:26:17,697 ERROR [stderr] (http-172.16.146.79-172.16.146.79-8330-1)     at org.jboss.solder.servlet.exception.CatchExceptionFilter.doFilter(CatchExceptionFilter.java:65)
      01:26:17,699 ERROR [stderr] (http-172.16.146.79-172.16.146.79-8330-1)     at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:280)
      01:26:17,701 ERROR [stderr] (http-172.16.146.79-172.16.146.79-8330-1)     at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:248)
      01:26:17,709 ERROR [stderr] (http-172.16.146.79-172.16.146.79-8330-1)     at org.jboss.solder.servlet.event.ServletEventBridgeFilter.doFilter(ServletEventBridgeFilter.java:74)
      01:26:17,712 ERROR [stderr] (http-172.16.146.79-172.16.146.79-8330-1)     at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:280)
      01:26:17,717 ERROR [stderr] (http-172.16.146.79-172.16.146.79-8330-1)     at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:248)
      01:26:17,719 ERROR [stderr] (http-172.16.146.79-172.16.146.79-8330-1)     at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:275)
      01:26:17,724 ERROR [stderr] (http-172.16.146.79-172.16.146.79-8330-1)     at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:161)
      01:26:17,728 ERROR [stderr] (http-172.16.146.79-172.16.146.79-8330-1)     at org.jboss.modcluster.container.jbossweb.JBossWebContext$RequestListenerValve.event(JBossWebContext.java:67)
      01:26:17,733 ERROR [stderr] (http-172.16.146.79-172.16.146.79-8330-1)     at org.jboss.modcluster.container.jbossweb.JBossWebContext$RequestListenerValve.invoke(JBossWebContext.java:48)
      01:26:17,739 ERROR [stderr] (http-172.16.146.79-172.16.146.79-8330-1)     at org.jboss.as.web.security.SecurityContextAssociationValve.invoke(SecurityContextAssociationValve.java:153)
      01:26:17,741 ERROR [stderr] (http-172.16.146.79-172.16.146.79-8330-1)     at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:155)
      01:26:17,745 ERROR [stderr] (http-172.16.146.79-172.16.146.79-8330-1)     at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
      01:26:17,750 ERROR [stderr] (http-172.16.146.79-172.16.146.79-8330-1)     at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
      01:26:17,751 ERROR [stderr] (http-172.16.146.79-172.16.146.79-8330-1)     at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:368)
      01:26:17,756 ERROR [stderr] (http-172.16.146.79-172.16.146.79-8330-1)     at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:877)
      01:26:17,758 ERROR [stderr] (http-172.16.146.79-172.16.146.79-8330-1)     at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:671)
      01:26:17,765 ERROR [stderr] (http-172.16.146.79-172.16.146.79-8330-1)     at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:930)
      01:26:17,770 ERROR [stderr] (http-172.16.146.79-172.16.146.79-8330-1)     at java.lang.Thread.run(Thread.java:662)
      01:26:17,870 INFO  [org.springframework.web.context.support.GenericWebApplicationContext] (http-172.16.146.79-172.16.146.79-8330-1) Refreshing org.springframework.web.context.support.GenericWebApplicationContext@1b508b6: startup date [Fri Jul 27 01:26:17 CST 2012]; parent: WebApplicationContext for namespace 'springServlet-servlet'
      01:26:17,874 INFO  [org.springframework.beans.factory.support.DefaultListableBeanFactory] (http-172.16.146.79-172.16.146.79-8330-1) Pre-instantiating singletons in org.springframework.beans.factory.support.DefaultListableBeanFactory@4382f9: defining beans [userListi18n]; parent: org.springframework.beans.factory.support.DefaultListableBeanFactory@1d05cdb
      

       

      There is no other way in the spring , thks


      My English is not very good I am from China

       


        • 1. Re: infinispan jndi problem
          pferraro

          I'm guessing that you have infinispan jars bundled with your application.  You'll need to remove these.  AS7 already supplies these - hence the classloader conflict.

           

          Also, you don't need to start your cache container eagerly if you inject the CacheContainer into your bean rather than rely on a vanilla JNDI lookup.

          e.g.

           

          {code}@Resource(lookup="java:jboss/infinispan/container/jboss-as7-quickstart")

          private CacheContainer container;{code}

           

          That way, your cache container will properly shutdown when your application is undeployed.

           

          N.B. You'll need to compile using JEE 1.6, since the Resource annotation in JSE 1.6 does not include the lookup property.