gpt4 book ai didi

alfresco - 在 Java 支持的 Alfresco-Share webscript 中使用响应输出流时出现异常

转载 作者:行者123 更新时间:2023-12-01 11:47:54 26 4
gpt4 key购买 nike

<强>1。上下文

我想实现一个 Alfresco-Share 支持 Java 的网络脚本,就像现有的“I18N 资源和消息网络脚本”一样。主要区别在于我想使用响应输出流(而不是编写器)。

使用的 Alfresco-Share 版本:4.1.1。

<强>2。用于重现错误的测试代码

- Spring bean :

<bean id="webscript.test.content.get" parent="webscript" class="test.TestWebscript" />

- Java 代码:

package test;

import java.io.IOException;

import org.springframework.extensions.webscripts.AbstractWebScript;
import org.springframework.extensions.webscripts.WebScriptRequest;
import org.springframework.extensions.webscripts.WebScriptResponse;

public final class TestWebscript extends AbstractWebScript
{
@Override
public void execute(final WebScriptRequest request, final WebScriptResponse response) throws IOException
{
response.getOutputStream().write("test".getBytes());
}
}

- Webscript desc 文件:

<?xml version="1.0" encoding="UTF-8"?>

<webscript>
<shortname>Test webscript</shortname>
<description>A webscript using the response outputstream</description>
<url>/test/content</url>
<format default="">extension</format>
<lifecycle>draft_public_api</lifecycle>
<authentication>guest</authentication>
<transaction>required</transaction>
<family>Tests</family>
</webscript>

<强>3。结果

我有以下异常(exception)情况:

java.lang.IllegalStateException: getOutputStream() has already been called for this response
at org.apache.catalina.connector.Response.getWriter(Response.java:611)
at org.apache.catalina.connector.ResponseFacade.getWriter(ResponseFacade.java:198)
at org.springframework.extensions.webscripts.servlet.WebScriptServletResponse.getWriter(WebScriptServletResponse.java:198)
at org.springframework.extensions.webscripts.LocalWebScriptRuntimeContainer.executeScript(LocalWebScriptRuntimeContainer.java:241)
at org.springframework.extensions.webscripts.AbstractRuntime.executeScript(AbstractRuntime.java:377)
at org.springframework.extensions.webscripts.AbstractRuntime.executeScript(AbstractRuntime.java:209)
at org.springframework.extensions.webscripts.servlet.mvc.WebScriptView.renderMergedOutputModel(WebScriptView.java:104)
at org.springframework.web.servlet.view.AbstractView.render(AbstractView.java:250)
at org.springframework.web.servlet.DispatcherServlet.render(DispatcherServlet.java:1047)
at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:817)
at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:719)
at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:644)
at org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:549)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:617)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.alfresco.web.site.servlet.MTAuthenticationFilter.doFilter(MTAuthenticationFilter.java:74)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.alfresco.web.site.servlet.SSOAuthenticationFilter.doFilter(SSOAuthenticationFilter.java:355)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:298)
at org.apache.coyote.http11.Http11NioProcessor.process(Http11NioProcessor.java:886)
at org.apache.coyote.http11.Http11NioProtocol$Http11ConnectionHandler.process(Http11NioProtocol.java:721)
at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.run(NioEndpoint.java:2256)
at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
at java.lang.Thread.run(Thread.java:662)

<强>4。问题

有什么方法可以使用 webscript outputstream 响应吗?

最佳答案

这是共享网络层上的 WebScript 运行时的限制。 Share 有一个强大的组件框架和可扩展性模型,它包装了所有 WebScript——在 JavaScript 代码、模板等的不同点启用高级定制。不幸的是,将 WebScript 视为将其输出合并到单个页面上的组件意味着运行时控​​制OutputStream 和 Writer - 您检索的 Writer 根本不是通常的 Servlet Writer,而是一个包装器。

关于alfresco - 在 Java 支持的 Alfresco-Share webscript 中使用响应输出流时出现异常,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14275961/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com