I am getting the following compilation error in eclipse when trying to instantiate an ObjectFactory:
cannot instantiate the type objectfactory
This compilation error is thrown at the following line:
objectFactory = new ObjectFactory();//throws error: "Cannot instantiate the type ObjectFactory"
The complete code for the calling class is as follows:
package maintest;
import java.io.File;
import javax.naming.spi.ObjectFactory;
import javax.xml.bind.JAXBContext;
import javax.xml.bind.JAXBElement;
import javax.xml.bind.JAXBException;
import javax.xml.bind.Unmarshaller;
public class Main {
private static JAXBContext context;
private static ObjectFactory objectFactory;
public static void main(String[] args) {
try {setUp();} catch (Exception e) {e.printStackTrace();}
unmarshal();
}
protected static void setUp() throws Exception {
context = JAXBContext.newInstance("generated");
objectFactory = new ObjectFactory();//throws error: "Cannot instantiate the type ObjectFactory"
}
public static <PurchaseOrderType> void unmarshal(){
Unmarshaller unmarshaller;
try {
unmarshaller = context.createUnmarshaller();
final Object object = unmarshaller.unmarshal(new File("src/test/samples/po.xml"));
} catch (JAXBException e) {e.printStackTrace();}
}
}
How can I resolve this error?