1 2 Previous Next 23 Replies Latest reply: Apr 3, 2013 11:25 AM by Tang Yong RSS

Infinispan 5.1.2 and Glassfish 3.1.2

Gregor Kovač Newbie

I'm trying to make mentioned products work together in an JEE application that I have.

I'm trying to override the default cache manager and start some named caches in advance. Then I want to inject that cache manager into one of my stateless EJBs.

This is the code I have:

- Config.java:

package com.mycompany;

import javax.enterprise.context.ApplicationScoped;
import javax.enterprise.inject.Produces;
import org.infinispan.configuration.cache.Configuration;
import org.infinispan.configuration.cache.ConfigurationBuilder;
import org.infinispan.eviction.EvictionStrategy;
import org.infinispan.manager.DefaultCacheManager;
import org.infinispan.manager.EmbeddedCacheManager;
import org.infinispan.transaction.lookup.GenericTransactionManagerLookup;

public class Config {
    @Produces
    @ApplicationScoped
    public EmbeddedCacheManager defaultEmbeddedCacheManager() {
        DefaultCacheManager returnCacheManager;


        ConfigurationBuilder builder = new ConfigurationBuilder();
        builder.eviction().strategy(EvictionStrategy.NONE).maxEntries(Integer.MAX_VALUE).transaction().transactionManagerLookup(new GenericTransactionManagerLookup()).expiration().lifespan(Long.valueOf(-1)).maxIdle(Long.valueOf(-1));
        Configuration config = builder.build();


        returnCacheManager = new DefaultCacheManager(config);
        String cacheNames[] = new String[2];
        cacheNames[0] = "cache1";
        cacheNames[1] = "cache2";
        returnCacheManager.startCaches(cacheNames);


        return returnCacheManager;
    }
}

 

- CacheBean.java:

package com.mycompany;

import javax.ejb.LocalBean;
import javax.ejb.Stateless;
import javax.inject.Inject;
import org.infinispan.manager.EmbeddedCacheManager;

@Stateless
@LocalBean
public class CacheBean {
    @Inject
    private EmbeddedCacheManager defaultCacheManager;
}

 

- pom.xml:

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <parent>
    <artifactId>TestJEE</artifactId>
    <groupId>com.mycompany</groupId>
    <version>1.0-SNAPSHOT</version>
  </parent>


    <groupId>com.mycompany</groupId>
    <artifactId>TestJEE-ejb</artifactId>
    <version>1.0-SNAPSHOT</version>
    <packaging>ejb</packaging>


    <name>TestJEE-ejb</name>


    <properties>
        <endorsed.dir>${project.build.directory}/endorsed</endorsed.dir>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    </properties>


    <dependencies>
        <dependency>
            <groupId>org.infinispan</groupId>
            <artifactId>infinispan-core</artifactId>
            <version>5.1.2.FINAL</version>
        </dependency>
        <dependency>
            <groupId>org.infinispan</groupId>
            <artifactId>infinispan-cdi</artifactId>
            <version>5.1.2.FINAL</version>
        </dependency>
        <dependency>
            <groupId>javax</groupId>
            <artifactId>javaee-api</artifactId>
            <version>6.0</version>
            <scope>provided</scope>
        </dependency>
    </dependencies>


    <build>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>2.3.2</version>
                <configuration>
                    <source>1.6</source>
                    <target>1.6</target>
                    <compilerArguments>
                        <endorseddirs>${endorsed.dir}</endorseddirs>
                    </compilerArguments>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-ejb-plugin</artifactId>
                <version>2.3</version>
                <configuration>
                    <ejbVersion>3.1</ejbVersion>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-dependency-plugin</artifactId>
                <version>2.1</version>
                <executions>
                    <execution>
                        <phase>validate</phase>
                        <goals>
                            <goal>copy</goal>
                        </goals>
                        <configuration>
                            <outputDirectory>${endorsed.dir}</outputDirectory>
                            <silent>true</silent>
                            <artifactItems>
                                <artifactItem>
                                    <groupId>javax</groupId>
                                    <artifactId>javaee-endorsed-api</artifactId>
                                    <version>6.0</version>
                                    <type>jar</type>
                                </artifactItem>
                            </artifactItems>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
        </plugins>
    </build>
    
        <profiles>
        <profile>
            <activation>
                <property>
                    <name>jboss-public-repository</name>
                    <value>!false</value>
                </property>
            </activation>
            <repositories>
                <repository>
                    <id>jboss-public-repository-group</id>
                    <name>JBoss Public Maven Repository Group</name>
                    <url>http://repository.jboss.org/nexus/content/groups/public</url>
                    <layout>default</layout>
                    <releases>
                        <enabled>true</enabled>
                        <updatePolicy>never</updatePolicy>
                    </releases>
                    <snapshots>
                        <enabled>false</enabled>
                        <updatePolicy>never</updatePolicy>
                    </snapshots>
                </repository>
            </repositories>
            <pluginRepositories>
                <pluginRepository>
                    <id>jboss-public-repository-group</id>
                    <name>JBoss Public Maven Repository Group</name>
                    <url>http://repository.jboss.org/nexus/content/groups/public</url>
                    <layout>default</layout>
                    <releases>
                        <enabled>true</enabled>
                        <updatePolicy>never</updatePolicy>
                    </releases>
                    <snapshots>
                        <enabled>true</enabled>
                        <updatePolicy>never</updatePolicy>
                    </snapshots>
                </pluginRepository>
            </pluginRepositories>
        </profile>
    </profiles>


