Servlet throws file not found excp when accessing network drive - java

I've a production env and test env. Production has win2k3+tomcat 6.0+ and network drive mapped to a drive letter for easy access (z:\app instead of \symba\files\app). My test env has windows xp (all the software is same including the source code for servlet) and test also has the same drive letter mapping to the network drive.
Tomcat is running with the same user id in both the systems and am able to access the file via windows explorer in the test m/c and production m/c.
Now the servlet in the windows xp m/c (test m/c) throws a file not found exception if try to access an existing file (reachable via windows explorer). The servlet in production is same as in test env and production servlet happily gives the file when i request it and does not throw any error what so ever.
I've see some posts that using drive letter is not a good idea and should use UNC paths instead and i've not tried this yet. I want to know the reason why test servlet fails to get file whereas production servlet works fine.
Thank you very much for your time and help
Bo

Are you running the application server as a service? Drive letter assignments are reliable only if you use interactive programs not services.
A couple of years ago, I tried to resolve a quite identical problem but, at last, I gave up and I used JCIFS to access the files.

If you run Tomcat with a security manager, the web app code is according to the default configuration only allowed file access to its deployment directory. If you want to change the application policies, you can do that in conf/catalina.policy or you can disable the security manager, if you want your web app code to gain all privileges.

You might want to consider running the Tomcat service as the user who has access to the mapped drive.
As pointed out by andcoz, the mappings will not apply for the SYSTEM user in Windows that I presume is being utilized for running Tomcat. You could change the service configuration to run as the user owning the drive mapping and verify if the failure continues to occur.
Related:
FileNotFoundException thrown when the file does exists.

Related

AzureDevOps pipeline loading file from external source

Hello dear Stack community,
I am looking for solution for my test execution. I am using Java & Selenium & TestNG tests kept on AzureDevOps.
Each execution needs to load input data from file stored in external source - where client have an access and can easily drag-drop files.
By now files are stored on my companys Share Drive. It works all fine when I run tests from local machine, but when using pipeline, I get FileNotFoundException in line where file is loaded.
Does anyone have an idea why does it happen and how can it be overcome?
Of course if there is any other solution, I would love to hear about it.
It works all fine when I run tests from local machine, but when using pipeline, I get FileNotFoundException in line where file is loaded.
If you use Microsoft-hosted agents to access to files, which are stored on company's Share Drive, you should check whether there is correct connection. If your organization is secured with a firewall or proxy server, you need to add certain IP addresses and domain URLs to the allowlist. See: Allowed address lists and network connections for details.
Also you could use self-hosted agents to access to this shared files so it will communicate with company's Share Drive via your internal network.

Impact to the web application when converting a local directory on to a NAS

We have a web application running at this point on Linux and weblogic setup.
There is one local directory /home/doc which stores the files used in our application.
At present, we make a call to this location via
Wls: virtual url mapping and wls:localPath in the weblogic configuration file.
My query is if this directory is pointing to NAS instead of local will this still work?
Also we access this path via our App url like this: https:///root/home/doc
This url is unprotected from the security authentication.
Will there be any impact to this? Can someone please suggest?
Yes it does not matter if the directory is on block storage or NFS/NAS so long as weblogic can read the files it will work just fine.

PHP process (started by the PHP-Java bridge) getting terminated unexpectedly

