Java servlets and local files

Hi,
I have a java code which works perfectly
in that code there is one object which is created using local *.pem files.
        ServerInfo si = new ServerInfo("www.vbv2bmshost.co.uk",
                                        9707,
                                        "ssl",
                                        35,
                                        35,
                                        1,
                                        10,
                                        "C:/Program Files/Arcot Systems/ssl/ServerRootCA.pem",
                                        "C:/Program Files/Arcot Systems/ssl/ClientCert.pem",
                                        "C:/Program Files/Arcot Systems/ssl/ClientKey.pem");
now, what I am trying to do is convert this software to servlet (bear in mind, this is my first servlet as well as my first java :)) So I managed to convert it to servlet but when I run remote server (www.vbv2bmshost.co.uk) returns an error
Error num: 9021
Error msg: A config value is missing or incorrect: Create Transport of type 'SSLv3'
So I assume it is something to do with accessing local file (pem files).
Could someone shed some light on this?
bilgehanyildirimAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

mrcoffee365Commented:
You'll have to read in the local files and include their content as Strings in your post to the server.  So, yes, you're right that the problem is you are trying to send file names from your local system to a remote server.

However, this isn't different for a servlet compared to regular Java code.  Did you send local file names to the remote server before, and it worked?

In which case, we'll need to see more of the code, to help with why sending from one environment is working, while it isn't in another.  It may be Tomcat's classpaths rather than the classpaths you used for your standalone Java app.
0
bilgehanyildirimAuthor Commented:
mrcoffee,
thanks for your reply.
"Did you send local file names to the remote server before, and it worked?"
yes,if I ran the same code with same parameters it works perfectly. That's why I assume it is something related to accessing to local file.Even if it is running under linux I use /opt/arcot/ssl instead of windows path.
0
mrcoffee365Commented:
Then we need to see more of the code.  Is is possible that your servlet engine doesn't have permissions to access the files you've specified?  But your standalone app does?

We need to know what code causes the error message, and what your servlet engine is -- is it Tomcat?  And what Web server you have locally.  

Are you making an HTTP Post to a remote server, and this message is from that server?  Because there's no reason for that to be different under a servlet engine than under a java app.

Maybe you're getting it from your local servlet engine or a library you are using.  In which case, it could be a permissions problem with your servlet engine not being able to get your local files.

0
Exploring SharePoint 2016

Explore SharePoint 2016, the web-based, collaborative platform that integrates with Microsoft Office to provide intranets, secure document management, and collaboration so you can develop your online and offline capabilities.

mrcoffee365Commented:
If you are running Win2003 and IIS, then IIS will have to have permissions to access those files.  The same would be true under the more recent servlet engines on Linux.
0
bilgehanyildirimAuthor Commented:
I will upload the source and the sdk i am using tomorrow when i get to the office.thanks.
0
bilgehanyildirimAuthor Commented:
Hi,
I am trying to sort out a server to upload the files for you.
Meantime,
I have tried the servlet on Tomcat and Sun App Server with same result.
All the communication between the host is made by SDK which I will upload as well.
0
bilgehanyildirimAuthor Commented:
You can dowload them from here.
http://www.netetechs.com
0
bilgehanyildirimAuthor Commented:
I have found a solution. Remove this settings from the app server
-Djava.security.policy=${com.sun.aas.instanceRoot}/config/server.policy
so it is working now.
But of course I cant leave it like that. I need to update the policy,don't I?
0
cavey_79Commented:
Typically, if you need to access them from a web application, just add them to that web application (to the war file for example). Application servers' security policy will not allow it read files outside of the web app (it's a security risk). Once you have your file in the war file, you can access it with ServletContext.getResourceAsStream. The parameter to getResourceAsStream will look like this:
/ssl/yourfilehere.pem - the corresponds to a ssl folder located inside the war file at the topmost level. Basically, it's like a mini-file system that starts at the root level of the war file. Let me know if that makes sense.
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
mrcoffee365Commented:
cavey_79 is right that it is usually a good idea to have web-app files in the web-app area.

However, if the files are shared with other applications and need to stay outside the web-app area, then read the files from your servlet and provide the required strings to the ServerInfo call.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Java EE

From novice to tech pro — start learning today.