problems with jboss an xerces

Discussion in 'Java' started by koslows, Jun 28, 2005.

  1. koslows

    koslows Guest

    Dear All!

    I'm writing a business method of an entity bean which is supposed to
    read some informations from an XML file. I use the following code:

    To get the parser and the document:
    Code:

    DocumentBuilderFactory factory =
    DocumentBuilderFactory.newInstance();
    DocumentBuilder builder = factory.newDocumentBuilder();
    Document doc = builder.parse( xmlFile );

    Then to get the informations I use:

    Code:

    NodeList nl = doc.getElementsByTagName( tagName );
    int elemCount = nl.getLength();
    for( int i = 0; i < elemCount; i++ )
    {
    Element element = ( Element )nl.item( i );
    String test = element.getTextContent();
    (...)
    }

    And I get the folowing exception:
    Code:

    org.jboss.tm.JBossTransactionRolledbackException: Unexpected Error
    java.lang.NoSuchMethodError:
    org.w3c.dom.Node.getTextContent()Ljava/lang/String;
    at
    levia.messages.ejb.MessageTypeBean.requiredInformations(MessageTypeBean.java:345)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at
    sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
    at
    sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    at java.lang.reflect.Method.invoke(Method.java:585)

    The problem is that outside Jboss this works perfectly. So I guess the
    problems comes from the fact that jboss uses xerces itself and it
    configures diferently the parser or something like this...

    When I write :
    Code:

    Text tester = (Text) elem.getFirstChild();
    String blalba = tester.getNodeValue();

    everything works well.... but still I would like to understand what is
    the couse of problems with the other solution.

    kind regards

    Karol

    PS: I use jboss 4.0 and xerces 2.6.2
     
    koslows, Jun 28, 2005
    #1
    1. Advertising

  2. koslows wrote:
    >
    > org.jboss.tm.JBossTransactionRolledbackException: Unexpected Error
    > java.lang.NoSuchMethodError:
    > org.w3c.dom.Node.getTextContent()Ljava/lang/String;
    > at
    > levia.messages.ejb.MessageTypeBean.requiredInformations(MessageTypeBean.java:345)
    > at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    > at
    > sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
    > at
    > sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    > at java.lang.reflect.Method.invoke(Method.java:585)
    >
    > The problem is that outside Jboss this works perfectly. So I guess the
    > problems comes from the fact that jboss uses xerces itself and it
    > configures diferently the parser or something like this...
    >


    org.w3c.dom.Node.getTextContent() is documented as being in for DOM
    level 3. Apparently the version of xerces within JBoss does not support
    this method. Presumably the JBoss xerces is a lower version than the
    one you explicitly included.

    You could try swapping in your xerces.jar for the one JBoss is using,
    although, there is a risk this will cause other problems.

    Ray

    --
    XML is the programmer's duct tape.
     
    Raymond DeCampo, Jun 28, 2005
    #2
    1. Advertising

  3. koslows

    koslows Guest

    Ok, but I guess it should be possible to "force" jboss to use any
    version of xerces it wants and let my application to use another no ?

    kind regards

    k.
     
    koslows, Jun 28, 2005
    #3
  4. koslows wrote:
    > Ok, but I guess it should be possible to "force" jboss to use any
    > version of xerces it wants and let my application to use another no ?
    >


    I would expect not, because of the way XML parser registration works.
    XML parser registration is essential global to the JVM, so even the
    usual classloader barriers that application servers use do not allow you
    to use another.

    OTOH, the risk in dropping in your desired version of xerces in place of
    the JBoss supplied one should be rather small. Just be aware that it
    exists.

    HTH,
    Ray

    --
    XML is the programmer's duct tape.
     
    Raymond DeCampo, Jun 28, 2005
    #4
  5. koslows

    koslows Guest

    Ok thx. it worked. It seems that there is no problem with jboss.

    Although I had to use the xerces 2.7.0 because with 2.6.2 it didnt'
    work.

    kind regards
    --
    k.
     
    koslows, Jun 29, 2005
    #5
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. John Smith

    Xerces SAX encoding problems

    John Smith, Sep 21, 2005, in forum: Java
    Replies:
    1
    Views:
    2,007
    Roedy Green
    Sep 21, 2005
  2. cvissy
    Replies:
    0
    Views:
    608
    cvissy
    Nov 16, 2004
  3. han
    Replies:
    0
    Views:
    479
  4. Jubz
    Replies:
    0
    Views:
    2,290
  5. LprzemekL
    Replies:
    0
    Views:
    529
    LprzemekL
    Apr 10, 2008
Loading...

Share This Page