Java Code Examples for javax.xml.bind.JAXBException#printStackTrace()
The following examples show how to use
javax.xml.bind.JAXBException#printStackTrace() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: MetainformationEditor.java From slr-toolkit with Eclipse Public License 1.0 | 6 votes |
/** * Initializes the editor's form fields. Unmarshalls XML object to * metainformation object and sets both path and object in the plugin's * singleton. */ public void initFormFields() { try { File file = new File(activeFilePath.toOSString()); metainformation = MetainformationUtil.getMetainformationFromFile(file); MetainformationActivator.setMetainformation(metainformation); MetainformationActivator.setCurrentFilepath(activeFilePath.toOSString()); textboxTitle.setText(metainformation.getTitle()); textboxKeywords.setText(metainformation.getKeywords()); textboxDescriptionTaxonomy.setText(metainformation.getTaxonomyDescription()); textboxAbstract.setText(metainformation.getProjectAbstract()); textboxFile.setText(activeFilePath.toOSString()); initializeKeyStatistics(); redrawAuthorsList(); } catch (JAXBException e) { e.printStackTrace(); } }
Example 2
Source File: Users.java From authy-java with MIT License | 6 votes |
public String toXML() { StringWriter sw = new StringWriter(); String xml = ""; try { JAXBContext context = JAXBContext.newInstance(this.getClass()); Marshaller marshaller = context.createMarshaller(); marshaller.marshal(this, sw); xml = sw.toString(); } catch (JAXBException e) { e.printStackTrace(); } return xml; }
Example 3
Source File: MainFrame.java From gpx-animator with Apache License 2.0 | 6 votes |
private void loadDefaults() { file = null; // NOPMD -- Loading defaults = resetting everything means unsetting the filename, too setChanged(false); if (defaultConfigFile == null || !defaultConfigFile.exists()) { setConfiguration(Configuration.createBuilder().build()); return; } try { final JAXBContext jaxbContext = JAXBContext.newInstance(Configuration.class); final Unmarshaller unmarshaller = jaxbContext.createUnmarshaller(); unmarshaller.setAdapter(new FileXmlAdapter(null)); setConfiguration((Configuration) unmarshaller.unmarshal(defaultConfigFile)); } catch (final JAXBException e1) { e1.printStackTrace(); JOptionPane.showMessageDialog(MainFrame.this, String.format(resourceBundle.getString("ui.mainframe.dialog.message.loaddefault.error"), e1.getMessage()), errorTitle, JOptionPane.ERROR_MESSAGE); } }
Example 4
Source File: JAXBContextCache.java From cxf with Apache License 2.0 | 6 votes |
private static boolean addJaxbObjectFactory(JAXBException e1, Set<Class<?>> classes) { boolean added = false; java.io.ByteArrayOutputStream bout = new java.io.ByteArrayOutputStream(); java.io.PrintStream pout = new java.io.PrintStream(bout); e1.printStackTrace(pout); String str = new String(bout.toByteArray()); Pattern pattern = Pattern.compile("(?<=There's\\sno\\sObjectFactory\\swith\\san\\s" + "@XmlElementDecl\\sfor\\sthe\\selement\\s\\{)\\S*(?=\\})"); java.util.regex.Matcher matcher = pattern.matcher(str); while (matcher.find()) { String pkgName = JAXBUtils.namespaceURIToPackage(matcher.group()); try { Class<?> clz = JAXBContextCache.class.getClassLoader() .loadClass(pkgName + "." + "ObjectFactory"); if (!classes.contains(clz)) { classes.add(clz); added = true; } } catch (ClassNotFoundException e) { // do nothing } } return added; }
Example 5
Source File: Solution.java From JavaRushTasks with MIT License | 6 votes |
public static String toXmlWithComment(Object obj, String tagName, String comment) { StringWriter writer = new StringWriter(); String res = null; try { JAXBContext context = JAXBContext.newInstance(obj.getClass()); Marshaller marshaller = context.createMarshaller(); marshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, Boolean.TRUE); marshaller.marshal(obj, writer); String xml = writer.toString(); if (xml.indexOf(tagName) > -1) res = xml.replace("<" + tagName + ">", "<!--" + comment + "-->\n" + "<" + tagName + ">"); else res = xml; } catch (JAXBException e) { e.printStackTrace(); } return res; }
Example 6
Source File: InitialContextInfoTest.java From juddi with Apache License 2.0 | 6 votes |
@Test public void initialContextInfo_XML2JAVA() { try { String INITIAL_CONTEXT_XML = "<initialContextInfo>" + "<contextProperty value=\"value1\" name=\"name1\"/>" + "<contextProperty value=\"value2\" name=\"name2\"/>" + "</initialContextInfo>"; StringReader reader = new StringReader(INITIAL_CONTEXT_XML); JAXBContext jc = JAXBContext.newInstance(InitialContextInfo.class); Unmarshaller um = jc.createUnmarshaller(); InitialContextInfo icInfo = (InitialContextInfo) um.unmarshal(new StreamSource(reader), InitialContextInfo.class).getValue(); assertEquals("name1", icInfo.getContextProperty().get(0).getName()); assertEquals("name2", icInfo.getContextProperty().get(1).getName()); assertEquals("value2", icInfo.getContextProperty().get(1).getValue()); } catch (JAXBException jaxbe) { jaxbe.printStackTrace(); fail("No exception should be thrown"); } }
Example 7
Source File: ReportBuilderService.java From axelor-open-suite with GNU Affero General Public License v3.0 | 6 votes |
/** * Process panelRelated to find right grid view of reference model. Grid view used to create html * table. * * @param panelRelated PanelRelated to use. * @param refModel Name of model refer by panelRelated. * @return Html table string created. */ private String createTable(PanelRelated panelRelated, String refModel) { List<AbstractWidget> items = panelRelated.getItems(); if (items != null && !items.isEmpty()) { return getHtmlTable(panelRelated.getName(), items, refModel); } MetaView gridView = findGridView(panelRelated.getGridView(), refModel); if (gridView != null) { try { ObjectViews views = XMLViews.fromXML(gridView.getXml()); GridView grid = (GridView) views.getViews().get(0); return getHtmlTable(panelRelated.getName(), grid.getItems(), refModel); } catch (JAXBException e) { e.printStackTrace(); } } return ""; }
Example 8
Source File: JaxbParser.java From tutorials with MIT License | 6 votes |
public void createNewDocument() { Tutorials tutorials = new Tutorials(); tutorials.setTutorial(new ArrayList<Tutorial>()); Tutorial tut = new Tutorial(); tut.setTutId("01"); tut.setType("XML"); tut.setTitle("XML with Jaxb"); tut.setDescription("XML Binding with Jaxb"); tut.setDate("04/02/2015"); tut.setAuthor("Jaxb author"); tutorials.getTutorial().add(tut); try { JAXBContext jaxbContext = JAXBContext.newInstance(Tutorials.class); Marshaller jaxbMarshaller = jaxbContext.createMarshaller(); jaxbMarshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, true); jaxbMarshaller.marshal(tutorials, file); } catch (JAXBException e) { e.printStackTrace(); } }
Example 9
Source File: XMLSerializer.java From container with Apache License 2.0 | 6 votes |
/** * {@inheritDoc} */ @Override public Object unmarshal(final Node nodeToUnmarshal, final Class<?> destinationClazz) { this.LOG.trace("Start the unmarshalling of the node: " + nodeToUnmarshal.toString() + " to clazz: " + destinationClazz.toString()); try { final Unmarshaller u = JAXBSupport.createUnmarshaller(); final JAXBElement<?> jaxbElement = u.unmarshal(nodeToUnmarshal, destinationClazz); if (jaxbElement != null) { return jaxbElement.getValue(); } } catch (final JAXBException e) { e.printStackTrace(); } finally { this.printErrorsWhileSerialization(); } return null; }
Example 10
Source File: DataForASchool.java From secure-data-service with Apache License 2.0 | 6 votes |
public void printOnScreen() throws Exception { try { printInterchangeEducationOrganization(System.out); printInterchangeMasterSchedule(System.out); printInterchangeAssessmentMetadata(System.out); printInterchangeStaffAssociation(System.out); printInterchangeStudentParent(System.out); printInterchangeStudentAssessment(System.out); printInterchangeEducationOrgCalendar(System.out); printInterchangeStudentEnrollment(System.out); printInterchangeStudentGrade(System.out); printInterchangeStudentProgram(System.out); printInterchangeStudentCohort(System.out); printInterchangeStudentDiscipline(System.out); printInterchangeStudentAttendance(System.out); } catch (JAXBException e) { // TODO Auto-generated catch block e.printStackTrace(); } }
Example 11
Source File: ODEEndpointUpdater.java From container with Apache License 2.0 | 6 votes |
/** * Returns PortType of the bpel process composed of the given files list * * @param planContents List of Files which make up the BPEL Process * @return QName which should be exactly the PortType of the given BPEL Process */ public QName getPortType(final List<File> planContents) { try { final File deployXML = getDeployXML(planContents); final JAXBContext context = JAXBContext.newInstance("org.apache.ode.schemas.dd._2007._03", this.getClass().getClassLoader()); final Unmarshaller unmarshaller = context.createUnmarshaller(); final TDeployment deploy = unmarshaller.unmarshal(new StreamSource(deployXML), TDeployment.class).getValue(); for (final TDeployment.Process process : deploy.getProcess()) { return process.getName(); } } catch (final JAXBException e) { e.printStackTrace(); } return null; }
Example 12
Source File: ExtractTagsFromDataset.java From TranskribusCore with GNU General Public License v3.0 | 5 votes |
public static void main(String[] args) { try { extractTags(); } catch (JAXBException e) { // TODO Auto-generated catch block e.printStackTrace(); } }
Example 13
Source File: GetPublisherDetailTest.java From juddi with Apache License 2.0 | 5 votes |
/** * Testing going from object to XML using JAXB using a XML Fragment. */ @Test public void marshall() { try { JAXBContext jaxbContext=JAXBContext.newInstance("org.apache.juddi.api_v3"); Marshaller marshaller = jaxbContext.createMarshaller(); marshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, Boolean.TRUE); marshaller.setProperty(Marshaller.JAXB_FRAGMENT, Boolean.TRUE); marshaller.setProperty(Marshaller.JAXB_ENCODING, "UTF-8"); ObjectFactory factory = new ObjectFactory(); GetPublisherDetail getPublisherDetail = new GetPublisherDetail(); getPublisherDetail.authInfo = "some token"; StringWriter writer = new StringWriter(); JAXBElement<GetPublisherDetail> element = new JAXBElement<GetPublisherDetail>(new QName("","fragment"),GetPublisherDetail.class,getPublisherDetail); marshaller.marshal(element,writer); String actualXml=writer.toString(); System.out.println(actualXml); } catch (JAXBException jaxbe) { jaxbe.printStackTrace(); fail("No exception should be thrown"); } }
Example 14
Source File: SchemaInfoCollectionTests.java From elastic-db-tools-for-java with MIT License | 5 votes |
private SchemaInfo fromXml(String schemaInfo) { try (StringReader sr = new StringReader(schemaInfo)) { Unmarshaller unmarshaller = jaxbContext.createUnmarshaller(); return (SchemaInfo) unmarshaller.unmarshal(sr); } catch (JAXBException e) { e.printStackTrace(); } return null; }
Example 15
Source File: JAXBTool.java From maintain with MIT License | 5 votes |
public static <T> T getXmlObject(Class<T> clazz, InputStream in) { try { JAXBContext jc = JAXBContext.newInstance(clazz); Unmarshaller u = jc.createUnmarshaller(); return (T) u.unmarshal(in); } catch (JAXBException e) { e.printStackTrace(); return null; } }
Example 16
Source File: MessageBodyReaderWriter.java From maven-framework-project with MIT License | 5 votes |
public Coffee readFrom(Class<Coffee> coffeeClass, java.lang.reflect.Type type, Annotation[] annotations, MediaType mediaType, MultivaluedMap<String, String> stringStringMultivaluedMap, InputStream inputStream) throws IOException, WebApplicationException { try { JAXBContext jaxbContext = JAXBContext.newInstance(Coffee.class.getPackage().getName()); Unmarshaller unmarshaller = jaxbContext.createUnmarshaller(); Coffee coffee = (Coffee) unmarshaller.unmarshal(inputStream); return coffee; } catch (JAXBException e) { e.printStackTrace(); } return null; }
Example 17
Source File: JAXBGeomTest.java From toxiclibs with GNU Lesser General Public License v2.1 | 5 votes |
private static void save() { try { JAXBGeomTest test = new JAXBGeomTest(); test.box = new AABB(); test.plane = new Plane(); test.quat = new Quaternion(0, Vec3D.X_AXIS); test.ray = new Ray3D(); test.rect = new Rect(0, 0, 100, 200); test.sphere = new Sphere(); test.tri = new Triangle3D(new Vec3D(), new Vec3D(), new Vec3D()); List<Vec2D> points2d = new ArrayList<Vec2D>(); points2d.add(new Vec2D()); points2d.add(new Vec2D()); points2d.add(new Vec2D()); points2d.add(new Vec2D()); test.spline2d = new Spline2D(points2d); List<Vec3D> points = new ArrayList<Vec3D>(); points.add(new Vec3D()); points.add(new Vec3D()); points.add(new Vec3D()); points.add(new Vec3D()); test.spline3d = new Spline3D(points); JAXBContext context = JAXBContext.newInstance(JAXBGeomTest.class); File file = new File(XML_FILE); context.createMarshaller().marshal(test, file); } catch (JAXBException e) { e.printStackTrace(); } }
Example 18
Source File: InitialConfigurator.java From NMapGUI with GNU General Public License v3.0 | 5 votes |
public void configure(){ try { loadMenu(); } catch (JAXBException e) { // TODO Auto-generated catch block e.printStackTrace(); } Command command = new Command("--script-help all"); CommandExecutor executor = new CommandExecutorImpl(command); executor.addObserver(this); executor.execute(); }
Example 19
Source File: RSSFeed.java From toxiclibs with GNU Lesser General Public License v2.1 | 5 votes |
public static RSSFeed newFromStream(InputStream stream) { RSSFeed feed = null; try { JAXBContext context = JAXBContext.newInstance(RSSFeed.class); feed = (RSSFeed) context.createUnmarshaller().unmarshal(stream); } catch (JAXBException e) { e.printStackTrace(); } return feed; }
Example 20
Source File: WSDiscoveryServiceImpl.java From cxf with Apache License 2.0 | 5 votes |
WSDiscoveryProvider() { try { context = JAXBContextCache.getCachedContextAndSchemas(ObjectFactory.class).getContext(); } catch (JAXBException e) { e.printStackTrace(); } }