0
votes

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?

2
Did you restart your server after modifying your config files?dtuckernet

2 Answers

3
votes

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&amp;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;

0
votes

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