Artifactory - 在进行REST调用时出现Tomcat错误

时间:2015-11-17 20:55:11

标签: python tomcat artifactory

我正在尝试使用REST API对我的Artifactory实例执行某些操作,但是当我进行某些调用时,我收到以下Tomcat错误:

HTTP Status 404
The requested resource is not available.

我使用Python脚本执行此操作,而我的Artifactory实例是使用RPM软件包通过这些instructions部署的v4.2.2 rev 40049。

当我使用api/ URI与artifactory/ URI进行某些REST调用时,似乎只会出现问题。以下是我的意思的一些例子:

我可以使用此命令成功部署工件:

>>import requests
>>session = requests.session()
>>response = session.put('http://artifactory.domain.com/artifactory/repo/test.txt')

响应:

>>response.status_code
201
>>response.text
u'{\n  "repo" : "repo",\n  "path" : "/",\n  "created" : "2015-11-17T12:10:12.679-07:00",\n  "createdBy" : "anonymous",\n  "downloadUri" : "http://artifactory.domain.com:8081/artifactory/repo/test.txt",\n  "mimeType" : "application/octet-stream",\n  "size" : "0",\n  "checksums" : {\n    "sha1" : "da39a3ee5e6b4b0d3255bfef95601890afd80709",\n    "md5" : "d41d8cd98f00b204e9800998ecf8427e"\n  },\n  "originalChecksums" : {\n  },\n  "uri" : "http://artifactory.domain.com:8081/artifactory/repo/test.txt"\n}'

但是,如果我尝试执行使用api/ URI的复制或移动之类的操作,那么我会收到Tomcat错误消息:

>>response = session.post('http://artifactory.domain.com/api/copy/repo/test.txt?to=/repo/folder/test.txt')
>>response.status_code
404
>>response.text
u'<!DOCTYPE html><html><head><title>Apache Tomcat/8.0.22 - Error report</title><style type="text/css">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;}.line {height: 1px; background-color: #525D76; border: none;}</style> </head><body><h1>HTTP Status 404 - /api/copy/repo/test.txt</h1><div class="line"></div><p><b>type</b> Status report</p><p><b>message</b> <u>/api/copy/repo/test.txt</u></p><p><b>description</b> <u>The requested resource is not available.</u></p><hr class="line"><h3>Apache Tomcat/8.0.22</h3></body></html>'

我在网上搜索过,发现当应用程序的文件夹权限错误时,有些人遇到resource not available个问题,但据我在JFrog的网站上可以看出我的文件夹权限是正确的。

我还检查了系统上的几个日志文件,它们甚至不包含对我所做的REST调用的任何引用,最终导致Tomcat错误:

Catalina日志:

/var/opt/jfrog/artifactory/logs/catalina/catalina.out

2015-11-17 12:16:47,434 [http-nio-8081-exec-5] [INFO ] (o.a.e.UploadServiceImpl:453) - Deploy to 'repo:test.txt' Content-Length: 6

主要工件日志:

/var/opt/jfrog/artifactory/logs/artifactory.log

2015-11-17 12:16:47,434 [http-nio-8081-exec-5] [INFO ] (o.a.e.UploadServiceImpl:453) - Deploy to 'repo:test.txt' Content-Length: 6

以下是/var/opt/jfrog/artifactory目录的内容:

drwxrwxr-x 3 artifactory artifactory 4096 Sep 22 02:00 backup
drwxrwxr-x 5 artifactory artifactory 4096 Nov  6 08:06 data
lrwxrwxrwx 1 artifactory artifactory   26 Nov  6 08:06 etc -> /etc/opt/jfrog/artifactory
drwxrwxr-x 3 artifactory artifactory 4096 Sep 21 13:24 logs
lrwxrwxrwx 1 artifactory artifactory   27 Nov  6 08:06 misc -> /opt/jfrog/artifactory/misc
drwxrwxr-x 2 artifactory artifactory 4096 Nov  6 09:23 temp
lrwxrwxrwx 1 artifactory artifactory   29 Nov  6 08:06 tomcat -> /opt/jfrog/artifactory/tomcat
lrwxrwxrwx 1 artifactory artifactory   30 Nov  6 08:06 webapps -> /opt/jfrog/artifactory/webapps
drwxrwxr-x 3 artifactory artifactory 4096 Sep 21 13:24 work

关于为什么某些REST调用成功而其他REST调用不成功的任何想法?

1 个答案:

答案 0 :(得分:0)

好的,显然我的API调用复制和移动等原因不起作用是因为我需要在URI字符串中的artifactory/前缀之前包含api/,如下所示:

>>response = session.post('http://artifactory.domain.com/artifactory/api/copy/repo/test.txt?to=/repo/folder/test.txt')
>>response.status_code
200
>>response.text
u'{\n  "messages" : [ {\n    "level" : "INFO",\n    "message" : "copying repo:test.txt to repo:folder/test.txt completed successfully, 1 artifacts and 0 folders were copied"\n  } ]\n}'