Java 8 JAXBException - top ranked examples from Open Source projects

These code examples were ranked by Codota’s semantic indexing as the best open source examples for Java 8 JAXBException class.

This code example shows how to use the following methods:getMessage
			try { 
				jaxbContext = JAXBContext.newInstance(clazz);
				this.jaxbContexts.putIfAbsent(clazz, jaxbContext);
			} 
			catch (JAXBException ex) {
				throw new HttpMessageConversionException(
						"Could not instantiate JAXBContext for class [" + clazz + "]: " + ex.getMessage(), ex);
			} 
		} 
		return jaxbContext;
	} 
 
} 
7
CodeRank
This code example shows how to use the following methods:getMessage
         coreJaxbContext = JAXBContext.newInstance(
                 org.openstack.docs.identity.api.v2.ObjectFactory.class, 
                 com.rackspace.docs.identity.api.ext.rax_auth.v1.ObjectFactory.class); 
         groupJaxbContext = JAXBContext.newInstance(com.rackspace.docs.identity.api.ext.rax_ksgrp.v1.ObjectFactory.class);
      } catch (JAXBException e) {
         LOG.error("Problem creating the jaxb context for the OpenStack Auth objects.", e);
         throw new AuthServiceException("Possible deployment problem! Unable to build JAXB Context for OpenStack Auth schema types. Reason: " 
                 + e.getMessage(), e);
      } 
 
      return new AuthenticationServiceClient(targetHostUri, username, password, tenantId,
              new ResponseUnmarshaller(coreJaxbContext),
              new ResponseUnmarshaller(groupJaxbContext),
              new JaxbEntityToXml(coreJaxbContext),
              akkaServiceClient);
   } 
} 
6
CodeRank
This code example shows how to use the following methods:getMessage, printStackTrace
			String xml = getStringFromDocument(doc);
			if (network) { // so stupid !! TODO eli - find a proper way to deal
							// with different name spaces under the space 
							// JAXBContext instance. 
							// i cant seem to find the azure xsd anywhere so 
							// that i can generate proper model object using 
							// xjc. 
				xml = addNameSpaceToRootElement(xml,
						"xmlns=\"http://schemas.microsoft.com/ServiceHosting/2011/07/NetworkConfiguration\""); 
			} else { 
				xml = addNameSpaceToRootElement(xml, "xmlns=\"http://schemas.microsoft.com/windowsazure\"");
                xml = addNameSpaceToRootElement(xml, "xmlns:i=\"http://www.w3.org/2001/XMLSchema-instance\"");
			} 
			return xml;
		} catch (JAXBException e) {
			throw new MicrosoftAzureException(e);
		} 
	} 
 
	/** 

6
CodeRank
This code example shows how to use the following methods:getMessage
		} 
		catch (UnmarshalException ex) {
			throw new HttpMessageNotReadableException("Could not unmarshal to [" + clazz + "]: " + ex.getMessage(), ex);
		} 
		catch (JAXBException ex) {
			throw new HttpMessageConversionException("Could not instantiate JAXBContext: " + ex.getMessage(), ex);
		} 
	} 
 
	@Override 
	protected final void writeToResult(E accessToken, HttpHeaders headers, Result result) throws IOException {
		I convertedAccessToken = convertToInternal(accessToken);
		try { 
			createMarshaller().marshal(convertedAccessToken, result);
		} 
		catch (MarshalException ex) {
			throw new HttpMessageNotWritableException("Could not marshal [" + accessToken + "]: " + ex.getMessage(), ex);
		} 
		catch (JAXBException ex) {
			throw new HttpMessageConversionException("Could not instantiate JAXBContext: " + ex.getMessage(), ex);
6
CodeRank
This code example shows how to use the following methods:getMessage
                    this.classLoader);
            if (getValidationEventHandler() != null) { 
                try { 
                    u.setEventHandler(getValidationEventHandler()); 
                } catch (JAXBException e) {
                    Context.getCurrentLogger().log(Level.WARNING,
                            "Unable to set the event handler", e);
                    throw new IOException("Unable to set the event handler."
                            + e.getMessage());
                } 
            } 
 
            try { 
                this.object = (T) u.unmarshal(this,
                        this.xmlRepresentation.getReader());
            } catch (JAXBException e) {
                Context.getCurrentLogger().log(Level.WARNING,
                        "Unable to unmarshal the XML representation", e);
                throw new IOException(
                        "Unable to unmarshal the XML representation." 

6
CodeRank
This code example shows how to use the following methods:getMessage, printStackTrace
	public static synchronized JAXBContext createInstance() {
		JAXBContext context = null;
		try { 
			context = JAXBContext.newInstance(getClasses());				
		} catch (JAXBException e) {
			e.printStackTrace();
			throw new RuntimeException("Could not create JAXBContext : " + e.getMessage());
		} 
		return context;
	} 
} 
6
CodeRank
This code example shows how to use the following methods:getMessage
	public void updateJaxbElementFromDocument() { 
		 
		try { 
			this.unmarshal(doc.getDocumentElement() );
		} catch (JAXBException e) {
			log.error(e.getMessage(), e);
		} 
	} 
	 
	 
	private NamespacePrefixMappings nsContext;
	private NamespacePrefixMappings getNamespaceContext() { 
		if (nsContext==null) {
			nsContext = new NamespacePrefixMappings();
			xPath.setNamespaceContext(nsContext);
		} 
		return nsContext;
	} 
	 
	public String xpathGetString(String xpathString, String prefixMappings)  throws Docx4JException {
6
CodeRank
This code example shows how to use the following methods:getMessage
        if (jaxbContext == null) {
            try { 
                jaxbContext = JAXBContext.newInstance(clazz);
                jaxbContexts.putIfAbsent(clazz, jaxbContext);
            } catch (JAXBException ex) {
                throw new HttpMessageConversionException(
                        "Could not instantiate JAXBContext for class [" + clazz + "]: " + ex.getMessage(), ex);
            } 
        } 
        return jaxbContext;
    } 
 
 
} 
 
6
CodeRank
This code example shows how to use the following methods:getMessage
            javax.xml.bind.Marshaller marshaller = jaxbContext.createMarshaller();
            marshaller.setProperty(javax.xml.bind.Marshaller.JAXB_SCHEMA_LOCATION, HTTPX_SCHEMA_LOCATION);
 
            marshaller.marshal(getObjectFactory().createHttpx(messageEnvelope), outputStream);
        } catch (JAXBException e) {
            throw new MarshallerException("An exception occurred when attempting to marshal the http message envelope. Reason: " + e.getMessage(), e);
        } 
 
        return new ByteArrayInputStream(outputStream.toByteArray());
    } 
} 
6
CodeRank
This code example shows how to use the following methods:
    public static class WhenUsingUnmarshallerConstructionStrategy { 
 
        @Test(expected = ResourceConstructionException.class)
        public void testMakeObject() throws Exception {
            JAXBContext jaxbContext = mock(JAXBContext.class);
            when(jaxbContext.createUnmarshaller()).thenThrow(new JAXBException("mock jaxb exception"));
                         
            PoolableObjectFactory<UnmarshallerValidator> poolableObjectFactory = new UnmarshallerPoolableObjectFactory(jaxbContext);
 
            poolableObjectFactory.makeObject();
        } 
    } 
} 
5
CodeRank
This code example shows how to use the following methods:getMessage
            try { 
                pooledObject.marshal(source, target);
            } catch (JAXBException jaxbe) {
                objectPool.invalidateObject(pooledObject);
                pooledObject = null;
                throw new ResourceContextException(jaxbe.getMessage(), jaxbe);
            } catch (Exception e) {
                objectPool.invalidateObject(pooledObject);
                pooledObject = null;
                LOG.error("Failed to utilize the Marshaller. Reason: {}", e.getLocalizedMessage());
                LOG.trace("", e);
            } finally { 
                if (pooledObject != null) {
                    objectPool.returnObject(pooledObject);
                } 
            } 
        } catch (ResourceContextException e) {
            throw e;
        } catch (Exception e) {
            LOG.error("Failed to obtain a Marshaller. Reason: {}", e.getLocalizedMessage());
6
CodeRank
This code example shows how to use the following methods:getMessage
            try { 
                rtn = (JAXBElement<T>) pooledObject.unmarshal(source);
            } catch (JAXBException jbe) {
                objectPool.invalidateObject(pooledObject);
                pooledObject = null;
                throw new ResourceContextException(jbe.getMessage(), jbe);
            } catch (Exception e) {
                objectPool.invalidateObject(pooledObject);
                pooledObject = null;
                LOG.error("Failed to utilize the Marshaller. Reason: {}", e.getLocalizedMessage());
                LOG.trace("", e);
            } finally { 
                if (pooledObject != null) {
                    objectPool.returnObject(pooledObject);
                } 
            } 
        } catch (ResourceContextException e) {
            throw e;
        } catch (Exception e) {
            LOG.error("Failed to obtain a Marshaller. Reason: {}", e.getLocalizedMessage());
6
CodeRank
This code example shows how to use the following methods:
            assertNotNull(jaxbTransform.getMarshallerPool());
        } 
 
        @Test(expected=ResourceConstructionException.class)
        public void shouldThrowExceptionIfCanNotCreateMarshallerPool() throws Exception {
            when(jaxbContext.createMarshaller()).thenThrow(new JAXBException("test"));
 
            jaxbTransform.getMarshallerPool().borrowObject();
        } 
 
        @Test
        public void shouldReturnNonNullForUnmarshallerPool() { 
            assertNotNull(jaxbTransform.getUnmarshallerPool());
        } 
 
        @Test(expected=ResourceConstructionException.class)
        public void shouldThrowExceptionIfCanNotCreateUnmarshallerPool() throws Exception {
            when(jaxbContext.createUnmarshaller()).thenThrow(new JAXBException("test"));
 
            jaxbTransform.getUnmarshallerPool().borrowObject();
5
CodeRank
This code example shows how to use the following methods:getMessage
            } 
            return uv;
        } catch (ParserConfigurationException pce) {
            throw new ResourceConstructionException("Failed to configure DOM parser. Reason: " + pce.getMessage(), pce);
        } catch (JAXBException jaxbe) {
            throw new ResourceConstructionException("Failed to construct JAXB unmarshaller. Reason: " + jaxbe.getMessage(), jaxbe);
        } catch (SAXException ex) {
            LOG.error("Error validating XML file", ex);
        } 
        return null; 
    } 
} 
6
CodeRank
This code example shows how to use the following methods:getMessage
 
        Object myJaxbObject = null; 
        try { 
            myJaxbObject = unmarshaller.unmarshal(source);
        } catch (JAXBException ex) {
            LOG.error("Unable to read message body stream. Reason: " + ex.getMessage(), ex);
        } 
 
        return CredentialFactory.getCredentials((JAXBElement<?>) myJaxbObject);
    } 
 
    @Override 
    public AuthCredentials parse(String content) {
        Charset CHAR_SET = Charset.forName("UTF-8");
        return this.parse(new ByteArrayInputStream(content.getBytes(CHAR_SET)));
    } 
} 
6
CodeRank
This code example shows how to use the following methods:getMessage
        try { 
            JAXBContext jaxbContext = JAXBContext.newInstance(org.openstack.docs.identity.api.v2.ObjectFactory.class,
                    com.rackspace.docs.identity.api.ext.rax_kskey.v1.ObjectFactory.class); 
            unmarshaller = jaxbContext.createUnmarshaller();
        } catch (JAXBException e) {
            LOG.error("Error when creating JABXContext for auth credentials. Reason: " + e.getMessage(), e);
        } 
    } 
 
    @Override 
    protected Map<Class, UpdateListener<?>> getListeners() {
        return new HashMap<Class, UpdateListener<?>>() {
            { 
                put(ContentIdentityAuthConfig.class, new ContentIdentityAuthConfigurationListener());
            } 
        }; 
    } 
 
    private class ContentIdentityAuthConfigurationListener implements UpdateListener<ContentIdentityAuthConfig> { 
 
6
CodeRank
This code example shows how to use the following methods:getMessage
				} 
			} 
			return jaxbElement; 
			 
		} catch (JAXBException e) {
			log.error(e.getMessage(), e);
			throw e;
		} 
	}	 
     
    NotesSlidePart notes;
    SlideLayoutPart layout;
    CommentsPart comments;
     
	public boolean setPartShortcut(Part part) {
		 
		if (part == null ){
			return false; 
		} else { 
			return setPartShortcut(part, part.getRelationshipType() );
6
CodeRank
This code example shows how to use the following methods:getMessage
				} else { 
					log.info("Lazily unmarshalling " + name);
					unmarshal( is );
				} 
			} catch (JAXBException e) {
				throw new Docx4JException(e.getMessage(), e);
//			} catch (Docx4JException e) { 
//				log.error(e.getMessage(), e); 
			} finally { 
				IOUtils.closeQuietly(is);
			}			 
		} 
		return jaxbElement;
	} 
	 
	/** 
	 * Get the live contents of this part. 
	 * (getContents() is preferred, this is the older/less friendly method name) 
	 * @return 
	 */ 

