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:jp.terasoluna.fw.web.struts.form.DynaValidatorActionFormExTest.java

/**
 * testGet02()//from   w  w w . ja  v a  2  s. c o m
 * <br><br>
 *
 * (?n)
 * <br>
 * _?FG
 * <br><br>
 * l?F(?) name:<br>
 *         (?) index:0<br>
 *
 * <br>
 * l?F(?) O:NullPointerException?F<br>
 *                    ?bZ?[W?F"No indexed value for '[0]'"<br>
 *
 * <br>
 * name??ANullPointerExceptionX??[mF?B
 * <br>
 *
 * @throws Exception ?\bh?O
 */
public void testGet02() throws Exception {
    // eXg?s
    try {
        this.formEx.get("", 0);
        fail();
    } catch (NullPointerException e) {
        // eXgmF
        assertEquals("No indexed value for '[0]'", e.getMessage());
    }
}

From source file:jp.terasoluna.fw.web.struts.form.DynaValidatorActionFormExTest.java

/**
 * testSetStringintObject03()//from   w  w w .  ja v  a  2  s.  c  o m
 * <br><br>
 *
 * (?n)
 * <br>
 * _?FG
 * <br><br>
 * l?F(?) name:"foo"?i?tB?[h?j<br>
 *         (?) index:0<br>
 *         (?) value:"hello"<br>
 *
 * <br>
 * l?F(?) O:NullPointerException?F<br>
 *                    ?bZ?[W?F"No indexed value for 'foo[0]'"<br>
 *         (?) namewtB?[h:?|<br>
 *
 * <br>
 * name?tB?[h??ANullPointerExceptionX??[mF?B
 * <br>
 *
 * @throws Exception ?\bh?O
 */
public void testSetStringintObject03() throws Exception {
    //eXg?s
    try {
        this.formEx.set("foo", 0, "hello");
        fail();
    } catch (NullPointerException e) {
        //eXgmF
        assertEquals("No indexed value for 'foo[0]'", e.getMessage());
    }
}

From source file:jp.terasoluna.fw.web.struts.form.DynaValidatorActionFormExTest.java

