JAXB Exception...!

When I coded the return value to java.String, I can deploy my web services. But After I changed my return value to java class with JAXB,
I can't deploy my web services. Pls,check my code. I need your advice! Thanks in advance.
- Persons.java
package com.aaa.ws;
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlType;
@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name="", propOrder = {"id", "name", "passwd"})
public class Persons {
@XmlElement
protected String id;
@XmlElement
protected String passwd;
@XmlElement
protected String name;
//getter and setter method
- WSLoginTestPort.java
package com.aaa.ws;
import javax.jws.WebService;
import javax.jws.WebMethod;
import javax.jws.WebResult;
import javax.jws.WebParam;
import com.aaa.ws.Persons;
@WebService
public interface WSLoginTestPort {
@WebMethod
@WebResult
public Persons loginFunc(@WebParam String id, @WebParam String passwd);
- WSLoginTest.java
package com.aaa.ws;
import javax.jws.WebService;
import com.aaa.ws.Persons;
@WebService
public class WSLoginTest implements WSLoginTestPort {
public Persons loginFunc(String ID, String Passwd) {
// TODO Auto-generated method stub
p.setId(ID);
p.setPasswd(Passwd);
p.setName("Jo");
return p;
But I can't deploy this web service. The Exception is like below
org.jboss.deployers.spi.DeploymentException: Error during deploy: vfsfile:/home/julian/workplace/.metadata/.plugins/org.jboss.ide.eclipse.as.core/JBoss_5.1_Runtime_Server1305009211342/deploy/TotalTestEAR.ear/TotalTest.war/
at org.jboss.deployers.spi.DeploymentException.rethrowAsDeploymentException(DeploymentException.java:49)
at org.jboss.deployers.plugins.deployers.DeployerWrapper.deploy(DeployerWrapper.java:177)
at org.jboss.deployers.plugins.deployers.DeployersImpl.doDeploy(DeployersImpl.java:1439)
at org.jboss.deployers.plugins.deployers.DeployersImpl.doInstallParentFirst(DeployersImpl.java:1157)
at org.jboss.deployers.plugins.deployers.DeployersImpl.doInstallParentFirst(DeployersImpl.java:1210)
at org.jboss.deployers.plugins.deployers.DeployersImpl.install(DeployersImpl.java:1098)
at org.jboss.dependency.plugins.AbstractControllerContext.install(AbstractControllerContext.java:348)
at org.jboss.dependency.plugins.AbstractController.install(AbstractController.java:1631)
at org.jboss.dependency.plugins.AbstractController.incrementState(AbstractController.java:934)
at org.jboss.dependency.plugins.AbstractController.resolveContexts(AbstractController.java:1082)
at org.jboss.dependency.plugins.AbstractController.resolveContexts(AbstractController.java:984)
at org.jboss.dependency.plugins.AbstractController.change(AbstractController.java:822)
at org.jboss.dependency.plugins.AbstractController.change(AbstractController.java:553)
at org.jboss.deployers.plugins.deployers.DeployersImpl.process(DeployersImpl.java:781)
at org.jboss.deployers.plugins.main.MainDeployerImpl.process(MainDeployerImpl.java:702)
at org.jboss.system.server.profileservice.repository.MainDeployerAdapter.process(MainDeployerAdapter.java:117)
at org.jboss.system.server.profileservice.hotdeploy.HDScanner.scan(HDScanner.java:362)
at org.jboss.system.server.profileservice.hotdeploy.HDScanner.run(HDScanner.java:255)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:441)
at java.util.concurrent.FutureTask$Sync.innerRunAndReset(FutureTask.java:317)
at java.util.concurrent.FutureTask.runAndReset(FutureTask.java:150)
at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$101(ScheduledThreadPoolExecutor.java:98)
at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.runPeriodic(ScheduledThreadPoolExecutor.java:180)
at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:204)
at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
at java.lang.Thread.run(Thread.java:662)
Caused by: javax.xml.ws.WebServiceException: org.apache.cxf.service.factory.ServiceConstructionException
at org.apache.cxf.jaxws.EndpointImpl.doPublish(EndpointImpl.java:335)
at org.jboss.wsf.stack.cxf.deployment.EndpointImpl.doPublish(EndpointImpl.java:62)
at org.apache.cxf.jaxws.EndpointImpl.publish(EndpointImpl.java:238)
at org.apache.cxf.jaxws.EndpointImpl.publish(EndpointImpl.java:481)
at org.jboss.wsf.stack.cxf.configuration.NonSpringBusHolder.configure(NonSpringBusHolder.java:112)
at org.jboss.wsf.stack.cxf.deployment.aspect.BusDeploymentAspect.start(BusDeploymentAspect.java:110)
at org.jboss.webservices.integration.deployers.WSDeploymentAspectDeployer.internalDeploy(WSDeploymentAspectDeployer.java:107)
at org.jboss.deployers.spi.deployer.helpers.AbstractRealDeployer.deploy(AbstractRealDeployer.java:50)
at org.jboss.deployers.plugins.deployers.DeployerWrapper.deploy(DeployerWrapper.java:171)
... 25 more
Caused by: org.apache.cxf.service.factory.ServiceConstructionException
at org.apache.cxf.jaxb.JAXBDataBinding.initialize(JAXBDataBinding.java:341)
at org.apache.cxf.service.factory.AbstractServiceFactoryBean.initializeDataBindings(AbstractServiceFactoryBean.java:86)
at org.apache.cxf.service.factory.ReflectionServiceFactoryBean.buildServiceFromClass(ReflectionServiceFactoryBean.java:442)
at org.apache.cxf.jaxws.support.JaxWsServiceFactoryBean.buildServiceFromClass(JaxWsServiceFactoryBean.java:680)
at org.apache.cxf.service.factory.ReflectionServiceFactoryBean.initializeServiceModel(ReflectionServiceFactoryBean.java:505)
at org.apache.cxf.service.factory.ReflectionServiceFactoryBean.create(ReflectionServiceFactoryBean.java:242)
at org.apache.cxf.jaxws.support.JaxWsServiceFactoryBean.create(JaxWsServiceFactoryBean.java:202)
at org.apache.cxf.frontend.AbstractWSDLBasedEndpointFactory.createEndpoint(AbstractWSDLBasedEndpointFactory.java:101)
at org.apache.cxf.frontend.ServerFactoryBean.create(ServerFactoryBean.java:148)
at org.apache.cxf.jaxws.JaxWsServerFactoryBean.create(JaxWsServerFactoryBean.java:183)
at org.apache.cxf.jaxws.EndpointImpl.getServer(EndpointImpl.java:407)
at org.apache.cxf.jaxws.EndpointImpl.doPublish(EndpointImpl.java:314)
... 33 more
Caused by: com.sun.xml.bind.v2.runtime.IllegalAnnotationsException: 2 counts of IllegalAnnotationExceptions
Two classes have the same XML type name "{http://ws.aaa.com/}loginFunc". Use @XmlType.name and @XmlType.namespace to assign different names to them.
this problem is related to the following location:
at com.aaa.ws.jaxws.LoginFunc
this problem is related to the following location:
at com.aaa.ws.LoginFunc
at public com.aaa.ws.LoginFunc com.aaa.ws.ObjectFactory.createLoginFunc()
at com.aaa.ws.ObjectFactory
Two classes have the same XML type name "{http://ws.aaa.com/}loginFuncResponse". Use @XmlType.name and @XmlType.namespace to assign different names to them.
this problem is related to the following location:
at com.aaa.ws.jaxws.LoginFuncResponse
this problem is related to the following location:
at com.aaa.ws.LoginFuncResponse
at public com.aaa.ws.LoginFuncResponse com.aaa.ws.ObjectFactory.createLoginFuncResponse()
at com.aaa.ws.ObjectFactory
at com.sun.xml.bind.v2.runtime.IllegalAnnotationsException$Builder.check(IllegalAnnotationsException.java:102)
at com.sun.xml.bind.v2.runtime.JAXBContextImpl.getTypeInfoSet(JAXBContextImpl.java:472)
at com.sun.xml.bind.v2.runtime.JAXBContextImpl.<init>(JAXBContextImpl.java:302)
at com.sun.xml.bind.v2.runtime.JAXBContextImpl$JAXBContextBuilder.build(JAXBContextImpl.java:1140)
at com.sun.xml.bind.v2.ContextFactory.createContext(ContextFactory.java:154)
at com.sun.xml.bind.v2.ContextFactory.createContext(ContextFactory.java:121)
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:597)
at javax.xml.bind.ContextFinder.newInstance(ContextFinder.java:201)
at javax.xml.bind.ContextFinder.find(ContextFinder.java:362)
at javax.xml.bind.JAXBContext.newInstance(JAXBContext.java:618)
at org.apache.cxf.jaxb.JAXBDataBinding.createContext(JAXBDataBinding.java:564)
at org.apache.cxf.jaxb.JAXBDataBinding.createJAXBContextAndSchemas(JAXBDataBinding.java:504)
at org.apache.cxf.jaxb.JAXBDataBinding.initialize(JAXBDataBinding.java:324)
... 44 more
17:38:25,420 WARN [HDScanner] Failed to process changes
org.jboss.deployers.client.spi.IncompleteDeploymentException: Summary of incomplete deployments (SEE PREVIOUS ERRORS FOR DETAILS):
*** DEPLOYMENTS IN ERROR: Name -> Error
vfsfile:/home/julian/workplace/.metadata/.plugins/org.jboss.ide.eclipse.as.core/JBoss_5.1_Runtime_Server1305009211342/deploy/TotalTestEAR.ear/ -> org.jboss.deployers.spi.DeploymentException: Error during deploy: vfsfile:/home/julian/workplace/.metadata/.plugins/org.jboss.ide.eclipse.as.core/JBoss_5.1_Runtime_Server1305009211342/deploy/TotalTestEAR.ear/TotalTest.war/
DEPLOYMENTS IN ERROR:
Deployment "vfsfile:/home/julian/workplace/.metadata/.plugins/org.jboss.ide.eclipse.as.core/JBoss_5.1_Runtime_Server1305009211342/deploy/TotalTestEAR.ear/" is in error due to the following reason(s): com.sun.xml.bind.v2.runtime.IllegalAnnotationsException: 2 counts of IllegalAnnotationExceptions
Two classes have the same XML type name "{http://ws.aaa.com/}loginFunc". Use @XmlType.name and @XmlType.namespace to assign different names to them.
this problem is related to the following location:
at com.aaa.ws.jaxws.LoginFunc
this problem is related to the following location:
at com.aaa.ws.LoginFunc
at public com.aaa.ws.LoginFunc com.aaa.ws.ObjectFactory.createLoginFunc()
at com.aaa.ws.ObjectFactory
Two classes have the same XML type name "{http://ws.aaa.com/}loginFuncResponse". Use @XmlType.name and @XmlType.namespace to assign different names to them.
this problem is related to the following location:
at com.aaa.ws.jaxws.LoginFuncResponse
this problem is related to the following location:
at com.aaa.ws.LoginFuncResponse
at public com.aaa.ws.LoginFuncResponse com.aaa.ws.ObjectFactory.createLoginFuncResponse()
at com.aaa.ws.ObjectFactory
at org.jboss.deployers.plugins.deployers.DeployersImpl.checkComplete(DeployersImpl.java:993)
at org.jboss.deployers.plugins.deployers.DeployersImpl.checkComplete(DeployersImpl.java:939)
at org.jboss.deployers.plugins.main.MainDeployerImpl.checkComplete(MainDeployerImpl.java:873)
at org.jboss.system.server.profileservice.repository.MainDeployerAdapter.checkComplete(MainDeployerAdapter.java:128)
at org.jboss.system.server.profileservice.hotdeploy.HDScanner.scan(HDScanner.java:369)
at org.jboss.system.server.profileservice.hotdeploy.HDScanner.run(HDScanner.java:255)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:441)
at java.util.concurrent.FutureTask$Sync.innerRunAndReset(FutureTask.java:317)
at java.util.concurrent.FutureTask.runAndReset(FutureTask.java:150)
at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$101(ScheduledThreadPoolExecutor.java:98)
at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.runPeriodic(ScheduledThreadPoolExecutor.java:180)
at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:204)
at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
at java.lang.Thread.run(Thread.java:662)