5
CodeRank
This code example shows how to use the following methods:getMessage
				} 
			} 
			return jaxbElement; 
			 
		} catch (JAXBException e) {
			log.error(e.getMessage(), e);
			throw e;
		} 
	} 
 
	 
//	private String toString(ByteBuffer bb) throws UnsupportedEncodingException { 
// 
//		byte[] bytes = null; 
//        bytes = new byte[bb.limit()]; 
//        bb.get(bytes);	        				 
//		return new String(bytes, "UTF-8"); 
//	} 
	 
} 
6
CodeRank
This code example shows how to use the following methods:getMessage
 
    private void initialize(Class<?> [] jaxbClasses) {
        try { 
            this.jaxbContext = JAXBContext.newInstance(jaxbClasses);
        } catch (JAXBException jaxbe) {
            throw new SerializationException("Unsupported JAXB Class encountered during initialization: " + jaxbe.getMessage(), jaxbe);
        } 
    } 
    
    /* (non-Javadoc) 
     * @see org.kie.services.client.serialization.JaxbSerializationProvider#dispose() 
     */ 
    @Override 
    public void dispose() {  
       if( this.extraJaxbClasses != null ) { 
           this.extraJaxbClasses.clear();
           this.extraJaxbClasses = null;
       } 
       if( this.jaxbContext != null ) { 
           this.jaxbContext = null;
6
CodeRank
This code example shows how to use the following methods:getMessage
This code example shows how to use the following methods:getMessage
 
    private void initialize(Class<?> [] jaxbClasses) {
        try { 
            this.jaxbContext = JAXBContext.newInstance(jaxbClasses);
        } catch (JAXBException jaxbe) {
            throw new SerializationException("Unsupported JAXB Class encountered during initialization: " + jaxbe.getMessage(), jaxbe);
        } 
    } 
    
    /* (non-Javadoc) 
     * @see org.kie.services.client.serialization.JaxbSerializationProvider#dispose() 
     */ 
    @Override 
    public void dispose() {  
       if( this.extraJaxbClasses != null ) { 
           this.extraJaxbClasses.clear();
           this.extraJaxbClasses = null;
       } 
       if( this.jaxbContext != null ) { 
           this.jaxbContext = null;
6
CodeRank
This code example shows how to use the following methods:getMessage
This code example shows how to use the following methods:getMessage
        } catch (MalformedURLException e) {
            // TODO: Display the error in the UI 
            LoggerFactory.getLogger(this.getClass()).error(e.getMessage(), e);
        } catch (JAXBException e) {
            // TODO: Display the error in the UI 
            LoggerFactory.getLogger(this.getClass()).error(e.getMessage(), e);
        } 
        return null; 
    } 
 
    @Override 
    public boolean display(List<VertexRef> targets, OperationContext operationContext) {
        return true; 
    } 
 
    @Override 
    public boolean enabled(List<VertexRef> targets, OperationContext operationContext) {
        return true; 
    } 
 
5
CodeRank
This code example shows how to use the following methods:getMessage
        try { 
            Unmarshaller unmarshaller = context.createUnmarshaller();
            FilterSpec spec = (FilterSpec) unmarshaller.unmarshal(in);
            return spec.getFilter();
        } catch (JAXBException e) {
            log.error(e);
            throw new RuntimeException(e.getMessage(), e);
        } 
    } 
 
    /** 
     * {@inheritDoc} 
     */ 
    @Override 
    public void saveFilter(FilterImpl filter, OutputStream output) {
        OutputStream out = null;
        try { 
            Marshaller m = context.createMarshaller();
            m.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, Boolean.TRUE);
            out = new BufferedOutputStream(output);
5
CodeRank
This code example shows how to use the following methods:getMessage
        try { 
            Unmarshaller unmarshaller = context.createUnmarshaller();
            ContainerSignatureDefinitions definitions = (ContainerSignatureDefinitions) unmarshaller.unmarshal(in);
            return definitions;
        } catch (JAXBException e) {
            throw new SignatureParseException(e.getMessage(), e);
        } 
    } 
 
} 
5
CodeRank
This code example shows how to use the following methods:getMessage
                    result = JAXBContext.newInstance(clazz);
                    jaxbContexts.putIfAbsent(clazz, result);
                } 
                catch (JAXBException ex)
                { 
                    throw new HttpMessageConversionException("Could not instantiate JAXBContext for class [" + clazz
                            + "]: " + ex.getMessage(), ex);
                } 
            } 
        } 
        return result;
    } 
} 
5
CodeRank
This code example shows how to use the following methods:getMessage, printStackTrace
 
        Marshaller marshaller = XMLSerializationHelper.createMarshaller( IndividualFactory.class.getPackage().getName() );
        try { 
            marshaller.marshal( r1, System.err );
        } catch ( JAXBException e ) {
            e.printStackTrace();
            fail( e.getMessage() );
        } 
    } 
 
    @Test
    public void testPOMOptions() { 
 
        // The extra options in the pom file should add an explicit toString 
        // with more content than the FQN + system hash 
        // so let's check it! 
 
        Rule r1 = (Rule) IndividualFactory.getNamedIndividuals().get( "rule1" );
        assertNotNull( r1 );
 
5
CodeRank
This code example shows how to use the following methods:printStackTrace
        try { 
            Marshaller marshaller = initContext( pmml );
            marshaller.marshal( pmml, out );
            return true; 
        } catch ( JAXBException e ) {
            e.printStackTrace();
        } 
        return false; 
    } 
 
    public static boolean streamPMML( PMML pmml, Writer out ) {
        try { 
            Marshaller marshaller = initContext( pmml );
            marshaller.marshal( pmml, out );
            return true; 
        } catch ( JAXBException e ) {
            e.printStackTrace();
        } 
        return false; 
    } 
5
CodeRank
This code example shows how to use the following methods:
      { 
         throw new JAXBException(e);
      } 
      catch (ParserConfigurationException e)
      { 
         throw new JAXBException(e);
      } 
   } 
 
   public Object unmarshal(Node node) throws JAXBException {
      return delegate.unmarshal(node);
   } 
 
   public Object unmarshal(Source source) throws JAXBException {
      if(source instanceof SAXSource)
      { 
         try 
         { 
            SAXParserFactory spf = SAXParserFactory.newInstance();
            configureParserFactory(spf);
5
CodeRank
See Code Examples for Java 8 JAXBException Methods: