首页 文章

Artifactory - 进行REST调用时的Tomcat错误

提问于
浏览
0

我正在尝试使用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>'

我在网上搜索过,发现当应用程序's folder had the wrong permissions, but as far as I can tell from JFrog'的网站我的文件夹权限正确时,有些人有 resource not available 问题 .

我还检查了系统上的几个日志文件,它们甚至没有包含对我所做的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调用成功而其他调用是否成功的任何想法?

1 回答

  • 0

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

    >>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}'
    

相关问题