1 2 Previous Next 15 Replies Latest reply on Dec 16, 2011 9:22 AM by sviluppatorefico

    Infinispan in OSGi container

    ivokolev

      Hallo,

       

      I downloaded Infinispan 4.0.0 and its dependencies (the jars you'd  listed). Then I created BND property files to customize the defaults for  impored and exported packages. I installed the "OSGified" bundles in my  Maven and build the project which is going to use Infinispan. The  bundles run in Apache Felix. All bundles are properly installed and  activated, but when creating SCR context for a bundle, an error in  Infinispan core bundle appears (trace below).

       

      I decided I can live without JMX for a while and disabled it in the config file. This one gone, but now another class is not accessible.

      It seems like class  loader issue.

       

      Have anyone succeded to run Infinispan in OSGi?

       

      Cheers, Ivo

       

      P.S.  If someone is interested I can share the scripts, though they are not  really worthy if Infinispan is not running in the end.

       

      2010-08-31  16:04:19,766 18610 [SCR Component Actor] ERROR  org.infinispan.jmx.AbstractJmxRegistration  - Could not instantiate  MBeanServerLookup('org.infinispan.jmx.PlatformMBeanServerLookup')
      java.lang.ClassNotFoundException: org.infinispan.jmx.PlatformMBeanServerLookup
          at java.net.URLClassLoader$1.run(Unknown Source)
          at java.security.AccessController.doPrivileged(Native Method)
          at java.net.URLClassLoader.findClass(Unknown Source)
          at java.lang.ClassLoader.loadClass(Unknown Source)
          at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
          at java.lang.ClassLoader.loadClass(Unknown Source)
          at org.infinispan.util.Util.loadClass(Util.java:56)
          at org.infinispan.util.Util.getInstance(Util.java:86)
          at org.infinispan.jmx.AbstractJmxRegistration.getMBeanServer(AbstractJmxRegistration.java:64)
          at org.infinispan.jmx.AbstractJmxRegistration.registerMBeans(AbstractJmxRegistration.java:51)
          at org.infinispan.jmx.CacheManagerJmxRegistration.start(CacheManagerJmxRegistration.java:39)
          at org.infinispan.manager.DefaultCacheManager.start(DefaultCacheManager.java:515)
          at org.infinispan.manager.DefaultCacheManager.<init>(DefaultCacheManager.java:336)
          at org.infinispan.manager.DefaultCacheManager.<init>(DefaultCacheManager.java:302)

        • 1. Re: Infinispan in OSGi container
          sellhorn

          ivailo,

           

          Let me know if you're still having this issue. I use infinispan in OSGi and I'm not getting this error. It did take quite a bit of effort to setup. I created a maven feature that does all the bnd stuff, and needed quite a bit of dynamic imports to get it all working (investigating if fragments are a better idea ...)

           

          Oh btw, I'm doing this in Infinispan 4.1, so maybe this JMX issue is related to the previous release.

          • 2. Re: Infinispan in OSGi container
            ivokolev

            Hallo, Augusto,

             

            I also tried the new 4.1, making all the jars bundles using BND. I also added dynamic imports tag to the manifests but it did not help: the issue with the class loader persists. I disabled JMX feature and another CNF exception was thrown.

             

            Looking at the code in Util.loadClass(), it uses Thread.currentThread().getContextClassLoader(), which I think causes the problem. So, by now I pause the attempts to integrate Infinispan into OSGi.

             

            Thanks for the feedback.

             

            Cheers, Ivo

            • 3. Re: Infinispan in OSGi container
              ivokolev

              Augusto,

               

              Would you please send me the manifest of infinispan-core bundle? I'm currious if yours differ somehow from these I created.

               

              Email it to ivailokolev at dir.bg or attach it to the current discussion.

               

              Cheers, Ivo

              • 4. Re: Infinispan in OSGi container
                sellhorn

                Do you know how to install features in Felix? If so, try creating and installing the following feature;

                 

                 

                {code:xml}

                    <feature name="infinispan-feature" version="1.1.0.a1-SNAPSHOT">
                        <bundle>wrap:mvn:org.infinispan/infinispan-core/4.1.0.CR3$DynamicImport-Package=*&amp;Bundle-SymbolicName=infinispan-core&amp;Bundle-Version=4.1.0.CR3</bundle>
                        <bundle>wrap:mvn:org.infinispan/infinispan-query/4.1.0.CR3$Bundle-SymbolicName=infinispan-query&amp;Bundle-Version=4.1.0.CR3</bundle>
                        <bundle>wrap:mvn:org.jboss.marshalling/river/1.2.2.GA$DynamicImport-Package=*&amp;Bundle-SymbolicName=jboss-river&amp;Bundle-Version=1.2.2.GA</bundle>
                        <bundle>wrap:mvn:org.jboss.marshalling/marshalling-api/1.2.2.GA$DynamicImport-Package=*&amp;Bundle-SymbolicName=jboss-marshalling-api&amp;Bundle-Version=1.2.2.GA</bundle>
                        <bundle>mvn:org.slf4j/slf4j-log4j12/1.5.8</bundle>
                        <bundle>wrap:mvn:org.jgroups/jgroups/2.10.0.GA$Bundle-SymbolicName=jgroups&amp;Bundle-Version=2.10.0.GA</bundle>
                        <bundle>wrap:mvn:org.jboss.javaee/jboss-transaction-api/1.0.1.GA$Bundle-SymbolicName=jboss-transaction-api&amp;Bundle-Version=1.0.1.GA</bundle>
                        <bundle>wrap:mvn:org.hibernate/hibernate-search/3.2.1.Final$DynamicImport-Package=*&amp;Bundle-SymbolicName=hibernate-search&amp;Bundle-Version=3.2.1.Final</bundle>
                        <bundle>wrap:mvn:org.hibernate/hibernate-commons-annotations/3.2.0.Final$DynamicImport-Package=*&amp;Bundle-SymbolicName=hibernate-commons-annotations&amp;Bundle-Version=3.2.0.Final</bundle>
                        <bundle>wrap:mvn:org.hibernate/hibernate-core/3.5.4-Final$Bundle-SymbolicName=hibernate-core&amp;Bundle-Version=3.5.4.Final</bundle>
                        <bundle>wrap:mvn:org.apache.lucene/lucene-core/2.9.3$Bundle-SymbolicName=lucene-core&amp;Bundle-Version=2.9.3</bundle>
                        <bundle>wrap:mvn:org.jboss/jboss-common-core/2.2.14.GA$Bundle-SymbolicName=jboss-common-core&amp;Bundle-Version=2.2.14.GA</bundle>
                        <bundle>wrap:mvn:org.rhq.helpers/rhq-pluginAnnotations/1.4.0.B01$Bundle-SymbolicName=rhq-pluginAnnotations&amp;Bundle-Version=1.4.0.B01</bundle>
                        <bundle>wrap:mvn:org.infinispan/infinispan-lucene-directory/4.1.0.CR3$Bundle-SymbolicName=infinispan-lucene-directory&amp;Bundle-Version=4.1.0.CR3</bundle>
                  </feature>

                    <feature name="infinispan-feature" version="0.0.1-SNAPSHOT">

                        <bundle>wrap:mvn:org.infinispan/infinispan-core/4.1.0.CR3$DynamicImport-Package=*&amp;Bundle-SymbolicName=infinispan-core&amp;Bundle-Version=4.1.0.CR3</bundle>

                        <bundle>wrap:mvn:org.infinispan/infinispan-query/4.1.0.CR3$Bundle-SymbolicName=infinispan-query&amp;Bundle-Version=4.1.0.CR3</bundle>

                        <bundle>wrap:mvn:org.jboss.marshalling/river/1.2.2.GA$DynamicImport-Package=*&amp;Bundle-SymbolicName=jboss-river&amp;Bundle-Version=1.2.2.GA</bundle>

                        <bundle>wrap:mvn:org.jboss.marshalling/marshalling-api/1.2.2.GA$DynamicImport-Package=*&amp;Bundle-SymbolicName=jboss-marshalling-api&amp;Bundle-Version=1.2.2.GA</bundle>

                        <bundle>mvn:org.slf4j/slf4j-log4j12/1.5.8</bundle>

                        <bundle>wrap:mvn:org.jgroups/jgroups/2.10.0.GA$Bundle-SymbolicName=jgroups&amp;Bundle-Version=2.10.0.GA</bundle>

                        <bundle>wrap:mvn:org.jboss.javaee/jboss-transaction-api/1.0.1.GA$Bundle-SymbolicName=jboss-transaction-api&amp;Bundle-Version=1.0.1.GA</bundle>

                        <bundle>wrap:mvn:org.hibernate/hibernate-search/3.2.1.Final$DynamicImport-Package=*&amp;Bundle-SymbolicName=hibernate-search&amp;Bundle-Version=3.2.1.Final</bundle>

                        <bundle>wrap:mvn:org.hibernate/hibernate-commons-annotations/3.2.0.Final$DynamicImport-Package=*&amp;Bundle-SymbolicName=hibernate-commons-annotations&amp;Bundle-Version=3.2.0.Final</bundle>

                        <bundle>wrap:mvn:org.hibernate/hibernate-core/3.5.4-Final$Bundle-SymbolicName=hibernate-core&amp;Bundle-Version=3.5.4.Final</bundle>

                        <bundle>wrap:mvn:org.apache.lucene/lucene-core/2.9.3$Bundle-SymbolicName=lucene-core&amp;Bundle-Version=2.9.3</bundle>

                        <bundle>wrap:mvn:org.jboss/jboss-common-core/2.2.14.GA$Bundle-SymbolicName=jboss-common-core&amp;Bundle-Version=2.2.14.GA</bundle>

                        <bundle>wrap:mvn:org.rhq.helpers/rhq-pluginAnnotations/1.4.0.B01$Bundle-SymbolicName=rhq-pluginAnnotations&amp;Bundle-Version=1.4.0.B01</bundle>

                  </feature>

                 

                {code}

                 

                This may have more jars than you need, like search for example but start from here by installing this feature and then having a bundle that uses the infinispan jars.

                • 5. Re: Infinispan in OSGi container
                  ivokolev

                  Hallo, Augusto,

                  Thank you for the help. In order to enable features I have to do changes in the environment which are not desired. So, I'll wait until Infinispam becomes OSGi-ready out of the box. A guy from the project team already said OSGi compliancy is in JIRA.

                   

                  Cheers, Ivo

                  • 6. Re: Infinispan in OSGi container
                    sellhorn

                    Anybody know what the ETA is for that JIRA (Infinispan in OSGi)?

                     

                    Kind of curious what you mean by changes in the environment. This is just the proper list of dependencies with the right wrap parameters ...

                    • 7. Re: Infinispan in OSGi container
                      trustin

                      All Infinispan JARs are now OSGi bundles.  This change will be included in 4.2.0.ALPHA2 and later.   I haven't tested it with an OSGi kernel yet, so there might be some rough edges that need a fix though.  Please feel free to check out the latest code and let me know if it works.  

                      1 of 1 people found this helpful
                      • 8. Re: Infinispan in OSGi container
                        sellhorn

                        I'll try it out this weekend or more likely next week. But, are the necessary 3rd party jars infinispan needs also OSGi bundles? For example, JBoss marshalling and river? Are you guys building an infinispan feature?

                        • 9. Re: Infinispan in OSGi container
                          ivokolev

                          Hallo, Augusto,

                           

                          The change is to add Infinispan and the other jars to the JVM class path and change some Felix configurations. Which actually breaks the OSGi concept. As far as Infinispan team is working in making it OSGi-ready, I would prefer to wait.

                          Thanks again for your help.

                           

                          Cheers, Ivo Kolev

                          • 10. Re: Infinispan in OSGi container
                            trustin

                            Some 3rd party artifacts are not OSGi bundles at the moment.  You will have to ask the maintainers of the respective projects about making them OSGi-compatible since Infinispan have no direct control over them.  Meanwhile, you might want to make them OSGi-bundle by yourself, or put them in the system classpath.  However, you don't need to put the Infinispan JARs into the system class path anymore because they are OSGi bundles now.

                             

                            It's a good idea to provide the Infinispan feature in the release by the way.  Since I'm not familiar with the feature descriptor at the moment, let me investigate a little bit more and get back to this thread.

                            1 of 1 people found this helpful
                            • 11. Re: Infinispan in OSGi container
                              sellhorn

                              Trustin Lee wrote:

                               

                              Some 3rd party artifacts are not OSGi bundles at the moment.  You will have to ask the maintainers of the respective projects about making them OSGi-compatible since Infinispan have no direct control over them.  Meanwhile, you might want to make them OSGi-bundle by yourself, or put them in the system classpath.  However, you don't need to put the Infinispan JARs into the system class path anymore because they are OSGi bundles now.

                               

                              It's a good idea to provide the Infinispan feature in the release by the way.  Since I'm not familiar with the feature descriptor at the moment, let me investigate a little bit more and get back to this thread.

                              Trustin;

                               

                              Well, I know the 3rd party jars outside Infinispan are not under the control of the Infinispan project, but obviously if Infinispan has dependencies on non-OSGi jars then one has to wonder if it's "truly" OSGi enabled.

                               

                              That's why I mentioned an infinispan feature, as the one I posted in this very thread, you can use Infinispan in an OSGi container (I've tested it in Equinox but should work fine in Felix) but you need to use the bnd (wrap in the feature) command to do so. It sounds like even if the infinispan jars are OSGi enabled in the near future, we'll need something like this to make it work. Putting jars on the system CLASSPATH is really not a viable option.

                               

                              ivalio;

                               

                              Note that Trustin is bundling up infinispan libraries in OSGi, but based on his message, you'll still have problems because the river marshaller (and other classes, like the Hibernate search ones) do dynamic class loading that doesn't work in OSGi. I don't know if it was clear, but the feature I posted allows you to load all of this and make it work without any classpath or system classpath tricks.

                              • 12. Re: Infinispan in OSGi container
                                sviluppatorefico

                                the porting of Infinispan in OSGI is still under work... I opened a jira issue:

                                 

                                https://jira.jboss.org/browse/ISPN-800

                                 

                                And I fixed a bug for infinispan-core here:

                                 

                                https://github.com/flashboss/infinispan

                                 

                                 

                                Infinispan core can be installed in a OSGI repository but we need some dependencies are OSGI compliant too.

                                • 13. Re: Infinispan in OSGi container
                                  surya46584

                                  Hi,

                                   

                                  can you please update on the Infinispan's OSGI compliance? Would like to use Infinispan for our caching needs, trying to find if Infisipan and its depencencies are OSGI ready?

                                   

                                  Regards,

                                  • 14. Re: Infinispan in OSGi container
                                    galder.zamarreno

                                    As you can see by the JIRA linked, some of our dependencies are still not OSGI compatible.

                                    1 2 Previous Next