Flex mySQL 数据库与 Blazeds 的连接

发布于 2024-11-28 21:02:19 字数 897 浏览 1 评论 0 原文

我目前正在编写一个小程序,希望将 Blazeds 与 Flex 结合使用。 Blazeds 和我的 MySQL 数据库之间的连接工作正常,但是当我尝试通过正在运行的 catalina 服务器上的 RemoteObject 连接时,我总是收到一条错误消息:

[RPC 故障错误字符串 =“没有向任何服务注册 id 'employeeService' 的目标” ”。错误代码=“服务器.处理”错误详细信息=“空”] 在 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]

我检查了远程配置文件和目标 id有没有。是否需要配置catalina?

I'm currently writing a little program and want to use Blazeds in combination with Flex. The connetion between Blazeds and my MySQL data base works fine but when I try to connect to via RemoteObject over the running catalina server I always get an error message:

[RPC Fault faultString="No destination with id 'employeeService' is registered with any service." faultCode="Server.Processing" faultDetail="null"]
at 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]
at mx.rpc::Responder/fault()[E:\dev\3.0.x\frameworks\projects\rpc\src\mx\rpc\Responder.as:49]
at mx.rpc::AsyncRequest/fault()[E:\dev\3.0.x\frameworks\projects\rpc\src\mx\rpc\AsyncRequest.as:103]
at NetConnectionMessageResponder/statusHandler()[E:\dev\3.0.x\frameworks\projects\rpc\src\mx\messaging\channels\NetConnectionChannel.as:523]
at mx.messaging::MessageResponder/status()[E:\dev\3.0.x\frameworks\projects\rpc\src\mx\messaging\MessageResponder.as:222]

I checked the remoting-config file and the destination id is there. Is it necessary to configure catalina?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

爱她像谁 2024-12-05 21:02:19

使用 Spring-Flex / Mysql / BlazeDS 4

在 lib 需要 jars

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

创建 Employee VO Actionscript

[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 中
[可绑定]
私有变量empl:员工;

使用 resultHandler 定义 RemoteObject roEmp
调用 roEmp.getEmployeeById(id)
empl= event.result 作为员工;

Using Spring-Flex / Mysql / BlazeDS 4

In lib need jars

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

Create Employee VO Actionscript

[Bindable]
[RemoteClass (alias="com.model.employee.Employee")]
public class Employee

Java side package 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;
}

Places complied classes in 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>

Do not require remote-config.xml

Fire up tomcat, should see
INFO: Remoting destination 'employeeService' has been started started
successfully.

IN MMXL
[Bindable]
private var empl:Employee;

define RemoteObject roEmp with resultHandler
call roEmp.getEmployeeById(id)
empl= event.result as Employee;

扎心 2024-12-05 21:02:19

我能想到的只是一些事情...

  • 确保您的 Flex 项目设置正确以引用您的服务器。项目->属性->Flex Server。
  • 在配置服务器方面,您是否已将 flex-messaging 和 blazeds jar 添加到您的项目或服务器库中?
  • 听起来可能很愚蠢,但它实际上解决了我过去的这些问题,请确保在这些类型的更改后重新启动服务器,并清理您的项目、服务器和服务器工作目录(我正在做这是通过 eclipse 在我的 Tomcat 服务器上进行的)
  • 如果您不断遇到问题并确信这可能是配置问题,请使用 交钥匙

Just a few things I can think of...

  • Make sure your flex project is set up correctly to refer to your server. Project->Properties->Flex Server.
  • In terms of configuring your server, have you added the flex-messaging and blazeds jars to your project or to your server lib?
  • As goofy as it may sound, but it's actually resolved issues like these for me in the past, make sure to restart the server after these types of changes, as well as clean your project, server, and server working directory (I'm doing this on my Tomcat server through eclipse)
  • If you keep running into issues and are convinced it may be configuration, use the turnkey
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文