Affects: 6.1.0
When migrate Spring Framework from 5.3.x to 6.1.x, we noticed that \
<jee:local-slsb id="myBean" jndi-name="ejb/local/MyBean" business-interface="com.mycompany.MyBean" resource-ref="true" />
Causing exception:
Caused by: org.xml.sax.SAXParseException; lineNumber: 15; columnNumber: 25; cvc-complex-type.3.2.2: Attribute 'business-interface' is not allowed to appear in element 'jee:local-slsb'.
at java.xml/com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper.createSAXParseException(ErrorHandlerWrapper.java:204)
at java.xml/com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper.error(ErrorHandlerWrapper.java:135)
at java.xml/com.sun.org.apache.xerces.internal.impl.XMLErrorReporter.reportError(XMLErrorReporter.java:396)
at java.xml/com.sun.org.apache.xerces.internal.impl.XMLErrorReporter.reportError(XMLErrorReporter.java:327)
at java.xml/com.sun.org.apache.xerces.internal.impl.XMLErrorReporter.reportError(XMLErrorReporter.java:284)
at java.xml/com.sun.org.apache.xerces.internal.impl.xs.XMLSchemaValidator$XSIErrorReporter.reportError(XMLSchemaValidator.java:512)
at java.xml/com.sun.org.apache.xerces.internal.impl.xs.XMLSchemaValidator.reportSchemaError(XMLSchemaValidator.java:3588)
at java.xml/com.sun.org.apache.xerces.internal.impl.xs.XMLSchemaValidator.processAttributes(XMLSchemaValidator.java:2993)
at java.xml/com.sun.org.apache.xerces.internal.impl.xs.XMLSchemaValidator.handleStartElement(XMLSchemaValidator.java:2287)
at java.xml/com.sun.org.apache.xerces.internal.impl.xs.XMLSchemaValidator.emptyElement(XMLSchemaValidator.java:850)
at java.xml/com.sun.org.apache.xerces.internal.impl.XMLNSDocumentScannerImpl.scanStartElement(XMLNSDocumentScannerImpl.java:351)
at java.xml/com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl$FragmentContentDriver.next(XMLDocumentFragmentScannerImpl.java:2726)
at java.xml/com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerImpl.next(XMLDocumentScannerImpl.java:605)
at java.xml/com.sun.org.apache.xerces.internal.impl.XMLNSDocumentScannerImpl.next(XMLNSDocumentScannerImpl.java:112)
at java.xml/com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanDocument(XMLDocumentFragmentScannerImpl.java:542)
at java.xml/com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:889)
at java.xml/com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:825)
at java.xml/com.sun.org.apache.xerces.internal.parsers.XMLParser.parse(XMLParser.java:141)
at java.xml/com.sun.org.apache.xerces.internal.parsers.DOMParser.parse(DOMParser.java:247)
at java.xml/com.sun.org.apache.xerces.internal.jaxp.DocumentBuilderImpl.parse(DocumentBuilderImpl.java:342)
at deployment.myproject.ear.xpc.war//org.springframework.beans.factory.xml.DefaultDocumentLoader.loadDocument(DefaultDocumentLoader.java:77)
at deployment.myproject.ear.xpc.war//org.springframework.beans.factory.xml.XmlBeanDefinitionReader.doLoadDocument(XmlBeanDefinitionReader.java:441)
at deployment.myproject.ear.xpc.war//org.springframework.beans.factory.xml.XmlBeanDefinitionReader.doLoadBeanDefinitions(XmlBeanDefinitionReader.java:399)
When tried to declared as regular bean XML as the documentation mentioned:
<bean id="myBean" class="org.springframework.ejb.access.LocalStatelessSessionProxyFactoryBean">
<property name="jndiName" value="ejb/local/MyBean" />
<property name="businessInterface" value="com.mycompany.MyBean" />
<property name="resourceRef" value="true" />
</bean>
resulting java.lang.ClassNotFoundException
as org.springframework.ejb.access.LocalStatelessSessionProxyFactoryBean
was removed in Spring Framework 6.x
Comment From: snicoll
Thanks for the report @sammyhk. This is an oversight on our end as the support for EJB access has been removed in Spring Framework 6. I've updated the upgrade notes and we will use this issue to fix the documentation.
If you need to lookup an EJB, please use JNDI directly.
Comment From: snicoll
Actually, let me take that back. I thought the support was completely removed but @jhoeller mentioned that the XML namespace has been preserved, delegating to JNDI.
@sammyhk can you please remove the business-interface
attribute and try again? This shouldn't be required with modern EJBs.
Comment From: sammyhk
Tried but the XSD marked business-interface
attribute use="required"
so cannot proceed.$
I think the proper fixed should be mark business-interface
optional and delegate to proxyInterfaces
of JNDI
Comment From: sammyhk
I think the proper fixed should be mark business-interface
optional and delegate to proxyInterfaces
of JNDI
Comment From: snicoll
I can see that the XSD is outdated on schema.springframework.org and our own test have this error. I am not sure what you mean by "cannot proceed" unless you have enabled XSD validation. You can turn that off for the time being and remove the business-interface
attribute. The code already delegates to JNDI as it is.
Comment From: sammyhk
I can see that the XSD is outdated on schema.springframework.org and our own test have this error. I am not sure what you mean by "cannot proceed" unless you have enabled XSD validation. You can turn that off for the time being and remove the
business-interface
attribute. The code already delegates to JNDI as it is.
I see, we have some XSD validation in our build time so I haven't proceed the test. Now tested and it works if skipped the XSD validation.
Comment From: snicoll
Alright. For your own purpose here, please move to <jee:jndi-lookup>
. We will re-add processing of the attribute (and ignoring it) to preserve backward compatibility.