title: Two Element form of Unmarshaller.unmarshal()
body: <p>I have seen the following syntax in various stack overflow postings and in blog entries:  </p>
  
  <pre><code>JAXBElement&lt;SomeClass&gt; sc = unmarshaller.unmarshal(is, SomeClass.class);
  </code></pre>
  
  <p>So why does eclipse give me a compilation error when I try to use this syntax?  And why is this syntax not in the api, which you can read <a href="http://docs.oracle.com/javaee/6/api/javax/xml/bind/Unmarshaller.html" rel="nofollow noreferrer">at this link</a>?  </p>
  
  <p>Here is the compilation error:  </p>
  
  <pre><code>The method unmarshal(Node, Class&lt;T&gt;) in the type Unmarshaller  
  is not applicable for the arguments (FileInputStream, Class&lt;SomeClass&gt;)  
  </code></pre>
  
  <p>Here is a complete method that would use the above syntax:  </p>
  
  <pre><code>public void unmarshal() throws FileNotFoundException{
      Unmarshaller unmarshaller;
      try {
          JAXBContext ctx = JAXBContext.newInstance(ObjectFactory.class);
          unmarshaller = ctx.createUnmarshaller();
          FileInputStream is = new FileInputStream("path/to/some.xml");
          JAXBElement&lt;SomeClass&gt; sc = unmarshaller.unmarshal(is, SomeClass.class);//error here
          System.out.println("title is: "+sc.getValue().getTitle());
      } catch (JAXBException e) {e.printStackTrace();}
  }
  </code></pre>
  
  <p>This syntax is given in examples where a developer needs to unmarshal xml that does not contain a defined root element.  One example is Sayantam's answer <a href="https://stackoverflow.com/questions/819720/no-xmlrootelement-generated-by-jaxb">to this question</a>.</p>