我目前正在编写一个小程序,并希望将Blazeds与Flex结合使用。 Blazeds和我的MySQL数据库之间的连接工作正常但是当我尝试通过运行的catalina服务器上的RemoteObject连接时,我总是收到一条错误消息:
[RPC Fault faultString =“没有ID为'employeeService'的目的地已在任何服务中注册。” faultCode =“Server.Processing”faultDetail =“null”] 在mx.rpc :: AbstractInvoker / http://www.adobe.com/2006/flex/mx/internal :: faultHandler()[E:\ dev \ 3.0.x \ frameworks \ projects \ rpc \ src \ mx \ RPC \ AbstractInvoker.as:216] 在mx.rpc :: Responder / fault()[E:\ dev \ 3.0.x \ frameworks \ projects \ rpc \ src \ mx \ rpc \ Responder.as:49] 在mx.rpc :: AsyncRequest / fault()[E:\ dev \ 3.0.x \ frameworks \ projects \ rpc \ src \ mx \ rpc \ AsyncRequest.as:103] 在NetConnectionMessageResponder / statusHandler()[E:\ dev \ 3.0.x \ frameworks \ projects \ rpc \ src \ mx \ messaging \ channels \ NetConnectionChannel.as:523] 在mx.messaging :: MessageResponder / status()[E:\ dev \ 3.0.x \ frameworks \ projects \ rpc \ src \ mx \ messaging \ MessageResponder.as:222]
我检查了remoting-config文件,目的地ID就在那里。是否有必要配置catalina?
答案 0 :(得分:3)
使用Spring-Flex / Mysql / BlazeDS 4
在lib中需要罐子
sping-flex-core-1.5
mysql-connector-java-5.1.10
org.springframework.beans-3.0.5.RELEASE
org.springframework.context-3.0.5.RELEASE
org.springframework.jdbc-3.0.5.RELEASE..etc
创建员工VO动作脚本
[Bindable]
[RemoteClass (alias="com.model.employee.Employee")]
public class Employee
Java端包com.model.employee;
Employee.java
EmployeeService.java(interface).. getEmployeeById(int id)
EmployeeServiceImpl.java
@Service("employeeService")
@RemotingDestination(channels = { "my-amf", "my-secure-amf" })
public class EmployeeServiceImpl implements EmployeeService {
private final DataSource dataSource;
public UserServiceImpl(DataSource dataSource) {
this.dataSource = dataSource;
}
@RemotingInclude
public Employee getEmployeeById(int id) {
Employee employee= new Employee ();
Connection c = null;
try {
c = this.dataSource.getConnection();
PreparedStatement ps = c.prepareStatement("SELECT * FROM employee WHERE employee_id=?");
ps.setInt(1, id);
ResultSet rs = ps.executeQuery();
if (rs.next()) {
employee= new Employee();
employee.setEmployeeId(rs.getInt("employee_id"));
employee.setEmployeeName(rs.getString("employee_name"));
}
} catch (Exception e) {
e.printStackTrace();
throw new RuntimeException(e);
}
return employee;
}
在WEB-INF / classes
中放置已编译的类WEB-INF / appicationContext.xml
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:flex="http://www.springframework.org/schema/flex"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:tx="http://www.springframework.org/schema/tx"
xmlns:jdbc="http://www.springframework.org/schema/jdbc"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="
http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
http://www.springframework.org/schema/flex
http://www.springframework.org/schema/flex/spring-flex-1.5.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context-3.0.xsd
http://www.springframework.org/schema/tx
http://www.springframework.org/schema/tx/spring-tx-3.0.xsd
http://www.springframework.org/schema/jdbc
http://www.springframework.org/schema/jdbc/spring-jdbc-3.0.xsd">
<flex:message-broker>
<flex:remoting-service default-channels="my-amf" />
</flex:message-broker>
<context:annotation-config />
<context:component-scan base-package="com.model" />
<tx:annotation-driven />
<bean id="employeeService" class="com.model.employee.EmployeeServiceImpl">
<constructor-arg ref="dataSource" />
</bean>
<bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource">
<property name="driverClassName" value="com.mysql.jdbc.Driver"/>
<property name="url"
value="jdbc:mysql://dxfcmm:3306/eunice? autoReconnect=true&zeroDateTimeBehavior=convertToNull"/>
<property name="username" value="XXX" />
<property name="password" value="YYY" />
<property name="validationQuery" value="SELECT 1"/>
</bean>
不要求remote-config.xml
开火tomcat,应该看看 信息:远程启动目标'employeeService'已启动 成功。
在MMXL [绑定] private var empl:Employee;
使用resultHandler定义RemoteObject roEmp 调用roEmp.getEmployeeById(id) empl = event.result as Employee;
答案 1 :(得分:0)
我能想到的一些事情......