提交XML时文件的过早末端

发布于 2025-01-17 22:37:15 字数 1166 浏览 2 评论 0原文

我面临奇怪的问题“文件过早”。在我们的Azure应用程序之一中,最近几天的例外。它是一个春季启动应用程序。我正在使用Spring Boot版本2.6.3(嵌入式tomcat)。该代码已经工作了8个月,但它不再起作用。我对Java 8进行的仅更改Java 11版本更新了Azure App Service。

我们在应用服务中使用“ Java 11上的Java 11”。 我们在以下行(设置新模式)上得到一个例外, 架构架构= sf.newschema(file);

这是以前工作的Java代码。

 public static <T> String marshal(Class<T> beanClass, Object object, String xsdSchemaPath)
        throws JAXBException, SAXException{
    JAXBContext jaxbContext = JAXBContext.newInstance(beanClass);
    Marshaller jaxbMarshaller = jaxbContext.createMarshaller();

    SchemaFactory sf = SchemaFactory.newInstance(XMLConstants.W3C_XML_SCHEMA_NS_URI);
    
    File file = new File(xsdSchemaPath);
    InputStream in = Thread.currentThread().getContextClassLoader().getResourceAsStream(xsdSchemaPath);
    try {
        FileUtils.copyInputStreamToFile(in, file);
    } catch (IOException e) {
        logger.error("Error occured in Marshalling the object", e.getMessage());
        throw new SriException(xsdSchemaPath + " not found ");
    }
    
    Schema schema = sf.newSchema(file);
    jaxbMarshaller.setSchema(schema);

我已经验证了XSD及其有效。 请让我知道是否有潜在客户。

I am facing strange issue "Premature end of file." exception for last few days on one of our azure application. Its a spring boot application. I am using spring boot version 2.6.3 (embedded tomcat). This code has been working for past 8 months but its not working anymore. Only changes I did for Java 8 to Java 11 version update on the azure app service.

We are using "Java 11 on JAVA SE linux stack" in app service.
We are getting an exception on below line (setting new schema),
Schema schema = sf.newSchema(file);

Here is the Java code which was working before.

 public static <T> String marshal(Class<T> beanClass, Object object, String xsdSchemaPath)
        throws JAXBException, SAXException{
    JAXBContext jaxbContext = JAXBContext.newInstance(beanClass);
    Marshaller jaxbMarshaller = jaxbContext.createMarshaller();

    SchemaFactory sf = SchemaFactory.newInstance(XMLConstants.W3C_XML_SCHEMA_NS_URI);
    
    File file = new File(xsdSchemaPath);
    InputStream in = Thread.currentThread().getContextClassLoader().getResourceAsStream(xsdSchemaPath);
    try {
        FileUtils.copyInputStreamToFile(in, file);
    } catch (IOException e) {
        logger.error("Error occured in Marshalling the object", e.getMessage());
        throw new SriException(xsdSchemaPath + " not found ");
    }
    
    Schema schema = sf.newSchema(file);
    jaxbMarshaller.setSchema(schema);

I have already verified xsd and its valid.
Please let me know if there are any leads.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

妥活 2025-01-24 22:37:15

我唯一能想到的是最大尺寸问题或超时。查看以下内容并尝试更改参数:

In conf\server.xml

<Connector port="80" protocol="HTTP/1.1"
               connectionTimeout="20000"
               redirectPort="8443"
                maxPostSize="67589953" />

在 webapps\manager\WEB-INF\web.xml

<multipart-config>
  <!-- 52MB max -->
  <max-file-size>52428800</max-file-size>
  <max-request-size>52428800</max-request-size>
  <file-size-threshold>0</file-size-threshold>
</multipart-config>

tomcat 中允许的 HttpRequest 最大大小?

the only thing I can think about it's a max size issue or timeout. Take a look in the following and try changing the parameters:

In conf\server.xml

<Connector port="80" protocol="HTTP/1.1"
               connectionTimeout="20000"
               redirectPort="8443"
                maxPostSize="67589953" />

In webapps\manager\WEB-INF\web.xml

<multipart-config>
  <!-- 52MB max -->
  <max-file-size>52428800</max-file-size>
  <max-request-size>52428800</max-request-size>
  <file-size-threshold>0</file-size-threshold>
</multipart-config>

HttpRequest maximum allowable size in tomcat?

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文