Solved

Java servlets and local files

Posted on 2007-04-04
10
401 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 26

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 26

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 26

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
What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

 

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 26

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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

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…
This was posted to the Netbeans forum a Feb, 2010 and I also sent it to Verisign. Who didn't help much in my struggles to get my application signed. ------------------------- Start The idea here is to target your cell phones with the correct…
Viewers learn about the “while” loop and how to utilize it correctly in Java. Additionally, viewers begin exploring how to include conditional statements within a while loop and avoid an endless loop. Define While Loop: Basic Example: Explanatio…
This video teaches viewers about errors in exception handling.

707 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

13 Experts available now in Live!

Get 1:1 Help Now