</project>

 

When I deploy the resulting EAR to Glassfish I get this exception:

org.jboss.weld.exceptions.DeploymentException: WELD-001408 Unsatisfied dependencies for type [CacheContainer] with qualifiers [@Default] at injection point [[field] @Inject private org.infinispan.cdi.AdvancedCacheProducer.defaultCacheContainer]
        at org.jboss.weld.bootstrap.Validator.validateInjectionPoint(Validator.java:274)
        at org.jboss.weld.bootstrap.Validator.validateInjectionPoint(Validator.java:243)
        at org.jboss.weld.bootstrap.Validator.validateBean(Validator.java:106)
        at org.jboss.weld.bootstrap.Validator.validateBeans(Validator.java:347)
        at org.jboss.weld.bootstrap.Validator.validateDeployment(Validator.java:330)
        at org.jboss.weld.bootstrap.WeldBootstrap.validateBeans(WeldBootstrap.java:366)
        at org.glassfish.weld.WeldDeployer.event(WeldDeployer.java:199)
        at org.glassfish.kernel.event.EventsImpl.send(EventsImpl.java:128)
        at org.glassfish.internal.data.ApplicationInfo.start(ApplicationInfo.java:313)
        at com.sun.enterprise.v3.server.ApplicationLifecycle.deploy(ApplicationLifecycle.java:461)
        at com.sun.enterprise.v3.server.ApplicationLifecycle.deploy(ApplicationLifecycle.java:240)
        at org.glassfish.deployment.admin.DeployCommand.execute(DeployCommand.java:389)
        at com.sun.enterprise.v3.admin.CommandRunnerImpl$1.execute(CommandRunnerImpl.java:348)
        at com.sun.enterprise.v3.admin.CommandRunnerImpl.doCommand(CommandRunnerImpl.java:363)
        at com.sun.enterprise.v3.admin.CommandRunnerImpl.doCommand(CommandRunnerImpl.java:1085)
        at com.sun.enterprise.v3.admin.CommandRunnerImpl.access$1200(CommandRunnerImpl.java:95)
        at com.sun.enterprise.v3.admin.CommandRunnerImpl$ExecutionContext.execute(CommandRunnerImpl.java:1291)
        at com.sun.enterprise.v3.admin.CommandRunnerImpl$ExecutionContext.execute(CommandRunnerImpl.java:1259)
        at com.sun.enterprise.v3.admin.AdminAdapter.doCommand(AdminAdapter.java:461)
        at com.sun.enterprise.v3.admin.AdminAdapter.service(AdminAdapter.java:212)
        at com.sun.grizzly.tcp.http11.GrizzlyAdapter.service(GrizzlyAdapter.java:179)
        at com.sun.enterprise.v3.server.HK2Dispatcher.dispath(HK2Dispatcher.java:117)
        at com.sun.enterprise.v3.services.impl.ContainerMapper$Hk2DispatcherCallable.call(ContainerMapper.java:354)
        at com.sun.enterprise.v3.services.impl.ContainerMapper.service(ContainerMapper.java:195)
        at com.sun.grizzly.http.ProcessorTask.invokeAdapter(ProcessorTask.java:849)
        at com.sun.grizzly.http.ProcessorTask.doProcess(ProcessorTask.java:746)
        at com.sun.grizzly.http.ProcessorTask.process(ProcessorTask.java:1045)
        at com.sun.grizzly.http.DefaultProtocolFilter.execute(DefaultProtocolFilter.java:228)
        at com.sun.grizzly.DefaultProtocolChain.executeProtocolFilter(DefaultProtocolChain.java:137)
        at com.sun.grizzly.DefaultProtocolChain.execute(DefaultProtocolChain.java:104)
        at com.sun.grizzly.DefaultProtocolChain.execute(DefaultProtocolChain.java:90)
        at com.sun.grizzly.http.HttpProtocolChain.execute(HttpProtocolChain.java:79)
        at com.sun.grizzly.ProtocolChainContextTask.doCall(ProtocolChainContextTask.java:54)
        at com.sun.grizzly.SelectionKeyContextTask.call(SelectionKeyContextTask.java:59)
        at com.sun.grizzly.ContextTask.run(ContextTask.java:71)
        at com.sun.grizzly.util.AbstractThreadPool$Worker.doWork(AbstractThreadPool.java:532)
        at com.sun.grizzly.util.AbstractThreadPool$Worker.run(AbstractThreadPool.java:513)
        at java.lang.Thread.run(Thread.java:722)

 

