1

I'm testing our software with several versions of Java 8. It works fine with RedHat's and Zulu, but with IBM's Java 8, it's throwing the following exception:

org.springframework.beans.factory.xml.XmlBeanDefinitionStoreException: 
Line 1 in XML document from file 
[C:\xxxx\image-server\.\res\conf\temp.xml] is invalid; 
nested exception is org.xml.sax.SAXParseException: 
cvc-elt.1: Cannot find the declaration of element 'server'.

The temp.xml file is as follows:

<?xml version="1.0" encoding="UTF-8"?><server id="myServer" max-logins="100" xmlns:beans="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://mina.apache.org/ftpserver/spring/v1 http://mina.apache.org/ftpserver/ftpserver-1.0.xsd">
   <listeners>
      <nio-listener name="default" port="21">
         <ssl>
            <keystore file="./res/ftpserver.jks" password="password"/>
         </ssl>
      </nio-listener>
   </listeners>
   <ftplets>
      <ftplet name="ImagePilot">
         <beans:bean class="com.xxxx.svp.imagepilot.ImagePilot">
            <beans:property name="createThumbNailEnabled" value="true"/>
            <beans:property name="defaultStoreToRoot" value="false"/>
            <beans:property name="defaultRootDirectory" value="d:/images"/>
            <beans:property name="scaleFactor" value="4"/>
            <beans:property name="copyThumbNails" value="false"/>
            <beans:property name="imageFileNameHandler">
               <beans:bean class="com.xxxx.svp.imagepilot.XxxxImageFileNameHandler">
                  <beans:constructor-arg>
                     <beans:value>^[a-zA-Z0-9\-]+_\d{8}_\d{6}_\d{8}\.(jpg|JPG|xml|XML|bmp|BMP)</beans:value>
                  </beans:constructor-arg>
                  <beans:property name="maxDelayedImageData" value="350"/>
               </beans:bean>
            </beans:property>
         </beans:bean>
      </ftplet>
   </ftplets>
   <file-user-manager file="./res/conf/icr890usersfile.properties"/>
</server>

Any idea what the problem might be? Why just IBM's implementation?

Edit: additional info

The "server" element which isn't being found is from the apache mina project.

https://mina.apache.org/ftpserver-project/configuration_server.html

<server xmlns="http://mina.apache.org/ftpserver/spring/v1"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://mina.apache.org/ftpserver/spring/v1 http://mina.apache.org/ftpserver/ftpserver-1.0.xsd"
    id="server"     
    max-logins="500"
    anon-enabled="false"
    max-anon-logins="123"
    max-login-failures="124"
    login-failure-delay="125">
...
</server>

A similar (but not the same) error appears in a bug report for mina ftp:

https://issues.apache.org/jira/browse/FTPSERVER-458

The comment on that was:

"The schema is located in ftpserver-core-1.0.6.jar/org/apache/ftpserver/config/spring/ftpserver-1.0.xsd.

This is a configuration problem, ftplets element should be placed before file-user-manager."

I wonder if this is a classpath or classloading issue, since the xsd is found in a jar file.

Edit:

This project is using a schema setup as described in the section "Appendix B. Extensible XML authoring" in the Spring docs at https://docs.spring.io/spring/docs/3.0.0.M3/reference/html/apb.html.

Besides setting up a schema, it has you create two properties files under META-INF: 1. spring-handlers, which maps the xsd to the custom handler (based on the targetNamespace in the schema).

The contents of this are:

http://mina.apache.org/ftpserver/spring/v1=org.apache.ftpserver.config.spring.FtpServerNamespaceHandler

Note the backslash after the "http" is required for the colon.

So the name matches as per the instructions.

  1. The properties file called 'spring.schemas' contains a mapping of XML Schema locations to classpath resources.

The contents of this second one look like this:

http://mina.apache.org/ftpserver/ftpserver-1.0.xsd=org/apache/ftpserver/config/spring/ftpserver-1.0.xsd

So, unusually for a resource, the XSD is distributed in the jar file at the same level as the handler class.

Jack BeNimble
  • 35,733
  • 41
  • 130
  • 213

1 Answers1

1

This has something to do with the way xml files are dynamically generated. When run with IBM Java, the server tag of the XML configuration file apparently doesn't have the line-feed between it and the header, it seems, so the parser doesn't see the server tag.

When run with the other Javas, the line feed is there, and no problem.

My next step is to recompile the module in question with IBMs jdk, and see if it works then. Unfortunately, it's not compiling, but that's another question.

Jack BeNimble
  • 35,733
  • 41
  • 130
  • 213