Java JAX-RPC NoClassDefFoundError 错误
我是 JAX-RPC 新手。我尝试在 RAD 7.0 中创建一个简单的 Java bean,并通过选项来创建 JAX-RPC Web 服务。我的方法如下。
public byte[] getData(byte[] argument) {
<Customclass> proxy = new <Customclass>();
List outputList = new ArrayList();
try {
// Call a method on proxy
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
byte[] output = getBytesFromObject(outputList);
return output;
}
1)如果我不导入任何依赖类,那么从客户端调用时效果很好。 2)但是,当我导入依赖类(上面显示的自定义类)时,我会看到下面的异常。
[9/12/09 9:59:00:182 IST] 00000026 UserException E WSWS3228E: Error: Exception: WebServicesFault
faultCode: {http://schemas.xmlsoap.org/soap/envelope/}Server.generalException
faultString: java.lang.NoClassDefFoundError: <Customclass>
faultActor: null
faultDetail:
java.lang.NoClassDefFoundError:
打包 - 上述方法驻留在应用程序(ear)中,该应用程序将所有必要的类作为 jar 文件包含在 Ear 中。上述方法是从客户端 - JAX-RPC 客户端调用的。
如果有人可以指导我,我将不胜感激。
I am new to JAX-RPC. I tried creating a simple Java bean in RAD 7.0, and went through the options to create a JAX-RPC webservice. My method is as below.
public byte[] getData(byte[] argument) {
<Customclass> proxy = new <Customclass>();
List outputList = new ArrayList();
try {
// Call a method on proxy
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
byte[] output = getBytesFromObject(outputList);
return output;
}
1) This works fine when called from a client, if i do not import any dependent classes.
2) However, when i import a dependent class (Customclass shown above), i get to see the below exception.
[9/12/09 9:59:00:182 IST] 00000026 UserException E WSWS3228E: Error: Exception: WebServicesFault
faultCode: {http://schemas.xmlsoap.org/soap/envelope/}Server.generalException
faultString: java.lang.NoClassDefFoundError: <Customclass>
faultActor: null
faultDetail:
java.lang.NoClassDefFoundError:
Packaging - the above method resides in an application(ear) which has all the necessary classes included as jar files within the ear. The above method is invoked from a client - JAX-RPC client.
Would appreciate if someone could guide me on this.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
jar 是在 /lib 文件夹中还是在部署描述符中指定的文件夹中?以下内容摘自 JSR-000244 JavaTM Platform, Enterprise Edition 5 规范 第 8.2.1 节。
EE.8.2.1
捆绑库
与应用程序捆绑在一起的库可以通过以下方式引用:
JAR 格式文件(例如 .jar 文件、.war 文件或 .rar 文件)可以通过命名引用的 .jar 文件或目录来引用 .jar 文件或目录。引用 JAR 文件的清单文件中的类路径标头中的 jar 文件或目录。引用的 .jar 文件或目录使用相对于引用的 URL 的 URL 来命名
JAR 文件。 Manifest 文件在 JAR 文件中名为 META-INF/MANIFEST.MF。清单文件中的类路径条目的形式为
类路径:jar 文件或目录列表(用空格分隔)
.ear 文件可能包含一个目录,该目录包含打包在 JAR 文件中的库。 .ear 文件的部署描述符的library-directory 元素包含该目录的名称。如果未指定库目录元素,
或者,如果 .ear 文件不包含部署描述符,则使用名为 lib 的目录。空的库目录元素可用于指定
没有库目录。
此目录(但不是子目录)中具有 .jar 扩展名的所有文件必须可供打包在 EAR 文件中的所有组件(包括应用程序客户端)使用。这些库可能引用其他库,或者捆绑在一起
使用此处描述的任何技术与应用程序一起安装或单独安装。
Web 应用程序可能包含 WEB-INF/lib 目录中的库。有关详细信息,请参阅 Servlet 规范。这些库可以使用此处描述的任何技术引用其他库,这些库可以与应用程序捆绑在一起,也可以单独安装。
另外,将 CustomClass 变量声明放入 try/catch & 中。看看您是否获得有关该异常的更多信息。
Are the jars in the /lib folder or the folder specified in the deployment descriptor? The following is from the JSR-000244 JavaTM Platform, Enterprise Edition 5 Specification section 8.2.1.
EE.8.2.1
Bundled Libraries
Libraries bundled with an application may be referenced in the following ways:
A JAR format file (such as a .jar file, .war file, or .rar file) may reference a .jar file or directory by naming the referenced .jar file or directory in a Class-Path header in the referencing JAR file’s Manifest file. The referenced .jar file or directory is named using a URL relative to the URL of the referencing
JAR file. The Manifest file is named META-INF/MANIFEST.MF in the JAR file. The Class-Path entry in the Manifest file is of the form
Class-Path: list-of-jar-files-or-directories-separated-by-spaces
A .ear file may contain a directory that contains libraries packaged in JAR files. The library-directory element of the .ear file’s deployment descriptor contains the name of this directory. If a library-directory element isn’t specified,
or if the .ear file does not contain a deployment descriptor, the directory named lib is used. An empty library-directory element may be used to specify
that there is no library directory.
All files in this directory (but not subdirectories) with a .jar extension must be made available to all components packaged in the EAR file, including application clients. These libraries may reference other libraries, either bundled
with the application or installed separately, using any of the techniques described herein.
A web application may include libraries in the WEB-INF/lib directory. See the Servlet specification for details. These libraries may reference other libraries, either bundled with the application or installed separately, using any of the techniques described herein.
Also, put the CustomClass variable declaration inside a try/catch & see if you get more information about the exception.
我遇到了 XStream - 它允许我按原样使用现有对象并将它们作为 xml 字符串传递到服务器,并在服务器端从 xml 字符串重新创建对象。
我想这是将 Map、List 对象从客户端传递到服务器的一种方法。
我计划现在将服务器模块移动到远程盒子。
I came across XStream - that allowed me to use my existing object as is and pass them to the server as a xml string, and re-create the object from xml string on the server side.
I guess this is one way to pass Map, List objects from client to server.
I plan to move the server module across to a remote box now.