Bluemix Java Liberty Web Project java.lang.NoClassDefFoundError: while loading third party jar

I am using IBM Bluemix Java for Liberty to deploy a web application.

I was trying to get the env system and convert it to JSONObject

enter image description here

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

enter image description here

However, after I run the app (tried to push to bluemix cloud and run locally on the libre profile app server) it throws java.lang.NoClassDefFoundError

enter image description here

please indicate how should I configure .....

+3


source to share


2 answers


The jars in the folder are dep-jar

NOT packaged with the final binary app (war). It is intended to be used at compile time only. If you want the jar to be included in the war (use it at runtime) you need to include it in the folder WebContent/WEB-INF/lib

.



If you create and upload a template template Java DB Web Starter

, you will see the correct structure configured -WebContent/WEB-INF/lib/nosqljson.jar

+1


source


You need to add your jar to the folder dep-jar

and create a war file with included build.xml

.

Search classPathDir

in build.xml

, it will look like this.

<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 jar to this 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 can do the following which will include all the jars in the 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>

      

+1


source







All Articles