CA Service Management

  • 1.  How to create a plug-in that queries MySQL database

    Posted Oct 06, 2016 08:35 AM

    I am trying to create a plug-in in Service Catalog that will query data from a MySQL database to populate a select box.  My question is how/where to add the MySQL jar file.

     

    I have followed the document http://www.ca.com/us/services-support/ca-support/ca-support-online/knowledge-base-articles.tec1267716.html to create the new plug-in.  In addition, I did the following:

     

    1)  updated the plugin code to include my MySQL connection and query

    2)  added the MySQL jar to the 'lib' folder under 'select.custom-src'

    3)  added the jar file name to build.xml:

      <path id="compile.src.classpath">
        <pathelement location="build" />
        <pathelement location="lib/commons-logging-api.jar" />
        <pathelement location="lib/plugins.apis.jar" />
        <!-- Add any additional jars here -->
        <pathelement location="lib/myql-connector-java-5.1.39-bin.jar" />
      </path>

    4) I ran 'ant', then continued on with the directions to copy plugin.jar and plugin.properties to the correct directory and reload the plug-in in Service Catalog.

     

    When I test my form, I am getting this error in the log:

    2016/10/06 07.52.26.033 TRACE [http-bio-8080-exec-14] [PrivateContextClassLoader] Class:com.mysql.jdbc.Driver is allowed to be loaded:false
    2016/10/06 07.52.26.033 TRACE [http-bio-8080-exec-14] [PluginClassLoader] Parent classloader could not find class :com.mysql.jdbc.Driver
    java.lang.ClassNotFoundException: com.mysql.jdbc.Driver

              

    Can someone provide some direction for the proper MySQL jar location?

     

    Thanks!!



  • 2.  Re: How to create a plug-in that queries MySQL database

    Broadcom Employee
    Posted Oct 06, 2016 09:38 AM


  • 3.  Re: How to create a plug-in that queries MySQL database

    Posted Oct 07, 2016 01:24 PM

    Thanks for the help Louis.  I looked through the info on each link, but I didn't really see anything that related to what I'm trying to do.



  • 4.  Re: How to create a plug-in that queries MySQL database

    Posted Oct 06, 2016 05:52 PM

    In your plugin.properties make sure 'classloader.type=shared' rather than 'classloader.type=private'.



  • 5.  Re: How to create a plug-in that queries MySQL database

    Posted Oct 07, 2016 01:52 PM

    Thanks Jason.  I changed 'private' to 'shared', but I'm still getting the same error. 

     

    I have looked at the build.xml and I see that external jars are added to the classpath for compiling, but how does it resolve the jars during run-time?  Here's what I see when I list the contents of my custom plugin using 'jar tf':

     

    META-INF/
    META-INF/MANIFEST.MF
    com/
    com/ca/
    com/ca/usm/
    com/ca/usm/plugins/
    com/ca/usm/plugins/custom/
    com/ca/usm/plugins/custom/select/
    com/ca/usm/plugins/custom/select/CustomExpressServerSelectPlugin.class

     

    I am not very familiar with 'Ant' and the build.xml file.  Should there be something pointing to the external plug-ins like the MySQL one?

     

    Thanks!



  • 6.  Re: How to create a plug-in that queries MySQL database

    Posted Oct 11, 2016 10:19 AM

    You should just need to add the .jar to lib and reference from build.xml as you noted in step 3 above.

     

    From the excerpt of the log it seems the mysql class was not accessible based on classloader.type=private in plugin.properties:

     

    [PrivateContextClassLoader] Class:com.mysql.jdbc.Driver is allowed to be loaded:false

     

    After updating to 'shared' did you 'Reload Plugins'? 

     

    If so can you test the form again and check the log?



  • 7.  Re: How to create a plug-in that queries MySQL database
    Best Answer

    Posted Oct 11, 2016 01:08 PM

    Thanks Jason!  That did not work either and I think it is because the reference to compile.src.classpath does not directly affect the runtime.  Since I could see a manifest.mf file in my plugin.jar, I decided to try adding a manifest task to the build.xml to include the MySQL jar file like below.  Thankfully this worked so I was able to successfully retrieve the data using the plug-in.

     

     

      <target name="jar" depends="build" description="creates jar file">
        <mkdir dir="build/META-INF" />
        <jar destfile="plugin.jar" basedir="build" />
        <manifest file="build/META-INF/MANIFEST.MF">
            <attribute name="Class-Path" value="lib/mysql-connector-java-5.1.39-bin.jar" />
        </manifest>
      </target>



  • 8.  Re: How to create a plug-in that queries MySQL database

    Posted Oct 11, 2016 01:42 PM

    Thanks for the update, Michele! Apologies for the confusion, you can also copy the .jar over to ..\Service Catalog\view\webapps\usm\WEB-INF\lib for runtime (I had done this a while ago for the plugin I was testing with).