Marshalling third party classes with JAXB

I put together a test case similar to what is illustrated at:
[https://jaxb.dev.java.net/guide/XML_layout_and_in_memory_data_layout.html#Using_XmlJavaTypeAdapter_for_element_attribute_values]
and here:
[http://weblogs.java.net/blog/kohsuke/archive/2005/09/using_jaxb_20s.html]
I declared a Color object, defined a ColorAdapter, and declared the @XmlJavaTypeAdapter to the package. Alas, it isn't getting called... If you consider the following sample code:
JAXBContext jc = JAXBContext.newInstance(Color.class);
// Note that a dump of the context confirms that com.acme.Color is listed!
//System.out.println("JAXBContext: " + jc.toString());
Marshaller m = jc.createMarshaller();
m.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, true);
Color color = Color.RED;
// Case 1: The following line works, but it does NOT call the ColorAdapter...
m.marshal( new JAXBElement( new QName("", "rootTag"), Color.class, color ), System.out);
// Case 2: This fails...
m.marshal(color, System.out);Case 1 "works" (doesn't error), but the output clearly shows that the ColorAdapter is not getting called.
Case 2 throws a javax.xml.bind.MarshalException exception:
javax.xml.bind.MarshalException
- with linked exception:
[com.sun.istack.SAXException2: unable to marshal type "com.acme.Color" as an element because it is missing an @XmlRootElement annotation]
at com.sun.xml.bind.v2.runtime.MarshallerImpl.write(MarshallerImpl.java:
328)
testMarshalling : javax.xml.bind.MarshalException
at com.sun.xml.bind.v2.runtime.MarshallerImpl.marshal(MarshallerImpl.jav
a:254)
at javax.xml.bind.helpers.AbstractMarshallerImpl.marshal(AbstractMarshal
lerImpl.java:75)
at resty.AppTest.testMarshalling(AppTest.java:68)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
- with linked exception:
[com.sun.istack.SAXException2: unable to marshal type "com.acme.Color" as an element because it is missing an @XmlRootElement annotation]
at java.lang.reflect.Method.invoke(Method.java:597)
at junit.framework.TestCase.runTest(TestCase.java:154)
at junit.framework.TestCase.runBare(TestCase.java:127)
at junit.framework.TestResult$1.protect(TestResult.java:106)
at junit.framework.TestResult.runProtected(TestResult.java:124)
at junit.framework.TestResult.run(TestResult.java:109)
at junit.framework.TestCase.run(TestCase.java:118)
at junit.framework.TestSuite.runTest(TestSuite.java:208)
at junit.framework.TestSuite.run(TestSuite.java:203)
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 org.apache.maven.surefire.junit.JUnitTestSet.execute(JUnitTestSet.java:213)
at org.apache.maven.surefire.suite.AbstractDirectoryTestSuite.executeTestSet(AbstractDirectoryTestSuite.java:140)
at org.apache.maven.surefire.suite.AbstractDirectoryTestSuite.execute(AbstractDirectoryTestSuite.java:127)
at org.apache.maven.surefire.Surefire.run(Surefire.java:177)
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 org.apache.maven.surefire.booter.SurefireBooter.runSuitesInProcess(SurefireBooter.java:338)
at org.apache.maven.surefire.booter.SurefireBooter.main(SurefireBooter.java:997)
Caused by: com.sun.istack.SAXException2: unable to marshal type "com.acme.Color"
as an element because it is missing an @XmlRootElement annotation
at com.sun.xml.bind.v2.runtime.XMLSerializer.reportError(XMLSerializer.java:244)
at com.sun.xml.bind.v2.runtime.ClassBeanInfoImpl.serializeRoot(ClassBeanInfoImpl.java:303)
at com.sun.xml.bind.v2.runtime.XMLSerializer.childAsRoot(XMLSerializer.java:490)
at com.sun.xml.bind.v2.runtime.MarshallerImpl.write(MarshallerImpl.java:325)
... 29 moreNote that my Color object represents a third-party class -- a class where I can't just annotate it with @XmlRootElement. Hence, why I am looking at @XmlJavaTypeAdapter.
Can somebody please tell me why my adapter is not getting called, and what I can do about customizing the marshaling of a third-party class?
Note that I am using JAXB 2.1.8.

what kind of third party API are using ?

Similar Messages

  • Memory leaks with Third party classes

    Hello all,
    This is fairly known problem. But I guess, my problem gives a new dimention to the problem.
    I have an application which is developed by me. This application ideally needed to use third party classes ( obviously no source code is supplied ). These third party classes provide extra functionality required.
    The problem is, when I don't use third party classes in my application, every thing is fine. When I include third party classes, I am having memory leaks.
    Then I tried to investigate memory leaks with Optimizeit tool. It is new to me. As of now, I understood, we can identify where the memory leaks are occuring.
    finally the problem is, in order to solve this, I need some patches in the code. But I don't have source code for those classes. How to solve this problem?
    For example,
    I use a third party classes in my code like this,
    ThirdPartyMemoryLeakClass obj = new ThirdPartyMemoryLeakClass();
    This 'obj' is made static, as it takes lot of time to create this object. Obviously this object contains several references to other objects, which I can't control.
    In the process of reusing this object, I am getting memory leaks.
    Any ideas regarding, how one has to deal this type of situations? What are the issues involved with this case? Are there any similar problems, which have been solved? are most welcome.
    many thanks for your time.
    Madhav

    Decompile it using jad. Find leak.Yes, I too got the idea and tried to decompile those classes and recompile. I had some problems while recompiling. Is this is the only way to get rid of this problem?
    I was refering to powersoft.datawindow.DataStore class. Does any body here has worked on these?
    Can you suggest me how to find the memory leak causes? if you were needed to find out memory leak causes, what would be your approach?
    Madhav

  • Deploying Common-utilities and Third-party Classes

    In your documentation you state that several jar-libraries (containing
    utilities, third-party classes, jdbc-drivers and also I suppose classes for
    custom realms) needs to added to the Java system classpath.
    This probably also means that they will not be distributed from the
    administration server to the managed servers as applications does. Since
    most non-trivial applications include startups, custom realms and so forth
    it renders the distribution feature (ie. from admin server to managed
    server) virtually useless. Installs needs to be made on all nodes anyway.
    One example on a solution for this is to distribute these jar-libraries to
    the new node-manager which then starts up the server with these jar-files on
    the classpath?
    Also one could include the startup and shutdown-classes in a
    weblogic-specific enterprise application deployment-descriptor so that these
    are run in the same classloader as the enterprise application. Most
    non-trivial startups probably needs to run in this classloader anyway. (If
    they for example access ejbs etc.)
    An alternative implementation would be to specify a servlet with a
    load-on-startup, but I'm not sure at what time the servlet will be loaded.
    Is this a recommended strategy for startup-classes that needs to run in the
    application classloader?

     

  • Can we integrate third party tool with solution manager

    Can we integrate third party toll with solution manager , If it is possible what API's we have?

    Hi Santosh Asuthkar,
    thank you for your answer.
    I've already read the steps in trx. spro and several documentations in sdn.
    There was a hint to trx. ictconf, wsconfig, lpconfig, wsadmin. If you call these transactions there
    is a message that these trx. are old and trx. SOAMANAGER should be used.
    Question is how to activate the webservice "ICT_SERVICE_DESK_API" in SOAMANAGER.
    I've never handled with bindings and proxy classes.
    Best regards
    Klaus

  • How to use third party APIs with Sun J2ME Toolkit

    I've installed Sun J2ME Toolkit 2.1. If I intend to use other third party APIs with my existing toolkit, how do I do that. I can manage to get the jar file of the associated API classes, but how to integrate the same with the toolkit. Thanks in advance to all who support.

    if I remember right, it is enough, if you put the .jar of the api in the lib/ directory of your project (<WTK>/apps/<yourProject>/lib/ )
    hth
    Kay

  • Problem in Partial Billing for Third Party Sales with Shipping Notification

    Hello Guys,
    There is one issue related to a scenario of Third party Sales with shipping notification. Here the basic process that runs
    are : Sales order --- > PR -- > PO --> MIGO --> Billing document --> Vendor Invoice Verification.
    In this specific scenario, partial billing is not happening and the billing relevance for item category "B" and in copying control data
    from sales order to billing doccument, the biling quantity field is "A".
    Could anyone throw some light on the configuration part so that partial invoicing can happen ??? Please make a note of the fact
    that billing documents are generated after MIGO is done.
    Regards,
    Sarthak

    Finally resolved

  • Integrating third party recruitment with SAP

    Hi folks,
    I had a question regarding intergrating the third party system with SAP HR masterdata. I am basically looking at transferring the applicant data from the Recruiting (third party tool ) system into SAP HR Masterdata. I found using the feature PAPLI something like integration could be done. I do not know how ???
    Right now, at the click of button something like Data transfer (entering the applicant id) can be manually imported into SAP Masterdata from the SAP recruiting module on the same system.
    Can such a process be achieived using  a third party tool? Is direct transfer process from the thrid party tool into SAP Employee Masterdata possible? Is the feature PAPLI (found from IMG) something like this can be accomplished?
    The version we are using is SAP 4.6C
    Any thoughts or leads in this area will be highly appreciated.
    Thanks in advance,
    SK

    I am not sure of any standard integration programs specific to recruitment, but through customization we can integrate third party rectt systems like People click, HRP etc.
    Develop inbound programs with ALE-IDOC system to transfer the data to Rectt tables.
    The switch will control activation of integration between the systems.
    If this helps, pl do reward.
    Thanks
    Narasimha

  • Third Party Order With Shipping Notification

    Hi SD folks,
    What is the Movement type we need to enter to do a dummy GR for third party order with shipping notification.
    Regards,
    Rahul

    101

  • Need connectivity of SAP Oracle with Third Party tool with dsn

    Hi Friends,
    We need to access SAP's Oracle database with third party tool with the help of dsn creation. For that we need to create 2 staging tables and need a new segment for these tables. Our data will move from SAP transactions to these 2 tables and we want to fetch this data via dsn into another third party S/W.
    I am unaware of such kind of working, can you please help me how to create new segment and how to create dsn for accessing tables in this segment.
    Our requirement is as follow.
    The staging tables are required in the SAP database with user name and password. The user should have all access to the staging table only.
    Requesting your kind help on this issue. Please suggest for further processing of activity.
    Rgds, Krishan Raheja.

    Hi,
    Common way to integrate SAP (database) with third party Application is to use and implement SAP Connector (Java or .Net).
    Using this, you can fetch the data from SAP database to use it in Third party application.
    As per my understanding the method you mentioned, will void the SAP database license term.
    So Please check before doing such configuraiton. Also that method is NOT recommended..
    Regards.
    Rajesh Narkhede

  • How to link third party software with labview program ?

    I have designed a labview  
    program to analyse and make  
    graph and save the datas  
    from the photon counter using  
    ni USB DAQ 6008. And the  
    photon counter is controlled  
    by the third party software with  
    itself. both programs are  
    executing successfully. But  
    my task is run both the  
    program at the same time. i.e.  
    link the third party software  
    with my labview program.  
    How to i do this?

    Your question is too vague since you give no information as to this third party application. Is it an application you wrote? Is it an application that you cannot change? Does it have a programming interface? Can you eliminate this third-party application and control the photon counter yourself? Have you tried to do a search, as this question has come up before many times. For example:
    http://forums.ni.com/t5/LabVIEW/how-do-I-use-labview-to-control-other-programs/m-p/424765
    http://forums.ni.com/t5/LabVIEW/How-to-operate-another-application-s-GUI-from-LV/m-p/668088

  • Third party integration with Oracle Apps

    Hi friends,
    I have a dot net application and I would like to integrate that with oracle applications(specifically HR module). Can I do that? Does oracle apps provide any APIs to provide this third party integration with 3rd party software we have?
    can you please post any links if there is one which helps me in this direction
    thanks

    Hello,
    I am new on this forum and I have difficulty in beginning.
    I'm working in a similar project, indeed I need an example or a document which can help me for using the HRMS api's of oracle e-business suite via a dotNet plateform or SharePoint application.
    I have to work on a middelware allowing retreiving and persisting data from oracle e-business suite database using oracle HRMS api's like hr_appraisals_api. So haw can i call these api's from .NET application how can i use a .NET code to call these api's ?
    Can you help me please ? i'm waiting for your answers if possible and this is my e-mail address if necessary "[email protected]" .
    I would be so grateful if someone can help me. Thank you in advance.
    Cordially.

  • Third party intergration with FICO

    Hi All,
    Do anyone have the link or the document(steps) related to intergration of the third party tool with SAP FICO.Please help me.
    Regards,
    MJ

    Hi,
    Depending on the business processes of your client  the third party tools can be put into use and integrated with SAP. What is your client requirement exactly?
    Regards,
    Satish Muvva.

  • Webinar- Connect Third Party Systems with SAP B1 – DI API, DI Server, B1WS

    Webinar happened on 21st August.
    Get the Presentation, Video recording and answers of all the questions asked in the webinar through the below link.
    Webinar- Connect Third Party Systems with SAP B1 - DI API, DI Server, B1WS

    Hi Oleksiy,
    I don't see anything strange in your code. You should receive an error message but it shoudn't loop without end ;o(
    The only thing I can propose you is to create a message for support, they will have a deepest look into your problem.
    Regards
    Trinidad.

  • Adding Third-Party Classes

    Hello, I have a bunch of third party classes that I wish to use as javac complies...
    Where do I place these files and what format do they have to be in (i.e. a folder or a jar file)?
    Thank you!

    They can be in either directories or jar files. You just need to make sure that they are included in your $CLASSPATH.

  • How do i access a third party .class file

    Hi,
    I am new to both java and enterprise 8, and would greatly appreciate some help.
    I have a third party .class file and want to include it in a project so i can call it's methods etc. I can access it by creating an object as follows
    thirdPartyClass tpc= new thirdPartyClass();and then create a .class file of my own using javac at the command line without any probles, but if I use the same code in enterprise 8 it reports an error stating "cannot access MyProjectName.thirdPartyClass" could someone please tell me how to reference this file as so far I have not been able to find anything.
    Thanks for any help.

    Thanks for the suggestions it appears I was doing more or less the right things but miss reading the error message:
    Cannot access keyword.classes.thirdPartyClass
    bad class file C:\java\keyword\classes\thirdPartyClass
    class file contains wrong class: thirdPartyClass
    please remove or make sure it appears in the correct subdirectroy of the classpath.
    While looking I have found that the classes do not contian src folders of Javadoc so I will go see if the third party can supply a Jar file or similar.
    Thanks

Maybe you are looking for

  • How to set up an integrated wired and wireless network

    I have an iMac 17" 1GHz connected to a ethernet hub which in turn is connected to a DSL modem and from there to my ISP. I also have a MacBook Pro wirelessly connected to an AirPort Express; the AE is connected to the same ethernet hub through its eth

  • How to prevent a text in script from displaying if its value is zero

    Dear all, How to prevent a text in script from displaying if its value is zero for eg   Price  = 0.00 if price is 0 it should'nt appear in output. I tried with    if price ne 0.                    price = &price&                     endif. but it's n

  • Invoice Verification - Issue/ Documents Posted to Dummy PC ( Frieght Cost)

    HI friends, I was observed that Users are posting the freight for indirect PO directly to Freight GL, it goes to Dummy Profit Center. The actual process is Freight cost which is not captured in PO & is with Invoice has to enter in unplanned delivery

  • Connection drops on a daily basis / Varying (low) ...

    People probably know the drill by now, everything is fine then suddenly they go through a period where they receive barely a 10th of their paid connection speed, with their connection dropping completely at least once per day. This all started happen

  • Designer 8.0 Form compatibility with Reader 6.0 - error message

    I created a form in Designer 8.0. I saved it to be compatible with 7.0, but for the most part need for it to be compatible with Reader 6.0, which is not an available option. This form actually works fine in Adobe Reader 6.0 but whenever a user initia