JAXBContext and unmarshaling xml document to a class that came from a jar.

I'm trying to unmarshal, code:
               try {
                    JAXBContext jc = JAXBContext.newInstance(clazz);
                    Unmarshaller m = jc.createUnmarshaller();
                    Document doc = XmlUtils.createDom(body);
                    javax.xml.bind.JAXBElement<T> res = (javax.xml.bind.JAXBElement<T>)m.unmarshal(doc);
                    return res.getValue();
               } catch (JAXBException e) {
                    Log.exception(e);
now i have an ObjectFactory inside the jar that resolve (xmlRegistry) the correct type.
but the @XmlAccessorType(XmlAccessType.FIELD) binding is not working while the class is comming from a jar.
when i 'Link source' to my project is working fine.
I guess it has something to do with reflection.
the class which i want to unmarshal to looks like this:
@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "GetSessionIDResponseType", propOrder = {
"sessionID"
public class GetSessionIDResponseType
extends AbstractResponseType
implements Serializable
private final static long serialVersionUID = 12343L;
@XmlElement(name = "SessionID")
protected String sessionID;
* Gets the value of the sessionID property.
* @return
* possible object is
* {@link String }
public String getSessionID() {
return sessionID;
* Sets the value of the sessionID property.
* @param value
* allowed object is
* {@link String }
public void setSessionID(String value) {
this.sessionID = value;
not the field as u can see is protected though it has getter and setter.
anyway i must get the link source project to a jar and i cant do that cause the unmarshal is basically failing.
any idea?
Edited by: 813927 on Nov 20, 2010 6:10 AM

I've overcome the problem by adding the unmarsheling code inside the jar.
though i dont the problem i tried to set the fields to be public and it didnt work.
very strange so far.

Similar Messages

  • Error adding package to class that is using a jar

    Hi,
    I have a class that is using a jar but I need it to be in a package so I can use it with JSP, but each time I put the package in the class I get some compile errors that the classes in the jar can't be found.
    Example:
    Compiling 1 source file to C:\Documents and Settings\ehasbunv\Mis documentos\proyecto\mex\cc\build\web\WEB-INF\classes
    C:\Documents and Settings\ehasbunv\Mis documentos\proyecto\mex\cc\src\java\tecno\Tecnomen.java:22: cannot find symbol
    symbol : class PP_OpenInterface
    location: class tecno.Tecnomen
    private PP_OpenInterface pp = null;
    C:\Documents and Settings\ehasbunv\Mis documentos\proyecto\mex\cc\src\java\tecno\Tecnomen.java:23: cannot find symbol
    symbol : class PP_OpenInterface_Factory
    location: class tecno.Tecnomen
         private PP_OpenInterface_Factory ppf     = null;
    C:\Documents and Settings\ehasbunv\Mis documentos\proyecto\mex\cc\src\java\tecno\Tecnomen.java:127: cannot find symbol
    symbol : class PP_exception
    location: class tecno.Tecnomen
    public int GenericRecharge (String Subid,int monto) throws PP_exception
    C:\Documents and Settings\ehasbunv\Mis documentos\proyecto\mex\cc\src\java\tecno\Tecnomen.java:79: cannot find symbol
    symbol : variable PP_OpenInterface_FactoryHelper
    location: class tecno.Tecnomen
    ppf = PP_OpenInterface_FactoryHelper.narrow(nsRef);
    C:\Documents and Settings\ehasbunv\Mis documentos\proyecto\mex\cc\src\java\tecno\Tecnomen.java:91: cannot find symbol
    symbol : class PP_exception
    location: class tecno.Tecnomen
    catch(PP_exception ex)
    C:\Documents and Settings\ehasbunv\Mis documentos\proyecto\mex\cc\src\java\tecno\Tecnomen.java:139: cannot find symbol
    symbol : class paramRecord
    location: class tecno.Tecnomen
    paramRecord pSeq [] = new paramRecord[] {
    C:\Documents and Settings\ehasbunv\Mis documentos\proyecto\mex\cc\src\java\tecno\Tecnomen.java:139: cannot find symbol
    symbol : class paramRecord
    location: class tecno.Tecnomen
    paramRecord pSeq [] = new paramRecord[] {
    C:\Documents and Settings\ehasbunv\Mis documentos\proyecto\mex\cc\src\java\tecno\Tecnomen.java:140: cannot find symbol
    symbol : class paramRecord
    location: class tecno.Tecnomen
    new paramRecord(0,subId),
    C:\Documents and Settings\ehasbunv\Mis documentos\proyecto\mex\cc\src\java\tecno\Tecnomen.java:141: cannot find symbol
    symbol : class paramRecord
    location: class tecno.Tecnomen
    new paramRecord(1,amount),

    Checking another file, the problem is that if I'm
    trying to use a class in the default package in
    another class and put a package name in the class
    then I can't use the default package. Is there any
    workaround?Nope. Get in the habit now of making ALL of your classes belong to packages. The "no-package" is only for creating 'toy' applications with no dependencies from other packaged classes.

  • Failed to load Main-Class manifest attribute from IWS.jar

    I have a problem that when I click the IWS.jar in dist folder, there is an error
    "Failed to load Main-Class manifest attribute from IWS.jar"
    i have search in internet with same case, they said to add a line
    "Main-Class: summary" in manifest.mf, so i have extract the .jar
    and open the manifest.mf file, but it said that main class will add automatically
    Manifest-Version: 1.0
    Ant-Version: Apache Ant 1.6.2
    Created-By: 1.5.0_06-b05 (Sun Microsystems Inc.)
    X-COMMENT: Main-Class will be added automatically by buildI am using Netbeans1.4 and jdk1.5.0_06 to create java application.
    How should I fix it?
    Thanks

    Thanks for the reply..
    I have fix it.
    Actually why I got the error is because I used panel form to create GUI form.
    So I try create new file using frame form rather than panel. It will generate this main class.
    public static void main(String args[]) {
            java.awt.EventQueue.invokeLater(new Runnable() {
                public void run() {
                    new NewJFrame().setVisible(true);
        } Thats why my .jar fail to load when I used panel form because its does not have main class in it.

  • Failed to load Main-Class manifest attribute from Hello.jar???

    HI all
    This is my first post, I hope its in the right section
    I followed the tutorial on [http://www.cs.princeton.edu/introcs/85application/jar/jar.html|http://www.cs.princeton.edu/introcs/85application/jar/jar.html] and I tried out the simple example below
    A simple example. Let's say we wanted to distribute the simple program Hello.java as a JAR. First, we create a text file named Hello.mf which contains:Manifest-Version: 1.0
    Main-Class: Hello
    Then, we create the archive by typing:
    jar cmf Hello.mf Hello.jar Hello.class Hello.java
    and run it by typing:
    java -jar Hello.jar 
    But when I ran the command java -jar Hello.jar the following error message showed on my command prompt
    Failed to load Main-Class manifest attribute from Hello.jar
    I don't know what I have done wrong, i followed the tutorial to the letter.
    Can anyone shed some light on whats going wrong please?
    Many thanks
    HLA91

    Sorry about double post but i dont know whether editing my first one will bump the thread, and i need it bumped :).
    I downloaded netbeans and I built my project and a jar file was created in oblong/dist (oblong is my project name) but again when i try to run the file the warning
    Failed to load Main-Class manifest attribute from oblong.jar
    appears and I dont know what i can do this time seen as i dont make the manifest file (read prior posts to see what i previously did wrong) , the compiler does it all for me so either im missing something that i have to do before building my project or netbeans is messing up for some strange reason. Can anyone provide insight?
    Many thanks
    HLA91

  • Failed to load Main-Class manifest attribute from HelloWorld.jar

    Hi,
    I got a file call HelloWorld.java and a file call mainClass which contain one line ==>
    Main-Class: HelloWorld
    Then I run the command:
    jar cmf mainClass HelloWorld.jar HelloWorld.class
    java -jar HelloWorld.jarAnd I got the following error:
    =======================================
    Failed to load Main-Class manifest attribute from
    HelloWorld.jar
    =======================================
    Why is that? I follow the instruction from the sun website, but still not working... can anybody help??
    Thanks

    For whatever reason the last line of the Manifest file is always ignored. So if your Main-Class is the first AND last line it is being ignored. Solution, make sure you have at least one or more blank lines after the Main-Class line.

  • Failed to load Main-Class manifest attribute from oc4j.jar

    Hi All
    I am trying to start OC4J in the SOA suite from the command line but every time i issue the command i.e.
    java -jar ORACLE_AS_HOME/j2ee/home/oc4j.jar
    I get the fololwing error
    "Failed to load Main-Class manifest attribute from oc4j.jar"
    I have checked the oc4j jar and the class oracle.oc4j.loader.boot.BootStrap does exits and it does have a main class
    Is the Manifest file broken?
    Does anyone know why this is happens?

    Hi,
    did you try the SOA Suite forum ?
    SOA Suite and OC4J 11g Technology Preview
    Frank
    Edited by: Frank Nimphius on Jan 30, 2009 1:41 PM

  • Failed to load Main-Class manifest attribute from test.jar

    Hi,
    I built a console application, there is a manifest.mf file which has Manifest-Version: 1.0 only.
    When I run C:>java -jar test.jar
    It showed
    Failed to load Main-Class manifest attribute from test.jar
    How should I fix it?
    Thanks

    Hi,
    I read
    http://java.sun.com/docs/books/tutorial/jar/basics/run.
    tml
    and do jar cmf mainClass app.jar HelloWorld.class on
    console window.
    Since my application is packaged like
    com.java.forum.HelloWorld, I changed it to
    jar cmf mainClass app.jar
    com.java.forum.HelloWorld.class
    It returned an error: java.io.FileNotFoundException:
    mainClass
    How should I do it?
    When you read that page, did you also read the link to Modifying a Manifest File? The mainClass that you specified should have been a text file that contains something like
    Main-Class: HelloWorld
    The FileNotFoundException indicates that the jar.exe program could not find a file named mainClass in the current directory. I can't help you with JBuilder or Eclipse.

  • Failed to load Main-Class manifest attribute from TextEditor.jar

    Hi, I'm trying to make a JAR file containing a Java application that I can run by double-clicking under windows.
    Everything works fine, except I get the error "Failed to load Main-Class manifest attribute from TextEditor.jar"
    I have tried to set up my manifest file to contain the Main-Class attribute. Eg:
    Manifest-Version: 1.0
    Main-Class: texteditor/TextEditorClass.classBut I get the error:
    java.io.IOException: invalid manifest formatIf I include a Name: header...
    Manifest-Version: 1.0
    Name: texteditor
    Main-Class: texteditor/TextEditorClass.class...then the manifest is used, (and I can even see my Main-Class attribute within the JAR), but if I double-click the JAR or use "java -jar TextEditor.jar" from an MSDOS prompt, then I still get the error message "Failed to load Main-Class manifest attribute from TextEditor.jar"
    I am using Java version "1.2fcs" Classic VM (build JDK-1.2fcs-S, native threads)
    How do I get the mainfest to accept the Main-Class attribute?
    thanks,
    Tim

    Thanks for the reply Kurt.
    Unfortunately I still get the same error. I have actually tried all sorts of combinations of the file with and without "Name:" and with and without .class.
    I must admit I never tried it with the Name line second like you showed, but I have now, and it gives me the same old "invalid manifest format" message.
    I was wondering if somehow I've ended up with an old version of JAR that cannot handle the Main-Class attribute. The problem is that unlike JAVA, JAR won't tell you what version it is. Any ideas how I might prove I'm running the latest version of JAR? Mind you, I get the same problem at home and at work, and my work version is the latest GenRel one so I think this is pretty unlikely.

  • Error: Failed to load Main-Class manifest attribute from HelloWorld.jar

    Hi,
    I got a file call HelloWorld.java and a file call mainClass which contain one line ==>
    Main-Class: HelloWorld
    Then I run the command:
    jar cmf mainClass HelloWorld.jar HelloWorld.class
    java -jar HelloWorld.jarAnd I got the following error:
    =======================================
    Failed to load Main-Class manifest attribute from
    HelloWorld.jar
    =======================================
    Why is that? I follow the instruction from the sun website, but still not working... can anybody help??
    Thanks

    For whatever reason the last line of the Manifest file is always ignored. So if your Main-Class is the first AND last line it is being ignored. Solution, make sure you have at least one or more blank lines after the Main-Class line.

  • HT5085 I would like to upload my music library from my PC to the Cloud through iTunes Match.  I also will be purchasing a Mac in the near future and would like to download some of that music from iCloud to my Mac.  Will I have compatability problems?

    I would like to upload my music library from my PC to the Cloud through iTunes Match.  I also will be purchasing a Mac in the near future and would like to download some of that music from iCloud to my Mac.  Will I have compatability problems?

    You should have no problems. To add a second computer or device to iTunes Match, see:
    http://support.apple.com/kb/ht4913
    Regards.

  • I was in a conversation with a colleague and a text (identical) came to both of our phones, when he researched it, it said it was blocked and I thought I might see where it came from through my phone. Is it possible to get a spam like that to our phones

    I was in a conversation with a colleague and a text (identical) came to both of our phones, when he researched it, it said it was blocked and I thought I might see where it came from through my phone. Is it possible to get a spam like that to our phones at the same time.If the text came to my number marked from him, it could only have been from him?. Is there a possibility that someone else sent it to both of us at the same time?

    Yes, it could be spam. I get spam text from time to time. Yes, you both could have gotten the same spam at the same time. Spammers re sending out thousands and thousands of messages.

  • HT3986 I got a plain macbook (not a pro) that I got on 2010 and I've lost the CD's that came with it, can I still download Windows7? If yes, can someone please send me a link where I can get the windows? Thanks

    I got a plain macbook (not a pro) that I got on 2010 and I've lost the CD's that came with it, can I still download Windows7? If yes, can someone please send me a link where I can get the windows? Thanks

    Thanks stevejobsfan0123 for the reply, I know I have to buy a disk but when I searched for it on amazon I read many reviews about saying that either it is inadequate or that it's a scam. Do you know any website where I can get a legitimate disk of windows7?

  • Parse and output XML document while preserving attribute order

    QUESTION: How can I take in an element with attributes from an XML and output the same element and attributes while preserving the order of those attributes?
    The following code will parse and XML document and generate (practically) unchanged output. However, all attributes are ordered a-z
    Example: The following element
    <work_item_type work_item_db_site="0000000000000000" work_item_db_id="0" work_item_type_code="3" user_tag_ident="Step" name="Work Step" gmt_last_updated="2008-12-31T18:00:00.000000000" last_upd_db_site="0000000000000000" last_upd_db_id="0" rstat_type_code="1">
    </work_item_type>is output as:
    <work_item_type gmt_last_updated="2008-12-31T18:00:00.000000000" last_upd_db_id="0" last_upd_db_site="0000000000000000" name="Work Step" rstat_type_code="1" user_tag_ident="Step" work_item_db_id="0" work_item_db_site="0000000000000000" work_item_type_code="3">
    </work_item_type>As you may notice, there is no difference in these besides order of the attributes!
    I am convened that the problem is not in the stylesheet.xslt but if you are not then it is posted bellow.
    Please, someone help me out with this! I have a feeling the solution is simple
    The following take the XML from source.xml and outputs it to DEST_filename with attributes in a-z order
    Code:
    private void OutputFile(String DEST_filename, String style_filename){
         //StreamSource stylesheet = new StreamSource(style_filename);
         try{
              File dest_file = new File(DEST_filename);
              if(!dest_file.exists())
                  dest_file.createNewFile();
              TransformerFactory tranFactory = TransformerFactory.newInstance();
              Transformer aTransformer = tranFactory.newTransformer();
              aTransformer.setOutputProperty(OutputKeys.ENCODING, "UTF-8");
              Source src = new DOMSource("source.xml");
              Result dest = new StreamResult(dest_file);
              aTransformer.transform(src, dest);
              System.out.println("Finished");
         catch(Exception e){
              System.err.print(e);
              System.exit(-1);
        }

    You can't. The reason is, the XML Recommendation explicitly says the order of attributes is not significant. Therefore conforming XML serializers won't treat it as if it were significant.
    If you have an environment where you think that the order of attributes is significant, your first step should be to reconsider. Possibly it isn't really significant and you are over-reaching in some way. Or possibly someone writing requirements is ignorant of this fact and the requirement can be discarded.
    Or possibly your output is being given to somebody else who has a defective parser which expects the attributes to be in a particular order. You could quote the XML Recommendation to those people but often XML bozos are resistant to change. If you're stuck writing for that parser then you'll have to apply some non-XML processing to your output to fix it up on their behalf.

  • Extracting and Loading XML document

    We need to extract and load an XML document into the database
    For e.g.
    <ROW> <EMP_ID>1</EMP_ID> <EMP_NAME>SSK</EMP_NAME>
    <RESUME> Resume of sssk
    </RESUME>
    </ROW>
    We need to load emp_id, emp_name to emp_id, emp_name field in the database and <RESUME> field to a CLOB.
    The table is as follows
    EMP_ID NUMBER
    EMP_NAME VARCHAR2(100)
    RESUME CLOB
    How exactly is this done using the XSU utility? Does it support loading of <RESUME> data in this case to a CLOB.
    Where could I find examples of doing this.
    null

    The "first child" of most of your elements is a white-space node containing a newline character. Your code incorrectly assumes it is an element node.

  • Difference between SDO and a xml document

    Hello,
    I want to know what is the exact difference between a SDO and XML document.According to my understanding, SDO defines a Java binding framework of its own. XML is a kind of data being bound to SDO.
    SDO can be represented as XML.
    But what is the difference between a normal XML document and a XML representing a SDO ?
    How can we say by looking at a XML doc that it is a representation of a SDO and not JUST ANY xml doc?
    Please clarify.
    Thanks
    Nutan

    Let's see.
    Facelets creates a facelets page
    JSP creates a JSP page
    {noformat}:){noformat}
    Facelets is the "official" view language for JSF 2.0
    http://www.realdevelopers.com/blog/development/facelets-vs-jsp should give you some more insight as well.
    John

Maybe you are looking for

  • 4.1.1 SDK Problems with missing xpacket tags in sidecar XMP files

    The current 4.1.1 SDK has problems with sidecar XMP files that don't have the xpacket headers and trailers, i.e: <?xpacket begin='' id='W5M0MpCehiHzreSzNTczkc9d'?> <?xpacket end='w'?> is missing. Now, unfortunately Adobe Bridge CS2/CS3 does not ex

  • Problem with an empty collection

    When a procedure executes FOR i IN g_tabla_situacion.FIRST..g_tabla_situacion.LAST LOOP END LOOP; and g_tabla_situacion has no elements, ORACLE returns a "*-6502:ORA-06502: PL/SQL: numeric or value error*" How can I avoid this problem? Now I am doing

  • DVI to HDMI

    Got a great picture on my Samsung 37" LCD using the above cable and configuration. But NO SOUND. Is anyone familiar with this problem and have the answer. I tried several settings changes, but to know avail. Thanks IKH

  • Flex char 100% with negative values.

    Hello. I have in my app a chart (cartessianchart) with a columnset of 100% columseries. All is fine until negative values appear in the series. For those negative values, the representation dissapears. I have ported my app to use "stacked" series ins

  • Creating OM Infotypes

    I am trying to create a new custom OM Infotype, the T77* entries are not creating automatically as they should. Also screens 2000 and 3000 are not creating, could this be stopping the table entries from creating? Any help would be appreciated.