Example usage for java.lang NullPointerException getMessage

List of usage examples for java.lang NullPointerException getMessage

Introduction

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

Prototype

public String getMessage() 

Source Link

Document

Returns the detail message string of this throwable.

Usage

From source file:edu.harvard.mcz.imagecapture.ImageDisplayFrame.java

/**
 * This method initializes jComboBoxImagePicker   
 *    /*from  w  w w  . j  a va  2  s .co m*/
 * @return javax.swing.JComboBox   
 */
private JComboBox getJComboBoxImagePicker() {
    if (jComboBoxImagePicker == null) {
        jComboBoxImagePicker = new JComboBox();
        if (targetSpecimen != null) {
            Iterator<ICImage> i = targetSpecimen.getICImages().iterator();
            while (i.hasNext()) {
                String filename = i.next().getFilename();
                jComboBoxImagePicker.addItem(filename);
                log.debug(filename);
            }
        }
        jComboBoxImagePicker.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent e) {
                // Intended to be fired when picklist item is selected, is
                // being fired on other events as well.
                log.debug(e.getActionCommand());
                // If there is no selection, then we shouldn't be doing anything.
                if (jComboBoxImagePicker.getSelectedItem() == null) {
                    log.debug("No selected item");
                } else {
                    ICImage pattern = new ICImage();
                    try {
                        boolean hasParameter = false;
                        if (jComboBoxImagePicker.getSelectedItem() != null) {
                            pattern.setFilename(jComboBoxImagePicker.getSelectedItem().toString());
                            hasParameter = true;
                            log.debug("Parameter: " + jComboBoxImagePicker.getSelectedItem().toString());
                        }
                        if (targetSpecimen != null) {
                            pattern.setSpecimen(targetSpecimen);
                            hasParameter = true;
                            log.debug("Parameter: " + targetSpecimen.getBarcode());
                        }
                        if (hasParameter) {
                            // find matching images, set first one as the display image.
                            ICImageLifeCycle ils = new ICImageLifeCycle();
                            List<ICImage> images = ils.findByExample(pattern);
                            if (images != null && images.size() > 0) {
                                log.debug("Found: " + images.size());
                                Iterator<ICImage> ii = images.iterator();
                                boolean found = false;
                                while (ii.hasNext() && !found) {
                                    ICImage image = ii.next();
                                    if (image.getSpecimen() != null && !image.getSpecimen().getBarcode()
                                            .equals(targetSpecimen.getBarcode())) {
                                        // same filename, but wrong path.
                                        log.debug("WrongFile: " + image.getPath());
                                    } else {
                                        found = true;
                                        //String startPointName = Singleton.getSingletonInstance().getProperties().getProperties().getProperty(ImageCaptureProperties.KEY_IMAGEBASE);
                                        String path = image.getPath();
                                        if (path == null) {
                                            path = "";
                                        }
                                        File fileToCheck = new File(ImageCaptureProperties
                                                .assemblePathWithBase(path, image.getFilename()));
                                        PositionTemplate defaultTemplate;
                                        try {
                                            defaultTemplate = PositionTemplate.findTemplateForImage(image);
                                            loadImagesFromFileSingle(fileToCheck, defaultTemplate, image);
                                        } catch (ImageLoadException e3) {
                                            log.error(e3);
                                        } catch (BadTemplateException e1) {
                                            log.error(e1);
                                        }
                                    }
                                }
                            }
                        }
                    } catch (NullPointerException e2) {
                        // Probably means an empty jComboBoxImagePicker
                        e2.printStackTrace();
                        log.error(e2.getMessage(), e2);
                    }
                }
            }
        });
    }
    return jComboBoxImagePicker;
}

From source file:org.royaldev.royalcommands.RoyalCommands.java

/**
 * Registers a command in the server. If the command isn't defined in plugin.yml
 * the NPE is caught, and a warning line is sent to the console.
 *
 * @param ce      CommandExecutor to be registered
 * @param command Command name as specified in plugin.yml
 * @param jp      Plugin to register under
 *///from  w w w.  j a  va 2s  .  c  o  m
private void registerCommand(CommandExecutor ce, String command, JavaPlugin jp) {
    if (RoyalCommands.disabledCommands.contains(command.toLowerCase()))
        return;
    try {
        jp.getCommand(command).setExecutor(ce);
    } catch (NullPointerException e) {
        getLogger().warning("Could not register command \"" + command + "\" - not registered in plugin.yml ("
                + e.getMessage() + ")");
    }
}

