How to configure @HandlerChain to point to a handler chain configuration file inside a JAR file?
Asked Answered
C

4

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.

Coimbatore answered 26/10, 2011 at 20:46 Comment(0)
A
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.

Aerobatics answered 26/10, 2011 at 20:49 Comment(4)
Gonzalo, does it work even if the handler configuration file is inside a JAR included in my WEB-INF/lib ?Coimbatore
I believe the XML file needs to be in the same jar as the class that is using it, no matter where the jar is located.Aerobatics
Gonzalo, my problem is that the XML is in a JAR file, as a dependency (e.g: my-handler.jar), and the web services are part of a webapp that uses this dependency. So, I cannot put the XML file and the classes in the same jar.Coimbatore
I am not aware of any strategy to read the xml configuration file if it is in another jarAerobatics
W
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.

Wrack answered 31/1, 2013 at 12:41 Comment(1)
Could you add some resource (manual, wiki, ...) as a reference?Starla
R
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);
Ripple answered 27/11, 2019 at 17:27 Comment(0)
D
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")
Diathermic answered 27/5, 2022 at 8:17 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.