Grails-Plugin-Consortium / grails-cxf-client

Easy cxf client for grails
http://grails.org/plugin/cxf-client
27 stars 30 forks source link

Plugin conflicts with grails-cxf? #36

Open JonNeat opened 10 years ago

JonNeat commented 10 years ago

Hi all,

We try to use both grails-cxf-client for endpoints and grails-cxf for exposing simple services.

They both work independently (only configurating one), but not together - why? No error messages are thrown, nothing what so ever.

We are running with grails 2.3.0RC1. Everything newest version.: runtime ":cxf:1.1.1" compile ":cxf-client:1.5.6"

Can anyone help? What are we doing wrong? We even tried a whole new "hello world"-grails project, and still doesn't work.

Jon.

ctoestreich commented 10 years ago

tested with grails 2.2.1 and https://github.com/Grails-Plugin-Consortium/grails-cxf-client-demo and they work fine together. Trying 2.3.0 now with that project.

ctoestreich commented 10 years ago

The demo project also works find with grails 2.3.0. You can clone that here. https://github.com/Grails-Plugin-Consortium/grails-cxf-client-demo/tree/grails-2.3.0

I will need more info to help debug. It could be in your config or some other conflicting plugins??

TobiasMahlmann commented 10 years ago

(I'm working on the same project as the OP) I traced the problem: it only occurs when a service (or one of the classes it references) references a bean that was created by the cxf-client plugin, i.e.

@GrailsCxfEndpoint(expose=EndpointType.SIMPLE)
class MyService {
...
}

works fine.

@GrailsCxfEndpoint(expose=EndpointType.SIMPLE)
class MyService {
  def endpointBeanWasSetupByCxfClientPluginInConfigDotGroovy
...
}

does not.

ctoestreich commented 10 years ago

I am not sure I ever tested this. I would guess it has to do with the order of bean wiring or the cxf proxy class.

Can you wrap the cxf client in a grails service and call the FooService class that will in turn call the endpointbean class?

TobiasMahlmann commented 10 years ago

Hi ctoestreich, I hope I got you right:

class FooService{
    def cxfClientEndpoint
    public String someMethod(){
       ...
    }
}

@GrailsCxfEndpoint(expose=EndpointType.SIMPLE)
class MyService {
    def fooService

    public String exposedMethod(){
      return fooService.someMethod()
   }
}

This is actually our setup, but unfortunately doesn't work. It did however work with grails 1.3.7 Would it make sense to try to not use the cxf-client plugin and write the cxf XML file ourselves?

TobiasMahlmann commented 10 years ago

I found a workaround for the problem:

cxf{
    client {
        targetServiceEndpoint {
           ...
        }
}

@GrailsCxfEndpoint(expose=EndpointType.SIMPLE)
class MyService{
   def grailsApplication
   MyEndpoint myEndpoint

   private MyEndpoint getEndpoint(){
        if(myEndpoint==null){
           myEndpoint = grailsApplication.getMainContext().getBean("targetServiceEndpoint")
        }
       return myEndpoint
    }

    public String exposedMethod(){
      return getEndpoint().someMethod()
   }
}

Not pretty, but works. I don't know enough about the Spring internals to make a prettier solution though.

bilgehanm commented 8 years ago

Had a similar problem. I have a cxf service that works fine when using cxf plugin alone. In that application i also need to consume an external service. After i add cxf-client and generate the stubs using wsdl2java, i get no service found error when trying to list services. Saw similar errors, one suggested modifying the cxf-client plugin WebServiceClientFactoryImpl class.

Bus bus = Holders.grailsApplication.mainContext.getBean("cxf") as Bus JaxWsProxyFactoryBean clientProxyFactory = new JaxWsProxyFactoryBean(serviceClass: serviceInterface,address: serviceEndpointAddress, bus: bus)

(http://stackoverflow.com/questions/26470223/cant-get-cxf-and-cxf-client-to-work-at-the-same-time-grails). I tried with no luck. Grails version 2.4.5 and cxf client version 2.1.1