From source file:org.gbif.harvest.digir.DigirMetadataHandler.java

/**
 * Determine the protocol.//from w w  w .  j  a  v a2 s  .c  o  m
 * If there is a problem loading the file, or no match exists for the
 * contentNamespace, the default is used.
 *
 * @param contentNamespace contentNamespace
 *
 * @return protocol name
 *
 * @throws HarvesterException thrown if method fails
 */
private String getProtocol(String contentNamespace) throws HarvesterException {

    // Initially, set the protocol to the default
    String protocol = DEFAULT_PROTOCOL;

    Properties mapping = new Properties();
    String mappingFilePath = fileUtils.constructMappingFilePath(BASE_LOCATION, MAPPING_DIRECTORY_NAME,
            PROTOCOL_MAPPING_FILENAME);
    InputStream is = null;
    try {
        is = DigirMetadataHandler.class.getResourceAsStream(mappingFilePath);
        mapping.load(is);
        boolean found = false;
        for (Object key : mapping.keySet()) {
            if (StringUtils.equals(contentNamespace, (String) key)) {
                protocol = mapping.getProperty((String) key);
                found = true;
            }
        }
        // if not found, alert operator
        if (!found) {
            log.error("digirmetadatahandler.default.protocolMappingNotFound", contentNamespace);
        }
    } catch (NullPointerException e) {
        log.info("error.mappingFileExists", new String[] { mappingFilePath, e.getMessage() }, e);
        throw new HarvesterException(e.getMessage(), e);
    } catch (IOException e) {
        log.error("digirmetadatahandler.error.getProtocol", e.getMessage(), e);
        log.debug("digirmetadatahandler.default.getProtocol", protocol);
    } finally {
        if (is != null) {
            try {
                is.close();
            } catch (IOException e) {
                log.error(
                        "An error occurred closing input stream on " + mappingFilePath + ": " + e.getMessage(),
                        e);
            }
        }
    }
    return protocol;
}

From source file:edu.gsgp.experiment.config.PropertiesManager.java

/**
 * Load a string property from the file.
 *
 * @param key The name of the property//from   w w w  .  j a va2  s .  co  m
 * @param isFile Specifies whether the property relates to a file
 * @return The value loaded from the file or the default value, if it is not
 * specified in the file.
 * @throws NumberFormatException The loaded value can not be converted to
 * string
 * @throws NullPointerException The parameter file was not initialized
 * @throws MissingOptionException The parameter is mandatory and it was not
 * found in the parameter file.
 */
private String getStringProperty(ParameterList key, boolean isFile)
        throws NumberFormatException, NullPointerException, MissingOptionException {
    try {
        boolean keyPresent = fileParameters.containsKey(key.name);
        String strValue = keyPresent ? fileParameters.getProperty(key.name).replaceAll("\\s", "") : null;
        if (!keyPresent && key.mandatory) {
            throw new MissingOptionException("Input parameter not found: " + key.name);
        } else if (!keyPresent) {
            return null;
        }
        if (isFile) {
            strValue = this.preProcessPath(strValue);
        }
        loadedParametersLog.append(key.name).append("=").append(strValue).append("\n");
        return strValue;
    } catch (NullPointerException e) {
        throw new NullPointerException(e.getMessage() + "\nThe parameter file was not initialized.");
    }
}

From source file:org.gbif.harvest.digir.DigirMetadataHandler.java

/**
 * Determine the mapping file.//from ww  w.j a v a2  s.com
 * If there is a problem loading the file, or no match exists for the
 * contentNamespace, the default is used.
 *
 * @param contentNamespace contentNamespace
 * @param directory        as String
 * @param resourceName     code
 *
 * @return mappingFile name
 *
 * @throws HarvesterException thrown if method fails
 */
