Results 1 to 8 of 8

Thread: Java 1.4 and NoClassDefFoundError: org/xml/sax/ext/EntityResolver2

  1. #1
    Join Date
    Oct 2007
    Posts
    14

    Default Java 1.4 and NoClassDefFoundError: org/xml/sax/ext/EntityResolver2

    I'm trying to run spring-ws under Java 1.4.

    I've added xalan.jar, xercesImpl.jar, serializer.jar and xml-apis.jar to $JAVAHOME/lib/endorsed as the Xalan/Xerces FAQs say, and that fixed the namespace errors.

    However I still get this exception while initializing the context:

    org.springframework.beans.factory.BeanDefinitionSt oreException: Unexpected exception parsing XML document from class path resource [context/applicationContext.xml]; nested exception is java.lang.NoClassDefFoundError: org/xml/sax/ext/EntityResolver2
    Caused by: java.lang.NoClassDefFoundError: org/xml/sax/ext/EntityResolver2
    at org.apache.xerces.parsers.DOMParser.setEntityResol ver(Unknown Source)
    at org.apache.xerces.jaxp.DocumentBuilderImpl.setEnti tyResolver(Unknown Source)
    at org.springframework.beans.factory.xml.DefaultDocum entLoader.createDocumentBuilder(DefaultDocumentLoa der.java:127)
    at org.springframework.beans.factory.xml.DefaultDocum entLoader.loadDocument(DefaultDocumentLoader.java: 75)
    at org.springframework.beans.factory.xml.XmlBeanDefin itionReader.doLoadBeanDefinitions(XmlBeanDefinitio nReader.java:388)
    at org.springframework.beans.factory.xml.XmlBeanDefin itionReader.loadBeanDefinitions(XmlBeanDefinitionR eader.java:340)
    at org.springframework.beans.factory.xml.XmlBeanDefin itionReader.loadBeanDefinitions(XmlBeanDefinitionR eader.java:317)
    at org.springframework.beans.factory.support.Abstract BeanDefinitionReader.loadBeanDefinitions(AbstractB eanDefinitionReader.java:125)
    at org.springframework.context.support.AbstractXmlApp licationContext.loadBeanDefinitions(AbstractXmlApp licationContext.java:109)
    at org.springframework.context.support.AbstractXmlApp licationContext.loadBeanDefinitions(AbstractXmlApp licationContext.java:79)
    at org.springframework.context.support.AbstractRefres hableApplicationContext.refreshBeanFactory(Abstrac tRefreshableApplicationContext.java:94)
    at org.springframework.context.support.AbstractApplic ationContext.refresh(AbstractApplicationContext.ja va:292)
    at org.springframework.context.support.ClassPathXmlAp plicationContext.<init>(ClassPathXmlApplicationCon text.java:180)
    at org.springframework.context.support.ClassPathXmlAp plicationContext.<init>(ClassPathXmlApplicationCon text.java:156)
    at org.springframework.context.support.ClassPathXmlAp plicationContext.<init>(ClassPathXmlApplicationCon text.java:143)
    at oh.my.Test.main(Test.java:17)


    I'm pretty sure that the problem is not with anything I'm doing in my code or configuration, since the same code works in Java 1.5.

    I've tried different Xalan/Xerces versions with no success (I'm currently using Xalan 2.7.0 and Xerces 2.9.0). Google said that someone somewhere said that xalan.jar has to be placed into Tomcat's endorsed directory, but this is client application which doesn't use Tomcat.

    Any ideas? Is anyone using spring-ws with Java 1.4?

  2. #2
    Join Date
    Jul 2005
    Location
    Rotterdam, the Netherlands
    Posts
    1,562

    Default

    That's weird, because EntityResolver2 should be in xml-apis.jar.
    Arjen Poutsma

    Spring Web Services Dev Lead
    Please read the FAQ

  3. #3
    Join Date
    Oct 2007
    Posts
    14

    Default

    I cracked it.

    The EntityResolver2 is in sax.jar. (Although xml-apis contains the same package.)

    And right now I have the following .jars in JRE endorsed folder:
    dom.jar
    sax.jar
    xalan.jar
    xercesImpl.jar
    xml-apis.jar
    jaxp-api.jar

    To get dom.jar and sax.jar, I had to download the older JAXP version (1.3.2 instead of 1.4.2) - but I'm using jaxp-api.jar from newer 1.4.2 version. Doesn't make much sense to me but I don't have the time and expertise to investigate further.

    Also, to make spring-ws work under Java 1.4, I had to use the older (1.2 instead 1.3) version of SAAJ, since the 1.3 is dependent on Java 1.5. The problem is, SAAJ 1.2 can't be downloaded legally from Sun anymore (or at least I haven't found a way) - in the end I had to Google the filenames and grab it from someone's CVS repository.

    Your mileage might vary if you don't use Xerces (and perhaps JDOM).

    Arjen, can you please update the spring-ws FAQ regarding Java 1.4?

  4. #4
    Join Date
    Oct 2007
    Posts
    14

    Default



    Unsecured messages go through as expected, but when I added security, I got the following exception since xws-security has dependancy on JAAS 1.3 (as can be seen on https://maven-repository.dev.java.ne...ty-2.0-FCS.pom).

    This is the exception:
    org.springframework.beans.factory.BeanCreationExce ption: Error creating bean with name 'simpleConsoleClient' defined in class path resource [applicationContext.xml]: Invocation of init method failed; nested exception is java.lang.NoClassDefFoundError: com/sun/org/apache/xerces/internal/jaxp/DocumentBuilderFactoryImpl
    Caused by: java.lang.NoClassDefFoundError: com/sun/org/apache/xerces/internal/jaxp/DocumentBuilderFactoryImpl
    at com.sun.xml.wss.impl.misc.XWSSProcessor2_0Impl.<in it>(XWSSProcessor2_0Impl.java:54)
    at com.sun.xml.wss.impl.misc.XWSSProcessorFactory2_0I mpl.createProcessorForSecurityConfiguration(XWSSPr ocessorFactory2_0Impl.java:35)
    at net.adriatica.central.online.client.console.Simple ConsoleClient.initGateway(SimpleConsoleClient.java :90)
    at org.springframework.ws.client.core.support.WebServ iceGatewaySupport.afterPropertiesSet(WebServiceGat ewaySupport.java:147)
    at org.springframework.beans.factory.support.Abstract AutowireCapableBeanFactory.invokeInitMethods(Abstr actAutowireCapableBeanFactory.java:1118)
    at org.springframework.beans.factory.support.Abstract AutowireCapableBeanFactory.initializeBean(Abstract AutowireCapableBeanFactory.java:1085)
    at org.springframework.beans.factory.support.Abstract AutowireCapableBeanFactory.createBean(AbstractAuto wireCapableBeanFactory.java:429)
    at org.springframework.beans.factory.support.Abstract BeanFactory$1.getObject(AbstractBeanFactory.java:2 50)
    at org.springframework.beans.factory.support.DefaultS ingletonBeanRegistry.getSingleton(DefaultSingleton BeanRegistry.java:141)
    at org.springframework.beans.factory.support.Abstract BeanFactory.getBean(AbstractBeanFactory.java:247)
    at org.springframework.beans.factory.support.Abstract BeanFactory.getBean(AbstractBeanFactory.java:161)
    at org.springframework.beans.factory.support.DefaultL istableBeanFactory.preInstantiateSingletons(Defaul tListableBeanFactory.java:273)
    at org.springframework.context.support.AbstractApplic ationContext.refresh(AbstractApplicationContext.ja va:346)
    at org.springframework.context.support.ClassPathXmlAp plicationContext.<init>(ClassPathXmlApplicationCon text.java:92)
    at org.springframework.context.support.ClassPathXmlAp plicationContext.<init>(ClassPathXmlApplicationCon text.java:77)
    at org.springframework.context.support.ClassPathXmlAp plicationContext.<init>(ClassPathXmlApplicationCon text.java:68)


    So basically JAAS 1.3 doesn't work with Java 1.4, and xws-security doesn't work with JAAS 1.2 which works with Java 1.4.

    Which is basically what the spring-ws FAQ says:
    "Note that the security module requires Java 5, because an underlying library (XWSS) requires it."

    Is there any way to have security on Java 1.4?

  5. #5
    Join Date
    Jul 2005
    Location
    Rotterdam, the Netherlands
    Posts
    1,562

    Default

    Which version of xml-apis do you use? You should use 1.3.0x version, not the 2.0.x version which can be found elsewhere. Contrary to what you might believe, 2.0.x is actually older than 1.3.x.

    What I have in my local 1.4.2 endorsed folder:

    xalan.jar version 2.7.0
    xercesImpl.jar 2.8.1
    xml-apis.jar 1.3.04

    xml-apis, jaxp-apis and probably dom and sax contain the same classes, so there is no reason to add them all.

    We publish SAAJ 1.2 on our maven repo. See http://springframework.svn.sourcefor...saaj-impl/1.2/ and http://springframework.svn.sourcefor...aj-api-1.2.pom.
    Arjen Poutsma

    Spring Web Services Dev Lead
    Please read the FAQ

  6. #6
    Join Date
    Jul 2005
    Location
    Rotterdam, the Netherlands
    Posts
    1,562

    Default

    Quote Originally Posted by Domchi View Post
    Is there any way to have security on Java 1.4?
    Not yet, but there is http://opensource.atlassian.com/proj...browse/SWS-207. You can vote for it if you want it implemented. (Or better yet: contribute )
    Arjen Poutsma

    Spring Web Services Dev Lead
    Please read the FAQ

  7. #7
    Join Date
    Oct 2007
    Posts
    14

    Default

    I'm not sure which xml-apis.jar I'm using - from manifest file, it looks like 1.3.1 (?). But it's not the same jar which comes with Xalan and Xerces. If I put only the files you're using in endorsed, I get NAMESPACE_ERR; even with older Xerces version you're using.

  8. #8
    Join Date
    Oct 2007
    Posts
    14

    Default

    Hm. There is another combination that works but includes Saxon - which is basically what I wanted.

    This is the endorsed folder:
    serializer.jar
    xalan.jar
    xercesImpl.jar
    xml-apis.jar

    All of these files come with Xalan 2.7.0 (which means that Xerces implementation is version 2.7.1!). Serializer.jar is necessary in this combination.

    I have the following libraries in classpath:
    activation.jar
    commons-logging.jar
    jaxen-core.jar
    jaxen-jdom.jar
    jdom.jar
    log4j.jar
    saaj-api.jar
    saaj-impl.jar
    saxpath.jar
    spring.jar
    spring-oxm.jar
    spring-ws-core.jar
    spring-xml.jar
    stax-api.jar
    mail.jar (SAAJ 1.2 dependency)
    saxon8.jar
    dom.jar (from JAXP 1.3)
    saxon8-dom.jar

    And I set this properties:
    System.setProperty("javax.xml.parsers.DocumentBuil derFactory", "org.apache.xerces.jaxp.DocumentBuilderFactoryImpl ");
    System.setProperty("javax.xml.parsers.SAXParserFac tory", "org.apache.xerces.jaxp.SAXParserFactoryImpl") ;
    System.setProperty("javax.xml.transform.Transforme rFactory", "net.sf.saxon.TransformerFactoryImpl");

    Regarding Saxon and DOMResult, which I'm using, and why I'm using dom.jar from JAXP 1.3:
    http://osdir.com/ml/text.xml.saxon.h.../msg00091.html

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •