1 Reply Latest reply on Aug 6, 2009 11:10 AM by YogLC

    Classpath issues inside custom component

    timo.trautmann Level 1

      Hi Forum,

       

      we have created our own component for a special database task.

      Within the the component implementation we have used XMLBeans 2.4.

      Now we run into a classloader issue because LC already contains a very old version of XML Beans (from 2004).

       

      Is there a way to have our own classloader that uses the new XML Beans version instead of the already existing one?

       

      We have planned to migrate several other components to be available inside Workbench and I'm afraid we will run into the same problem several times.

       

      Thank and best regards,

      Timo

        • 1. Re: Classpath issues inside custom component
          YogLC Level 1

          Timo,

          If you would like to override the classpath then I would suggest you to put your version of the XMLBeans jar file while making a component jar file and override the classpath in your service java class.

          See if that help.

          Thanks

          YogLC

           

           

          component.xml file defines service impl class as below

          <services>

          <service name="MY_Service">

          <!-- service implementation class definition -->

          <implementation-class>com.company.component.MYServiceImpl</implementation-class>

           

          package com.company.componen;

          public class MYServiceImpl{

           

               public void myServiemethod(){

                    // first line in your service method

                    ClassLoader originalClassloader = Thread.currentThread().getContextClassLoader();

           

                    //--- your code here ---

                    // finally make sureset the classloader back

                    if (originalClassloader != null) {

                         Thread.currentThread().setContextClassLoader(originalClassloader);

                    }

               }

          }