private String getMappingFile(String contentNamespace, String directory, String resourceName)
        throws HarvesterException {

    // Initially, set the mapping file to the default
    String mappingFile = DEFAULT_MAPPING_FILE;

    if (StringUtils.isNotBlank(contentNamespace)) {
        Properties mapping = new Properties();
        String mappingFilePath = fileUtils.constructMappingFilePath(BASE_LOCATION, MAPPING_DIRECTORY_NAME,
                SCHEMA_LOCATION_MAPPING_FILENAME);
        InputStream is = null;
        try {
            is = DigirMetadataHandler.class.getResourceAsStream(mappingFilePath);
            mapping.load(is);
            boolean found = false;
            for (Object key : mapping.keySet()) {
                if (StringUtils.equals(contentNamespace, (String) key)) {
                    mappingFile = mapping.getProperty((String) key);
                    found = true;
                }
            }
            // if not found, alert operator
            if (!found) {
                log.error("digirmetadatahandler.default.conceptualMappingNotFound",
                        new String[] { resourceName, contentNamespace });
                // and write GBIF Log Message
                gbifLogger.openAndWriteToGbifLogMessageFile(directory,
                        CommonGBIFLogEvent.COMMON_MESSAGES_UNKNOWN_SCHEMA_LOCATION.getName(),
                        CommonGBIFLogEvent.COMMON_MESSAGES_UNKNOWN_SCHEMA_LOCATION.getValue(), Level.ERROR_INT,
                        "For resource=" + resourceName + ": the schemaLocation " + contentNamespace
                                + " was not found in the DiGIR conceptualMapping.properties file. If this is a valid schemaLocation, please update this file and try again. Defaulting to DwC 1.0",
                        1, false);
            }
        } catch (NullPointerException e) {
            log.info("error.mappingFileExists", new String[] { mappingFilePath, e.getMessage() }, e);
            throw new HarvesterException(e.getMessage(), e);
        } catch (IOException e) {
            log.error("digirmetadatahandler.error.getMappingFile", e.getMessage(), e);
            log.error("digirmetadatahandler.default.getMappingFile", mappingFile);
        } finally {
            if (is != null) {
                try {
                    is.close();
                } catch (IOException e) {
                    log.error("An error occurred closing input stream on " + mappingFilePath + ": "
                            + e.getMessage(), e);
                }
            }
        }
    } else {
        log.error(
                "No schemaLocation attribute was specified in element conceptualSchema: defaulting to DwC 1.0");
    }

    return mappingFile;
}

From source file:org.wso2.carbon.application.deployer.synapse.SynapseAppDeployer.java

/**
 * Deploy synapse libraries contains in the CApp
 *
 * @param artifacts  List of Artifacts contains in the capp
 * @param axisConfig AxisConfiguration of the current tenant
 * @throws DeploymentException if something goes wrong while deployment
 *///from  w  w  w.j av a 2 s.co m
private void deploySynapseLibrary(List<Artifact.Dependency> artifacts, AxisConfiguration axisConfig)
        throws DeploymentException {
    for (Artifact.Dependency dependency : artifacts) {

        Artifact artifact = dependency.getArtifact();
        if (!validateArtifact(artifact)) {
            continue;
        }

        if (SynapseAppDeployerConstants.SYNAPSE_LIBRARY_TYPE.equals(artifact.getType())) {

            Deployer deployer = getSynapseLibraryDeployer(axisConfig);

            if (deployer != null) {
                artifact.setRuntimeObjectName(artifact.getName());
                String fileName = artifact.getFiles().get(0).getName();
                String artifactPath = artifact.getExtractedPath() + File.separator + fileName;
                String artifactDir = getArtifactDirPath(axisConfig, SynapseAppDeployerConstants.SYNAPSE_LIBS);
                File artifactInRepo = new File(artifactDir + File.separator + fileName);
                if (artifactInRepo.exists()) {
                    log.warn("Synapse Library " + fileName + " already found in "
                            + artifactInRepo.getAbsolutePath() + ". Ignoring CAPP's artifact");
                    artifact.setDeploymentStatus(AppDeployerConstants.DEPLOYMENT_STATUS_DEPLOYED);
                } else {
                    try {
                        deployer.deploy(new DeploymentFileData(new File(artifactPath), deployer));
                        artifact.setDeploymentStatus(AppDeployerConstants.DEPLOYMENT_STATUS_DEPLOYED);
                        try {
                            String artifactName = getArtifactName(artifactPath, axisConfig);
                            SynapseConfiguration configuration = getSynapseConfiguration(axisConfig);
                            if (artifactName != null) {
                                if (configuration.getSynapseImports().get(artifactName) == null) {
                                    String libName = artifactName.substring(artifactName.lastIndexOf("}") + 1);
                                    String libraryPackage = artifactName.substring(1,
                                            artifactName.lastIndexOf("}"));
                                    updateStatus(artifactName, libName, libraryPackage,
                                            ServiceBusConstants.ENABLED, axisConfig);
                                }
                            }
                        } catch (AxisFault axisFault) {
                            log.error("Unable to update status for the synapse library : "
                                    + axisFault.getMessage());
                        } catch (NullPointerException nullException) {
                            log.error("Error while getting qualified name of the synapse library : "
                                    + nullException.getMessage());
                        }
                    } catch (DeploymentException e) {
                        artifact.setDeploymentStatus(AppDeployerConstants.DEPLOYMENT_STATUS_FAILED);
                        log.error("Error while deploying the synapse library : " + e.getMessage());
                        throw e;
                    }
                }
            }
        }
    }
}

