Java servlets and local files

Posted on 2007-04-04
Last Modified: 2013-11-24
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("",
                                        "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 ( 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?
Question by:bilgehanyildirim
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 5
  • 4
LVL 27

Expert Comment

ID: 18852782
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.

Author Comment

ID: 18853214
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.
LVL 27

Expert Comment

ID: 18853278
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.

MS Dynamics Made Instantly Simpler

Make Your Microsoft Dynamics Investment Count  & Drastically Decrease Training Time by Providing Intuitive Step-By-Step WalkThru Tutorials.

LVL 27

Expert Comment

ID: 18853289
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.

Author Comment

ID: 18853824
I will upload the source and the sdk i am using tomorrow when i get to the office.thanks.

Author Comment

ID: 18856404
I am trying to sort out a server to upload the files for you.
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.

Author Comment

ID: 18856505
You can dowload them from here.

Author Comment

ID: 18856812
I have found a solution. Remove this settings from the app server${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?

Accepted Solution

cavey_79 earned 500 total points
ID: 18857710
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.
LVL 27

Expert Comment

ID: 18858728
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.

Featured Post

[Live Webinar] The Cloud Skills Gap

As Cloud technologies come of age, business leaders grapple with the impact it has on their team's skills and the gap associated with the use of a cloud platform.

Join experts from 451 Research and Concerto Cloud Services on July 27th where we will examine fact and fiction.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Are you developing a Java application and want to create Excel Spreadsheets? You have come to the right place, this article will describe how you can create Excel Spreadsheets from a Java Application. For the purposes of this article, I will be u…
Basic understanding on "OO- Object Orientation" is needed for designing a logical solution to solve a problem. Basic OOAD is a prerequisite for a coder to ensure that they follow the basic design of OO. This would help developers to understand the b…
Viewers learn how to read error messages and identify possible mistakes that could cause hours of frustration. Coding is as much about debugging your code as it is about writing it. Define Error Message: Line Numbers: Type of Error: Break Down…
Viewers will learn about if statements in Java and their use The if statement: The condition required to create an if statement: Variations of if statements: An example using if statements:
Suggested Courses

615 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question