搞了有一会了,搞不出来。
在Web应用程序中我写的
StudentService.java
interface StudentService extends Remote{
List getStudents()
}
StudentServiceImpl .java
class StudentServiceImpl implements StudentService{
static expose = ['hessian', 'rmi']
static remote = [
protocol: 'hessian',
iface: StudentService,
host: 'localhost',
port: '8080',
webcontext: 'Student',
]
@Override
public List getStudents() {
ArrayList students=Student.list()
println students
return students;
}
}
Student这个类我序列化了。 我已经安装了插件remoting,其实我是按照http://www.grails.org/plugin/remoting 一步一步操作的。
在客户端的应用程序写的代码:并且加入了hessian-3.2.0.jar
StudentService.java
interface StudentService{
List getStudents()
}
RemoteClient .java
public class RemoteClient {
public static main(args) {
def url = "http://localhost:8080/GrailsTest/hessian/StudentServiceImpl"
def factory = new HessianProxyFactory()
def basic = factory.create(StudentService.class,url)
println basic.getStudents()
}
}
在web控制台的错误:
org.springframework.beans.factory.NoSuchBeanDefinitionException: No bean named 'hessian.StudentServiceImpl' is defined
在客户端应用程序的错误:
Exception in thread "main" com.caucho.hessian.client.HessianConnectionException: 500: java.io.IOException: Server returned HTTP response code: 500 for URL: http://localhost:8080/GrailsTest/hessian/StudentServiceImpl
我的分析:我知道web这里没有配置好,唉,菜鸟嘛,能力有限。。求帮助了。谢谢哈