UnsatisfiedLinkError on Java/Windows 7 Environment - Hello_simple

9 posts / 0 new
Last post
Offline
Last seen: 11 years 7 months ago
Joined: 04/18/2013
Posts: 5
UnsatisfiedLinkError on Java/Windows 7 Environment - Hello_simple

I just installed RTI DDS Community and I'm getting this error when I try to execute "runSub":

 c:\****\ndds.5.0.0\example\JAVA\Hello_simple>runPub.cmd
The library nddsjava.dll could not be loaded by Windows.
Make sure that the library is in your Path environment variable.
Exception in thread "main" java.lang.UnsatisfiedLinkError: C:\****\ndds.5.0.0\lib\x64Win64jdk\nddsjava.dll: The application has failed to sta
rt because its side-by-side configuration is incorrect. Please see the applicati
on event log or use the command-line sxstrace.exe tool for more detail
        at java.lang.ClassLoader$NativeLibrary.load(Native Method)
        at java.lang.ClassLoader.loadLibrary0(ClassLoader.java:1807)
        at java.lang.ClassLoader.loadLibrary(ClassLoader.java:1732)
        at java.lang.Runtime.loadLibrary0(Runtime.java:823)
        at java.lang.System.loadLibrary(System.java:1028)
        at com.rti.dds.util.NativeInterface.loadNativeLibrary(Unknown Source)
        at com.rti.dds.util.NativeInterface.loadNativeLibraries(Unknown Source)
        at com.rti.dds.domain.DomainParticipantFactory.<clinit>(Unknown Source)
        at com.rti.simple.HelloPublisher.main(HelloPublisher.java:29)

 

 I'm running this with Java on a 64-bit Windows 7 machine. These are the zip files I downloaded:

- RTI_Connext_DDS_Host-5.0.0-i86Win32.zip

- RTI_Connext_DDS_Target-5.0.0-x64Win64VS2010.zip

This is what I included in my PATH:

JAVA_HOME = C:\Program Files\Java\jdk1.6.0_45

CLASSPATH = %JAVA_HOME%/jre/lib

NDDSHOME = C:\****\ndds.5.0.0

Path = %NDDSHOME%\lib\x64Win64jdk;%NDDSHOME%\class;%JAVA_HOME%\bin;etc...

 

That file mentioned in the error is present in the directory that is specified but it always returns this error.

Any ideas??

rose's picture
Offline
Last seen: 3 years 4 months ago
Joined: 08/22/2011
Posts: 148

Are you running this from an IDE like Eclipse?  If you are running it from Eclipse, you have to set the environment variable of the Eclipse run configuration - it doesn't pick up the environment variables from the system, necessarily.

  Eclipse Run Configuration - Environment Tab

Offline
Last seen: 11 years 7 months ago
Joined: 04/18/2013
Posts: 5

I'm not running it on an IDE. I'm just using the Windows command line. 

I'll try to put the code in Eclipse and give it a try there.

rip
rip's picture
Offline
Last seen: 4 days 48 min ago
Joined: 04/06/2012
Posts: 324

Hi,

The classpath has to include the jar file:  %NDDSHOME%\class\nddsjava.jar

That isn't the error you are seeing, but you will once you've fixed the other one.

The error you are seeing could be a 32bit x 64bit thing.  What does

C:\****\ndds.5.0.0\example\JAVA\Hello_simple> java -version

return?  Because you are trying to run an x64Win64jdk-based application, the JNI library (the .dll) is 64bit.  If you are running a 32bit JRE, that's a problem.

