Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 361969 - Namespace not returned on JAXBIntrospector call
Summary: Namespace not returned on JAXBIntrospector call
Status: RESOLVED FIXED
Alias: None
Product: z_Archived
Classification: Eclipse Foundation
Component: Eclipselink (show other bugs)
Version: unspecified   Edit
Hardware: PC Windows XP
: P3 normal (vote)
Target Milestone: ---   Edit
Assignee: Nobody - feel free to take it CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-10-25 13:20 EDT by Blaise Doughan CLA
Modified: 2022-06-09 10:21 EDT (History)
1 user (show)

See Also:


Attachments
MOXy - Fix (1.55 KB, patch)
2011-10-25 13:26 EDT, Blaise Doughan CLA
no flags Details | Diff
New Test Case (6.51 KB, patch)
2011-10-26 11:10 EDT, Denise Smith CLA
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Blaise Doughan CLA 2011-10-25 13:20:47 EDT
Given the following model, a namespace is not being returned as expected from the JAXBIntrospector call:

---

package-info

@javax.xml.bind.annotation.XmlSchema(namespace = "http://fish.com/example",
                                     elementFormDefault =
                                     javax.xml.bind.annotation.XmlNsForm.QUALIFIED)
package org.example;


---

ExampleElement

package org.example;

import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlType;


/**
 * <p>Java class for anonymous complex type.
 *
 * <p>The following schema fragment specifies the expected content contained within this class.
 *
 * <pre>
 * &lt;complexType>
 *   &lt;complexContent>
 *     &lt;restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
 *       &lt;sequence>
 *         &lt;element name="child" type="{http://www.w3.org/2001/XMLSchema}string"/>
 *       &lt;/sequence>
 *     &lt;/restriction>
 *   &lt;/complexContent>
 * &lt;/complexType>
 * </pre>
 *
 *
 */
@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "", propOrder = { "child" })
@XmlRootElement(name = "exampleElement", namespace="http://fish.com/example")
public class ExampleElement {

    @XmlElement(required = true)
    protected String child;

    /**
     * Gets the value of the child property.
     *
     * @return
     *     possible object is
     *     {@link String }
     *
     */
    public String getChild() {
        return child;
    }

    /**
     * Sets the value of the child property.
     *
     * @param value
     *     allowed object is
     *     {@link String }
     *
     */
    public void setChild(String value) {
        this.child = value;
    }

}

---

Demo

package org.example;

import javax.xml.bind.JAXBContext;
import javax.xml.bind.JAXBIntrospector;

public class Demo {

    public static void main(String[] args) throws Exception {
        JAXBContext jc = JAXBContext.newInstance(ExampleElement.class);
        System.out.println(jc.getClass());

        JAXBIntrospector ji = jc.createJAXBIntrospector();
        ExampleElement ee = new ExampleElement();
        System.out.println(ji.getElementName(ee));
    }
}
Comment 1 Blaise Doughan CLA 2011-10-25 13:26:32 EDT
Created attachment 205937 [details]
MOXy - Fix
Comment 2 Denise Smith CLA 2011-10-26 11:10:57 EDT
Created attachment 205993 [details]
New Test Case
Comment 3 Denise Smith CLA 2011-10-26 11:16:42 EDT
Fixed in 2.3 and 2.4.   Change to JAXBIntrospector getElementName to use the existing XPathFragment from the descriptor's root element field.
Comment 4 Eclipse Webmaster CLA 2022-06-09 10:14:49 EDT
The Eclipselink project has moved to Github: https://github.com/eclipse-ee4j/eclipselink
Comment 5 Eclipse Webmaster CLA 2022-06-09 10:21:49 EDT
The Eclipselink project has moved to Github: https://github.com/eclipse-ee4j/eclipselink