简体   繁体   English

尽管存在JAR,但找不到类异常

[英]class not found exception though JAR exists

I am deploying a web application to weblogic with a bunch of JAR files in web-inf\\lib. 我正在使用web-inf \\ lib中的一堆JAR文件将Web应用程序部署到weblogic。 When I invoke a number of methods from classes in these jar files in my servlet - things work fine . 当我从servlet的这些jar文件中的类调用许多方法时,一切正常。 However I have a RMI client jar also - and when I invoke one of its methods - it gives me ClassNotFoundException : 但是我也有一个RMI客户端jar-当我调用其方法之一时-它给了我ClassNotFoundException

Caused By: java.lang.ClassNotFoundException: com.xyz.RMIClientImpl 
    at sun.rmi.server.LoaderHandler.loadClass(LoaderHandler.java:393)
    at sun.rmi.server.LoaderHandler.loadClass(LoaderHandler.java:185)
    at java.rmi.server.RMIClassLoader$2.loadClass(RMIClassLoader.java:637)
    at java.rmi.server.RMIClassLoader.loadClass(RMIClassLoader.java:219)
    at java.rmi.server.RMIClassLoader.loadClass(RMIClassLoader.java:152)

I dont quite understand classloading in application server but from stacktrace it is clearly seen that some rmi classloader is trying to load the class and not finding it - though it is very much present in my web-inf/lib 我不太了解应用程序服务器中的类加载,但是从stacktrace中可以清楚地看到一些rmi类加载器正在尝试加载类而不是找到它-尽管它在我的web-inf / lib中非常存在

NOTE1 : If I try and load the class myself using Class.forName("com.xyz.RMIClientImpl") it works fine . 注意1 :如果我尝试使用Class.forName("com.xyz.RMIClientImpl")自己加载类,则可以正常工作。

So something related to classloading and RMI - if someone can explain what is happening would be great . 所以与类加载和RMI有关的东西-如果有人可以解释发生的事情将会很棒。

NOTE2 : If I try a stand alone client ( not a web application ) and invoke the RMI Client things work fine - so the issue is only when deployed to an app server ( weblogic ) 注意2 :如果我尝试使用独立客户端(而不是Web应用程序)并调用RMI Client,则一切正常,因此问题仅在部署到应用程序服务器(weblogic)时出现

NOTE3 : I copied all my jars from my application's lib folder and placed them in weblogic's library and then I did not get this exception. 注意3 :我从应用程序的lib文件夹中复制了所有jar,并将其放在weblogic的库中,然后没有得到此异常。 Yes I am aware that this is not the right way to solve the issue but then please do point me in the right direction :) 是的,我知道这不是解决问题的正确方法,但请确实指出正确的方向:)

NOTE4 : setting up the following also did not help: 注意4 :设置以下内容也无济于事:

<wls:container-descriptor><wls:prefer-web-inf-classes>true</wls:prefer-web-inf-classes></wls:container-descriptor>

Try this ! 尝试这个 ! You need to add the jar to the classpath explicitly. 您需要将jar显式添加到类路径。 right click on project name -> Project properties -> Library and Classpath -> Add jar/directory 右键单击项目名称->项目属性->库和类路径->添加jar /目录

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM