Jump to content

[P4java] com.perforce.p4java.exception.AccessException: Perforce password (P4PASSWD) invalid or unset.


  • Please log in to reply
1 reply to this topic

#1 averbitsky



  • Members
  • Pip
  • 1 posts

Posted 24 September 2019 - 08:33 PM


I'm trying to use the P4java sdk to connect to Perforce server and list and extract content.

I instantiate a P4server

[color=#cc7832]val [/color]server = ServerFactory.getOptionsServer([color=#6a8759]"p4java://[/color][color=#cc7832]$[/color]serverConnectionString[color=#6a8759]"[/color][color=#cc7832], null[/color])
server.[color=#9876aa][i]userName [/i][/color]= [color=#9876aa]username

Later on when I try to list ChangeLists based on a FileSpec

[color=#A9B7C6][font=Menlo][size=1][background=rgb(43, 43, 43)]server.getChangelists(FileSpecBuilder.makeFileSpecList(depotPathSpec)[/background][/size][/font][/color][color=#CC7832][font=Menlo][size=1], [/size][/font][/color][color=#A9B7C6][font=Menlo][size=1][background=rgb(43, 43, 43)]GetChangelistsOptions())[/background][/size][/font][/color] 

I'm getting the following exception
com.perforce.p4java.exception.AccessException: Perforce password (P4PASSWD) invalid or unset.
at com.perforce.p4java.impl.mapbased.server.cmd.ResultMapParser.handleErrorStr(ResultMapParser.java:143)
at com.perforce.p4java.impl.mapbased.server.cmd.ResultListBuilder.buildNonNullObjectListFromCommandResultMaps(ResultListBuilder.java:36)
at com.perforce.p4java.impl.mapbased.server.cmd.ChangesDelegator.getChangelists(ChangesDelegator.java:131)
at com.perforce.p4java.impl.mapbased.server.Server.getChangelists(Server.java:1274)

I tried to set environment variable P4PASSWD, and still getting the same exception.

Please let me know what I'm missing

- user credentials are correct,
- p4java version: 2019.1.1827134


#2 Matt Albrecht

Matt Albrecht


  • Members
  • PipPip
  • 24 posts

Posted 03 October 2019 - 01:23 PM

The P4 Java API does not itself load values from the environment or Windows registry.  Instead, you must set these explicitly through the API.  For the password, you will need to run an explicit login for each connection:

final LoginOptions loginOptions = new LoginOptions();
// Set login options, as necessary
server.login(password, loginOptions);

Also tagged with one or more of these keywords: P4PASSWD, P4Java

0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users