Perforce Public Knowledge Base - P4Java method throws Exception with "Access is denied"
Reset Search
 

 

Article

P4Java method throws Exception with "Access is denied"

« Go Back

Information

 
Problem

You are either trying to sync files, login, or disconnect from a Perforce Server.  You receive a java.io exception with the message "(Access is denied)".  Using the OS to examine the given file, it shows that the file is owned by you.

This "Access denied" exception can happen on any file that is read-only but P4Java needs write access.

Example:

Caused by: java.io.FileNotFoundException: C:\Users\oinker\p4tickets.txt (Access is denied)
	at java.io.FileOutputStream.open(Native Method)
	at java.io.FileOutputStream.<init>(FileOutputStream.java:179)
	at com.perforce.p4java.server.AuthTicketsHelper.copy(AuthTicketsHelper.java:345)
	at com.perforce.p4java.server.AuthTicketsHelper.saveTicket(AuthTicketsHelper.java:314)
	at com.perforce.p4java.server.AuthTicketsHelper.saveTicket(AuthTicketsHelper.java:224)
	at com.perforce.p4java.impl.mapbased.rpc.RpcServer.saveTicket(RpcServer.java:502)

Solution

First verify that the user running your P4Java application has the privileges to access the file.   Typically this means the user should be the owner of the file as the user must have the privileges to alter the file's read/write permission.

If the accessing user owns the file, using Java 1.5 is a likely root cause of this problem.

Using Java 1.5 requires additional programming steps.  See "Using P4Java with Java 1.5" for information on using Java 1.5 with P4Java.

If you encounter these errors when using P4Ant or P4Maven, see "Using Java 1.5 with P4Maven and P4Ant" for the changes needed.

 

ILogCallback Method Invocation

If you have implemented an ILogCallback class, information about this Java 1.5 deficiency will present itself with calls to your ILogCallback class's internalError(), internalException(), and internalWarn() methods at startup:

internalError:  No such method for helper class: java.io.File.setWritable(boolean)

internalException:  java.io.File.setWritable(boolean)

internalWarn:  No such method for helper class: java.io.File.canExecute()

internalException:  java.io.File.canExecute()

internalError: No such method for helper class: java.io.File.setReadable(boolean, boolean)


internalException:  java.io.File.setReadable(boolean, boolean)
Related Links

Feedback

 

Was this article helpful?


   

Feedback

Please tell us how we can make this article more useful.

Characters Remaining: 255