springgrailsgroovyremotinghttpinvoker

grails remoting plugin - always 404?


I'm trying to expose a remote interface to a spring web application, and I'm having issues, always getting 404. What's wrong with my setup below?

Grails:
services - package mypackage

class RemoteUserService implements RemoteUserServiceInterface {
    static expose = ['httpinvoker']

    User findUser(String userId) {
        return User.findByUserId(userId);
    }
}

src/groovy/mypackage

class RemoteUserService implements RemoteUserServiceInterface {
    static expose = ['httpinvoker']

    User findUser(String userId) {
        return User.findByUserId(userId);
    }
}

Spring:
mypackage

public class MyController extends AbstractController {
    RemoteUserServiceInterface remoteUserService
}

appContext

<bean id="viewController" class="mypackage.MyController">
    <property name="remoteUserService" ref="remoteUserService"/>
</bean>

<bean id="remoteUserService" class="org.springframework.remoting.httpinvoker.HttpInvokerProxyFactoryBean">
    <property name="serviceUrl" value="http://localhost:8080/grails-app-name/httpinvoker/RemoteUserService"/>
    <property name="serviceInterface" value="mypackage.RemoteUserServiceInterface"/>
</bean>

Solution

  • You need to define a UrlMapping of

    "$controller/$action?/$id?" {}

    or else the plugin won't work correctly.