Im using IBM Bluemix's Java For Liberty to deploying a web app.
I was trying to get the system env and converted it to JSONObject

And I pretty sure Ive added the jar file to the classpath

However, after I ran the app(tried push to bluemix cloud and running locally in a liberty profile app server), it throws java.lang.NoClassDefFoundError

please indicate how should I configure.....
The jars in the dep-jar folder do NOT get packaged with the final application binary(war). It is meant to be used during compilation only. If you want the jar to be included in the war (use during runtime), you need to include it in WebContent/WEB-INF/lib folder.
If you create and download the Java DB Web Starter boilerplate, you will see the right structure set up - WebContent/WEB-INF/lib/nosqljson.jar
You need to add your jar's to the dep-jar folder and build the war file with the included build.xml.
Look for classPathDir in build.xml, it will look like the following.
<path id="classpathDir">
<pathelement location="bin"/>
<pathelement location="dep-jar/com.ibm.ws.javaee.jaxrs.1.1_1.0.1.jar"/>
</path>
You will need to add each of your jar's to that block. For example.
<path id="classpathDir">
<pathelement location="bin"/>
<pathelement location="dep-jar/com.ibm.ws.javaee.jaxrs.1.1_1.0.1.jar"/>
<pathelement location="dep-jar/json-1.0.0.jar"/>
</path>
Or you could do the following which would include all jar's in dep-jar.
<path id="classpathDir">
<pathelement location="bin"/>
<pathelement location="dep-jar/com.ibm.ws.javaee.jaxrs.1.1_1.0.1.jar"/>
<fileset dir="dep-jar/" includes="*.jar" />
</path>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With