Reputation: 53
I use Artifactory Java client, and cant upload file to Artifactory. My code is very simple, taken from Artifactory Java Client test folder:
artifactoryClient = ArtifactoryClient.create("localhost:8081", "admin", "admin");
InputStream content = new ByteArrayInputStream("I want to test my upload!".getBytes());
UploadableArtifact apAtrifact = artifactoryClient.repository("ext-snapshotlocal").upload("test/content.txt", content);
File res = apAtrifact.doUpload();
I got error:
02:44:26.014 [main] DEBUG org.apache.http.headers - >> Accept-Encoding: gzip,deflate
02:44:26.014 [main] DEBUG org.apache.http.wire - >> "I want to test my upload!"
02:44:26.248 [main] DEBUG org.apache.http.wire - << "HTTP/1.1 403 Forbidden[\r][\n]"
02:44:26.250 [main] DEBUG org.apache.http.wire - << "Server: Apache-Coyote/1.1[\r][\n]"
02:44:26.250 [main] DEBUG org.apache.http.wire - << "Content-Type: text/html;charset=utf-8[\r][\n]"
02:44:26.250 [main] DEBUG org.apache.http.wire - << "Content-Length: 961[\r][\n]"
02:44:26.250 [main] DEBUG org.apache.http.wire - << "Date: Sun, 24 Nov 2013 00:44:25 GMT[\r][\n]"
02:44:26.250 [main] DEBUG org.apache.http.wire - << "[\r][\n]"
02:44:26.250 [main] DEBUG o.a.h.i.conn.DefaultClientConnection - Receiving response: HTTP/1.1 403 Forbidden
02:44:26.250 [main] DEBUG org.apache.http.headers - << HTTP/1.1 403 Forbidden
02:44:26.250 [main] DEBUG org.apache.http.headers - << Server: Apache-Coyote/1.1
02:44:26.250 [main] DEBUG org.apache.http.headers - << Content-Type: text/html;charset=utf-8
02:44:26.250 [main] DEBUG org.apache.http.headers - << Content-Length: 961
02:44:26.250 [main] DEBUG org.apache.http.headers - << Date: Sun, 24 Nov 2013 00:44:25 GMT
02:44:26.253 [main] DEBUG o.a.h.impl.client.DefaultHttpClient - Connection can be kept alive indefinitely
02:44:26.254 [main] DEBUG groovyx.net.http.RESTClient - Response code: 403; found handler: org.codehaus.groovy.runtime.MethodClosure@41feeacb
02:44:26.254 [main] DEBUG groovyx.net.http.RESTClient - Parsing response as: application/json
02:44:26.265 [main] DEBUG org.apache.http.wire - << "<html><head><title>Apache Tomcat/7.0.39 - Error report</title><style><!--H1 {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;font-size:22px;} H2 {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;font-size:16px;} H3 {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;font-size:14px;} BODY {font-family:Tahoma,Arial,sans-serif;color:black;background-color:white;} B {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;} P {font-family:Tahoma,Arial,sans-serif;background:white;color:black;font-size:12px;}A {color : black;}A.name {color : black;}HR {color : #525D76;}--></style> </head><body><h1>HTTP Status 403 - </h1><HR size="1" noshade="noshade"><p><b>type</b> Status report</p><p><b>message</b> <u></u></p><p><b>description</b> <u>Access to the specified resource has been forbidden.</u></p><HR size="1" noshade="noshade"><h3>Apache Tomcat/7.0.39</h3></body></html>"
02:44:26.272 [main] DEBUG o.a.h.i.c.BasicClientConnectionManager - Releasing connection org.apache.http.impl.conn.ManagedClientConnectionImpl@4349f1b6
02:44:26.272 [main] DEBUG o.a.h.i.c.BasicClientConnectionManager - Connection can be kept alive indefinitely
02:44:26.278 [main] WARN groovyx.net.http.RESTClient - Error parsing 'text/html;charset=utf-8' response
com.fasterxml.jackson.core.JsonParseException: Unexpected character ('<' (code 60)): expected a valid value (number, String, array, object, 'true', 'false' or 'null')
at [Source: org.apache.http.conn.EofSensorInputStream@494f0b41; line: 1, column: 2]
at com.fasterxml.jackson.core.JsonParser._constructError(JsonParser.java:1284) ~[services-0.9-all.jar:na]
at com.fasterxml.jackson.core.base.ParserMinimalBase._reportError(ParserMinimalBase.java:588) ~[services-0.9-all.jar:na]
Could you help me with this issue?
Upvotes: 2
Views: 3281
Reputation: 4350
I actually had this exact thing happen to me. I assume you're using this client. It turned out I wasn't being specific enough in the URL. I needed to provide the full path, like so:
artifactoryClient = ArtifactoryClient.create("http://localhost:8081/artifactory", "admin", "password");
I'd assume that if you're using a separate container to run it other than what bin/artifactory.sh uses, you might have to tweak that URL.
Upvotes: 1
Reputation: 22893
You got 403 Forbidden
, so you probably should check your credentials. In case of default Artifactory installation, they should be admin:password
, not admin:admin
.
Another very possible cause is the encrypted password policy. If the policy is set to "mandatory", you have to use encrypted password when creating the client.
BTW, you try to upload a non-snapshot file to a snapshot repository. You should check whether it accepts releases, otherwise you'll get 409
after getting the credentials straight.
Upvotes: 0