Current JSON jar conflicts with JSON classes on CM Server

I am writing some extensions to integrate CM System with Brightcove online video platform. In order to use Brightcove’s Java API (which is a wrapper around their REST API), I need to deploy a jar file with JSON classes (json-org.jar) to the class library directory (<server-root>/AppServer/server/rx/deploy/rxapp.ear/rxapp.war/WEB-INF/lib). Unfortunately, the very same classes (org.json.) that are in this jar are also in a jar file (json.jar) that’s already on the CM server in that same directory, and the class definitions (also org.json.) in that jar file are quite different from those in the newer jar file. I suspect the file on the server is older - the date on the file is 6/24/2009.

Does anyone know some way that I can load the JSON classes I need for my extension without interfering with the server’s use of the older definitions of the same class? Some trick of packaging the classes in my extension jar? Some class loading magic? Anything?

FYI - We’re on CM Server 6.7.

Thanks for any suggestions-
Kathleen

I think you are kind of stuck. The class loader will load the first of the jars it finds by default. You could try swapping jars but I am not sure what will break.

If they were in different webapps you could isolate them. I would submit a ticket to support@percussion.com requesting an upgraded JSON (include version info for BrightCove, JSON etc).

If you are in a hurry and need a quick work around you could create a separate web app and load your BrightCove JSON there, and access that app from your extension.

-n

If your json-org.jar is newer than json.jar (from 6.7) and both from the same source, then it may be ok to replace the json.jar (from 6.7) with your newer json-org.jar. If the your newer json-org.jar works for you, please submit an issue to support@percussion.com, so that the jar file will be updated for future releases.

The extension mechanism was designed to handle this kind of issue, each extension has it’s own classloader. Rather than putting the jar in the server’s common directory, you upload it as part of the definition of the extension. This jar will then only be available to this extension and any classes uploaded with the extension. Note - the current behavior of this mechanism requires that any jar(s) be included with each save of the definition.

As a side note - this is a good way to develop extensions. You can upload new instances of the class and not require a server restart. When it is fully developed, you can move it to a common jar if desired.

Thanks for the replies.

I have started working on a separate web application that will provide services to the CMS extensions, and will be my proxy to interface to Brightcove. That web app will contain the updated JSON library, which will not conflict with the older one used by CM System.

I actually already tried loading the newer JSON library in our installation of CM System 6.7, and we ran into serious errors in the publishing process, so the newer JSON jar is definitely not compatible with that version of CM System. I would leave it to Percussion to worry about upgrading their JSON, since it’s part of the server installation.

I didn’t realize that additional jars could be contained as part of an extension - that is very useful information. I think I will likely stick with the current architecture of a separate web app providing a service, but I may find that information useful in the future.

-Kathleen