RegistryException: The system cannot find the file specified

320 views
Skip to first unread message

Gruverman, Steven

unread,
Sep 3, 2015, 5:11:50 PM9/3/15
to jniwrappe...@teamdev.com, jniwrapp...@teamdev.com

We just purchased JNIWrapper (3.10) and are trying to use it in an application that is running as a Windows service using a org.tanukisoftware.wrapper.

 

When I try to open a Registry key (which I know exists), we get this exception:

com.jniwrapper.win32.registry.RegistryException: The system cannot find the file specified.

 

Here’s what the stack trace looks like once our code calls jniwrapper:

com.jniwrapper.win32.registry.RegistryKey.checkError(RegistryKey.java:223)

com.jniwrapper.win32.registry.RegistryKey.openSubKey(RegistryKey.java:549)

com.jniwrapper.win32.registry.RegistryKey.openSubKey(RegistryKey.java:518)

com.jniwrapper.win32.registry.RegistryKey.openSubKey(RegistryKey.java:502)

 

I wish it reported the file that couldn’t be found! Is it the native code DLL? The license file? Something else??

These are all in the same folder as jniwrap-3.10.jar. I have also tried *including* them in the jar (this worked for another team here):

jniwrap.dll and jniwrap64.dll in the root of the jar, jniwrap.lic in META-INF.

 

I do most of my coding as a .NET web developer, so a Java Windows service is unfamiliar in few ways! But other possibilities for the problem might
be file or registry permissions or 32 vs 64 bit issues.

 

Any suggestion would be most appreciated!

 

Steve Gruverman | Application Developer II

IDEXX Laboratories, Inc. | Steven-G...@idexx.com

Phone: + 1 207 556 6981

Mobile: + 1 207 798 2893

 

Gruverman, Steven

unread,
Sep 3, 2015, 5:30:27 PM9/3/15
to jniwrappe...@teamdev.com, jniwrapp...@teamdev.com

I think I may have solved this shortly after sending out this email:

We were trying to read Registry keys under HKEY_CURRENT_USER. HKEY_LOCAL_MACHINE is a better choice when a service is reading the Registry.

 

 

Steve Gruverman | Application Developer II

IDEXX Laboratories, Inc. | Steven-G...@idexx.com

Phone: + 1 207 556 6981

Mobile: + 1 207 798 2893

 

Sergei Piletsky

unread,
Sep 4, 2015, 7:32:46 AM9/4/15
to Gruverman, Steven, jniwrappe...@teamdev.com, jniwrapp...@teamdev.com
Hi Steve,

That "The system cannot find the file specified." last error exception simply indicates that the openSubKey method could not open a specified path. This issue has nothing to do with a license or native DLL at all.

If you know for sure that the specified path exists in the Windows registry, then one of the possible explanations could be an architectural restriction: 32-bit applications cannot access the 64-bit registry keys and vice versa. So, if the required registry key exists in 32-bit branch of Windows registry, then you should be able accessing it by running your Java application with 32-bit JVM. But if you run your application with a 64-bit JVM then you will get that last error exception.

In order to overcome that restriction you can use the openSubKey() method that has RegistryAccessMode parameter:

    public RegistryKey openSubKey(String name, boolean writable, boolean quietly, RegistryAccessMode accessMode)

The RegistryAccessMode variable there can be specified as WOW64, WOW32 or DEFAULT. So, if your Java application runs on a 32-bit JVM  and you specify WOW64, then you should be able to open a required key from 64-bit registry branch even in 32-bit application.

We can also help you out with resolving that issue if you can provide us with the sample code that reproduces the issue.

Regards,
Sergei

--
You received this message because you are subscribed to the Google Groups "JNIWrapper Forum" group.
To unsubscribe from this group and stop receiving emails from it, send an email to jniwrapper-for...@teamdev.com.
To view this discussion on the web visit https://groups.google.com/a/teamdev.com/d/msgid/jniwrapper-forum/201509032111.t83L2knv011481%40mx0a-00116901.pphosted.com.

Sergei Piletsky

unread,
Sep 4, 2015, 7:36:52 AM9/4/15
to Gruverman, Steven, jniwrappe...@teamdev.com, jniwrapp...@teamdev.com
Hi Steve,

Thanks for letting us know that you found out how to solve that issue. I missed your reply in this thread and asked you to provide the sample - please disregard it.

Let us know if you have any further questions.

Regards,
Sergei


--
You received this message because you are subscribed to the Google Groups "JNIWrapper Forum" group.
To unsubscribe from this group and stop receiving emails from it, send an email to jniwrapper-for...@teamdev.com.
Reply all
Reply to author
Forward
0 new messages