I have two web-applications which need to run on Tomcat 6, MS SQL 2008 and JTDS-1.2.2 as driver.
If I start only one web application everything is working fine, but as soon as I start the second one I get the following error (it does not matter the order):
java.sql.SQLException: I/O Error: SSO Failed: Native SSPI library
Of course, the library ntlmauth.dll is under C:\WINDOWS\system32
It seems that the second application which starts is not able to find the ntlmauth.dll for the single sign on.
I got past this by changing the url from
jdbc:jtds:sqlserver://host_server:1433/Database_name
to
jdbc:jtds:sqlserver://host_server:1433/Database_name;user=XXX;password=YYY
Apparently, "When URL [does] not contains user and password properties, systems uses Windows authentication method, and "SSPI Native library not found" error appears."
This is the solution:
Download the jTDS driver, unzip it, and copy x86\SSO\ntlmauth.dll to jdk\jre\bin.
This should solve your issue.
Edit:
Without the JDK installed the path for me was C:\Program Files\Java\jre7\bin\ntlmauth.dll
jTDS must be able to load the native SPPI library (ntlmauth.dll). Place this DLL anywhere in the system path (defined by the PATH system variable) and you're all set.
If you are trying to run two (or more) Tomcat applications on the same server that both access a SQL Server using the JTDS driver and windows authentication, a very helpful answer courtesy of Chris White is here.
Chris' answer has to do with sqljdbc_auth.dll, but the recommendations are the same for the JTDS driver and ntlmauth.dll:
Put ntlmauth.dll into the tomcat 7.0\bin directory. Actually, I believe you can put ntlmauth.dll into any directory in the system path, or the Java jre\bin directory.
Importantly, don't bundle the JTDS jar in the war file of any Tomcat application using the JTDS driver. Instead, put one copy in the Tomcat\lib directory, where Tomcat will load it and make it available to all apps.
If you are on 64-bit windows but running 32-bit java (the one in program files x86) then you need the 32-bit ntlmauth dll and not the 64 bit one that you might have expected.
Related
With macOS Catalina we are experiencing the following problem: opening Java Web Start applications behaves differently when application starts by double clicking on JNLP file and when it is started by double clicking on a shortcut installed on a desktop.
In the first case (double click on a downloaded JNLP file) application opens without permissions to access file system - trying to get the directory listing in user's Desktop directory in JAVA code always returns null. There are no prompts presented to the user asking for any permissions to access the file system. This is not an expected behaviour.
In the second case (starting it from desktop shortcut) user is first prompted that application is trying to access the file system and asked for a permission. When user allows application to access files - application reads user's Desktop directory properly. This is the expected behaviour.
Is there a workaround for this? How can we make web start application access file system on Catalina if it is started by double clicking on JNLP file (which is how the application must be started at least for the first time)?
I've run into a similar problem running a legacy .jnlp app. I was able to get around it by simply invoking the application from CLI (iTerm/Terminal/etc.) :
# javaws filename.jnlp
The root cause is that macOS 10.15 (Catalina) now requires non-Apple applications to be specifically granted "Full Disk Access" permission. Check out this and this for details. Using the explanation there, I added /usr/bin/javaws (and other java binaries such as java and appletviewer) to "Full Disk Access", but that didn't resolve the issue.
Based on an older thread, it seems that if the path to the application is not under /Applications/ (in this case, java and javaws are under /System/ and not under /Applications/), then Full Disk Access is not honored. So it's very likely that a fix needs to be provided by Apple to allow running these applications from the UI.
We were able to resolve this by granting Full Disk Access to /System/Library/CoreServices/Java Web Start.app
For me the problem was solved by installing a different version of Java.
I had the same issue on OSX Catalina 10.15.7. I was able to launch the jnlp file by first setting JAVA_HOME.
export JAVA_HOME=$(/usr/libexec/java_home)
javaws /path/to/file.jnlp
I am using Tomcat7 and Ubuntu. I have a Java web application which uses some native libraries. When I run the web application within Eclipse it works through Eclipse internal Tomcat server during debugging. However, when I deploy the applcation to a hosted Tomcat service, the application fails when it reaches the point of loading these libraries.
I put the native libraries in /home/me/my_shared_libs, and gave
folder and file ownership to user "Tomcat7" -- sudo chown
I give all permissions of the native libraries to "Tomcat7" user
-- sudo chmod
In do sudo vi /usr/share/tomcat7/bin/setenv.sh, and put the following
in the file export CATALINA_OPTS="-Djava.library.path=/home/me/my_shared_libs"
Then I restart Tomcat -- sudo service tomcat7 restart And, whenever
refernce to load native libraries is reached, I get an error about InvocationTargetException.
I am also open to the option of adding the native libraries as part of the the application's .WAR file. (Although I am not sure how to do this in Eclipse).
Log of /var/log/tomcat7/catalina.out-->
Jun 30, 2016 8:11:50 PM org.apache.catalina.startup.Catalina start
INFO: Server startup in 3643 ms
Load my_native_lib_called. libmachoman.so: cannot open shared object file: No such file or directory
EDIT:
I found out something very interesting. Tomcat does pick up the library location that I set above. What happens is I have two types of libraries (.so) files in the location. The first library (libcore.so) calls/loads the the second library (libmachoman.so). libcore.so is found and loaded both libmachoman.so is not, even though both are in the same location.
It can be done from the code itself. That should give you confidence in the loading of the library.
To do this you can use System.load()
It takes absolute path of the library for example
System.load("/PATH/TO/.so");
Run this piece of code one once when the application starts up before calling the library functions.
You'll have to place your library in a custom location on all the servers.
System.loadLibrary() is also used for the same purpose but the difference is that it would load library by name and would look into locations specified by the Java environment variable java.library.path.
But that can be a pain to set as you have mentioned, this change would have to be done in all the instances of tomcat.
After days of headache, I have a solution.
Edit file
sudo vi /etc/ld.so.conf
Append the location of native libs in file
include /etc/ld.so.conf.d/*.conf
/home/me/my_shared_lib
load config
sudo ldconfig
View the new change
ldconfig -p | grep my_shared_lib
This tells the dynamic linker where to look for native libraries.
My problem is solved.
There are other alternative solutions here, which may or may not have some cons.
Alternatively (also found out), you can can export LD_LIBRARY_PATH in the setenv.sh file under /usr/share/tomcat7/bin/ instead of the above steps. Settings become part of Tomcat; cleaner approach.
I have web based application and have MSSQL server 2012 and need to access that database using window authentication and using Tomcat 6 and OS Windows
But same functionality work fine (window authentication) with MSSQL server 2008 not MSSQL server 2012. So may i know the reason is there some thing miss in configuration.
i put jtds-1.2.5.jar in apache\lib directory and also put the ntlmauth.dll in C:\Windows\System32 location and also added the system variable "JAVA_OPTS" for the dll location but it does not work. It gives the error message :
2014-10-14 13:35:35,237 ERROR Unable to get database connection: SQL Exception occurred
java.sql.SQLException: Cannot open database "Test" requested by the login. The login failed.
Then i put the dll in jre\bin directory but it does not work please let is any wrong am doing.
Also try put the dll in apache\bin loc still getting the same issue.
But as per the client requirement that want using JTDS api not the Microsoft driver so need solution in JTDS api. Although it work fine MSSQL server 2008 but does not work in MSSQL server 2012.
I follow the link http://www.dekho.com.au/dekho-connecting-to-sql-server-using-windows-authentication/
we had similar problems with JDTS and at some point resorted to using the official JDBC driver from Microsoft. The Microsoft Driver works on Windows, Linux and MacOS and did not require me to put any DLLs or something like this anywhere.
http://msdn.microsoft.com/en-us/sqlserver/aa937724.aspx
The only downsides to this driver are (1) it is not open source so you cannot change it in case you need to, and (2) you need to accept a license. However (2) should not be a problem since you are using MSSQL Server anyways.
Finally (I am not sure if this applies to you) the Microsoft driver cannot be used with Maven. So I (on a Mac) use the following bash script to install the driver into my local Maven repository.
#!/bin/bash
mvn install:install-file -Dfile=lib/sqljdbc4.jar -DgroupId=com.microsoft.sqlserver -DartifactId=sqljdbc4 -Dversion=3.0 -Dpackaging=jar
For the JDBC Connection strings see the following webpage:
http://msdn.microsoft.com/en-us/library/ms378428(v=sql.110).aspx
In your case since you want to do Windows authentication you need to make sure that you add
;integratedSecurity=true;
to the jdbcUrl.
Is anyone having a problem running a Windows Service with JavaExe, and is there a solution?
The JavaExe examples all work except for the Service examples, Example3, Example5, and Example23.
In each case, the Windows Service gets created, but any attempt to start the service brings a popup error message:
"The system cannot find the file specified."
There is a registry entry for the serivce which contains the following:
Name: ImagePath
Type: REG_EXPAND_SZ
Data: "\JavaExe\JavaExe\doc\examples\3 - Service\Example3.exe" __RunService__
If I run Example3.exe from a command line with the argument __RunService__, then a Java process starts and runs briefly before crashing.
The examples are all self-contained in the JavaExe download, so it's hard to see how there could be missing libraries.
Background: JavaExe (http://devwizard.free.fr/html/en/JavaExe.html) appears to implement a sound approach to allowing a Java application program to be invoked from another Java program running as a service. Windows prevents services from accessing the desktop, so JavaExe sets up a socket connection between the service and the application Java program, each running as a User process, as outlined here:
http://msdn.microsoft.com/en-us/library/windows/desktop/ms683502(v=vs.85).aspx
Windows 7 x64 (but it fails in the same way on XP [SEE UPDATE BELOW])
Java version 1.7.0_45
--
UPDATE:
The developer replied to my email and advised that 32-bit and 64-bit Java versions were being confused.
I straightened this out. The Example3 Service, run from the .exe and .jar files obtained from the
JavaExe .zip download (which are all 32 bit by default), now run correctly on WinXP (x86).
For x64 machines, it is necessary to recompile the jar files using the package's compilx64.bat script.
(And to use the x64 versions of JaveExe.exe as stated in the documentation.)
I did these things but the Example3 service still fails to start, with the error,
"The system cannot find the file specified."
The .jar files built from compilx64.bat are mostly identical to the x86 versions, but a few
contain .class files that are a few bytes larger. I assume that the code must therefore be referring to native libraries? And maybe some are not found? But which ones?
When I type sc qc Example3 I get:
TYPE: : 10 WIN32_OWN_PROCESS
START_TYPE: 2 AUTO_START
ERROR_CONTROL: 1 NORMAL
BINARY_PATH_NAME : "[...filepath...]\JavaExe\JavaExe\doc\examples\3 - Service\Example3.exe" __RunService__
LOAD_ORDER_GROUP: 0
DISPLAY_NAME: JavaExe : Example3
DEPENDENCIES: eventlog
SERVICE_START_NAME: LocalSystem
Answer:
The filepath to the Example3.exe was on a network drive.
To get a Windows Service to run from a network drive is either impossible or requires considerable contortions. See for example,
Map a network drive to be used by a service
When I moved everything to the local C: drive, it worked.
Thank you to bb67 for providing the hints that led to figuring this out.
A web application has been developed in C# which hits my Java code through a restful web service which returns a JSON response.This process was working on a local machine with tomcat server. Now my Java application needs to be hosted on an external server in Linux environment.
Using putty, I logged into the particular hostname and as a root admin.
I have installed Java JDK 1.7, Apache tomcat server 7, my Java application as a war file is placed in the webapps folder. I can start the tomcat server too.
My question is:
How do I hit my application from windows. Is it http://x.y.z.k:8080//MYAPPNAME(war file name)/?
How do i check the java logs in the linux env?
Also I have a set of files that I read from my windows folders as in C://uploads//file.txt or C:\DeveloperTool\Pluggins\
I replaced them with the linux structure in my java code. as /home/opt/file.txt
Will this work?
How do I hit my application from windows. Is it
http://x.y.z.k:8080//MYAPPNAME(war file name)/?
If 8080 is the port Tomcat is configured to listen on (I think by default, it is), then that is correct. Bare in mind the web app name is case sensitive. You can configure this setting in $TOMCAT_HOME/conf/server.xml
How do i check the java logs in the linux env?
Since you're using a remote shell over SSH, you will want to use either tail or less to monitor logs in real time. The log files are stored in $TOMCAT_HOME/logs.
Try
$ less +F /path/to/tomcat/logs/catalina.out
catalina.out is the main file when running Tomcat on *nix systems.
Also I have a set of files that I read from my windows folders as in
C://uploads//file.txt or C:\DeveloperTool\Pluggins\
I replaced them with the linux structure in my java code. as
/home/opt/file.txt Will this work?
As Lutz Horn mentioned in the comments, try it. In theory, that should work fine as long as the permissions are setup properly.