From source file:edu.hawaii.soest.hioos.storx.StorXDispatcher.java

private boolean parseConfiguration() {

    boolean failed = true;

    try {/*from w w w.j  a v a 2  s  . co  m*/
        // create an XML Configuration object from the sensor XML file
        File xmlConfigFile = new File(this.xmlConfigurationFile);
        this.xmlConfiguration = new XMLConfiguration(xmlConfigFile);
        failed = false;

    } catch (NullPointerException npe) {
        logger.info("There was an error reading the XML configuration file. " + "The error message was: "
                + npe.getMessage());

    } catch (ConfigurationException ce) {
        logger.info("There was an error creating the XML configuration. " + "The error message was: "
                + ce.getMessage());

    }
    return !failed;

}

From source file:org.gbif.harvest.digir.DigirMetadataHandler.java

/**
 * Iterates over the metadata mapping file, populating the various
 * elements-of-interest maps. Regular expressions divide the mapping file's
 * properties into the appropriate element-of-interest map.
 * Note: The mapping file's properties are in the following format:
 * [element-of-interest name] + [property name] = [XPath expresson]
 * The regular expression matches according to the [element-of-interest
 * name]/*from  w  ww. j a va 2 s. co m*/
 * The corresponding element-of-interest map is then populated with: key =
 * [property name] & value = [XPath expression]
 *
 * @param mappingFile name
 * @param protocol    name
 *
 * @throws HarvesterException thrown if method fails
 */
private void populateElementOfInterestsMapsFromMappingFile(String mappingFile, String protocol)
        throws HarvesterException {

    // Create regex patterns
    // we're interested in all non-contact related properties
    Pattern metadataKeyPattern = Pattern.compile("metadata([\\S]*)");
    Pattern providerContactKeyPattern = Pattern.compile("providerContact([\\S]*)");
    Pattern resourceContactKeyPattern = Pattern.compile("resourceContact([\\S]*)");

    // properties we harvest are read from file
    Properties mapping = new Properties();
    String mappingFilePath = fileUtils.constructMappingFilePath(BASE_LOCATION, protocol, MAPPING_DIRECTORY_NAME,
            mappingFile);
    InputStream is = null;
    try {
        is = DigirMetadataHandler.class.getResourceAsStream(mappingFilePath);
        mapping.load(is);

        // Divide the mapping properties into various element-of-interest maps
        for (Object key : mapping.keySet()) {
            Boolean matched = false;
            // Matchers matching keys belonging to repeating element groups
            Matcher metadataKeyMatcher = metadataKeyPattern.matcher((String) key);

            if (metadataKeyMatcher.matches()) {
                String property = metadataKeyMatcher.group(1);
                metadataElementsOfInterest.put(property, mapping.getProperty((String) key));
                matched = true;
            }
            if (!matched) {
                Matcher providerContactKeyMatcher = providerContactKeyPattern.matcher((String) key);
                if (providerContactKeyMatcher.matches()) {
                    String property = providerContactKeyMatcher.group(1);
                    metadataProviderContactElementsOfInterest.put(property, mapping.getProperty((String) key));
                    matched = true;

                }
                if (!matched) {
                    Matcher resourceContactKeyMatcher = resourceContactKeyPattern.matcher((String) key);
                    if (resourceContactKeyMatcher.matches()) {
                        String property = resourceContactKeyMatcher.group(1);
                        metadataResourceContactElementsOfInterest.put(property,
                                mapping.getProperty((String) key));
                        matched = true;

                    }
                    if (!matched) {
                        // Determines the XPath expressions used to isolate repeating elements in a
                        // metadata xml response.
                        if (metadataRepeatingElementsXpath.keySet().contains(key)) {
                            // construct an XPath expression for repeating Element
                            DefaultXPath xpath = new DefaultXPath(mapping.getProperty((String) key));
                            xpath.setNamespaceURIs(namespaceMap);
                            metadataRepeatingElementsXpath.put((String) key, xpath);
                        }
                    }
                }
            }
        }
    } catch (NullPointerException e) {
        log.info("error.mappingFileExists", new String[] { mappingFilePath, e.getMessage() }, e);
        throw new HarvesterException(e.getMessage(), e);
    } catch (Exception e) {
        log.error("error.populateElementOfInterestsMapsFromMappingFile",
                new String[] { mappingFile, e.getMessage() }, e);
        throw new HarvesterException(e.getMessage(), e);
    } finally {
        if (is != null) {
            try {
                is.close();
            } catch (IOException e) {
                log.error(
                        "An error occurred closing input stream on " + mappingFilePath + ": " + e.getMessage(),
                        e);
            }
        }
    }
}

