legacy-knowledge-base
公開されました Sep. 10, 2025

DXP 7.4のGraphQLマルチパートリクエスト

written-by

Solyom Nagy-Györkös

How To articles are not official guidelines or officially supported documentation. They are community-contributed content and may not always reflect the latest updates to Liferay DXP. We welcome your feedback to improve How To articles!

While we make every effort to ensure this Knowledge Base is accurate, it may not always reflect the most recent updates or official guidelines.We appreciate your understanding and encourage you to reach out with any feedback or concerns.

legacy-article

learn-legacy-article-disclaimer-text

問題

  • GraphQL API (createDocumentFolderDocument メソッド) を使用して DXP 7.4 に画像をアップロードしようとしています。
  • このアプローチはDXP 7.2以降では有効ではないようだ:
    https://help.liferay.com/hc/en-us/articles/360039026272-Multipart-Requests
  • DXP 7.2で使用されたアプローチでは、以下のエラーが発生するようになりました:
ERROR [http-nio-8080-exec-7][AbstractGraphQLHttpServlet:86] Error executing GraphQL request!
java.lang.IllegalStateException: getInputStream() has already been called for this request
at org.apache.catalina.connector.Request.getReader(Request.java:1206) ~[catalina.jar:9.0.75]
at org.apache.catalina.connector.RequestFacade.getReader(RequestFacade.java:392) ~[catalina.jar:9.0.75]
at javax.servlet.ServletRequestWrapper.getReader(ServletRequestWrapper.java:213) ~[servlet-api.jar:4.0.FR]
at javax.servlet.ServletRequestWrapper.getReader(ServletRequestWrapper.java:213) ~[servlet-api.jar:4.0.FR]
at javax.servlet.ServletRequestWrapper.getReader(ServletRequestWrapper.java:213) ~[servlet-api.jar:4.0.FR]
at javax.servlet.ServletRequestWrapper.getReader(ServletRequestWrapper.java:213) ~[servlet-api.jar:4.0.FR]
at graphql.kickstart.servlet.GraphQLPostInvocationInputParser.getGraphQLInvocationInput(GraphQLPostInvocationInputParser.java:35) ~[graphql-java-servlet-12.0.0.jar:?]
at graphql.kickstart.servlet.HttpRequestHandlerImpl.handle(HttpRequestHandlerImpl.java:42) ~[graphql-java-servlet-12.0.0.jar:?]
at graphql.kickstart.servlet.AbstractGraphQLHttpServlet.doRequest(AbstractGraphQLHttpServlet.java:84) [graphql-java-servlet-12.0.0.jar:?]
at graphql.kickstart.servlet.AbstractGraphQLHttpServlet.doPost(AbstractGraphQLHttpServlet.java:79) [graphql-java-servlet-12.0.0.jar:?]
at javax.servlet.http.HttpServlet.service(HttpServlet.java:555) [servlet-api.jar:4.0.FR]
at javax.servlet.http.HttpServlet.service(HttpServlet.java:623) [servlet-api.jar:4.0.FR]
at jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:?]
at jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[?:?]
at jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:?]
at java.lang.reflect.Method.invoke(Method.java:566) ~[?:?]
at com.liferay.portal.vulcan.internal.graphql.servlet.GraphQLServletExtender$10.invoke(GraphQLServletExtender.java:654) [bundleFile:?]
at com.sun.proxy.$Proxy470.service(Unknown Source) [?:?]
at org.eclipse.equinox.http.servlet.internal.registration.EndpointRegistration.service(EndpointRegistration.java:153) [bundleFile:?]

環境

  • DXP 7.4

解像度

  1. GraphQL API(createDocumentFolderDocumentメソッド)は7.4で利用可能で、ドキュメントに記載されているとおりに動作します。
  2. 突然変異を成功させるために必要なステップは以下の通りである:
  • shielded-container-web.xml コンテナが tomcat-9.0.83 の場合は以下のパスにあります。 bundles/tomcat-9.0.83/webapps/ROOT/WEB-INF/shielded-container-web.xml
  • 次に、 shielded-container-web.xml ファイルにある "Module Framework Servlet" のサーブレット設定を変更します。 この名前は、 <servlet-name></servlet-name> タグの間に含まれる。 モジュール・フレームワーク・サーブレット」の完全なコンフィギュレーションは、次のようになります:
<servlet> 
<servlet-name>Module Framework Servlet</servlet-name>
<servlet-class>com.liferay.portal.module.framework.ModuleFrameworkServletAdapter</servlet-class>
<load-on-startup>1</load-on-startup>
<async-supported>true</async-supported>
<multipart-config>
<location>/tmp</location>
<max-file-size>20848820</max-file-size>
<max-request-size>418018841</max-request-size>
<file-size-threshold>1048576</file-size-threshold>
</multipart-config>
</servlet>
  • 修正して保存したら、ポータルを再起動する。
  • 再起動後、コンピュータ内で見つかった既存の文書がある既存の文書フォルダの変異クエリを実行します。 そのためのCURLを紹介しよう:
curl 'http://localhost:8080/o/graphql' \ 
-u 'test@liferay.com:test' \
-F operations='{
"query":"mutation($files: [Upload]) {createDocumentFolderDocument(multipartBody: $files, documentFolderId: \"33449\") {id}}",
"variables":{
"files":[
null
]
}
}' \
-F map='{ "0": ["variables.files.0"]}' \
-F 0=@"file.txt"

注: リクエストを動作させるためには、 authentication, documentFolderId and file path をあなたのケースに合わせて変更する必要があります。

did-this-article-resolve-your-issue

legacy-knowledge-base