将外部JAR导入Websphere Liberty?[NoClassDefFoundError的]

use*_*667 4 eclipse websphere java-ee websphere-liberty

我想在我的运行在Websphere Liberty上的JAX-RS应用程序中使用这个JSON解析器.

我做了以下事情:

1)右键单击Project - > Properties - > Java Build Path - > Add External Jar - > C:\ javalib\quick-json.jar

2)将C:\ javalib添加到环境变量CLASSPATH中

3)将文件集xml添加到serverl.xml

<library id="ExternalLibs">
    <fileset dir="C:\javalib" includes="*.jar"/>
</library>
Run Code Online (Sandbox Code Playgroud)

4)在"Java编译器"中未选中"启用项目特定设置"

5)清理项目

[编辑]

我最初创建了一个新实例,然后将其转换为@ApplicationScoped bean并将其注入.现在我收到这个错误:

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
Run Code Online (Sandbox Code Playgroud)

第一步足以让它编译.现在我得到了我学到的运行时错误.我很感激帮助!

Hol*_*ins 6

您还需要<classloader>server.xml中的应用程序定义中的元素,该元素引用共享库.例如,

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

或者,如果您的应用程序是库的唯一用户,则可以将其打包在战争的WEB-INF/lib文件夹中.(将它放在Eclipse中的WebContent/lib中应该可以实现这一点.)