Your problem is that you try to overload the webservice method 'loginFunc' - that is not possible in jax-ws without some additional parameters. I do not know how to do it from the top of my head, but try to investigate in the annotations that the stack trace mentions:
Use @XmlType.name and @XmlType.namespace
A quick and dirty solution would be to just rename one of the methods and so not to use overloading.

Similar Messages

  • ESB deployment - jaxb exception

    [extractESBDeploymentPlan] javax.xml.bind.JAXBException: Unable to locate jaxb.properties for package oracle.tip.esb.client.metadata.deploymentplan.model
    [extractESBDeploymentPlan]      at javax.xml.bind.ContextFinder.searchcontextPath(ContextFinder.java:205)
    [extractESBDeploymentPlan]      at javax.xml.bind.ContextFinder.find(ContextFinder.java:149)
    [extractESBDeploymentPlan]      at javax.xml.bind.JAXBContext.newInstance(JAXBContext.java:281)
    [extractESBDeploymentPlan]      at oracle.tip.esb.client.metadata.deploymentplan.utils.DeploymentPlanUtils.getJAXBContext(DeploymentPlanUtils.java:37)
    [extractESBDeploymentPlan]      at oracle.tip.esb.client.metadata.deploymentplan.utils.DeploymentPlanUtils.getMarshaller(DeploymentPlanUtils.java:65)
    [extractESBDeploymentPlan]      at oracle.tip.esb.client.anttasks.ExtractESBDeploymentPlanTask.saveDeploymentPlan(ExtractESBDeploymentPlanTask.java:506)
    [extractESBDeploymentPlan]      at oracle.tip.esb.client.anttasks.ExtractESBDeploymentPlanTask.execute(ExtractESBDeploymentPlanTask.java:541)
    [extractESBDeploymentPlan]      at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:288)
    [extractESBDeploymentPlan]      at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    [extractESBDeploymentPlan]      at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
    [extractESBDeploymentPlan]      at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    [extractESBDeploymentPlan]      at java.lang.reflect.Method.invoke(Method.java:585)
    [extractESBDeploymentPlan]      at org.apache.tools.ant.dispatch.DispatchUtils.execute(DispatchUtils.java:105)
    [extractESBDeploymentPlan]      at org.apache.tools.ant.Task.perform(Task.java:348)
    [extractESBDeploymentPlan]      at org.apache.tools.ant.Target.execute(Target.java:357)
    [extractESBDeploymentPlan]      at org.apache.tools.ant.Target.performTasks(Target.java:385)
    [extractESBDeploymentPlan]      at org.apache.tools.ant.Project.executeSortedTargets(Project.java:1329)
    [extractESBDeploymentPlan]      at org.apache.tools.ant.Project.executeTarget(Project.java:1298)
    [extractESBDeploymentPlan]      at org.apache.tools.ant.helper.DefaultExecutor.executeTargets(DefaultExecutor.java:41)
    [extractESBDeploymentPlan]      at org.apache.tools.ant.Project.executeTargets(Project.java:1181)
    [extractESBDeploymentPlan]      at oracle.jdevimpl.ant.runner.AntLauncher.launch(AntLauncher.java:321)
    [extractESBDeploymentPlan]      at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    [extractESBDeploymentPlan]      at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
    [extractESBDeploymentPlan]      at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    [extractESBDeploymentPlan]      at java.lang.reflect.Method.invoke(Method.java:585)
    [extractESBDeploymentPlan]      at oracle.jdevimpl.ant.runner.InProcessAntStarter.runAnt(InProcessAntStarter.java:295)
    [extractESBDeploymentPlan]      at oracle.jdevimpl.ant.runner.InProcessAntStarter.mav$runAnt(InProcessAntStarter.java:43)
    [extractESBDeploymentPlan]      at oracle.jdevimpl.ant.runner.InProcessAntStarter$1.run(InProcessAntStarter.java:71)
    Target 'AntTest' failed with message 'javax.xml.bind.JAXBException: Unable to locate jaxb.properties for package oracle.tip.esb.client.metadata.deploymentplan.model'.
    BUILD FAILED
    AntTestBuild.xml:11: javax.xml.bind.JAXBException: Unable to locate jaxb.properties for package oracle.tip.esb.client.metadata.deploymentplan.model
         at oracle.tip.esb.client.anttasks.ExtractESBDeploymentPlanTask.execute(ExtractESBDeploymentPlanTask.java:546)
    I am trying to build an ESB project with a deplyoment plan, or rather I'm trying to generate a deplyoment plan first.
    I am stuck on this jaxb exception and would really appreciate some help.
    I am using the correct jaxb version (I've tried several different version), I've set classpath in jdev (10.1.3.4) and the lib directories are correct in the ESBMetadataMigrationTaskdefs.xml:
    <taskdef resource="oracle/tip/esb/client/anttasks/antlib.xml">
    <classpath>
    <pathelement location="${esbdeployment.home}/ESBMetadataMigration.jar"/>
    <pathelement location="${commons.httpclient.home}/commons-httpclient-3.1.jar"/>
    <pathelement location="${soa.suite.home}/lib/xmlparserv2.jar"/>
    <pathelement location="${soa.suite.home}/integration/esb/lib/commons-logging.jar"/>
    <pathelement location="${esbdeployment.home}/commons-codec-1.2.jar"/>
    <pathelement location="${soa.suite.home}/integration/esb/lib/oraesb.jar"/>
    <pathelement location="C:\esbdeploymentautomation\jaxb-ri-20120516\lib\activation.jar"/>
    <pathelement location="C:\esbdeploymentautomation\jaxb-ri-20120516\lib\jaxb-api.jar"/>
    <!--pathelement location="C:\esbdeploymentautomation\jaxb-ri-20120516\lib\jsr173_1.0_api.jar"/-->
    <pathelement location="C:\esbdeploymentautomation\jaxb-ri-20120516\lib\jaxb-impl.jar"/>
    </classpath>
    </taskdef>
    </project>

    The SOA Suite may give you better support for this kind of ESB related questions.
    -Eric

  • Getting the JAXB exception like "Two classes have the same XML type name-"

    Getting the JAXB exception like "Two classes have the same XML type name...",
    Here is the exception details:
    Exception in thread "main" com.sun.xml.internal.bind.v2.runtime.IllegalAnnotationsException: 1 counts of IllegalAnnotationExceptions Two classes have the same XML type name "city". Use @XmlType.name and @XmlType.namespace to assign different names to them. this problem is related to the following location: at com.model.City at public com.model.City com.model.Address.getCurrentCity() at com.model.Address this problem is related to the following location: at com.common.City at public com.common.City com.model.Address.getPreviousCity() at com.model.Address
    at com.sun.xml.internal.bind.v2.runtime.IllegalAnnotationsException$Builder.check(Unknown Source) at com.sun.xml.internal.bind.v2.runtime.JAXBContextImpl.getTypeInfoSet(Unknown Source) at com.sun.xml.internal.bind.v2.runtime.JAXBContextImpl.(Unknown Source) at com.sun.xml.internal.bind.v2.runtime.JAXBContextImpl$JAXBContextBuilder.build(Unknown Source) at com.sun.xml.internal.bind.v2.ContextFactory.createContext(Unknown Source) at com.sun.xml.internal.bind.v2.ContextFactory.createContext(Unknown Source) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) at java.lang.reflect.Method.invoke(Unknown Source) at javax.xml.bind.ContextFinder.newInstance(Unknown Source) at javax.xml.bind.ContextFinder.find(Unknown Source) at javax.xml.bind.JAXBContext.newInstance(Unknown Source) at javax.xml.bind.JAXBContext.newInstance(Unknown Source) at com.PojoToXSD.main(PojoToXSD.java:17)
    I took the example like:
    package com.model; ---->this package contains 'Address' class and 'City' class
    public class Address {
    private String areaName; private City currentCity; private com.common.City previousCity;
    package com.model;
    public class City {
    private String cityName;
    Another city class in "com.common" package.
    package com.common;
    public class City {
    private String pinCode;
    We need to create XSDs and needs to do the Marshalling and unmarshalling with the existing code in our project(like as above example code), code does not have any annotations like "@XmlRootElement/@XmlType" and we can not able to change the source code.
    I would like to know is there any solution to fix the above issue or any other ways to create XSDs and marshaling/unmarshalling(like MOXy..etc)?
    It would be great if i can get the solution from any one....May thanks in advance.
    Thanks,
    Satya.

    Getting the JAXB exception like "Two classes have the same XML type name...",
    Here is the exception details:
    Exception in thread "main" com.sun.xml.internal.bind.v2.runtime.IllegalAnnotationsException: 1 counts of IllegalAnnotationExceptions Two classes have the same XML type name "city". Use @XmlType.name and @XmlType.namespace to assign different names to them. this problem is related to the following location: at com.model.City at public com.model.City com.model.Address.getCurrentCity() at com.model.Address this problem is related to the following location: at com.common.City at public com.common.City com.model.Address.getPreviousCity() at com.model.Address
    at com.sun.xml.internal.bind.v2.runtime.IllegalAnnotationsException$Builder.check(Unknown Source) at com.sun.xml.internal.bind.v2.runtime.JAXBContextImpl.getTypeInfoSet(Unknown Source) at com.sun.xml.internal.bind.v2.runtime.JAXBContextImpl.(Unknown Source) at com.sun.xml.internal.bind.v2.runtime.JAXBContextImpl$JAXBContextBuilder.build(Unknown Source) at com.sun.xml.internal.bind.v2.ContextFactory.createContext(Unknown Source) at com.sun.xml.internal.bind.v2.ContextFactory.createContext(Unknown Source) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) at java.lang.reflect.Method.invoke(Unknown Source) at javax.xml.bind.ContextFinder.newInstance(Unknown Source) at javax.xml.bind.ContextFinder.find(Unknown Source) at javax.xml.bind.JAXBContext.newInstance(Unknown Source) at javax.xml.bind.JAXBContext.newInstance(Unknown Source) at com.PojoToXSD.main(PojoToXSD.java:17)
    I took the example like:
    package com.model; ---->this package contains 'Address' class and 'City' class
    public class Address {
    private String areaName; private City currentCity; private com.common.City previousCity;
    package com.model;
    public class City {
    private String cityName;
    Another city class in "com.common" package.
    package com.common;
    public class City {
    private String pinCode;
    We need to create XSDs and needs to do the Marshalling and unmarshalling with the existing code in our project(like as above example code), code does not have any annotations like "@XmlRootElement/@XmlType" and we can not able to change the source code.
    I would like to know is there any solution to fix the above issue or any other ways to create XSDs and marshaling/unmarshalling(like MOXy..etc)?
    It would be great if i can get the solution from any one....May thanks in advance.
    Thanks,
    Satya.

  • JAXB Exception: doesn't contain ObjectFactory.class or jaxb.index

    I'm able to run this fine using Idea, but as soon as I package the project into BuildDesk and install it, I keep getting this JAXB Exception.
    I do have the ObjectFactory.class file which was automatically generated for me, but I really don't know what's that jaxb.index. Any Idea on
    how to make this work, I just need to package this project up and submit it.
    Thanks.

    In fact, I am familiar with JAXB and used it in several projects. I wrote the ObjectFactory by myself, of course, we can generate it by using xjc command. The project runs well in eclipse or netbeans without this exception because the file is there.
    This exceptioin occurs only when I make installation package by using BuildDesk. I find when I don't choose the obfuscation options in BuildDesk, it runs well. I think the shrink/optimize/obfuscate operation destroyed the ObjectFactory.class when processing the .jar file. I think the solution is package the JAXB model into a separate jar and use it as a external library, so BuildDesk doesn't process it in any case. Thank you all the same. :)
    Edited by: 807218 on Nov 3, 2010 7:29 AM

  • JAXB Exception while

    Hi,
    Greetings.
    I don't know if this is a correct forum to place this query. Kindly bear with me.
    I am having some special characters in an XML which i parse using JAXB and store in the DB (Oracle). Current implementation is using ISO-8859-1.
    Using this encoding some special characters like 'µ' gets converted to '?' on retrieval from DB. Hence wrongly displayed in Java Webstart based Client.
    I have problem only while retrieval from DB. 'µ' gets stored properly in DB on insert.
    I tried using 'UTF-8' encoding in the XML, but i get the following exception.
    javax.xml.stream.XMLStreamException
    javax.xml.stream.XMLStreamException
         at com.bea.xml.stream.MXParser.fillBuf(MXParser.java:3223)
         at com.bea.xml.stream.MXParser.more(MXParser.java:3238)
         at com.bea.xml.stream.MXParser.parseProlog(MXParser.java:1739)
         at com.bea.xml.stream.MXParser.nextImpl(MXParser.java:1717)
         at com.bea.xml.stream.MXParser.next(MXParser.java:1180)
         at com.bea.xml.stream.MXParser.setInput(MXParser.java:703)
         at com.bea.xml.stream.MXParserFactory.createXMLStreamReader(MXParserFactory.java:220)
         at com.bea.xml.stream.MXParserFactory.createXMLStreamReader(MXParserFactory.java:36)
    I have the code snippet for Unmarshalling:
    initJaxBContext();
         Unmarshaller u = jc.createUnmarshaller();      
    //u.setProperty("jaxb.encoding", "ISO-8859-1");
    obj = u.unmarshal(input_stream);
    I have the code snippet for Marshalling:
    Marshaller m = getMarshaller();
    m.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, Boolean.TRUE);
    os = new ByteArrayOutputStream();
    m.marshal(obj, os);
    xml_output = os.toString();
    I have the following clarifications:
    1. Can someone tell me what is the default encoding used by the JAXB?
    2. Does the Java Webstart supports utf-8? If no, is there any work around?
    3. Will explicitly setting the encoding to UTF-8 help to avoid the above excpetion?
    Thanks in advance,
    paskal

    Hi,
    Thanks for your reply.
    I checked in my Oracle DB. My charset is set to "UTF-8". Still the issue is happening :-(
    Does anyone has answer for any of these questions below:
    1. Can someone tell me what is the default encoding used by the JAXB?
    2. Does the Java Webstart supports utf-8? If no, is there any work around?
    3. Will explicitly setting the encoding to UTF-8 help to avoid the above exception?
    Any help in this regard will be greatly appreciated.
    regards,
    Paskal

  • JAXB: Exception thrown during Unmarshalling ! HELP !

    Hi, my JAXB works fine when the input XML conforms with the schema. But sometimes the input XML contains some extra non-business related fields (populated by the client application) that are absent from my schema definitions and cannot be predicted. In such scenarios JAXB fails during unmarshalling. Is there a way round this ? I have tried Unmarshaller.setValidating( false), but still fails ! Ideally I would want the parser to ignore such fields. Do I need to write a custom EventHandler as means of a way out? Kindly suggest
    Raj

    I found the following in JAXB specification 1.0, Section 5.9.5
    Bind wildcard schema component:
    A wildcard is mapped to a simple content-property with:
    &#9679; Content-property name set to the constant �any�. A binding schema customization could provide a more semantically meaningful contentproperty name.
    &#9679; Content-property base type set to java.lang.Object by default. Wildcard content encountering during unmarshalling is supported if global XML element tags occurring in �strict� or �lax� wildcard context
    are known to the instance of javax.xml.bind.JAXBContext, meaning that the schema(s) describing the element content occurring in the wildcard context is registered with the JAXBContext instance, see
    Section 3.2, �JAXBContext,� on page 24 on how bindings are registered with a JAXBContext instance. A JAXB implementation is only required to be able to marshall and unmarshal global element content to/
    from �strict�/�lax� wildcard context that is registered and valid5 according to the schema(s) registered to JAXBContext. The specification does not specify how a JAXB implementation handles element content that it does not know how to map to a Java representation.
    &#9679; See content-property predicate for a wildcard.
    &#9679; If the maxOccurs is greater than one, the content property is mapped
    to a collection property. The default collection property is a List
    property.
    &#9679; These is no default value.
    Does anyone know how to go about setting Content-property name & Content-property base type as the specification suggests ?

  • Exception while unmarshalling UTF-8 encoded XML String, using JAXB.

    hi folks. First of all, thank you for contributing to my queries as of now.
    Problem statement.
    - This happens when i try to unmarshall a webservice response, which is nothing but a simple UTF-8 encoded XML string in an soap envelope.
    - 0xae is the register character: &reg;.
    - My next step was to ensure that my code works without this character. So I removed all occurances from my XML. It worked just fine...
    - So what do you guys suggest me to get rid of this problem?
    - Any suggestion will be treated as valuable resource.
    - Is there some kind of encoding setting with jaxb ?
    An invalid XML character (Unicode: 0xae) was found in the element content of the document.
    org.xml.sax.SAXParseException: An invalid XML character (Unicode: 0xae) was found in the element content of the document.
         at weblogic.apache.xerces.framework.XMLParser.reportError(XMLParser.java:1273)
         at weblogic.apache.xerces.framework.XMLDocumentScanner.reportFatalXMLError(XMLDocumentScanner.java:603)
         at weblogic.apache.xerces.framework.XMLDocumentScanner$ContentDispatcher.dispatch(XMLDocumentScanner.java:1319)
         at weblogic.apache.xerces.framework.XMLDocumentScanner.parseSome(XMLDocumentScanner.java:396)
         at weblogic.apache.xerces.framework.XMLParser.parse(XMLParser.java:1119)
         at weblogic.xml.jaxp.WebLogicXMLReader.parse(WebLogicXMLReader.java:135)
         at weblogic.xml.jaxp.RegistryXMLReader.parse(RegistryXMLReader.java:133)
         at com.sun.xml.bind.unmarshaller.UnmarshallerImpl.unmarshal(UnmarshallerImpl.java:139)
         at javax.xml.bind.helpers.AbstractUnmarshallerImpl.unmarshal(AbstractUnmarshallerImpl.java:129)
         at javax.xml.bind.helpers.AbstractUnmarshallerImpl.unmarshal(AbstractUnmarshallerImpl.java:166)
         at com.hp.wwopsit.econfigure.helper.JaxbUtils.xmlStringToJaxbObject(JaxbUtils.java:66)
         at com.hp.wwopsit.econfigure.core.transformation.IPCAdapterMapper.x2oLoadConfig(IPCAdapterMapper.java:376)
         at com.hp.wwopsit.econfigure.core.adapter.IPCAdapter.loadConfiguration(IPCAdapter.java:144)
         at com.hp.wwopsit.econfigure.core.adapter.IPCAdapter.main(IPCAdapter.java:291)
    --------------- linked to ------------------
    javax.xml.bind.UnmarshalException
    - with linked exception:
    [org.xml.sax.SAXParseException: An invalid XML character (Unicode: 0xae) was found in the element content of the document.]
         at javax.xml.bind.helpers.AbstractUnmarshallerImpl.createUnmarshalException(AbstractUnmarshallerImpl.java:284)
         at com.sun.xml.bind.unmarshaller.UnmarshallerImpl.unmarshal(UnmarshallerImpl.java:143)
         at javax.xml.bind.helpers.AbstractUnmarshallerImpl.unmarshal(AbstractUnmarshallerImpl.java:129)
         at javax.xml.bind.helpers.AbstractUnmarshallerImpl.unmarshal(AbstractUnmarshallerImpl.java:166)
         at com.hp.wwopsit.econfigure.helper.JaxbUtils.xmlStringToJaxbObject(JaxbUtils.java:66)
         at com.hp.wwopsit.econfigure.core.transformation.IPCAdapterMapper.x2oLoadConfig(IPCAdapterMapper.java:376)
         at com.hp.wwopsit.econfigure.core.adapter.IPCAdapter.loadConfiguration(IPCAdapter.java:144)
         at com.hp.wwopsit.econfigure.core.adapter.IPCAdapter.main(IPCAdapter.java:291)
    ***Jaxb Exception while converting xml file to object. Possible cause, Invalid schema or unrecognized elements in input XML. Actuall exception message:javax.xml.bind.UnmarshalException
    - with linked exception:
    [org.xml.sax.SAXParseException: An invalid XML character (Unicode: 0xae) was found in the element content of the document.]
    End..
    Output completed (44 sec consumed) - Normal Termination

    This is how the XML looks like ..
    <?xml version="1.0" encoding="UTF-8" ?>
    - <configresponse xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
    <csticShortText>processor</csticShortText>
    - <csticValues>
    - <csticValue id="024" selected="false">
    <desc>Pentium� 4 1.7GHz/400MHz</desc>
    </configresponse>

  • Use jaxb api

    Hello,
    I would like to use the JAXB api to parse XML document.
    The aim is to parse SOAP message sent by a server.
    - I've download jaxb-api.jar, jaxb-impl.jar, jaxb-lib.jar and jaxb-xjc.jar.
      - Here my <b>code</b> :
    JAXBContext jc = JAXBContext.newInstance( "aaa.bbb.ccc");
    Unmarshaller u = jc.createUnmarshaller();
    Object o = u.unmarshal( httpConn.getInputStream() );
    ==> Here generated <b>error</b> :
    JAXBException : Unable to locate jaxb.properties for package aaa.bbb.ccc
    I use the IDE Eclipse, must I do a particular configuration ?
    Could you help me please ?
    Thanks.
    Delphine.

    Delphine,
    As far as I understand other than adding the 4 java archives you mentioned to the class path, there's nothing else as far as set up/configuration is concerned.
    As the exception clearly says, its a pure JAXB exception and not from the SAP server.  Are you using jaxb-1.0-beta , if yes, it has this bug.
    There are some solutions mentioned in
    PO number ranges
    and
    Hope this helps,
    Kiran<u></u><u></u><u></u><u></u>

  • JAXB UnmarshalException - Filename w/ # or ? or %

    I have a requirement to allow file names with a set of non alpha numeric characters (except /). All of them seem to do fine except for filenames with the characters # or ? or % when it comes time to unmarshal the xml file. The error displayed below is for a file with the name: 2#2.txt.xml
    I have traced through my code and the file path and full name remain intact and the file is verified as being on the system. When I get to the call below in the code, the application throws the JAXB Exception shown below:      
    // Unmarshall the data in the file
         object = getUnmarshalledObject( unmarshaller.unmarshal( file ) );
    I am using JAXB 2.0
    Is there a way to get the JAXB Unmarshaller to recognize these special characters?
    I receive the JAXB Exception:
    javax.xml.bind.UnmarshalException
    - with linked exception:
    [java.io.FileNotFoundException: \var\data\EMU1.EMUApplication\.metadata\2 (The system cannot find the file specified.)]
         at javax.xml.bind.UnmarshalException.<init>(UnmarshalException.java:56)
    Complete Method:
         JAXBContext jaxbContext;
         Unmarshaller unmarshaller;
         Object object;
         // Make sure the file exists, is a file and is readable
         if ( ! file.exists() ) throw new OnsConfigException("Missing document file " + file.getAbsolutePath() );
         if ( ! file.canRead() ) throw new OnsConfigException("Non readable document file " + file.getAbsolutePath() );
         if ( file.isDirectory() ) throw new OnsConfigException("Cannot unmarshall directory " + file.getAbsolutePath() );
         try {
         // Create the context
         jaxbContext = JAXBContext.newInstance( packageName );
         // Create the unmarshaller
         unmarshaller = jaxbContext.createUnmarshaller();
         // Enable/disable validation
         unmarshaller.setSchema( schema );
         // Unmarshall the data in the file
         object = getUnmarshalledObject( unmarshaller.unmarshal( file ) );
         } catch (JAXBException jaxbExc) {
         // Rethrow as ONS exception
         jaxbExc.printStackTrace();
         throw new OnsConfigException( "XML Parse File Error", jaxbExc );
         } catch (Throwable e) {
         // Rethrow as ONS exception
         e.printStackTrace();
         throw new OnsConfigException( "XML Unmarshal File System Error", e );      
         }Thank you for your assistance.
    Edited by: Barbara5 on May 7, 2009 11:10 PM

    I suspect that something, somewhere, is treating those file names as if they were components of a URL. I say that because the characters you named in your post title all have special meanings in a URL.
    So you might have to URL-escape your file name, or there might be some other special thing you have to do. I don't know anything specifically about JAXB or about your application, but that's what I would investigate.

  • JWSDP1.2 JAXB Out of memory exception

    Hai,
    I am using JAXB in JWSDP1.2,while compiling with xjc it is giving out of memory error.I increased the size JVM memory to 1024m.
    It is giving when weinclude some imporrted schemas in the schema.is anyone have idea of this kind of problem. Is there any limit of innerclasees or included schemas.
    Thank you
    Sreen

    HI,
    THanks for the reply..AM using workshop IDE and have tried the "clean" option also but of no use..Is there any other alternative to get rid of this exception ???
    Regards

  • JAXB 1.0 Throws Exception and WebLogic Server Goes Mad !

    Hi,
    I've currently got JAXB Running within a standalone application running on Tomcat/Apache.
    When I try and Jar it up and run it on Weblogic 7.0 I get the following error being shown.
    The JAXB is being called from the onMessage event in a MessageDrivenBean which is sat on the application server. When it received the first message the server logs go mad repeatedly printing out the info below.
    <10-Jan-03 10:09:48 GMT> <Warning> <EJB> <010065> <MessageDrivenBean threw an Ex
    ception in onMessage(). The exception was:
    java.lang.NoClassDefFoundError: javax/xml/bind/JAXBException
    java.lang.NoClassDefFoundError: javax/xml/bind/JAXBException
    at uk.tester.deploy.messages.server.messageinbound.MessageHandlerBean.
    onMessage(MessageHandlerBean.java:46)
    at weblogic.ejb20.internal.MDListener.execute(MDListener.java:356)
    at weblogic.ejb20.internal.MDListener.transactionalOnMessage(MDListener.
    java:290)
    at weblogic.ejb20.internal.MDListener.onMessage(MDListener.java:271)
    at weblogic.jms.client.JMSSession.onMessage(JMSSession.java:2303)
    at weblogic.jms.client.JMSSession.execute(JMSSession.java:2226)
    at weblogic.kernel.ExecuteThread.execute(ExecuteThread.java:153)
    at weblogic.kernel.ExecuteThread.run(ExecuteThread.java:134)
    >
    The actual crash starts when the line
    JAXBContext jc = JAXBContext.newInstance("package structure........messageinbound.helpers.test");
    is called, I've attempted the fix found on this site using the
    public class JAXBClassLoader extends ClassLoader{
    public URL getResource(String name){
    if (name.endsWith("jaxb.properties")){
    name="jaxb.properties";
    return super.getResource(name);
    snippet of code and then changing the context to be
    JAXBContext jc = JAXBContext.newInstance("package structure.........messageinbound.helpers.test",new JAXBClassLoader());
    but this does not seem to help - any ideas please ???????

    Got Passed the first problem by correctly placing jaxb jars on the server and then sorting out the property file location but I still get the following problem.
    javax.xml.bind.JAXBException: Provider com.sun.xml.bind.ContextFactory not found
    I see a number of other postings are talking about this - has anyone got a solution yet ?

  • Exception from Jaxb

    Hi,
    I�m getting the follwoing error when I try to marshal a content tree to a new xml file:
    DefaultValidationEventHandler: [ERROR]: a required field "Profile" is missing an object
    I know that this error occurs because the element "Profile" in my application doesn�t have any value sometimes. So, when there is no values the exception is thrown. And I get later, at the time of marshaling the content tree, a java.lang.NullPointerException.
    Could anybody tell me, please, how to overcome this? I�d like to know if it is necessary that all the elements have a value all the time or there is a way to set some sort of property that makes the element without values be ignored.
    Thank You!

    While creating XML against a XSD , u must have all the elements(tags) in that XML file that are mentioned in the XSD , BUT u can have blank value for that element.
    In ur case u r not writing that "Profile" element in the XML file. thats why it giving error. U just write that element in the XML and keep its value as blank. So when a XML is created it will contain that element just like this-
    </Profile>
    i.e. it contains blank value but the element is present in XML file. So while marshalling set this element to the JAXB object. Now xjc it will not complain.

  • JAXB orajaxb exception with unbounded property

    orajaxb compiler generates an exception with the following simple xsd:
    <?xml version="1.0" encoding="UTF-8"?>
    <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified">
    <xs:element name="Emp_Name" type="xs:string"/>
    <xs:element name="Employer">
    <xs:complexType>
    <xs:sequence maxOccurs="unbounded">
    <xs:element ref="Emp_Name"/>
    </xs:sequence>
    </xs:complexType>
    </xs:element>
    </xs:schema>
    the exception is:
    Exception in thread "main" java.lang.NoSuchMethodError
    at oracle.xml.jaxb.JaxbSourceGen.genObjectFactoryCreateInnerInterface(Ja
    xbSourceGen.java:1616)
    at oracle.xml.jaxb.JaxbSourceGen.genObjectFactory(JaxbSourceGen.java:154
    3)
    at oracle.xml.jaxb.JaxbSourceGen.generate(JaxbSourceGen.java:193)
    at oracle.xml.jaxb.JaxbSourceGen.generate(JaxbSourceGen.java:169)
    at oracle.xml.jaxb.orajaxb.generate(orajaxb.java:221)
    at oracle.xml.jaxb.orajaxb.main(orajaxb.java:112)
    IF I manually edit to XSD to remove the maxOccurs="unbounded" on the Employer sequence, it compiles successfully.
    Is this a bug in orajaxb or am I doing something wrong?
    Note: The unbounded property is automatically created for the XSD based on a DTD using the "+" qualifier.
    eg:
    <!ELEMENT Employer (Emp_Name)+>
    which means the Employer element which has an employer name must appear 1 or more times.
    Issues:
    1. I cant change the DTD.
    2. Has the XSD been created successfully (ie is it correct for the "+" qualifier in the DTD to generate an "unbounded" property in the XSD?
    I used XMLSpy to convert the DTD to XML Schema.
    Has anyone else had this problem?

    Interfaces & Implementation classes get generated with the schema provided.
    Are <XDK>/lib/xml.jar, <XDK>/lib/xmlparserv2.jar, and <XDK>/lib/xmlmesg.jar in the Classpath variable?

  • JAXB - Unexpected end of element {} - UnmarshalException Exception

    Hi
    I am using Jaxb 1.0 Beta on AIX an I am getting javax.xml.bind.UnmarshalException exception when I try to unmarshall XML document. XML document and schema are valid ( I generated both using XML spy )
    Interestingly, the code works fine on windows 2000 but when I put the jar ,XML schema and xml document on unix it throws Unmarshall exception.
    Here's what I am trying to do.
    Code :
    JAXBContext jc =
    JAXBContext.newInstance( context,
    new com.xyz.retail.app.points.pgp.JAXBClassLoader());
    if(jc != null)
         System.out.println("Got the context");
    else
         System.out.println("Error in getting context");
    System.out.println("");
    // create an Unmarshaller
    Unmarshaller u = jc.createUnmarshaller();
    System.out.println("Created the Unmarshaller");
    System.out.println("");
    // Unmarshal securities document into Java content tree
    SecurityInfo securityInfo =
         (SecurityInfo)u.unmarshal( new FileInputStream( secFile ) );
    System.out.println("Unmarshaled the Document");
    System.out.println("");
    Schema :
    <?xml version="1.0" encoding="UTF-8"?>
    <!-- edited with XMLSPY v5 rel. 2 U (http://www.xmlspy.com) by Yogesh
    -->
    <xs:schema targetNamespace="http://www.xyz.com/retail/app/points/pgp/util"
    xmlns="http://www.xyz.com/retail/app/points/pgp/util" xmlns:xs="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified" attributeFormDefault="unqualified">
    <xs:element name="SecurityInfo" type="SecurityInfoType"/>
    <xs:complexType name="SecurityInfoType">
    <xs:sequence>
    <xs:element ref="AirlinePartners"/>
    </xs:sequence>
    </xs:complexType>
    <xs:element name="AirlinePartners">
    <xs:complexType>
    <xs:sequence>
    <xs:element ref="AirlinePartner" maxOccurs="unbounded"/>
    </xs:sequence>
    </xs:complexType>
    </xs:element>
    <xs:element name="AirlinePartner">
    <xs:complexType>
    <xs:sequence>
    <xs:element name="CardType" type="xs:string"/>
    <xs:element name="Description" type="xs:string" minOccurs="0"/>
    <xs:element name="TPrivate" type="xs:string"/>
    <xs:element name="TPassphrase" type="xs:string"/>
    <xs:element name="APublic" type="xs:string"/>
    <xs:element name="PlainText" type="xs:string"/>
    <xs:element name="CypherText" type="xs:string"/>
    <xs:element name="TKeyExpiry" type="xs:date" min
    Occurs="0"/>
    <xs:element name="AKeyExpiry" type="xs:date" min
    Occurs="0"/>
    </xs:sequence>
    </xs:complexType>
    /xs:element>
    </xs:schema>
    XML File :
    <?xml version="1.0" encoding="UTF-8"?>
    <!-- edited with XMLSPY v5 rel. 2 U (http://www.xmlspy.com) by Yogesh
    -->
    <!--Sample XML file generated by XMLSPY v5 rel. 2 U (http://www.xmlspy.com)-->
    <SecurityInfo xmlns="http://www.xyz.com/retail/app/points/pgp/util"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation=
    "http://www.xyz.com/retail/app/points/pgp/util /home/lcards/temp/APSecInfo.xsd">
    <AirlinePartners>
    <AirlinePartner>
    <CardType>x</CardType>
    <Description>some card</Description>
    <TPrivate>/home/lcards/temp/sachin.asc</TPrivate>
    <TPassphrase>worldcup2003</TPassphrase>
    <APublic>/home/lcards/temp/sunil.asc</APublic>
    <PlainText>/home/lcards/files/outbox/x</PlainText>
    <CypherText>/home/lcards/files/outbox/x</CypherText>
    <TKeyExpiry>2005-08-15</TKeyExpiry>
    <AKeyExpiry>2005-08-15</AKeyExpiry>
    </AirlinePartner>
    <AirlinePartner>
    <CardType>y</CardType>
    <Description>Another card</Description>
    <TPrivate>/home/lcards/temp/kapil.asc</TPrivate>
    <TPassphrase>worldcup1983</TPassphrase>
    <APublic>/home/lcards/temp/dilip.asc</APublic>
    <PlainText>/home/lcards/files/outbox/y</PlainText>
    <CypherText>/home/lcards/files/outbox/y</CypherText>
    <TKeyExpiry>2005-08-15</TKeyExpiry>
    <AKeyExpiry>2005-08-15</AKeyExpiry>
    </AirlinePartner>
    </AirlinePartners>
    </SecurityInfo>
    Output:
    Got the context
    Created the Unmarshaller
    DefaultValidationEventHandler: [ERROR]: Unexpected end of element {}:CardType
    javax.xml.bind.UnmarshalException: Unexpected end of element {}:CardType
    at com.sun.xml.bind.unmarshaller.UnreportedException.createUnmarshalExce
    ption(UnreportedException.java:59)
    at com.sun.xml.bind.unmarshaller.SAXUnmarshallerHandlerImpl.reportAndThr
    ow(SAXUnmarshallerHandlerImpl.java:406)
    at com.sun.xml.bind.unmarshaller.SAXUnmarshallerHandlerImpl.endElement(S
    AXUnmarshallerHandlerImpl.java:108)
    at org.apache.xerces.parsers.AbstractSAXParser.endElement(Unknown Source
    at org.apache.xerces.impl.XMLNSDocumentScannerImpl.scanEndElement(Unknow
    n Source)
    at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl$FragmentContent
    Dispatcher.dispatch(Unknown Source)
    at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl.scanDocument(Un
    known Source)
    at org.apache.xerces.parsers.DTDConfiguration.parse(Unknown Source)
    at org.apache.xerces.parsers.DTDConfiguration.parse(Unknown Source)
    at org.apache.xerces.parsers.XMLParser.parse(Unknown Source)
    at org.apache.xerces.parsers.AbstractSAXParser.parse(Unknown Source)
    at com.sun.xml.bind.unmarshaller.UnmarshallerImpl.unmarshal(Unmarshaller
    Impl.java:139)
    at javax.xml.bind.helpers.AbstractUnmarshallerImpl.unmarshal(AbstractUnm
    arshallerImpl.java:129)
    at javax.xml.bind.helpers.AbstractUnmarshallerImpl.unmarshal(AbstractUnm
    arshallerImpl.java:166)
    at com.xyz.retail.app.points.pgp.APSecurityInfoFactory.getAPSecInfo
    (APSecurityInfoFactory.java:102)
    at com.xyz.retail.app.points.pgp.EncryptAndSign.init(EncryptAndSign
    .java:183)
    at com.xyz.retail.app.points.pgp.EncryptAndSign.encrypt(EncryptAndS
    ign.java:581)
    at com.xyz.retail.app.points.pos.CreateExportFiles.main(CreateExpor
    tFiles.java:149)
    Inside readKeys()
    java.lang.NullPointerException
    at com.xyz.retail.app.points.pgp.EncryptAndSign.readKeys(EncryptAnd
    Sign.java:215)
    at com.xyz.retail.app.points.pgp.EncryptAndSign.encrypt(EncryptAndS
    ign.java:583)
    at com.xyz.retail.app.points.pos.CreateExportFiles.main(CreateExpor
    tFiles.java:149)
    Inside buildCypherTextFileName()
    java.lang.NullPointerException
    at com.xyz.retail.app.points.pgp.EncryptAndSign.buildCypherTextFile
    Name(EncryptAndSign.java:311)
    at com.xyz.retail.app.points.pgp.EncryptAndSign.encrypt(EncryptAndS
    ign.java:667)
    at com.xyz.retail.app.points.pos.CreateExportFiles.main(CreateExpor
    tFiles.java:149)
    Exception in Main method
    Thanks in advance for any help.
    Yogesh.

    I'm having error. I'm using the lastest JWSDP (1.3) with JDK 1.4.2
    Here is my XML file:
    <?xml version="1.0"?>
    <dataQA>
    <table name="ELECTORAL_DISTRICT" >
    <rules>
    <rule number="1.1" description="Check if we have 301 EDs" >
    <query result="301" >
         <sql>SELECT COUNT(ED_ID) FROM ELECTORAL_DISTRICT</sql>
    </query>
    </rule>
    <rule number="1.3" description="All fields must be populated" >
    <query result="0" >
    <sql>SELECT COUNT(ED_ID) FROM ELECTORAL_DISTRICT WHERE ED_CODE IS NULL OR ED_NAMEE IS NULL OR ED_NAMEF IS NULL</sql>
    </query>
    </rule>
    </rules>
    <reports>
    <report number="1.4" name="Listing of EDs" file="ed_list" format="HTML" >
         <column name="ED_ID" label="ID" ></column>
         <column name="ED_CODE" label="Code" ></column>
         <column name="ED_NAMEE" label="English Name" ></column>
         <column name="ED_NAMEF" label="French Name" ></column>
         <column name="PRVNC_ID" label="Province ID" ></column>
    </report>
    </reports>
    </table>
    </dataQA>
    And my shema:
    <xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema">
    <xsd:element name="dataQA" type="DataQAType"/>
    <xsd:complexType name="DataQAType">
    <xsd:sequence>
    <xsd:element name="table" type="TableType" minOccurs="1" maxOccurs="unbounded" />
    </xsd:sequence>
    </xsd:complexType>
    <xsd:complexType name="TableType">
    <xsd:sequence>
    <xsd:element name="rules" type="RulesType" />
    <xsd:element name="reports" type="ReportsType" />
    </xsd:sequence>
    <xsd:attribute name="name" type="xsd:string" />
    </xsd:complexType>
    <xsd:complexType name="RulesType">
    <xsd:sequence>
    <xsd:element name="rule" minOccurs="1" maxOccurs="unbounded" >
    <xsd:complexType>
    <xsd:sequence>
    <xsd:element name="query" type="QueryType" />
    </xsd:sequence>
    <xsd:attribute name="number" type="xsd:string" />
         <xsd:attribute name="description" type="xsd:string" />
    </xsd:complexType>
    </xsd:element>
    </xsd:sequence>
    </xsd:complexType>
    <xsd:complexType name="ReportsType">
    <xsd:sequence>
    <xsd:element name="report" minOccurs="1" maxOccurs="unbounded" >
    <xsd:complexType>
    <xsd:sequence>
    <xsd:element name="column" type="ColumnType" minOccurs="1" maxOccurs="unbounded" />
    <xsd:element name="condition" type="xsd:string" />
    </xsd:sequence>
    <xsd:attribute name="number" type="xsd:string" />
    <xsd:attribute name="name" type="xsd:string" />
    <xsd:attribute name="file" type="xsd:string" />
    <xsd:attribute name="format" type="xsd:string" />
    </xsd:complexType>
    </xsd:element>
    </xsd:sequence>
    </xsd:complexType>
    <xsd:complexType name="ColumnType">
    <xsd:attribute name="name" type="xsd:string" />
    <xsd:attribute name="label" type="xsd:string" />
    </xsd:complexType>
    <xsd:complexType name="QueryType">
    <xsd:sequence>
    <xsd:element name="sql" type="xsd:string" />
    </xsd:sequence>
    <xsd:attribute name="result" type="xsd:string" />
    </xsd:complexType>
    </xsd:schema>
    I get the following exception:
    DefaultValidationEventHandler: [FATAL_ERROR]: Unexpected end of element {}:report
    Location: line 23 of file:/D:/Revise2.5/DataQA/config/test.xml
    javax.xml.bind.UnmarshalException: Unexpected end of element {}:report
    I'm currenlty in the processing of writting parser with DOM since I haven't found the yet. Is this a bug or I'm doing something wrong.
    Thanks in advance for the reply,
    - N. Thomassin

  • JAXB unmarshal exception "unexpected root element"

    I have a very simple xsd and just one xml file I am trying to unmarshal. I switched to jws-2.0 and am still getting the same exception I go when using jws-1.5. I would be very grateful for any assistance on this:
    Here is my main program:
    public static void main(String[] args) {
    getCancelPenalty();
    public static void getCancelPenalty() {
    String jaxbContext = "generated";
    String cancelPenaltyFilename = "CancelPenaltyOne.xml";
    JAXBContext jc = null;
    Unmarshaller u = null;
    CancelPenalty cancelPenalty = null;
    try {
    jc = JAXBContext.newInstance(jaxbContext);
    u = jc.createUnmarshaller();
    cancelPenalty = (CancelPenalty) u.unmarshal(
    new FileInputStream(cancelPenaltyFilename));
    } catch (Exception e) {
    e.printStackTrace();
    System.exit(0);
    int updateTUID = cancelPenalty.getUpdateTUID();
    System.out.println("These values were retrieved from " +
    "the Cancel Penalty object:");
    System.out.println("UpdateTUID: "+ updateTUID);
    Here is my xsd file:
    <?xml version="1.0" encoding="UTF-8"?>
    <xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema">
    <xsd:complexType name="CancelPenalty">
    <xsd:sequence>
    <xsd:element name="UpdateTUID" type="xsd:int"/>
    </xsd:sequence>
    </xsd:complexType>
    </xsd:schema>
    Here is my xml file that i am trying to parse:
    <?xml version="1.0" encoding="UTF-8"?>
    <CancelPenalty>
    <UpdateTUID>1</UpdateTUID>
    </CancelPenalty>
    And finally here is stack trace of exception:
    javax.xml.bind.UnmarshalException: unexpected element (uri:"", local:"CancelPenalty"). Expected elements are (unknown)
         at com.sun.xml.bind.v2.runtime.unmarshaller.UnmarshallingContext.handleEvent(UnmarshallingContext.java:523)
         at com.sun.xml.bind.v2.runtime.unmarshaller.Loader.reportError(Loader.java:199)
         at com.sun.xml.bind.v2.runtime.unmarshaller.Loader.reportError(Loader.java:194)
         at com.sun.xml.bind.v2.runtime.unmarshaller.Loader.reportUnexpectedChildElement(Loader.java:71)
         at com.sun.xml.bind.v2.runtime.unmarshaller.UnmarshallingContext$DefaultRootLoader.childElement(UnmarshallingContext.java:920)
         at com.sun.xml.bind.v2.runtime.unmarshaller.UnmarshallingContext._startElement(UnmarshallingContext.java:364)
         at com.sun.xml.bind.v2.runtime.unmarshaller.UnmarshallingContext.startElement(UnmarshallingContext.java:345)
         at com.sun.xml.bind.v2.runtime.unmarshaller.SAXConnector.startElement(SAXConnector.java:117)
         at com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.startElement(Unknown Source)
         at com.sun.org.apache.xerces.internal.impl.XMLNSDocumentScannerImpl.scanStartElement(Unknown Source)
         at com.sun.org.apache.xerces.internal.impl.XMLNSDocumentScannerImpl$NSContentDispatcher.scanRootElementHook(Unknown Source)
         at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl$FragmentContentDispatcher.dispatch(Unknown Source)
         at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanDocument(Unknown Source)
         at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(Unknown Source)
         at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(Unknown Source)
         at com.sun.org.apache.xerces.internal.parsers.XMLParser.parse(Unknown Source)
         at com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.parse(Unknown Source)
         at com.sun.xml.bind.v2.runtime.unmarshaller.UnmarshallerImpl.unmarshal0(UnmarshallerImpl.java:200)
         at com.sun.xml.bind.v2.runtime.unmarshaller.UnmarshallerImpl.unmarshal(UnmarshallerImpl.java:173)
         at javax.xml.bind.helpers.AbstractUnmarshallerImpl.unmarshal(AbstractUnmarshallerImpl.java:137)
         at javax.xml.bind.helpers.AbstractUnmarshallerImpl.unmarshal(AbstractUnmarshallerImpl.java:184)
         at populateDB.Populate.getCancelPenalty(Populate.java:28)
         at populateDB.Populate.main(Populate.java:15)
    Any ideas what is going awry?

    Solved:
    My xsd file was incorrect (I guess):
    instead of:
         <xs:complexType name="CancelPenalty">
    I needed to use:
         <xsd:element name="CancelPenalty">
              <xsd:complexType>
    Not sure why the first construct is incorrect, but I found another example of an xsd file that used the second construct and it worked for me as well.

Maybe you are looking for