Struts 2
  1. Struts 2
  2. WW-3958

Struts2 OSGi plugin does not work with GlassFish

    Details

    • Type: Improvement Improvement
    • Status: Closed
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: 2.3.1
    • Fix Version/s: 2.3.15
    • Component/s: Other
    • Labels:
      None
    • Environment:

      GlassFish 3.1.2.2

      Description

      The OSGi plugin does not work with GlassFish where Felix is already included. When including in the Struts web application a bundle containing an activator class the following exception occurs:

      java.lang.ClassCastException: myosgi.Activator cannot be cast to org.osgi.framework.BundleActivator

      while when including a bundle with a class which implements BundleContextAware the following exception occurs:

      Exception starting filter struts2 java.lang.LinkageError: loader constraint violation: loader (instance of org/apache/felix/framework/searchpolicy/ContentClassLoader) previously initiated loading for a different type with name "org/osgi/framework/BundleContext"

      It also seems that the plugin uses an old version of Felix which could be (at least partly) responsible for the errors since GlassFish uses a newer one.

      More details on the errors also available in this stackoverflow post

      1. Struts2OSGi.zip
        266 kB
        Christina Kaskoura
      2. 2.3.8-error.txt
        20 kB
        Christina Kaskoura

        Issue Links

          Activity

          Hide
          Hudson added a comment -

          Integrated in Struts2-JDK6 #708 (See https://builds.apache.org/job/Struts2-JDK6/708/)
          WW-3958 Reverts cast to String to satisfy JDK7 (Revision 1485066)

          Result = SUCCESS
          lukaszlenart :
          Files :

          • /struts/struts2/trunk/plugins/osgi/src/main/java/org/apache/struts2/osgi/OsgiConfigurationProvider.java
          Show
          Hudson added a comment - Integrated in Struts2-JDK6 #708 (See https://builds.apache.org/job/Struts2-JDK6/708/ ) WW-3958 Reverts cast to String to satisfy JDK7 (Revision 1485066) Result = SUCCESS lukaszlenart : Files : /struts/struts2/trunk/plugins/osgi/src/main/java/org/apache/struts2/osgi/OsgiConfigurationProvider.java
          Hide
          TangYong added a comment -

          Another thing:

          If I came back struts2 glassfish, I will see whether the fixing also works for glassfish 4.0 branch.

          Show
          TangYong added a comment - Another thing: If I came back struts2 glassfish, I will see whether the fixing also works for glassfish 4.0 branch.
          Hide
          Lukasz Lenart added a comment -

          I would like to prepare also sample application with admin bundle included - WW-4074

          Show
          Lukasz Lenart added a comment - I would like to prepare also sample application with admin bundle included - WW-4074
          Hide
          TangYong added a comment -

          Great News! Thanks Lukasz!

          Show
          TangYong added a comment - Great News! Thanks Lukasz!
          Hide
          Hudson added a comment -

          Integrated in Struts2-JDK6 #707 (See https://builds.apache.org/job/Struts2-JDK6/707/)
          WW-3958 Updates Apache Felix and adds option to cooperate with Felix integrated in Glassfish (Revision 1484815)

          Result = SUCCESS
          lukaszlenart :
          Files :

          • /struts/struts2/trunk/bundles/admin/src/main/java/org/apache/struts2/osgi/admin/actions/BundlesAction.java
          • /struts/struts2/trunk/plugins/osgi/pom.xml
          • /struts/struts2/trunk/plugins/osgi/src/main/java/org/apache/struts2/osgi/BundleAccessor.java
          • /struts/struts2/trunk/plugins/osgi/src/main/java/org/apache/struts2/osgi/BundleClassLoaderInterface.java
          • /struts/struts2/trunk/plugins/osgi/src/main/java/org/apache/struts2/osgi/BundlePackageLoader.java
          • /struts/struts2/trunk/plugins/osgi/src/main/java/org/apache/struts2/osgi/DefaultBundleAccessor.java
          • /struts/struts2/trunk/plugins/osgi/src/main/java/org/apache/struts2/osgi/DelegatingObjectFactory.java
          • /struts/struts2/trunk/plugins/osgi/src/main/java/org/apache/struts2/osgi/FelixOsgiHost.java
          • /struts/struts2/trunk/plugins/osgi/src/main/java/org/apache/struts2/osgi/OsgiConfigurationProvider.java
          • /struts/struts2/trunk/plugins/osgi/src/main/java/org/apache/struts2/osgi/OsgiHost.java
          • /struts/struts2/trunk/plugins/osgi/src/main/java/org/apache/struts2/osgi/OsgiHostFactory.java
          • /struts/struts2/trunk/plugins/osgi/src/main/java/org/apache/struts2/osgi/OsgiUtil.java
          • /struts/struts2/trunk/plugins/osgi/src/main/java/org/apache/struts2/osgi/PackageLoader.java
          • /struts/struts2/trunk/plugins/osgi/src/main/java/org/apache/struts2/osgi/SpringOsgiObjectFactory.java
          • /struts/struts2/trunk/plugins/osgi/src/main/java/org/apache/struts2/osgi/StrutsOsgiListener.java
          • /struts/struts2/trunk/plugins/osgi/src/main/java/org/apache/struts2/osgi/host
          • /struts/struts2/trunk/plugins/osgi/src/main/java/org/apache/struts2/osgi/host/BaseOsgiHost.java
          • /struts/struts2/trunk/plugins/osgi/src/main/java/org/apache/struts2/osgi/host/FelixOsgiHost.java
          • /struts/struts2/trunk/plugins/osgi/src/main/java/org/apache/struts2/osgi/host/GlassfishOSGiHost.java
          • /struts/struts2/trunk/plugins/osgi/src/main/java/org/apache/struts2/osgi/host/OsgiHost.java
          • /struts/struts2/trunk/plugins/osgi/src/main/java/org/apache/struts2/osgi/interceptor/BundleContextAware.java
          • /struts/struts2/trunk/plugins/osgi/src/main/java/org/apache/struts2/osgi/interceptor/OsgiInterceptor.java
          • /struts/struts2/trunk/plugins/osgi/src/main/java/org/apache/struts2/osgi/interceptor/ServiceAware.java
          • /struts/struts2/trunk/plugins/osgi/src/main/java/org/apache/struts2/osgi/loaders/StaticContentBundleResourceLoader.java
          • /struts/struts2/trunk/plugins/osgi/src/main/java/org/apache/struts2/osgi/loaders/VelocityBundleResourceLoader.java
          • /struts/struts2/trunk/plugins/osgi/src/test/java/org/apache/struts2/osgi/FelixOsgiHostTest.java
          • /struts/struts2/trunk/plugins/osgi/src/test/java/org/apache/struts2/osgi/host
          • /struts/struts2/trunk/plugins/osgi/src/test/java/org/apache/struts2/osgi/host/FelixOsgiHostTest.java
          • /struts/struts2/trunk/plugins/osgi/src/test/java/org/apache/struts2/osgi/interceptor/OsgiInterceptorTest.java
          • /struts/struts2/trunk/pom.xml
          Show
          Hudson added a comment - Integrated in Struts2-JDK6 #707 (See https://builds.apache.org/job/Struts2-JDK6/707/ ) WW-3958 Updates Apache Felix and adds option to cooperate with Felix integrated in Glassfish (Revision 1484815) Result = SUCCESS lukaszlenart : Files : /struts/struts2/trunk/bundles/admin/src/main/java/org/apache/struts2/osgi/admin/actions/BundlesAction.java /struts/struts2/trunk/plugins/osgi/pom.xml /struts/struts2/trunk/plugins/osgi/src/main/java/org/apache/struts2/osgi/BundleAccessor.java /struts/struts2/trunk/plugins/osgi/src/main/java/org/apache/struts2/osgi/BundleClassLoaderInterface.java /struts/struts2/trunk/plugins/osgi/src/main/java/org/apache/struts2/osgi/BundlePackageLoader.java /struts/struts2/trunk/plugins/osgi/src/main/java/org/apache/struts2/osgi/DefaultBundleAccessor.java /struts/struts2/trunk/plugins/osgi/src/main/java/org/apache/struts2/osgi/DelegatingObjectFactory.java /struts/struts2/trunk/plugins/osgi/src/main/java/org/apache/struts2/osgi/FelixOsgiHost.java /struts/struts2/trunk/plugins/osgi/src/main/java/org/apache/struts2/osgi/OsgiConfigurationProvider.java /struts/struts2/trunk/plugins/osgi/src/main/java/org/apache/struts2/osgi/OsgiHost.java /struts/struts2/trunk/plugins/osgi/src/main/java/org/apache/struts2/osgi/OsgiHostFactory.java /struts/struts2/trunk/plugins/osgi/src/main/java/org/apache/struts2/osgi/OsgiUtil.java /struts/struts2/trunk/plugins/osgi/src/main/java/org/apache/struts2/osgi/PackageLoader.java /struts/struts2/trunk/plugins/osgi/src/main/java/org/apache/struts2/osgi/SpringOsgiObjectFactory.java /struts/struts2/trunk/plugins/osgi/src/main/java/org/apache/struts2/osgi/StrutsOsgiListener.java /struts/struts2/trunk/plugins/osgi/src/main/java/org/apache/struts2/osgi/host /struts/struts2/trunk/plugins/osgi/src/main/java/org/apache/struts2/osgi/host/BaseOsgiHost.java /struts/struts2/trunk/plugins/osgi/src/main/java/org/apache/struts2/osgi/host/FelixOsgiHost.java /struts/struts2/trunk/plugins/osgi/src/main/java/org/apache/struts2/osgi/host/GlassfishOSGiHost.java /struts/struts2/trunk/plugins/osgi/src/main/java/org/apache/struts2/osgi/host/OsgiHost.java /struts/struts2/trunk/plugins/osgi/src/main/java/org/apache/struts2/osgi/interceptor/BundleContextAware.java /struts/struts2/trunk/plugins/osgi/src/main/java/org/apache/struts2/osgi/interceptor/OsgiInterceptor.java /struts/struts2/trunk/plugins/osgi/src/main/java/org/apache/struts2/osgi/interceptor/ServiceAware.java /struts/struts2/trunk/plugins/osgi/src/main/java/org/apache/struts2/osgi/loaders/StaticContentBundleResourceLoader.java /struts/struts2/trunk/plugins/osgi/src/main/java/org/apache/struts2/osgi/loaders/VelocityBundleResourceLoader.java /struts/struts2/trunk/plugins/osgi/src/test/java/org/apache/struts2/osgi/FelixOsgiHostTest.java /struts/struts2/trunk/plugins/osgi/src/test/java/org/apache/struts2/osgi/host /struts/struts2/trunk/plugins/osgi/src/test/java/org/apache/struts2/osgi/host/FelixOsgiHostTest.java /struts/struts2/trunk/plugins/osgi/src/test/java/org/apache/struts2/osgi/interceptor/OsgiInterceptorTest.java /struts/struts2/trunk/pom.xml
          Hide
          Lukasz Lenart added a comment -

          Done, changes applied, docs updated! Thanks a lot TangYong!

          https://cwiki.apache.org/confluence/display/WW/OSGi+Plugin

          Show
          Lukasz Lenart added a comment - Done, changes applied, docs updated! Thanks a lot TangYong ! https://cwiki.apache.org/confluence/display/WW/OSGi+Plugin
          Hide
          TangYong added a comment -

          Good news, Lukasz, if needing me help deeply, pl. telling me.

          Show
          TangYong added a comment - Good news, Lukasz, if needing me help deeply, pl. telling me.
          Hide
          Lukasz Lenart added a comment - - edited

          Ok, found the problem

          Show
          Lukasz Lenart added a comment - - edited Ok, found the problem
          Hide
          Lukasz Lenart added a comment -

          TangYong no problem, I will try to do it on myself. Thanks for your awesome effort

          Show
          Lukasz Lenart added a comment - TangYong no problem, I will try to do it on myself. Thanks for your awesome effort
          Hide
          TangYong added a comment -

          LuKasz,

          I will come back the issue after two days because recently I have no more time to check this issue on glassfish v4.So, pl. giving me more time. In addition, about the issue, maybe I need to re-discuss with gf leader(Sahoo).

          Thanks
          --Tang

          Show
          TangYong added a comment - LuKasz, I will come back the issue after two days because recently I have no more time to check this issue on glassfish v4.So, pl. giving me more time. In addition, about the issue, maybe I need to re-discuss with gf leader(Sahoo). Thanks --Tang
          Hide
          Lukasz Lenart added a comment -

          I have ported your changes but still getting some NullPointerException in XmlConfigurationProvider#loadConfiguration

          Show
          Lukasz Lenart added a comment - I have ported your changes but still getting some NullPointerException in XmlConfigurationProvider#loadConfiguration
          Hide
          Lukasz Lenart added a comment -

          TangYong could you create a patch and attach it here?

          Show
          Lukasz Lenart added a comment - TangYong could you create a patch and attach it here?
          Hide
          TangYong added a comment -

          Now, I have tested in glassfish 3.1.2.2, and can access http://localhost:8080/osgi-2.3.1/osgi/admin/, although having a exception found in server.log.

          [#|2013-01-22T21:16:24.781+0900|WARNING|glassfish3.1.2|javax.enterprise.system.container.web.com.sun.enterprise.web|_ThreadID=88;_ThreadName=Thread-2;|StandardWrapperValve[default]: PWC1406: Servlet.service() for servlet default threw exception
          java.lang.NullPointerException
          at org.apache.struts2.osgi.DefaultBundleAccessor.loadResourceFromAllBundles(DefaultBundleAccessor.java:158)
          at org.apache.struts2.osgi.loaders.StaticContentBundleResourceLoader.findResource(StaticContentBundleResourceLoader.java:41)
          at org.apache.struts2.dispatcher.DefaultStaticContentLoader.findStaticResource(DefaultStaticContentLoader.java:163)
          ...

          Show
          TangYong added a comment - Now, I have tested in glassfish 3.1.2.2, and can access http://localhost:8080/osgi-2.3.1/osgi/admin/ , although having a exception found in server.log. [#|2013-01-22T21:16:24.781+0900|WARNING|glassfish3.1.2|javax.enterprise.system.container.web.com.sun.enterprise.web|_ThreadID=88;_ThreadName=Thread-2;|StandardWrapperValve [default] : PWC1406: Servlet.service() for servlet default threw exception java.lang.NullPointerException at org.apache.struts2.osgi.DefaultBundleAccessor.loadResourceFromAllBundles(DefaultBundleAccessor.java:158) at org.apache.struts2.osgi.loaders.StaticContentBundleResourceLoader.findResource(StaticContentBundleResourceLoader.java:41) at org.apache.struts2.dispatcher.DefaultStaticContentLoader.findStaticResource(DefaultStaticContentLoader.java:163) ...
          Hide
          TangYong added a comment -

          Hi Lukasz, Christina,

          I have finished and updating my source and Please seeing it again.

          Please according to readme's using way to see the result.

          In addition, updating into felix 4.0.x has been also finished.

          Thanks
          --Tang

          Show
          TangYong added a comment - Hi Lukasz, Christina, I have finished and updating my source and Please seeing it again. Please according to readme's using way to see the result. In addition, updating into felix 4.0.x has been also finished. Thanks --Tang
          Hide
          Christina Kaskoura added a comment -

          As a temporary workaround I managed to deploy the sample application in GlassFish by using the GlasssFish_Platform=Static option which starts GlassFish without OSGi. However, when attempting to use Struts version 2.3.8 instead of 2.3.1 I get the attached errors, which seem to be due to the fact that the XWork file manager is null. I get the same errors also when deploying in Tomcat instead of GlassFish.

          Show
          Christina Kaskoura added a comment - As a temporary workaround I managed to deploy the sample application in GlassFish by using the GlasssFish_Platform=Static option which starts GlassFish without OSGi. However, when attempting to use Struts version 2.3.8 instead of 2.3.1 I get the attached errors, which seem to be due to the fact that the XWork file manager is null. I get the same errors also when deploying in Tomcat instead of GlassFish.
          Hide
          TangYong added a comment -

          Hi Lukasz,

          OK, and I am refracting my source and tomorrow, I will complete and update it. Once finishing it, I will notice you.

          In addition, about updating felix 4.x, there are still some codes needing to be updated. So, please wait.

          Thanks

          -Tang

          Show
          TangYong added a comment - Hi Lukasz, OK, and I am refracting my source and tomorrow, I will complete and update it. Once finishing it, I will notice you. In addition, about updating felix 4.x, there are still some codes needing to be updated. So, please wait. Thanks -Tang
          Hide
          Lukasz Lenart added a comment -

          TangYong I've checked out your code and it's missing GlassfishOSGiHost class, could you add it?

          Show
          Lukasz Lenart added a comment - TangYong I've checked out your code and it's missing GlassfishOSGiHost class, could you add it?
          Hide
          TangYong added a comment -

          I have made a fixing on my github to update felix 1.4.1 to 4.0.2.
          Please see.

          https://github.com/tangyong/struts2-osgi-plugin-glassfish

          Thanks
          --Tang

          Show
          TangYong added a comment - I have made a fixing on my github to update felix 1.4.1 to 4.0.2. Please see. https://github.com/tangyong/struts2-osgi-plugin-glassfish Thanks --Tang
          Hide
          Lukasz Lenart added a comment -

          First step is to upgrade Felix to the latest version.

          Show
          Lukasz Lenart added a comment - First step is to upgrade Felix to the latest version.
          Hide
          Christina Kaskoura added a comment -

          Tested with this sample application found here

          Show
          Christina Kaskoura added a comment - Tested with this sample application found here

            People

            • Assignee:
              Lukasz Lenart
              Reporter:
              Christina Kaskoura
            • Votes:
              0 Vote for this issue
              Watchers:
              4 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:

                Development