Example usage for java.lang NoSuchMethodError getMessage

List of usage examples for java.lang NoSuchMethodError getMessage

Introduction

In this page you can find the example usage for java.lang NoSuchMethodError getMessage.

Prototype

public String getMessage() 

Source Link

Document

Returns the detail message string of this throwable.

Usage

From source file:com.opensource.frameworks.processframework.utils.DefaultPropertiesPersister.java

public void loadFromXml(Properties props, InputStream is) throws IOException {
    try {/*from   www  . j  av a 2 s .c  o  m*/
        props.loadFromXML(is);
    } catch (NoSuchMethodError err) {
        throw new IOException("Cannot load properties XML file - not running on JDK 1.5+: " + err.getMessage());
    }
}

From source file:com.opensource.frameworks.processframework.utils.DefaultPropertiesPersister.java

public void storeToXml(Properties props, OutputStream os, String header) throws IOException {
    try {//from w  w w.  ja  va  2s.c  o  m
        props.storeToXML(os, header);
    } catch (NoSuchMethodError err) {
        throw new IOException(
                "Cannot store properties XML file - not running on JDK 1.5+: " + err.getMessage());
    }
}

From source file:com.opensource.frameworks.processframework.utils.DefaultPropertiesPersister.java

public void storeToXml(Properties props, OutputStream os, String header, String encoding) throws IOException {
    try {/*w w w  . j  a v  a2 s . c o m*/
        props.storeToXML(os, header, encoding);
    } catch (NoSuchMethodError err) {
        throw new IOException(
                "Cannot store properties XML file - not running on JDK 1.5+: " + err.getMessage());
    }
}

From source file:org.apache.hadoop.hbase.client.TestFastFailWithoutTestUtil.java

@Test
public void testExceptionsIdentifiedByInterceptor() throws IOException {
    Throwable[] networkexceptions = new Throwable[] { new ConnectException("Mary is unwell"),
            new SocketTimeoutException("Mike is too late"), new ClosedChannelException(),
            new SyncFailedException("Dave is not on the same page"), new TimeoutException("Mike is late again"),
            new EOFException("This is the end... "), new ConnectionClosingException("Its closing") };
    final String INDUCED = "Induced";
    Throwable[] nonNetworkExceptions = new Throwable[] { new IOException("Bob died"),
            new RemoteException("Bob's cousin died", null), new NoSuchMethodError(INDUCED),
            new NullPointerException(INDUCED), new DoNotRetryIOException(INDUCED), new Error(INDUCED) };

    Configuration conf = HBaseConfiguration.create();
    long CLEANUP_TIMEOUT = 0;
    long FAST_FAIL_THRESHOLD = 1000000;
    conf.setBoolean(HConstants.HBASE_CLIENT_FAST_FAIL_MODE_ENABLED, true);
    conf.setLong(HConstants.HBASE_CLIENT_FAST_FAIL_CLEANUP_MS_DURATION_MS, CLEANUP_TIMEOUT);
    conf.setLong(HConstants.HBASE_CLIENT_FAST_FAIL_THREASHOLD_MS, FAST_FAIL_THRESHOLD);
    for (Throwable e : networkexceptions) {
        PreemptiveFastFailInterceptor interceptor = TestFastFailWithoutTestUtil
                .createPreemptiveInterceptor(conf);
        FastFailInterceptorContext context = (FastFailInterceptorContext) interceptor.createEmptyContext();

        RetryingCallable<?> callable = getDummyRetryingCallable(getSomeServerName());
        context.prepare(callable, 0);//  w  w  w . jav  a  2s  .c  o m
        interceptor.intercept(context);
        interceptor.handleFailure(context, e);
        interceptor.updateFailureInfo(context);
        assertTrue("The call shouldn't have been successful if there was a ConnectException",
                context.getCouldNotCommunicateWithServer().booleanValue());
    }
    for (Throwable e : nonNetworkExceptions) {
        try {
            PreemptiveFastFailInterceptor interceptor = TestFastFailWithoutTestUtil
                    .createPreemptiveInterceptor(conf);
            FastFailInterceptorContext context = (FastFailInterceptorContext) interceptor.createEmptyContext();

            RetryingCallable<?> callable = getDummyRetryingCallable(getSomeServerName());
            context.prepare(callable, 0);
            interceptor.intercept(context);
            interceptor.handleFailure(context, e);
            interceptor.updateFailureInfo(context);
            assertFalse("The call shouldn't have been successful if there was a ConnectException",
                    context.getCouldNotCommunicateWithServer().booleanValue());
        } catch (NoSuchMethodError t) {
            assertTrue("Exception not induced", t.getMessage().contains(INDUCED));
        } catch (NullPointerException t) {
            assertTrue("Exception not induced", t.getMessage().contains(INDUCED));
        } catch (DoNotRetryIOException t) {
            assertTrue("Exception not induced", t.getMessage().contains(INDUCED));
        } catch (Error t) {
            assertTrue("Exception not induced", t.getMessage().contains(INDUCED));
        }
    }
}

From source file:org.apache.openjpa.meta.MetaDataRepository.java

/**
 * Return the class for the given name, or null if not loadable.
 *//* ww w . j a v  a 2  s .  co m*/
private Class<?> classForName(String name, ClassLoader loader) {
    try {
        return Class.forName(name, true, loader);
    } catch (Exception e) {
        if ((_validate & VALIDATE_RUNTIME) != 0) {
            if (_log.isWarnEnabled())
                _log.warn(_loc.get("bad-discover-class", name, loader));
        } else if (_log.isInfoEnabled())
            _log.info(_loc.get("bad-discover-class", name, loader));
        if (_log.isTraceEnabled())
            _log.trace(e);
    } catch (NoSuchMethodError nsme) {
        if (nsme.getMessage().indexOf(".pc") == -1)
            throw nsme;

        // if the error is about a method that uses the PersistenceCapable
        // 'pc' method prefix, perform some logging and continue. This
        // probably just means that the class is not yet enhanced.
        if ((_validate & VALIDATE_RUNTIME) != 0) {
            if (_log.isWarnEnabled())
                _log.warn(_loc.get("bad-discover-class", name, loader));
        } else if (_log.isInfoEnabled())
            _log.info(_loc.get("bad-discover-class", name, loader));
        if (_log.isTraceEnabled())
            _log.trace(nsme);
    }
    return null;
}

From source file:org.springframework.ws.soap.saaj.SaajSoapMessageFactory.java

public void afterPropertiesSet() {
    if (messageFactory == null) {
        try {/* w  w w .  j  a  v  a 2s . co m*/
            if (SaajUtils.getSaajVersion() >= SaajUtils.SAAJ_13) {
                if (!StringUtils.hasLength(messageFactoryProtocol)) {
                    messageFactoryProtocol = SOAPConstants.SOAP_1_1_PROTOCOL;
                }
                if (logger.isInfoEnabled()) {
                    logger.info("Creating SAAJ 1.3 MessageFactory with " + messageFactoryProtocol);
                }
                messageFactory = MessageFactory.newInstance(messageFactoryProtocol);
            } else if (SaajUtils.getSaajVersion() == SaajUtils.SAAJ_12) {
                logger.info("Creating SAAJ 1.2 MessageFactory");
                messageFactory = MessageFactory.newInstance();
            } else if (SaajUtils.getSaajVersion() == SaajUtils.SAAJ_11) {
                logger.info("Creating SAAJ 1.1 MessageFactory");
                messageFactory = MessageFactory.newInstance();
            } else {
                throw new IllegalStateException(
                        "SaajSoapMessageFactory requires SAAJ 1.1, which was not found on the classpath");
            }
        } catch (NoSuchMethodError ex) {
            throw new SoapMessageCreationException(
                    "Could not create SAAJ MessageFactory. Is the version of the SAAJ specification interfaces ["
                            + SaajUtils.getSaajVersionString()
                            + "] the same as the version supported by the application server?",
                    ex);
        } catch (SOAPException ex) {
            throw new SoapMessageCreationException("Could not create SAAJ MessageFactory: " + ex.getMessage(),
                    ex);
        }
    }
    if (logger.isDebugEnabled()) {
        logger.debug("Using MessageFactory class [" + messageFactory.getClass().getName() + "]");
    }
}