From source file:org.LexGrid.LexBIG.gui.LB_VSD_GUI.java

public void resolveValueSetDef(ValueSetDefinition vsd, AbsoluteCodingSchemeVersionReferenceList csrList,
        String revisionId) throws LBException {
    ConvenienceMethods cm = new ConvenienceMethods();
    org.LexGrid.LexBIG.LexBIGService.CodedNodeSet finalCNS = null;
    try {/* w  w  w.ja  v a 2 s.  c om*/
        ResolvedValueSetDefinition rvdDef = getValueSetDefinitionService().resolveValueSetDefinition(vsd,
                csrList, null, null);
        org.LexGrid.LexBIG.LexBIGService.CodedNodeSet cns = null;
        while (rvdDef.getResolvedConceptReferenceIterator().hasNext()) {
            ResolvedConceptReference rcr = rvdDef.getResolvedConceptReferenceIterator().next();
            if (rcr.getCodingSchemeURI() != null) {
                cns = cm.createCodedNodeSet(new String[] { rcr.getCode() }, rcr.getCodingSchemeURI(),
                        Constructors.createCodingSchemeVersionOrTag(null, rcr.getCodingSchemeVersion()));
                if (finalCNS == null)
                    finalCNS = cns;
                else
                    finalCNS = finalCNS.union(cns);
            }
        }
    } catch (NullPointerException e) {
        errorHandler.showError("Error", e.getMessage());
        return;
    }

    new VDDisplayCodedNodeSet(this, finalCNS, null);
}

From source file:org.catechis.Stats.java

/**
*<p>This method has to cycle through all the tests and evaluate them to determine
* when a word goes up a level, and how long it takes before it then fails a test and
* goes back down.  For instance, if a user passes a word on a writing test, and then
* two weeks later fails on the word, and then another word is failed after four weeks,
* then the average Rate Of Forgetting would be two three weeks.
*
*<p>This means that the user should be tested on words that has gone up a level 
* (or at least reviewing the word, for instance by getting an e-mail thats lists the words
* about to pass the date of the R.O.F.) before the R.O.F date has passed.
*<p>First I think we should create two lists for reading and writing that consist of
* the date and the score sorted by date.  Then we cycle thru the lists and keep track
* of the level as it goes up and down, and then create two more lists that contain the
* average time elapsed before a failed test stored at the failed level.
* Does that make sense?//w ww  .  ja  v  a  2 s.  com
*/
public void getRateOfForgetting(Word word) {
    ArrayList reading_tests = new ArrayList();
    ArrayList writing_tests = new ArrayList();
    Test[] tests = word.getTests();
    int number = tests.length;
    int i = 0;
    while (i < number) {
        try {
            Vector return_args = unbindTest(i, tests, reading_tests, writing_tests);
            reading_tests = (ArrayList) return_args.get(0);
            writing_tests = (ArrayList) return_args.get(1);
        } catch (java.lang.NullPointerException npe) {
            log.add(npe.getMessage());
            // ignore problems but go on to next test
        }
        i++;
    }
    Comparator comparator = new BeanComparator("date");
    Collections.sort(reading_tests, comparator);
    Collections.sort(writing_tests, comparator);
    try {
        evaluateTests(reading_tests);
    } catch (java.lang.NullPointerException npe) {
    }
    try {
        evaluateTests(writing_tests);
    } catch (java.lang.NullPointerException npe) {
    }
}