I have a pretty basic Java web application (created using Eclipse openshift plugin). The app runs fine on the OpenShift server. Now I need to use an external JAR library for JSON parsing and creation in Java. I can't understand my way around how to add that JAR to openshift server.
I went to project properties>>BuildPath>>Add external JAR. While that does import the JAR, it does not work on openshift server and gives error relating to that file's import (NoClassDefFound
, I guess). Could you tell me how to import external jars into openshift project?
Since we use Maven for the build process, all you have to do is add it as a dependency in your pom.xml
Here is an example that adds a mongo driver
https://github.com/thesteve0/openshift-mongo-spatial-jee6/blob/master/pom.xml
Look under the dependencies tag
You can add the jar as a dependency in your pom.xml file. This will cause the jar to be included in your war. If the jar is not available in a public maven repo, please see here: http://www.billdecoste.net/?p=16
[Updates in 2017]
You might want to take a look at this link from OpenShift itself.
It includes information about adding jars with and without maven dependencies.