4

I want to use this JSON parser in my JAX-RS application that runs on Websphere Liberty.

I have done the following:

1) Right-click on Project -> Properties -> Java Build Path -> Add External Jar -> C:\javalib\quick-json.jar

2) Added C:\javalib to enviroment variable CLASSPATH

3) Added fileset xml to serverl.xml

<library id="ExternalLibs">
    <fileset dir="C:\javalib" includes="*.jar"/>
</library>

4) Unchecked 'Enable project specific settings' in 'Java Compiler'

5) Cleaned the Project

[EDIT]

I was initially creating a new instance and then I turned it into an @ApplicationScoped bean and injected it. Now I get this error:

The JNDI lookup failed for JNDI name java:module/ConsoleREST with the following Exception CNTR4007E: An error occurred creating the websphere.jaxrs.service.ConsoleREST interface for the ConsoleREST enterprise bean in the WebApiConsole.war module in the WebApiConsole application. The enterprise bean look up failed using the java:module/ConsoleREST JNDI name. Exception: com/json/parsers/JsonParserFactory.
CNTR4007E: An error occurred creating the websphere.jaxrs.service.ConsoleREST interface for the ConsoleREST enterprise bean in the WebApiConsole.war module in the WebApiConsole application. The enterprise bean look up failed using the java:module/ConsoleREST JNDI name. Exception: com/json/parsers/JsonParserFactory

The first step was enough to get it to compile. Now I'm getting what I learned to be a runtime error. I would appreciate help!

user2316667
  • 5,444
  • 13
  • 49
  • 71

1 Answers1

6

You also need a <classloader> element in your application definition in the server.xml, which references the shared library. For example,

<application id="myapp" name="My App" type="war" location="somewhere.war"> <classloader commonLibraryRef="ExternalLibs" /> </application>

Alternatively, if your application is the only user of the library, you could package it in the WEB-INF/lib folder of your war. (Putting it in WebContent/lib in Eclipse should accomplish this.)

Holly Cummins
  • 10,767
  • 3
  • 23
  • 25
  • Thanks so much! I wasted two-three hours last night and did not figure it out. Where did you get this information if I may inquire? Just for my own future reference. – user2316667 Jun 19 '14 at 13:15
  • I used http://pic.dhe.ibm.com/infocenter/radhelp/v9/index.jsp?topic=%2Fcom.ibm.websphere.wlp.nd.multiplatform.doc%2Fae%2Ftwlp_classloader.html, although that's actually RAD documentation. – Holly Cummins Jun 20 '14 at 09:49
  • The websphere tag on this site (http://stackoverflow.com/tags/websphere/info) has links to various documentation. The corresponding link in the WebSphere Application Server documentation is here: http://www-01.ibm.com/support/knowledgecenter/SS7K4U_8.5.5/com.ibm.websphere.wlp.nd.multiplatform.doc/ae/twlp_classloader.html – Brett Kail Jun 21 '14 at 19:26
  • @HollyCummins I am facing issue with Liberty shared library configuration for a simple Spring Web application.Can you pls help me on this question http://stackoverflow.com/questions/41307906/shared-library-jar-are-not-loaded-by-liberty – springbootlearner Dec 30 '16 at 16:34