Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

XML to JAVA XPATH array index doesn't work under Oracle JDK 1.8 #141

Open
RapperChen opened this issue Jul 11, 2017 · 3 comments
Open

XML to JAVA XPATH array index doesn't work under Oracle JDK 1.8 #141

RapperChen opened this issue Jul 11, 2017 · 3 comments
Assignees

Comments

@RapperChen
Copy link

RapperChen commented Jul 11, 2017

We are using smooks 1.7 to transform data from XML to Java Object. We found that the xpath array index
/xxx/yyy/zzz[1] doesn't work under oracle JDK 1.8, and hit a NullPointerException.

java.lang.NullPointerException
  at org.milyn.cdr.xpath.SelectorStep.getEvaluators(SelectorStep.java:365)
  at org.milyn.cdr.xpath.SelectorStep.getEvaluators(SelectorStep.java:361)
  at org.milyn.delivery.sax.SAXContentDeliveryConfig.addIndexCounters(SAXContentDeliveryConfig.java:233)
  at org.milyn.delivery.sax.SAXContentDeliveryConfig.addIndexCounters(SAXContentDeliveryConfig.java:215)
  at org.milyn.delivery.ContentDeliveryConfigBuilder.createConfig(ContentDeliveryConfigBuilder.java:218)
  at org.milyn.delivery.ContentDeliveryConfigBuilder.getConfig(ContentDeliveryConfigBuilder.java:148)
  at org.milyn.container.standalone.StandaloneExecutionContext.<init>(StandaloneExecutionContext.java:91)
  at org.milyn.container.standalone.StandaloneExecutionContext.<init>(StandaloneExecutionContext.java:65)
  at org.milyn.Smooks.createExecutionContext(Smooks.java:418)
  at org.milyn.Smooks.createExecutionContext(Smooks.java:376)
  at org.milyn.Smooks.filterSource(Smooks.java:456)
@asgs
Copy link

asgs commented Aug 19, 2017

can you post a sample XML and Java testcase to reproduce the issue mentioned above?

@RapperChen
Copy link
Author

RapperChen commented Aug 21, 2017

To simulate our test, I have downloaded the sample project xml-to-java, and made some changes as below.

smooks-config.xml

<?xml version="1.0"?>
<smooks-resource-list xmlns="http://www.milyn.org/xsd/smooks-1.1.xsd" xmlns:jb="http://www.milyn.org/xsd/smooks/javabean-1.2.xsd">
    <!--
    Create an "example.beans.Order" bean instance when we visit the start of the <order> element.
    Assign the new bean instance to the beanId of "order".
    Wire in the "header" and "orderItems" beans.
    -->
    <jb:bean beanId="order" class="org.milyn.javabean.decoders.demo.Order" createOnElement="order">
        <jb:wiring property="header" beanIdRef="header" />
        <jb:wiring property="orderItems" beanIdRef="orderItems" />
    </jb:bean>

    <!--
    Create an ArrayList bean instance when we visit the start of the <order> element.
    This bean is wired into the "order" bean.
    -->
    <jb:bean beanId="orderItems" class="java.util.ArrayList" createOnElement="order/order-items/order-item/order-item">
        <jb:wiring beanIdRef="orderItem" />
    </jb:bean>

    <!--
    Create an "example.beans.Header" bean instance when we visit the start of the <header> element.
    This bean is wired into the "order" bean.
    -->
    <jb:bean beanId="header" class="org.milyn.javabean.decoders.demo.Header" createOnElement="header">
        <jb:value property="date" decoder="Date" data="header/date">
            <jb:decodeParam name="format">EEE MMM dd HH:mm:ss z yyyy</jb:decodeParam>
            <jb:decodeParam name="locale-language">en</jb:decodeParam>
            <jb:decodeParam name="locale-country">IE</jb:decodeParam>
        </jb:value>
        <jb:value property="customerNumber" decoder="Long" data="header/customer/@number" />
        <jb:value property="customerName" data="header/customer" />
    </jb:bean>

    <!--
    Create an "example.beans.OrderItem" bean instance when we visit the start of the <order-item> element.
    This bean is wired into the "orderItems" ArrayList bean.
    -->
    <jb:bean beanId="orderItem" class="org.milyn.javabean.decoders.demo.OrderItem" createOnElement="order/order-items/order-item/order-item[1]/product">
        <jb:value property="productId" decoder="Long" data="order/order-items/order-item/order-item/product" />
        <jb:value property="quantity" decoder="Integer" data="order/order-items/order-item/order-item/quantity" />
        <jb:value property="price" decoder="Double" data="order/order-items/order-item/order-item/price" />
    </jb:bean>
</smooks-resource-list>

input-message.xml

<order>
    <header>
        <date>Wed Nov 15 13:45:28 EST 2006</date>
        <customer number="123123">Joe</customer>
    </header>
    <order-items>
        <order-item>
            <order-item>
                <product>111</product>
                <quantity>2</quantity>
                <price>8.90</price>
            </order-item>

            <order-item>
                <product>222</product>
                <quantity>7</quantity>
                <price>5.20</price>
            </order-item>
        </order-item>
    </order-items>
</order>

@RapperChen
Copy link
Author

the input-message.xml can't be displayed correctly in the comment.

I have added another node "order-item" as order-items' child.

@cjmamo cjmamo self-assigned this Dec 29, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

3 participants