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

x
?
Solved

Access is denied when writing to file

Posted on 2006-06-12
10
Medium Priority
?
547 Views
Last Modified: 2008-02-01

Hi!

I am writing a small java module inside a larger application that is runned in Jaguar server. This module is basically responsible for creating a file and then moving it to a destination directory which is placed on another server.

Clearly I am experiencing some access problem here, because I cannot successfully send anything to my target directory.

First I tried to to like:

File f = new File("my filename");
File d = new File("my target filename");
f.renameTo(d);

but that did not work - no exception was thrown, but the file was not moved.

Then I tried to copy the file by re-writing it to the destination with a FileOutputStream like this:

File d = new File("my target filename");
FileOutputStream fos = new FileOutputStream(d);

but that resulted in a FileNotFound exception with the message "Access is denied".

The funny thing here is, that if I run my module from java command-line it works fine!! So there seems to be some access-limitations applied on the virtual machine that is started inside jaguar.

Any ideas on how to proceed on this?

Best regards,

Nicolai
0
Comment
Question by:JNic
[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
  • 3
  • 3
  • 3
  • +1
10 Comments
 
LVL 24

Expert Comment

by:sciuriware
ID: 16886023
It seems you don't have write access to the directory.

;JOOP!
0
 
LVL 30

Accepted Solution

by:
Mayank S earned 1000 total points
ID: 16886080
>> but the file was not moved.

Make sure the original file was not read-only. Also make sure your path was correct.

>> So there seems to be some access-limitations applied on the virtual machine that is started inside jaguar

Looks like there is a JVM version difference, or the two processes are running under different accounts.
0
 
LVL 1

Author Comment

by:JNic
ID: 16888798
Hi, and thanks for the replys!

mayankeagle: That does not sound unreasonable :-) The service that starts jaguar-server is started from its own account - perhaps there could be some permission-problem with that account.

About your other thought: Should a different JVM version really affect this? Do you have some concrete facts that supports that explanation?

sciuriware: As mentioned the java-module works when ran from command-line, but as mankayeagle writes, it might be possible that there are differences of permissions of my login-account and the jaguar-service account

I'll look into the account permissions tomorrow.
0
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
LVL 30

Expert Comment

by:Mayank S
ID: 16891791
>> Should a different JVM version really affect this

Not really, I would look into it only if I am sure that the Jaguar one is using the same version.
0
 
LVL 4

Expert Comment

by:Yagantappa
ID: 16892906
As it works fine when your run thru command line, there should be directory access problem for user that starts Jaguar server.

Try to provide write access for user that starts Jaguar server.
0
 
LVL 1

Author Comment

by:JNic
ID: 16900503
The problem was solved by assigning a specific user to Jaguar service who did have write permissions to the directory.

Earlier the service was assigned to local user, which gave unpredictable results, since each time the service was restarted it used the current users permissions.

Thanks for the help :-D
0
 
LVL 4

Expert Comment

by:Yagantappa
ID: 16909215
Answer accepted for a different solution. I am confused which one solution solved the problem.
0
 
LVL 30

Expert Comment

by:Mayank S
ID: 16909245
The answer was that the user account under which the Jaguar process was running was different, and that is what my comment suggested.
0
 
LVL 1

Author Comment

by:JNic
ID: 16909333
Yes, mayankeagle wrote: "or the two processes are running under different accounts"

which was exactly the case here: My command-line java was running under a different account than the jaguar service.

Yagantappa, I know that you were right also and thanks for your comment, but mayankeagle was there first with a 100% correct answer, so I had to give him 100% of the points...

Best regards,

Nicolai
0
 
LVL 4

Expert Comment

by:Yagantappa
ID: 16909347
I understand. I am sorry for not reading mayankeagle solution completely.
0

Featured Post

The top UI technologies you need to be aware of

An important part of the job as a front-end developer is to stay up to date and in contact with new tools, trends and workflows. That’s why you cannot miss this upcoming webinar to explore the latest trends in UI technologies!

Question has a verified solution.

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

Java had always been an easily readable and understandable language.  Some relatively recent changes in the language seem to be changing this pretty fast, and anyone that had not seen any Java code for the last 5 years will possibly have issues unde…
In this post we will learn how to make Android Gesture Tutorial and give different functionality whenever a user Touch or Scroll android screen.
Viewers learn about the “for” loop and how it works in Java. By comparing it to the while loop learned before, viewers can make the transition easily. You will learn about the formatting of the for loop as we write a program that prints even numbers…
This tutorial covers a step-by-step guide to install VisualVM launcher in eclipse.
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