You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by Thorsten Schöning <ts...@am-soft.de> on 2018/11/23 16:06:54 UTC

Re: What is the correct place to specifiy SPI service files for Java?

Guten Tag Mark Thomas,
am Mittwoch, 1. August 2018 um 21:12 schrieben Sie:

> Service files are loaded by class loaders from the META-INF/services
> directory.

> *.jar!/META-INF/services
> and
> *.war/WEB-INF/classes/META-INF/services
> are visible to class loaders

> *.war!/META-INF/services
> is not.

I just came across another issue with using service files in my
environment: "Something" works in Ubuntu 16.04 with Tomcat 7 and Java
8, while it doesn't in Windows 10 with the same version of Tomcat and
Java.

The important thing to note is that I'm using Axis 2 in this scenario
and the service file is part of a service I'm hosting within Axis 2.
This results in the following directory in both environments:

> [...]\webapps\axis2\WEB-INF\services\de.am_soft.sm_mtg.backend\META-INF\services\SOME_FILE

Using Process Monitor I can see that only the following directories
are queried on Windows:

> [...]\webapps\axis2\WEB-INF\classes\META-INF\services\SOME_FILE
> [...]\lib\META-INF\services\SOME_FILE

Querying the above two dirs looks like what you have written before
and that explains why it fails on Windows. But it doesn't on Ubuntu,
while it does fail if I remove the "services"-dir where it is
currently. So querying this dir seems non-standard.

But who is querying it most likely, Tomcat or Axis 2? I came across
different classloaders in Axis 2 for different OS in the past already,
so I guess it has to do with Axis 2. What do you think?

I'm using ServiceLoader the following way:

> ClassLoader                cl = MdRecOmsEnc.class.getClassLoader();
> ServiceLoader<MdRecOmsEnc> sl = ServiceLoader.load(MdRecOmsEnc.class, cl);
> Iterator<MdRecOmsEnc>      it = sl.iterator();

Providing the classloader is needed for other issues in very specific
environments, but in my opinion shouldn't be the root cause, as that
is provided with Ubuntu as well.

Mit freundlichen Grüßen,

Thorsten Schöning

-- 
Thorsten Schöning       E-Mail: Thorsten.Schoening@AM-SoFT.de
AM-SoFT IT-Systeme      http://www.AM-SoFT.de/

Telefon...........05151-  9468- 55
Fax...............05151-  9468- 88
Mobil..............0178-8 9468- 04

AM-SoFT GmbH IT-Systeme, Brandenburger Str. 7c, 31789 Hameln
AG Hannover HRB 207 694 - Geschäftsführer: Andreas Muchow


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org