Topic
4 replies Latest Post - ‏2013-12-04T15:37:35Z by CBD6_Christoph_Ihrenberger
U6HU
U6HU
2 Posts
ACCEPTED ANSWER

Pinned topic java.lang.NoClassDefFoundError in Websphere Liberty when accessing classes from runtime

‏2013-11-12T12:57:16Z |

Hi,

 

Our application uses  org.apache.openjpa.jdbc.meta.ValueMapping and other Classes from jar available in websphere runtimes. However the application is unable to start because it can't find those classes during startup with  java.lang.NoClassDefFoundError

We have default class loading (parentFirst) in the webapp. It uses JSF2, JPA2 and CDI. It runs fine on websphere full profiles. Is this an issue due to the lazy loading of feature within liberty profile, maybe?

Thank you

  • AlexMulholland
    AlexMulholland
    32 Posts
    ACCEPTED ANSWER

    Re: java.lang.NoClassDefFoundError in Websphere Liberty when accessing classes from runtime

    ‏2013-11-12T15:58:20Z  in response to U6HU

    Hi,

    The org.apache.openjpa packages are classified as 'third-party' API in Liberty.  This reflects the minor risk of incompatible changes when Liberty moves to a later version of OpenJPA because we don't control the code.  To ensure you are aware of that risk we require you to override the default class loading and explicitly configure access to third-party packages, as documented at this link:

    http://www14.software.ibm.com/webapp/wsbroker/redirect?version=phil&product=was-libcore-mp&topic=twlp_classloader_3p_apis

    You will need to add a configuration entry for your application along these lines….

    <application id="scholar" name="Scholar" type="ear" location="scholar.ear">

    <classloader apiTypeVisibility="spec, ibm-api, api, third-party" />

    
    </application>
    

    Also note that if your application is configured to access any shared libraries, those will also need to be configured to have third-party API access.

    I hope this helps.

    Regards, Alex.

    • U6HU
      U6HU
      2 Posts
      ACCEPTED ANSWER

      Re: java.lang.NoClassDefFoundError in Websphere Liberty when accessing classes from runtime

      ‏2013-11-12T16:38:14Z  in response to AlexMulholland

      Thank you Alex for this helpful answer.

      The Application runs on primefaces. It is included in its Maven POM. Does primefaces have to be a shared library then? Primefaces tries to instantiate runtime classes from MyFaces when it applies AjaxBehaviorHandlers to UIComponents. Ultimately it does the following:

       Class.forName("org.apache.myfaces.view.facelets.FaceletCompositionContext");

      This works in Full Server profile but not on Liberty? Is this also a class-loading issue as before?

       

      Cheers,

      markus

      • bergmark
        bergmark
        42 Posts
        ACCEPTED ANSWER

        Re: java.lang.NoClassDefFoundError in Websphere Liberty when accessing classes from runtime

        ‏2013-11-12T20:49:11Z  in response to U6HU

        WebSphere Liberty Profile does not currently expose any of the MyFaces internal classes as 3rd party SPI.

        One option might be to disable the jsf-2.0 feature in your server.xml and bundle your own MyFaces jars.  You would lose EE injection support into JSF managed instances (@Resource, @Inject into JSF Managed Beans), and you would lose integration with CDI (Conversation scope wouldn't work correctly, and CDI wouldn't have its hook into EL evaluation).

        • CBD6_Christoph_Ihrenberger
          1 Post
          ACCEPTED ANSWER

          Re: java.lang.NoClassDefFoundError in Websphere Liberty when accessing classes from runtime

          ‏2013-12-04T15:37:35Z  in response to bergmark

          Are there any plans for future versions that libertyprofile allows access to internal classes/apis?

          Regards, Christoph