I have an application running in Tomcat 6.0.36. There was a requirement to implement CMS (content management) in our application. For this, a third party vendor is signed up to provide the static content. The CMS pages are written in PHP and hence it became necessary for us to render the PHP content using tomcat server.
To achieve this, I downloaded the “JavaBridgeTemplate621.war” (from http://sourceforge.net/projects/php-java-bridge/files/Binary%20package/php-java-bridge_6.2.1/JavaBridgeTemplate621.war/download) and deployed it in the webapps folder. Later I renamed the exploded folder and renamed it to ‘cms’ (deleted the JavaBridgeTemplate621.war file this time). The PHP files placed in this ‘webapps/cms’ folder is rendered properly by the tomcat server. This was the exact requirement.
While starting the tomcat server, the PHP-Java bridge also created a few Java processes. On the LIVE environment, these processes were killed 3-4 days after the deployment(restart) happened.
The error in the catalina log is,
PHP application terminated unexpectedly, have you started php-cgi with the environment setting PHP_FCGI_MAX_REQUESTS=5000? Error: php.java.bridge.http.FCGIConnectionException
php.java.bridge.http.FCGIConnectionException
at php.java.bridge.http.FCGIConnectionOutputStream.flush(FCGIConnectionOutputStream.java:87)
at php.java.bridge.http.FCGIConnectionOutputStream.close(FCGIConnectionOutputStream.java:71)
at php.java.servlet.fastcgi.FastCGIServlet.parseBody(FastCGIServlet.java:357)
Can someone help me understand the root cause of this issue?
The ‘memory_limit’ variable is seen to have the value 64M. Is it too low a value ? If so, what would be an ideal value that needs to be set ?
How will the setting ‘expose_php=off’ affect ?

Accessing Windows directory from java application running on linux websphere

I am working on an application that generates excel reports from a report generated by Mainframe.
Input report location and ouput location for generated reports are on company common drive that is mapped on my local windows box.
Things were wokring fine from my eclipse since my account have access to those locations on common drive. I am using JAVA File io to access common drive.
But when I deployed on webpshere, it wasn't able to access common drive and I think it could be websphere is using different account to access common drive and that account doesn't have permissions.
My question is how to force Java File io to use particular account.
And also when I deploy application on linux websphere, will this work assuming, common drive will also be mapped on linux boxes.
The proper account must be specified at the time of mounting the network location. (This can be done in both Windows (net use command) and Linux (mount command).)
Then, access mounted network location from your Java application.

Recommended server for JNLP

I have never used JNLP, and I have no web/war server already running so I will install it from sratch:
Which to use?
GlassFish
Tomcat
Apache
Jetty
Another?
I wonder if someone already using JNLP could make any recomendation for the server.
I just want a blank page with a button in the middle for starting the application nothing more, nothing less.
If you use only JNLP you don't need Java server. JNLP is client side. Simple http server like Apache HTTP Server should be OK. HTTP server will be better solution than use of web container/Java EE server because JNLP (usually) is a static content. Even lighthttpd should be enough.
As already stated any server capable to serve HTTP will do. If your WebStart application is not signed by itself (i.e. you code-signed the corresponding Jar files) you could probably consider to publish the JNLP plus its resources via HTTPS. This way your clients will know that the software they are going to execute came from its rightful origin. Although unsigned WebStart applications are restricted in their privileges on the client's machine it still is a measure to elicit trust in your clients. On the other hand this requires more configuration effort with regard to the server you chose.
If your application will need some extended privileges on the client's machine such as access to the file system then I would recommend that you do sign your jar files to gain the necessary privileges automatically (don't forget to specify them in a element within your JNLP).
These are the default restrictions for unsigned WebStart apps:
No access to local disk.
All your jars must be downloaded from the same host. Note, however, that you can download extensions and JREs from any host as long as they are signed and trusted.
Network connections are allowed only to host from which your jars were downloaded. ("Phone home restriction.")
No security manager can be installed.
No native libraries (not even in extensions).
Limited access to system properties. (The application has read/write access to all system properties defined in the jnlp file, as well as read-only access to the same set of properties as applets
You dont need a server to run JNLP(Webstart).. This is how webstart works
it simply is an application that can be started over the web, this would be the procedure from the user perspective:
user goes to yourwebsite.com
user see's link: run my awesome app
user clicks link, which downloads .jnlp file
user runs the jnlp file through java web start (part of java SE, user requires java runtime environment JRE to run this)
java web start reads jnlp to get information about the server that holds the corresponding application
jar files get downloaded automatically (the first time) and then the application starts
user gets bored and closes application
the next day, user comes back and clicks your link again
application is already downloaded, so it starts right away
user gets bored again and closes your application
1 day later, you decide to update your application and you deploy the new jar file on your
server, replacing one of the old files
after 2 days user clicks your link again
java web start recognizes that the user has a different version, downloads update automatically and starts the application again
...
..
.

Categories