Search code examples
javaapache-flexexceptiongraniteds

What is simpliest way to dispatch fault event in GraniteDS service


I am trying to dispatch fault event in GraniteDS service

method call (Flex):

userService.addUser(user, null, function addUserFault(e:TideFaultEvent):void {
                Alert.show(e.fault.faultString); 
            });

server method (Spring):

@Override
    public User addUser(User user) throws Exception{
        if(findUserByName(user.getUsername()) != null)
            throw new Exception("Username Already Exist");
        entityManager.persist(user);
        return user;
    }

But what i get is silence on client side and java.lang.NoSuchMethodException in server console.
How can i use default graniteds exception converter to deliver fault event to client (Flex)?


Solution

  • Solved. I dont know if it's a bug or not, but you cannot set result function to null and specify fault function only - this wont work. My call method should look like:

    userService.addUser(user, function addUserResult(e:TideResultEvent){
                    // do nothing
                }, function addUserFault(e:TideFaultEvent):void {
                    Alert.show(e.fault.faultString); 
                });
    

    in this case java Exception in remote method will be send back to flex as TideFaultEvent.