Solved

Java servlets and local files

Posted on 2007-04-04
10
415 Views
Last Modified: 2013-11-24
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?
0
Comment
Question by:bilgehanyildirim
  • 5
  • 4
10 Comments
 
LVL 27

Expert Comment

by:mrcoffee365
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.
0
 

Author Comment

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

Expert Comment

by:mrcoffee365
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.

0
 
LVL 27

Expert Comment

by:mrcoffee365
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.
0
 

Author Comment

by:bilgehanyildirim
ID: 18853824
I will upload the source and the sdk i am using tomorrow when i get to the office.thanks.
0
3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

 

Author Comment

by:bilgehanyildirim
ID: 18856404
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
 

Author Comment

by:bilgehanyildirim
ID: 18856505
You can dowload them from here.
http://www.netetechs.com
0
 

Author Comment

by:bilgehanyildirim
ID: 18856812
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
 
LVL 3

Accepted Solution

by:
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.
0
 
LVL 27

Expert Comment

by:mrcoffee365
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.
0

Featured Post

3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

Question has a verified solution.

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

Suggested Solutions

An old method to applying the Singleton pattern in your Java code is to check if a static instance, defined in the same class that needs to be instantiated once and only once, is null and then create a new instance; otherwise, the pre-existing insta…
Introduction This article is the second of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article covers the basic installation and configuration of the test automation tools used by…
Viewers will learn about basic arrays, how to declare them, and how to use them. Introduction and definition: Declare an array and cover the syntax of declaring them: Initialize every index in the created array: Example/Features of a basic arr…
Viewers will learn about the regular for loop in Java and how to use it. Definition: Break the for loop down into 3 parts: Syntax when using for loops: Example using a for loop:

867 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

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now