6

Is there a way to reference a handler configuration file (e.g.: handler.xml) that is distributed inside a JAR file?

Something like this: @HandlerChain(file="somefile.jar") or @HandlerChain(file="myhandler.xml"), assuming that myhandler.xml is stored in somefile.jar.

Joaquim Oliveira
  • 1,208
  • 2
  • 16
  • 29

4 Answers4

5

For both server and client implementations of handlers using the @HandlerChain annotation, you must specify the location of the handler configuration as either a relative path from the annotated file or as an absolute URL. For example:

@HandlerChain(file="../../common/handlers/myhandlers.xml")

or

@HandlerChain(file="http://foo.com/myhandlers.xml")

Taken from this doc.

1

handler-chain.xml file must be inside the same classpath or same jar. You need to specify the actual location of xml to load.

Vinod Cyriac
  • 189
  • 2
  • 4
1

If there is no tight dependency on configuration file, you can skip it alltogether and handle everything in the code itself.

List<Handler> handlerChain = new ArrayList<>();
handlerChain.add(new MyHandler());
((BindingProvider) port).getBinding().setHandlerChain(handlerChain);
Vasudev
  • 803
  • 1
  • 7
  • 16
0

I noticed when creating a jar, xml file was being excluded. So I moved my xml file to

resources/handlers/callbackHandler.xml

and then referred to this file as

@HandlerChain(file = "/handlers/callbackHandler.xml")
Hritik Gupta
  • 611
  • 5
  • 20