sun.nio.fs.UnixException No such file or directory

4.1k views Asked by At

I have SOAP web service deployed on Wildfly 15 linux server and I am using Dynatrace for monitoring this web service.Log4j2 for logging. I am logging every detail in code and I have duration of every private and public methods' execution. At first look everythink is fine, but I have one strange case. When I am looking in log, for example one request of web method has 80ms duration, but in Dynatrace it has 780.

In Dynatrace when I am looking at this request's details, there is the situation, It takes 700ms for some sun.nio.fs.UnixException which appears just in dynatrace, than goes in web method and web method needs 80ms(Like in the log).

There is details of this sun.nio.fs.UnixException :

Exception:
sun.nio.fs.UnixException

Message:
No such file or directory

Stacktrace:
sun.nio.fs.UnixNativeDispatcher.access0(UnixNativeDispatcher.java)
sun.nio.fs.UnixNativeDispatcher.access(UnixNativeDispatcher.java:449)
sun.nio.fs.UnixFileSystemProvider.checkAccess(UnixFileSystemProvider.java:306)
java.nio.file.Files.exists(Files.java:2385)
org.jboss.modules.PathResourceLoader.lambda$
org.jboss.modules.PathResourceLoader$$Lambda$.run
org.jboss.modules.PathResourceLoader.doPrivilegedIfNeeded(PathResourceLoader.java:248)
org.jboss.modules.PathResourceLoader.getResource(PathResourceLoader.java:155)
org.jboss.modules.ModuleClassLoader.loadResourceLocal(ModuleClassLoader.java:410)
org.jboss.modules.ModuleClassLoader$1.loadResourceLocal(ModuleClassLoader.java:144)
org.jboss.modules.Module.getResource(Module.java:764)
org.jboss.modules.ModuleClassLoader.findResource(ModuleClassLoader.java:616)
org.jboss.modules.ConcurrentClassLoader.getResource(ConcurrentClassLoader.java:255)
java.lang.Class.getResource(Class.java:2267)
ge.my.package.ws.security.ConfigManager.getConfigManager(ConfigManager.java:44)
ge.my.package.ws.Ccs.handleUserRequest(Ccs.java:610)
ge.my.package.ws.Ccs.getAuthorizationsByCardSerno(Ccs.java:466)
sun.reflect.GeneratedMethodAccessor.invoke
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
java.lang.reflect.Method.invoke(Method.java:498)
com.sun.xml.ws.util.Trampoline.invoke(MethodUtil.java:82)
sun.reflect.GeneratedMethodAccessor.invoke
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
java.lang.reflect.Method.invoke(Method.java:498)
com.sun.xml.ws.util.MethodUtil.invoke(MethodUtil.java:107)
com.sun.xml.ws.api.server.MethodUtil.invoke(MethodUtil.java:64)
com.sun.xml.ws.api.server.InstanceResolver$1.invoke(InstanceResolver.java:250)
com.sun.xml.ws.server.InvokerTube$2.invoke(InvokerTube.java:149)
com.sun.xml.ws.server.sei.SEIInvokerTube.processRequest(SEIInvokerTube.java:88)
com.sun.xml.ws.api.pipe.Fiber.__doRun(Fiber.java:1136)
com.sun.xml.ws.api.pipe.Fiber._doRun(Fiber.java:1050)
com.sun.xml.ws.api.pipe.Fiber.doRun(Fiber.java:1019)
com.sun.xml.ws.api.pipe.Fiber.run(Fiber.java:813)
com.sun.xml.ws.api.pipe.Fiber.start(Fiber.java:420)
com.sun.xml.ws.server.WSEndpointImpl.processAsync(WSEndpointImpl.java:368)
com.sun.xml.ws.server.WSEndpointImpl.process(WSEndpointImpl.java:398)
com.sun.xml.ws.transport.http.HttpAdapter.invokeAsync(HttpAdapter.java:734)
com.sun.xml.ws.transport.http.servlet.ServletAdapter.invokeAsync(ServletAdapter.java:212)
com.sun.xml.ws.transport.http.servlet.WSServletDelegate.doGet(WSServletDelegate.java:161)

and There is my code of ge.my.package.ws.security.ConfigManager.geConfigManager(ConfigManager.java:44) Line:

URL url = CcsConfigManager.class.getResource("/config.properties");

There looks like, it tries to take configuration file even before request really goes into web method and starts logging(I have log as soons as request goes into web method), I even don't have anything in log about this try and error message. When it goes into web method and starts logging, it takes and reads config.properties file and everything is fine.

I have Dynatrace just to monitor production server and as I said I have nothing in the log about this error, because of this reasons I cann't make any deep research about this problem, I don't really know if this is a problem of my code, environment or dynatrace shows something wrong.

  1. If it really goes into my service and calls my methods with fail, why don't I have anything in the log ? If something happens in the serivce, any kind of RuntimeException I am logging them.
  2. Does it affects on response time? How should I know is it realy 80ms or 780ms ?
  3. If it is possible what can I do to write this error in the log?
1

There are 1 answers

1
rmunge On
  1. The thrown sun.nio.fs.UnixException is catched within java.nio.io.Files#exists (for the the code see here). That's the reason why you do not see the exception in your logs.

  2. Since the code that triggers the exception is executed before your method is entered, this increases of course the response time of the whole request. The Files.exists method has noticeably poor performance in JDK 8, and can slow an application significantly when used to check files that don't actually exist. Source code analysis tools like Sonar even show a warning for this (see for example here). The root cause of the poor performance is the exception that is shown by Dynatrace, or to be more precise, it is its costly fillInStackTrace() method.

  3. You cannot log exceptions that are catched by JRE-internal classes or third party libraries. The only way to track all thrown exceptions is to use monitoring tools like Dynatrace or you develop your own monitoring tool that makes use of the Java Instrumentation / Agent API.