Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Java servlets and local files

Posted on 2007-04-04
10
Medium Priority
?
451 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
[X]
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
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
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
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
 

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 2000 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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Introduction This article is the last of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article covers our test design approach and then goes through a simple test case example, how …
Java functions are among the best things for programmers to work with as Java sites can be very easy to read and prepare. Java especially simplifies many processes in the coding industry as it helps integrate many forms of technology and different d…
Video by: Michael
Viewers learn about how to reduce the potential repetitiveness of coding in main by developing methods to perform specific tasks for their program. Additionally, objects are introduced for the purpose of learning how to call methods in Java. Define …
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…
Suggested Courses

670 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