/**
 * testGet03()/*from  ww  w .ja  va 2 s.  c  om*/
 * <br><br>
 *
 * (?n)
 * <br>
 * _?FG
 * <br><br>
 * l?F(?) name:"foo"?i?tB?[h?j<br>
 *         (?) index:0<br>
 *
 * <br>
 * l?F(?) O:NullPointerException?F<br>
 *                    ?bZ?[W?F"No indexed value for 'foo[0]'"<br>
 *
 * <br>
 * name?tB?[h??ANullPointerExceptionX??[mF?B
 * <br>
 *
 * @throws Exception ?\bh?O
 */
public void testGet03() throws Exception {
    // eXg?s
    try {
        this.formEx.get("foo", 0);
        fail();
    } catch (NullPointerException e) {
        // eXgmF
        assertEquals("No indexed value for 'foo[0]'", e.getMessage());
    }
}

From source file:jp.terasoluna.fw.web.struts.form.DynaValidatorActionFormExTest.java

/**
 * testSetStringintObject01()/*from  w ww.  ja  v  a  2 s .co m*/
 * <br><br>
 *
 * (?n)
 * <br>
 * _?FG
 * <br><br>
 * l?F(?) name:null<br>
 *         (?) index:0<br>
 *         (?) value:"hello"<br>
 *
 * <br>
 * l?F(?) O:NullPointerException?F<br>
 *                    ?bZ?[W?F"No indexed value for 'null[0]'"<br>
 *         (?) namewtB?[h:?|<br>
 *
 * <br>
 * namenull??ANullPointerExceptionX??[mF?B
 * <br>
 *
 * @throws Exception ?\bh?O
 */
public void testSetStringintObject01() throws Exception {
    //eXg?s
    try {
        this.formEx.set(null, 0, "hello");
        fail();
    } catch (NullPointerException e) {
        //eXgmF
        assertEquals("No indexed value for 'null[0]'", e.getMessage());
    }
}

From source file:jp.terasoluna.fw.web.struts.form.DynaValidatorActionFormExTest.java

/**
 * testGet01()/*ww  w. j  av a  2  s  .  c  om*/
 * <br><br>
 *
 * (?n)
 * <br>
 * _?FG
 * <br><br>
 * l?F(?) name:null<br>
 *         (?) index:0<br>
 *
 * <br>
 * l?F(?) O:NullPointerException?F<br>
 *                    ?bZ?[W?F"No indexed value for 'null[0]'"<br>
 *
 * <br>
 * namenull??ANullPointerExceptionX??[mF?B
 * <br>
 *
 * @throws Exception ?\bh?O
 */
public void testGet01() throws Exception {
    // eXg?s
    try {
        this.formEx.get(null, 0);
        fail();
    } catch (NullPointerException e) {
        // eXgmF
        assertEquals("No indexed value for 'null[0]'", e.getMessage());
    }
}

From source file:org.openbaton.clients.interfaces.client.openstack.OpenstackClient.java

private DeploymentFlavour getFlavorById(VimInstance vimInstance, String extId) throws VimDriverException {
    log.debug("Finding Flavor with ExtId: " + extId + " on VimInstance with name: " + vimInstance.getName());
    try {//from  w w w  .j a v  a  2 s . co m
        NovaApi novaApi = ContextBuilder.newBuilder("openstack-nova").endpoint(vimInstance.getAuthUrl())
                .credentials(vimInstance.getTenant() + ":" + vimInstance.getUsername(),
                        vimInstance.getPassword())
                .modules(modules).overrides(overrides).buildApi(NovaApi.class);
        FlavorApi flavorApi = novaApi.getFlavorApi(getZone(vimInstance));
        org.jclouds.openstack.nova.v2_0.domain.Flavor jcloudsFlavor = flavorApi.get(extId);
        DeploymentFlavour flavor = new DeploymentFlavour();
        flavor.setFlavour_key(jcloudsFlavor.getName());
        flavor.setExtId(jcloudsFlavor.getId());
        flavor.setRam(jcloudsFlavor.getRam());
        flavor.setDisk(jcloudsFlavor.getDisk());
        flavor.setVcpus(jcloudsFlavor.getVcpus());
        log.info("Found Flavor with ExtId: " + extId + " on VimInstance with name: " + vimInstance.getName());
        return flavor;
    } catch (NullPointerException e) {
        log.warn(e.getMessage(), new NullPointerException("Flavor with extId: " + extId
                + " not found on VimInstance with name: " + vimInstance.getName()));
        DeploymentFlavour flavor = new DeploymentFlavour();
        flavor.setExtId(extId);
        return flavor;
    } catch (Exception e) {
        log.error(e.getMessage(), e);
        throw new VimDriverException(e.getMessage());
    }
}

From source file:org.openbaton.clients.interfaces.client.openstack.OpenstackClient.java

private NFVImage getImageById(VimInstance vimInstance, String extId) throws VimDriverException {
    log.debug("Finding Image by ExtId: " + extId);
    try {//from   w  ww. j av  a  2 s  .  com
        NovaApi novaApi = ContextBuilder.newBuilder("openstack-nova").endpoint(vimInstance.getAuthUrl())
                .credentials(vimInstance.getTenant() + ":" + vimInstance.getUsername(),
                        vimInstance.getPassword())
                .modules(modules).overrides(overrides).buildApi(NovaApi.class);
        org.jclouds.openstack.nova.v2_0.features.ImageApi imageApi = novaApi.getImageApi(getZone(vimInstance));
        org.jclouds.openstack.nova.v2_0.domain.Image jcloudsImage = imageApi.get(extId);
        NFVImage image = new NFVImage();
        image.setExtId(jcloudsImage.getId());
        image.setName(jcloudsImage.getName());
        image.setCreated(jcloudsImage.getCreated());
        image.setUpdated(jcloudsImage.getUpdated());
        image.setMinDiskSpace(jcloudsImage.getMinDisk());
        image.setMinRam(jcloudsImage.getMinRam());
        image.setIsPublic(false);
        image.setContainerFormat("not provided");
        image.setDiskFormat("not provided");
        log.info("Found Image by ExtId: " + extId + " -> Image: " + image);
        return image;
    } catch (NullPointerException e) {
        log.warn(e.getMessage(), new NullPointerException("Image with extId: " + extId + " not found."));
        NFVImage image = new NFVImage();
        image.setExtId(extId);
        return image;
    } catch (Exception e) {
        log.error(e.getMessage(), e);
        throw new VimDriverException(e.getMessage());
    }
}

From source file:org.dart.matlab.MatlabExpression.java

public synchronized void fire() throws IllegalActionException {
    super.fire();
    boolean fireSwitch = true;

    if (triggerSwitch.getWidth() > 0) {
        Object inputSwitch = triggerSwitch.get(0);
        if (inputSwitch instanceof IntToken) {
            if (((IntToken) inputSwitch).intValue() >= 1) {
                fireSwitch = true;//from  w  w w.  j ava2 s  .co m
            } else {
                fireSwitch = false;
            }

        } else if (inputSwitch instanceof BooleanToken) {

            if (((BooleanToken) inputSwitch).booleanValue()) {
                fireSwitch = true;
            } else {
                fireSwitch = false;
            }
        }

    }
    // if switch is set, then we execute actor
    // else do nothing.
    if (fireSwitch) {

        // get the script commands needed to pass into -r command
        String script = buildScript();

        String outputString = "";
        String randomFilename = tempFilename + "." + Math.abs((new Random()).nextInt());
        boolean isWindows = (System.getProperty("os.name").indexOf("Windows") > -1);

        // build the command array

        if (isWindows) {
            File f = new File(mlCmd.getExpression());
            if (!f.exists()) {
                throw new IllegalActionException("Matlab process " + mlCmd.getExpression() + " doesn't exist");
            }
        }
        // TODO: same as above under unix

        // List argList = new ArrayList();
        String[] argList;

        // for some reason windows matlab doesn't work when supplied with
        // an array of arguments, and linux matlab doesn't work when
        // supplied
        // a single string with all the arguments.......
        if (isWindows) {
            argList = new String[1];
            argList[0] = mlCmd.getExpression() + " -r" + " \"" + script + "\"" + " -nodesktop" + " -nosplash"
                    + " -logfile " + randomFilename;
        } else {
            argList = new String[4];

            argList[0] = mlCmd.getExpression();
            argList[1] = "-nodesktop";
            argList[2] = "-nosplash" + " ";
            argList[3] = "-r" + " \"" + script + "\"";
        }

        // run the process and get output
        try {
            // Process p;
            if (isWindows) {

                _p = Runtime.getRuntime().exec(argList[0]);
            } else {
                _p = Runtime.getRuntime().exec(argList);
            }

            BufferedInputStream inputstream = null;
            int result = -1;

            // if we are running under windows
            if (isWindows) {
                // wait for the process to end
                result = _p.waitFor();
                if (result == 0) {
                    // create the input stream from the log file created by
                    // matlab
                    inputstream = new BufferedInputStream(new FileInputStream(randomFilename));
                }

                // if not running under windows
            } else {
                // get the processes input stream
                inputstream = new BufferedInputStream(_p.getInputStream());
            }

            // read the stream until there is nothing left to read
            if (inputstream != null) {
                while (true) {
                    int in;
                    try {
                        in = inputstream.read();
                    } catch (NullPointerException e) {
                        in = -1;
                    }
                    if (in == -1) {
                        break;
                    } else {
                        outputString += (char) in;
                    }
                }

                // close the input stream
                inputstream.close();
            }

            if (isWindows) {
                // delete the temp file. if it doesn't exist, then it will
                // just return false
                (new File(randomFilename)).delete();
            } else {
                // make sure matlab exited OK.
                result = _p.waitFor();
            }

            switch (result) {
            case 0:
                break;
            case -113:
                output.send(0, new StringToken("Matlab process was forcfully killed"));
                return;
            case 129:
                output.send(0, new StringToken("Matlab process was forcfully killed"));
                return;
            default:
                output.send(0, new StringToken(
                        "Matlab process returned \"" + result + "\".\nSomething must have gone wrong"));
                return;
            }

        } catch (IOException e) {
            log.error("IOException: " + e.getMessage());
        } catch (InterruptedException e) {
            log.debug("interupted!");
        }

        // process the output from matlab
        parseOutput(outputString);
    }

}

From source file:org.openmrs.module.rheapocadapter.handler.ClientRegistryService.java

/**
 * @see org.openmrs.module.rheapocadapter.service.ClientRegistryService#updateClientDetails(java.util.TreeMap)
 *      UpdatePatientData//from  ww  w. j a va2 s  .  co m
 */
public String updateClientDetails(Patient patient) {
    try {
        String implementationId = "";
        try {
            implementationId = (Context.getAdministrationService().getImplementationId()
                    .getImplementationId() != null)
                            ? Context.getAdministrationService().getImplementationId().getImplementationId()
                            : "rwanda000";
        } catch (NullPointerException e) {
            log.error("No Implementation Id  set;");
            implementationId = "rwanda000";
        }
        String result = "";
        MessageTransformer messageTransformer = new HL7MessageTransformer();
        String message = (String) messageTransformer.generateMessage(patient, "Update");
        TransactionUtil.setCreator(patient.getCreator());
        String[] methd = new String[] { "PUT", "UpdatePatientData" };
        TreeMap<String, String> parameters = new TreeMap<String, String>();
        if (patient.getPatientIdentifier("NID") != null) {
            parameters.put("patientId", "NID-" + patient.getPatientIdentifier("NID"));
        } else if (patient.getPatientIdentifier("Mutuelle") != null) {
            parameters.put("patientId", "Mutuelle-" + patient.getPatientIdentifier("Mutuelle"));
        } else if (patient.getPatientIdentifier("RAMA") != null) {
            parameters.put("patientId", "RAMA-" + patient.getPatientIdentifier("RAMA"));
        } else {
            if (patient.getPatientIdentifier().getIdentifierType().getName().equals("Primary Care ID Type")) {
                implementationId = implementationId.toLowerCase();
                String fosaid = implementationId.substring(implementationId.indexOf("rwanda") + 6);

                String clientId = "OMRS" + fosaid + "-" + patient.getPatientIdentifier().getIdentifier();
                parameters.put("patientId", clientId);
            } else {
                parameters.put("patientId", patient.getPatientIdentifier().getIdentifierType().getName() + "-"
                        + patient.getPatientIdentifier());
            }
        }

        Thread thread = new Thread(new PatientMessageThread(methd, message, parameters, patient, "Updating "));
        thread.setDaemon(true);
        thread.start();

        return null;
    } catch (NullPointerException e) {
        log.error(e.getMessage());
        return "";
    }
}

From source file:edu.cornell.mannlib.vitro.webapp.controller.edit.DatatypeRetryController.java

public void doPost(HttpServletRequest req, HttpServletResponse response) {
    if (!isAuthorizedToDisplayPage(req, response, SimplePermission.EDIT_ONTOLOGY.ACTION)) {
        return;/*from   ww  w. j  a v a  2s  .c o  m*/
    }

    VitroRequest request = new VitroRequest(req);

    //create an EditProcessObject for this and put it in the session
    EditProcessObject epo = super.createEpo(request);

    DatatypeDao dDao = request.getUnfilteredWebappDaoFactory().getDatatypeDao();
    epo.setDataAccessObject(dDao);
    Datatype objectForEditing = null;
    String action = "";

    if (request.getParameter("id") != null) {
        int id = Integer.parseInt(request.getParameter("id"));

        if (id > 0) {
            try {
                log.debug("Trying to retrieve datatype " + id);
                objectForEditing = dDao.getDatatypeById(id);
                action = "update";
            } catch (NullPointerException e) {
                log.error("Need to implement 'record not found' error message.");
            }
        }
    } else {
        action = "insert";
        objectForEditing = new Datatype();
    }

    epo.setOriginalBean(objectForEditing);

    //put this in the parent class?
    //make a simple mask for the class's id
    Object[] simpleMaskPair = new Object[2];
    simpleMaskPair[0] = "Id";
    simpleMaskPair[1] = Integer.valueOf(objectForEditing.getId());
    epo.getSimpleMask().add(simpleMaskPair);

    //set the getMethod so we can retrieve a new bean after we've inserted it
    try {
        Class[] args = new Class[1];
        args[0] = int.class;
        epo.setGetMethod(dDao.getClass().getDeclaredMethod("getDatatypeById", args));
    } catch (NoSuchMethodException e) {
        log.error("EntityRetryController could not find the entityById method in the facade");
    }

    epo.setPostInsertPageForwarder(new DatatypeInsertPageForwarder());
    epo.setPostDeletePageForwarder(new DatatypeDeletePageForwarder());

    FormObject foo = new FormObject();
    epo.setFormObject(foo);
    FormUtils.populateFormFromBean(objectForEditing, action, foo);
    //for now, this is also making the value hash - need to separate this out

    RequestDispatcher rd = request.getRequestDispatcher(Controllers.BASIC_JSP);
    request.setAttribute("bodyJsp", "/templates/edit/formBasic.jsp");
    request.setAttribute("scripts", "/templates/edit/formBasic.js");
    request.setAttribute("formJsp", "/templates/edit/specific/datatype_retry.jsp");
    request.setAttribute("title", "Datatype Editing Form");
    request.setAttribute("_action", action);
    request.setAttribute("unqualifiedClassName", "Datatype");
    setRequestAttributes(request, epo);

    try {
        rd.forward(request, response);
    } catch (Exception e) {
        log.error("VclassRetryContro" + "ller could not forward to view.");
        log.error(e.getMessage());
        log.error(e.getStackTrace());
    }

}