Note also that the error message that Windows is giving you does not mean that the .dll could not be loaded.  What it means is that the dll, or one of the dll's component dll's (or one of the those dlls' dlls) could not be loaded.  Someplace in the linking chain, something wasn't found, and so Windows complains about the top level one.


Regards,

rip

Gerardo Pardo's picture
Offline
Last seen: 3 weeks 6 days ago
Joined: 06/02/2010
Posts: 602

Hi,

I am not sure this is a problem with the PATH. The Windows "side-by-side configuration" error is normally caused by windows not having the correct version of the C runtime libraries installed.

A bit of background: This is one of the more obscure/magic aspects of Windows. The C runtime libraries are part of the Visual Studio releases and may be installed with several different Microsoft and third party products. These libraries are installed under C:\Windows\winsxs. Even for a single installation of Visual Studio (e.g. VS 2008) there are many versions of the runtime. The "crazy" thing is that any application that loads a DLL compiled with VisualStudio must find under the C:\Windows\winsxs the runtime-libraries for the exact version of the VS compiler used. And there are literally hundreds of possibilities even for a single Visual Studio (e.g. VS 2008) version.  You can see all the C run-times you have already installed related to Visual Studio 2008 in the directories that start with C:\Windows\winsxs\x64_microsoft.vc90.crt_xxxxxxx\...

Most of the time this works transparently under the hood. The system detects the version on the DLL you are trying to load, then looks at the C:\Windows\winsxs\ directory, finds the exact version of the library it needs, loads it, and it all works.

However when it does not find the exact version it prints the  "side-by-side configuration" error you are seeing.

I have run into this problem before and fixing it always seems a bit of black magic. Meaning I have not found yet a recipe that works reliably under all conditions. One thing that works often is to install the VC problem is a bit of black magic. In many cases the problems goes away by installing the latest version of the VC re-distributable for the VS used by the DLL. You get the VC-redistributable from the Microsoft web page. For  example for VS 2008 on Intel 64 bits you can get them here http://www.microsoft.com/en-us/download/details.aspx?id=2092  -- Note that I am assuming that the nddsjava.dll you have was built with VS 2008. If not you will need to download/install the redistributable for the VS version that was used to build that DLL.

To get additional clues, I have also looked at the Windows "Event Viewer". There it is normally possible to see the error mentioning the problem findind the "Dependent Assembly" and the exact version of the C runtime that it is not able to find.   There is also a Windows utility called sxstrace.exe which can also be helpful in finding which version of the C runtime is failing to load.

Gerardo 

 

Offline
Last seen: 11 years 7 months ago
Joined: 04/18/2013
Posts: 5

This is the output of the "java -version" command:

c:\****\ndds.5.0.0\example\JAVA\Hello_simple>java -version
java version "1.6.0_45"
Java(TM) SE Runtime Environment (build 1.6.0_45-b06)
Java HotSpot(TM) 64-Bit Server VM (build 20.45-b01, mixed mode)

 

I switched my workspace to eclipse and set up the link to the corresponding JAR and DLL's and I'm getting the exact same error message.

Gerardo Pardo's picture
Offline
Last seen: 3 weeks 6 days ago
Joined: 06/02/2010
Posts: 602

As I mentioned it seems unlikely this has anything to do with paths or java VM versions. Most likely this has to do with missing the correct version of the Visual Studio C runtime...  

Did you try to install the Windows VS redistributables?  Were you able to see anything in the Windows Event  Viewer?

Gerardo

Offline
Last seen: 11 years 7 months ago
Joined: 04/18/2013
Posts: 5

I installed my corresponding VS redistributables and got the same error message again.

Here is the output for the error on Windows Event Viewer (XML):

- <Event xmlns="http://schemas.microsoft.com/win/2004/08/events/event">
- <System>
  <Provider Name="SideBySide" /> 
  <EventID Qualifiers="49409">33</EventID> 
  <Level>2</Level> 
  <Task>0</Task> 
  <Keywords>0x80000000000000</Keywords> 
  <TimeCreated SystemTime="2013-04-22T17:22:57.000000000Z" /> 
  <EventRecordID>3800</EventRecordID> 
  <Channel>Application</Channel> 
  <Computer>****</Computer> 
  <Security /> 
  </System>
- <EventData>
  <Data>Microsoft.VC80.DebugCRT,processorArchitecture="amd64",publicKeyToken="1fc8b3b9a1e18e3b",type="win32",version="8.0.50727.6195"</Data> 
  <Data /> 
  <Data /> 
  <Data /> 
  <Data /> 
  <Data /> 
  <Data /> 
  <Data /> 
  <Data /> 
  <Data /> 
  <Data>C:\****\ndds.5.0.0\lib\x64Win64jdk\nddsjavad.dll</Data> 
  <Data /> 
  <Data /> 
  <Data /> 
  <Data /> 
  <Data /> 
  <Data /> 
  <Data /> 
  <Data /> 
  <Data /> 
  </EventData>
  </Event>

 

Offline
Last seen: 11 years 7 months ago
Joined: 04/18/2013
Posts: 5

So I used sxstrace to find out what was going on, here's the output file:

=================
Begin Activation Context Generation.
Input Parameter:
 Flags = 0
 ProcessorArchitecture = AMD64
 CultureFallBacks = en-US;en
 ManifestPath = C:\****\ndds.5.0.0\lib\x64Win64jdk\nddsjava.dll
 AssemblyDirectory = C:\****\ndds.5.0.0\lib\x64Win64jdk\
 Application Config File = 
-----------------
INFO: Parsing Manifest File C:\****\ndds.5.0.0\lib\x64Win64jdk\nddsjava.dll.
 INFO: Manifest Definition Identity is (null).
 INFO: Reference: Microsoft.VC80.CRT,processorArchitecture="amd64",publicKeyToken="1fc8b3b9a1e18e3b",type="win32",version="8.0.50727.6195"
INFO: Resolving reference Microsoft.VC80.CRT,processorArchitecture="amd64",publicKeyToken="1fc8b3b9a1e18e3b",type="win32",version="8.0.50727.6195".
 INFO: Resolving reference for ProcessorArchitecture amd64.
  INFO: Resolving reference for culture Neutral.
   INFO: Applying Binding Policy.
    INFO: Find publisher policy at C:\WINDOWS\WinSxS\manifests\amd64_policy.8.0.microsoft.vc80.crt_1fc8b3b9a1e18e3b_8.0.50727.4940_none_09c03a53facd313f.manifest
    INFO: No binding policy redirect found.
   INFO: Begin assembly probing.
    INFO: Did not find the assembly in WinSxS.
    INFO: Attempt to probe manifest at C:\WINDOWS\assembly\GAC_64\Microsoft.VC80.CRT\8.0.50727.6195__1fc8b3b9a1e18e3b\Microsoft.VC80.CRT.DLL.
    INFO: Attempt to probe manifest at C:\****\ndds.5.0.0\lib\x64Win64jdk\Microsoft.VC80.CRT.DLL.
    INFO: Attempt to probe manifest at C:\****\ndds.5.0.0\lib\x64Win64jdk\Microsoft.VC80.CRT.MANIFEST.
    INFO: Attempt to probe manifest at C:\****\ndds.5.0.0\lib\x64Win64jdk\Microsoft.VC80.CRT\Microsoft.VC80.CRT.DLL.
    INFO: Attempt to probe manifest at C:\****\ndds.5.0.0\lib\x64Win64jdk\Microsoft.VC80.CRT\Microsoft.VC80.CRT.MANIFEST.
    INFO: Did not find manifest for culture Neutral.
   INFO: End assembly probing.
 ERROR: Cannot resolve reference Microsoft.VC80.CRT,processorArchitecture="amd64",publicKeyToken="1fc8b3b9a1e18e3b",type="win32",version="8.0.50727.6195".
ERROR: Activation Context generation failed.
End Activation Context Generation.

 

So what obviously stood out was: "Cannot resolve reference Microsoft.VC80.CRT"

Did a quick search for this and brought me to this Stack Overflow question: http://stackoverflow.com/questions/9110184/winsxs-fails-to-load-vc-dlls

I ended up installing the "Microsoft Visual C++ 2005 Service Pack 1 Redistributable Package MFC Security Update", which can be found here:  http://www.microsoft.com/download/en/details.aspx?id=26347

Everything works just fine now! Thanks to everyone that replied.