What am I doing wrong?

 

Best regards,

    Kovi

  • 1. Re: Infinispan 5.1.2 and Glassfish 3.1.2
    Galder Zamarreño Master

    Hmmmm, very weird. Can you try if the same works in AS7 (it should do)?

     

    Does your app include any descriptors?

     

    If you could provide a unit test case that we could integrate in our testsuite, it'd be awesome

  • 2. Re: Infinispan 5.1.2 and Glassfish 3.1.2
    Gregor Kovač Newbie

    Hi!

     

    Thanks for the reply.

    I've tried an test application on JBoss 7.1.1 and I don't see the exception, but I see this

    08:19:10,869 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)]

     

    The whole deployment process:

    08:18:54,721 INFO  [org.jboss.as.repository] (HttpManagementService-threads - 8) JBAS014900: Content added at location /home/myUser/jboss/standalone/data/content/fc/7ae84b47930c032edf8857beea579ae6e3f205/content

    08:19:08,874 INFO  [org.jboss.as.server.deployment] (MSC service thread 1-1) JBAS015876: Starting deployment of "TestJEE-ear-1.0-SNAPSHOT.ear"

    08:19:09,558 INFO  [org.jboss.as.server.deployment] (MSC service thread 1-2) JBAS015876: Starting deployment of "TestJEE-ejb-1.0-SNAPSHOT.jar"

    08:19:09,657 INFO  [org.jboss.weld.deployer] (MSC service thread 1-2) JBAS016002: Processing weld deployment TestJEE-ear-1.0-SNAPSHOT.ear

    08:19:09,737 INFO  [org.jboss.weld.deployer] (MSC service thread 1-3) JBAS016002: Processing weld deployment TestJEE-ejb-1.0-SNAPSHOT.jar

    08:19:09,740 INFO  [org.jboss.as.ejb3.deployment.processors.EjbJndiBindingsDeploymentUnitProcessor] (MSC service thread 1-3) JNDI bindings for session bean named CacheBean in deployment unit subdeployment "TestJEE-ejb-1.0-SNAPSHOT.jar" of deployment "TestJEE-ear-1.0-SNAPSHOT.ear" are as follows:

     

     

            java:global/TestJEE-ear-1.0-SNAPSHOT/TestJEE-ejb-1.0-SNAPSHOT/CacheBean!com.mycompany.CacheBean

            java:app/TestJEE-ejb-1.0-SNAPSHOT/CacheBean!com.mycompany.CacheBean

            java:module/CacheBean!com.mycompany.CacheBean

            java:global/TestJEE-ear-1.0-SNAPSHOT/TestJEE-ejb-1.0-SNAPSHOT/CacheBean

            java:app/TestJEE-ejb-1.0-SNAPSHOT/CacheBean

            java:module/CacheBean

     

     

    08:19:09,747 INFO  [org.jboss.weld.deployer] (MSC service thread 1-4) JBAS016005: Starting Services for CDI deployment: TestJEE-ear-1.0-SNAPSHOT.ear

    08:19:09,750 INFO  [org.jboss.weld.deployer] (MSC service thread 1-1) JBAS016008: Starting weld service for deployment TestJEE-ear-1.0-SNAPSHOT.ear

    08:19:09,832 INFO  [org.infinispan.cdi.InfinispanExtension] (MSC service thread 1-1) ISPN017001: Infinispan CDI extension version: 5.1.2.FINAL

    08:19:09,844 INFO  [org.jboss.solder.config.xml.bootstrap.XmlConfigExtension] (MSC service thread 1-1) Solder Config XML provider starting...

    08:19:09,846 INFO  [org.jboss.solder.config.xml.bootstrap.XmlConfigExtension] (MSC service thread 1-1) Loading XmlDocumentProvider: org.jboss.solder.config.xml.bootstrap.ResourceLoaderXmlDocumentProvider

    08:19:09,860 INFO  [org.jboss.solder.config.xml.bootstrap.XmlConfigExtension] (MSC service thread 1-1) Reading XML file: vfs:/content/TestJEE-ear-1.0-SNAPSHOT.ear/TestJEE-ejb-1.0-SNAPSHOT.jar/META-INF/beans.xml

    08:19:09,875 INFO  [org.jboss.solder.config.xml.bootstrap.XmlConfigExtension] (MSC service thread 1-1) Reading XML file: vfs:/content/TestJEE-ear-1.0-SNAPSHOT.ear/lib/infinispan-cdi-5.1.2.FINAL.jar/META-INF/beans.xml

    08:19:09,889 INFO  [org.jboss.solder.Version] (MSC service thread 1-1) Solder 3.1.0.Final (build id: 3.1.0.Final)

    08:19:10,869 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)]

    08:19:11,144 INFO  [org.jboss.as.server] (HttpManagementService-threads - 8) JBAS018559: Deployed "TestJEE-ear-1.0-SNAPSHOT.ear"

     

     

    I assume this is not OK. Right?

    I've also attached a sample Maven based test application.

     

    Best regards,

        Kovi

  • 3. Re: Infinispan 5.1.2 and Glassfish 3.1.2
    Kevin Pollet Newbie

    Hi,

     

    Looks good to me :-)

     

    08:19:10,869 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)]

     

     

    This message says that your default embedded cache manager producer is used instead of the default one provided by the extension.

    The Infinispan CDI extension uses the default bean feature from Seam Solder to allow the overriding of default providers.

     

    Your application is working, right?

     

    BTW, It seems that there is an issue with GlassFish.

     

    Hope this help!

  • 4. Re: Infinispan 5.1.2 and Glassfish 3.1.2
    Gregor Kovač Newbie

    Hi!

     

    Well, the application I attached a file of, didn't have any logic in in. The EJB just had the cache manager injected.

    How I've added a @Startup bean that uses that CacheBean that uses the cache manager. Now I get a massive Out Of Memory Exception.

     

    I've attached the file containing the application and the server.log with the exception.

     

    Best regards,

        Kovi

  • 5. Re: Infinispan 5.1.2 and Glassfish 3.1.2
    Kevin Pollet Newbie

    Hi,

     

    Looking at the exception, it seems to be a problem with the transaction manager.

    Have you tried to remove it from the cache manager configuration? (just for the test)

  • 6. Re: Infinispan 5.1.2 and Glassfish 3.1.2
    Gregor Kovač Newbie

    Hi!

     

    the problem is NOT in the transactrion managet. The problem was with the maxEntries method. I removed that and now it is working.

    Config line:

    - before (not working, throwing Out of Memory exception)

        builder.eviction().strategy(EvictionStrategy.NONE).maxEntries(Integer.MAX_VALUE).transaction().transactionManagerLookup(new GenericTransactionManagerLookup()).expiration().lifespan(Long.valueOf(-1)).maxIdle(Long.valueOf(-1));

    - after (working)

        builder.eviction().strategy(EvictionStrategy.NONE).transaction().transactionManagerLookup(new GenericTransactionManagerLookup()).expiration().lifespan(Long.valueOf(-1)).maxIdle(Long.valueOf(-1));

     

    The application is working on JBoss. the same is still not working on Glassfish. I get the same " WELD-001408 Unsatisfied dependencies for type [CacheContainer] with qualifiers [@Default] at injection point [[field] @Inject private org.infinispan.cdi.AdvancedCacheProducer.defaultCacheContainer]"

     

    Best regards,

        Kovi

  • 7. Re: Infinispan 5.1.2 and Glassfish 3.1.2
    Kevin Pollet Newbie

    Hi,

     

    I think that's an issue with Solder and Glassfih.

    I'll try to investigate!

     

    For the cache manager I think that's because you define no eviction strategy and the max entries property.

     

    Galder?

  • 8. Re: Infinispan 5.1.2 and Glassfish 3.1.2
    Gregor Kovač Newbie

    I've also opened an issue on the glassfish side:

    http://java.net/jira/browse/GLASSFISH-18549

     

    Best regards,

        Kovi

  • 9. Re: Infinispan 5.1.2 and Glassfish 3.1.2
    Dan Berindei Apprentice

    Gregor Kovač wrote:

     

    Hi!

     

    the problem is NOT in the transactrion managet. The problem was with the maxEntries method. I removed that and now it is working.

    Config line:

    - before (not working, throwing Out of Memory exception)

        builder.eviction().strategy(EvictionStrategy.NONE).maxEntries(Integer.MAX_VALUE).transaction().transactionManagerLookup(new GenericTransactionManagerLookup()).expiration().lifespan(Long.valueOf(-1)).maxIdle(Long.valueOf(-1));

    - after (working)

        builder.eviction().strategy(EvictionStrategy.NONE).transaction().transactionManagerLookup(new GenericTransactionManagerLookup()).expiration().lifespan(Long.valueOf(-1)).maxIdle(Long.valueOf(-1));

     

     

    If you don't specify a maxEntries value, the cache will start with a small map and gradually grow it when you insert new entries.

    If you do specify a maxEntries value, we assume that you have enough memory for all the entries and so we create from the start a map big enough to hold all the entries.

    Actually we do limit the number of entries to 2^30 instead of 2^31, but even the HashEntry arrays will take about 8GB (4GB if you're on a 32-bit architecture, but it doesn't matter because you can't allocate 4GB either on 32-bit).

  • 10. Re: Infinispan 5.1.2 and Glassfish 3.1.2
    Gregor Kovač Newbie

    Hi!

     

    Is anyone still working on this? Kevin Pollet? You said you'll investigate a bit more. What are your findings?

     

    Best regards,

        Kovi

  • 11. Re: Infinispan 5.1.2 and Glassfish 3.1.2
    Tang Yong Newbie

    I am investigating the issue and if  Kevin has some conclustion, please tell us.

  • 12. Re: Infinispan 5.1.2 and Glassfish 3.1.2
    Gregor Kovač Newbie

    I hoper this is not a 1st April joke, since I'm very glad someone is looking into it. :

  • 13. Re: Infinispan 5.1.2 and Glassfish 3.1.2
    Tang Yong Newbie

    ,  1st April has gone out and I am still here, please giving me or gf members more time, because this issue is not simple.

     

    A big guess is that there is something wrong between solder and gf.

     

    --Tang Yong

  • 14. Re: Infinispan 5.1.2 and Glassfish 3.1.2
    Tang Yong Newbie

    @Pete Muir, @Kevin Pollet, @Kovac

     

    While deploying the sample ear into gf and scanning org.infinispan.cdi.AdvancedCacheProducer ,  because the following injection point can not be satisfied,

     

       @Inject

       private CacheContainer defaultCacheContainer;

     

    WELD-001408 happened.

     

    CacheContainer's implementation comes from infinispan-core and it can not be built as bean archieve(it can not be also as bean archieve!)

    Instead, The sample ear has a produce method called com.mycompany.defaultEmbeddedCacheManager() to create a EmbeddedCacheManager which implements CacheContainer.

     

    Deeply, while deploying an app with beans.xml into gf, gf will scan and validate all artifacts with beans.xml (including CDI extensions), so, infinispan-cdi is scanned. However, while validating

    these cdi extensions, in this scene, WELD-001408 happened.

     

    Although you maybe think that this should belong to glassfish weld integration's issue( I am discussion with gf cdi team), I still have a question as following:

     

    Since a fact that the sample is deployed and run normally on jboss 7.1.1 final(I have confirmed the point), I want to know how JBOSS 7 handles the scene based on the above I said?

     

    Thanks

    --Tang

1 2 Previous Next