I am getting a NullPointerException when trying to use the Service class

I am getting a NullPointerException which is as follows
java.lang.NullPointerException
file:/K:/Learner/JavaFx2/ProductApplication/dist/run166129449/ProductApplication.jar!/com/product/app/view/viewsingle.fxml
  at com.product.app.controller.ViewSingleController.initialize(ViewSingleController.java:70)
  at javafx.fxml.FXMLLoader.load(Unknown Source)
  at javafx.fxml.FXMLLoader.load(Unknown Source)
And my View SingleController is as follows
package com.product.app.controller;
import com.product.app.model.Product;
import com.product.app.service.ViewProductsService;
import com.product.app.util.JSONParser;
import com.product.app.util.TagConstants;
import java.net.URL;
import java.util.ArrayList;
import java.util.List;
import java.util.ResourceBundle;
import javafx.collections.ObservableList;
import javafx.concurrent.Service;
import javafx.concurrent.Task;
import javafx.event.ActionEvent;
import javafx.fxml.FXML;
import javafx.fxml.Initializable;
import javafx.scene.control.ProgressIndicator;
import javafx.scene.control.TextArea;
import javafx.scene.control.TextField;
import javafx.scene.layout.Region;
import javafx.stage.Stage;
import javax.swing.JOptionPane;
import org.apache.http.NameValuePair;
import org.apache.http.message.BasicNameValuePair;
import org.json.JSONArray;
import org.json.JSONObject;
* FXML Controller class
* @author Arun Joseph
public class ViewSingleController implements Initializable {
    private static String action = "";
    @FXML
    private TextField txtID;
    @FXML
    private TextField txtName;
    @FXML
    private TextField txtPrice;
    @FXML
    private TextArea txtDesc;
    @FXML
    private Region veil;
    @FXML
    private ProgressIndicator p;
    private ViewProductsService service = new ViewProductsService();
    private JSONObject product = null;
    private JSONParser parser = new JSONParser();
    private int pid = 1;
    public void setPid(int pid) {
        this.pid = pid;
     * Initializes the controller class.
    @Override
    public void initialize(URL url, ResourceBundle rb) {
        veil.setStyle("-fx-background-color: rgba(0, 0, 0, 0.4)");
        p.setMaxSize(150, 150);
        p.progressProperty().bind(service.progressProperty());
        veil.visibleProperty().bind(service.runningProperty());
        p.visibleProperty().bind(service.runningProperty());
        Product product = new Product();
        service.start();
        ObservableList<Product> products = service.valueProperty().get();
        products.get(pid);
        txtID.textProperty().set(String.valueOf(products.get(pid).getPid()));
        //product = service.valueProperty().get().get(pid);
        //txtID.setText(String.valueOf(product.getPid()));
        txtName.textProperty().set(product.getName());
        txtPrice.textProperty().set(String.valueOf(product.getPrize()));
        txtDesc.textProperty().set(product.getDescription());
    private SomeService someService = new SomeService();
    @FXML
    private void handleUpdateButtonClick(ActionEvent event) {
        action = "update";
        someService.start();
        p.progressProperty().bind(service.progressProperty());
        veil.visibleProperty().bind(service.runningProperty());
        p.visibleProperty().bind(service.runningProperty());
    @FXML
    private void handleDeleteButtonClick(ActionEvent event) {
        action = "delete";
        someService.start();
        p.progressProperty().bind(service.progressProperty());
        veil.visibleProperty().bind(service.runningProperty());
        p.visibleProperty().bind(service.runningProperty());
    @FXML
    private void handleCancelButtonClick(ActionEvent event) {
        closeStage();
    private void closeStage() {
        ViewSingleController.stage.close();
    private static Stage stage = null;
    public static void setStage(Stage stage) {
        ViewSingleController.stage = stage;
    private class SomeService extends Service<String> {
        @Override
        protected Task<String> createTask() {
            return new SomeTask();
        private class SomeTask extends Task<String> {
            @Override
            protected String call() throws Exception {
                String result = "";
                int success = 0;
                List<NameValuePair> params = new ArrayList<NameValuePair>();
                switch (action) {
                    case "update":
                        params.add(new BasicNameValuePair("pid", txtID.getText()));
                        params.add(new BasicNameValuePair("name", txtName.getText()));
                        params.add(new BasicNameValuePair("price", txtPrice.getText()));
                        params.add(new BasicNameValuePair("description", txtDesc.getText()));
                        product = parser.makeHttpRequest(TagConstants.url_update_product_with_id, "POST", params);
                        success = product.getInt(TagConstants.TAG_SUCCESS);
                        if (success == 1) {
                            result = "Successfully Updated the product";
                            JOptionPane.showMessageDialog(null, result);
                            closeStage();
                        break;
                    case "delete":
                        params.add(new BasicNameValuePair("pid", txtID.getText()));
                        product = parser.makeHttpRequest(TagConstants.url_delete_product_with_id, "POST", params);
                        success = product.getInt(TagConstants.TAG_SUCCESS);
                        if (success == 1) {
                            result = "Successfully Deleted the product";
                            JOptionPane.showMessageDialog(null, result);
                            closeStage();
                        break;
                return result;

Time Machine has its own mechanism for deleting files. The number you are seeing may represent a "underflow" or a number of files which exceeds the limit and becomes negative.
The best way to remove TM files is via the TM interface: select the files and click the Gear and select delete from all backups.
If you are deleting files on an external drive which once included TM files, it is best to use the terminal and just delete them directly. They go bye-bye without ever seeing the trash bucket.
Of course, using the terminal is not for everyone.
What you might be able to do is restore the files from trash and then delete them properly or in smaller bundles.

Similar Messages

Maybe you are looking for