dimanche 3 mai 2015

Merge Sort Not Working Java

This merge sort algorithm fails because an ArrayIndexIsOut of bounds.

public static int[] mergeSort(int[] toBeSorted) {
    //If there is only one item in the array, and it is said to be sorted
    if (toBeSorted.length <= 1){
        return toBeSorted;
    }

    //find the indexes of the two sub-groups
    int[] left = new int[toBeSorted.length/2];
    int[] right = new int[toBeSorted.length-left.length];
    //Fill each sub-group with the correct numbers
    //Starting with the left group
    for(int i = 0; i <= left.length - 1; i++){
        left[i] = toBeSorted[i];
    }
    //Then the right group
    for(int i = left.length - 1; i <= toBeSorted.length - 1; i++){
        right[i] = toBeSorted[i];
    }


    //Merge sort each sub-group
    mergeSort(left);
    mergeSort(right);

    //Merge the two sub-groups
    toBeSorted = merge(left, right);

    return toBeSorted;
}

//Merging method
public static int[] merge(int[] left, int[] right){
    //Answer array
    int[] merged = new int[left.length + right.length];
    //Next index to check in each array
    int lCursor = 0;
    int rCursor = 0;
    //Next index to place numbers into answer
    int mergedCursor = 0; 

    //The merging part:
    //If there are still items to merge, then do so
    while(mergedCursor != merged.length){
        //left index is empty
        if(lCursor == left.length) {
            merged[mergedCursor] = right[rCursor];
            //increment the correct cursors
            rCursor += 1;
            mergedCursor += 1;
        }
        //right index is empty
        else if(rCursor == right.length) {
            merged[mergedCursor] = right[lCursor];
            //increment the correct cursors
            lCursor += 1;
            mergedCursor += 1;
        } 
        //Left side is smaller
        else if(left[lCursor]<right[rCursor]){
            merged[mergedCursor] = left[lCursor];
            //increment the correct cursors
            lCursor += 1;
            mergedCursor +=1;
        }
        //Right side is smaller
        else if(right[rCursor]<left[lCursor]){
            merged[mergedCursor] = right[rCursor];
            //increment the correct cursors
            rCursor += 1;
            mergedCursor +=1;
        }
    }
    //return the merged output
    return merged;
}

The line inside the for loop assigning numbers to the right array is where the problem is, but I can't tell why. Also, originally I had i = left.length in that for loop, but that was causing the entire right array to be set to zeros.

Can any of you help me?

Programatically set the username and password of a DataSource

I need a datasource to pass into a Spring NamedParameterJdbcTemplate so I can run a parametised query on it.

public void setDataSource(DataSource dataSource)
{
    this.dataSource = dataSource;
    this.jdbcTemplateObject = new NamedParameterJdbcTemplate(dataSource);
}

Set<Integer> parameters = getSomeIds();
List<TableRow> rows = this.jdbcTemplateObject.query(config.getSql(), parameters, new TableRowMapper());

Now this is fine if I'm setting the username and password for the DataSource in the Spring Xml.

However, I need to dynamically assign these. How can I configure the username and password?

How to pass a Console output to show as a pop up box in browser

I have a java code which outputs an Alert if it meet some condition. I am setting that value as below.

message = "Alert, Net Usage greater than or equal to threshold";
System.out.println(message);
request.setAttribute("message",message);
 RequestDispatcher dispatcher = request.getRequestDispatcher("jsppage.jsp");
 dispatcher.forward(request, response);

I want to display the "message" in a pop up in the browser. Please help.

com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: Table 'bus' already exists

I am trying to make my code to work smoothly but after the first insert and when the table exist I am always getting the this error com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: Table 'bus' already exists also after the creation of the fisr table and inserting the data this error occures?! I want just to check whether the table exists if not create the tabe and insert the data if yes just update the data.

Database class:

package org.busTracker.serverSide;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;

public class Database {

    public void connection() {
        try {
            Class.forName("com.mysql.jdbc.Driver");
            System.out.println("jar works :) ");

        } catch (ClassNotFoundException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
    }

    public void insertData(String mac, int route, float latitude,
            float longitude) {

        connection();
        String host = "jdbc:mysql://localhost/busTracker";
        String user = "root";
        String password = "";

        try {
            Connection con = DriverManager.getConnection(host, user, password);

            // Create a statement
            Statement stt = con.createStatement();

            // Check whether table exists.
            boolean rest = stt.execute("SHOW TABLES like 'bus' ");

            if (rest) {

                PreparedStatement prep = con
                        .prepareStatement("REPLACE INTO bus(mac, route, latitude, longitude)"
                                + "VALUES( ?, ?, ? , ? )");
                prep.setString(1, mac);
                prep.setInt(2, route);
                prep.setFloat(3, latitude);
                prep.setFloat(4, longitude);
                prep.executeQuery();

            } else {

                // Create bus table
                stt.execute("CREATE TABLE bus"
                        + "(id INT(11) NOT NULL AUTO_INCREMENT PRIMARY KEY,"
                        + "mac VARCHAR(30) NOT NULL UNIQUE,"
                        + "route int(11) NOT NULL,"
                        + "latitude FLOAT(10,6) NOT NULL,"
                        + "longitude FLOAT(10,6) NOT NULL,"
                        + "created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP)");

                PreparedStatement prep = con
                        .prepareStatement("REPLACE INTO bus(mac, route, latitude, longitude)"
                                + "VALUES( ?, ?, ? , ? )");
                prep.setString(1, mac);
                prep.setInt(2, route);
                prep.setFloat(3, latitude);
                prep.setFloat(4, longitude);
                prep.executeQuery();

            }

        } catch (SQLException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
    }

}

Mathematical expressions binary tree

i'm supposed to implement a binary tree that holds mathematical expressions, using different classes for each binary or unary expression. for example:

Expression e = new Sin(
                     new Pow(
                        new Mul(
                           new Plus(
                              new Mul(new Num(2), new Var("x")),
                              new Var("y")),
                           new Num(4)),
                     new Var("x")));

the leaves of the tree can be either variable or numbers. each variable could be converted to another expression with the method:

Expression assign(String var, Expression expression)

I have 2 abstract classes for unary and binary operators.

I've been experiencing difficulties figuring out how to assign the same expression to one of the variables in the expression itself. for example:

Expression e1 = new Plus(1,"x");
e1.assign("x", e1);
System.out.println(e1.toString());

the output should be:

((x+1)+1)

what's actually happening is that the left part of the expression is pointing on itself which causes an infinite loop. is there a way to make a duplication of the object but with a different pointer to avoid it? or maybe a different way to implement the way that the method "assign" works?

here is my implementation:

BinaryExpression Class:

import java.util.List;
import java.util.Map;


abstract public class BinaryExpression extends BaseExpression implements Expression {

    protected Expression first, second;

    public BinaryExpression(Expression first, Expression second) {
        this.setSecond(second);
        this.setFirst(first);
    }
    public BinaryExpression(double number1, double number2) {
        this(new Num(number1), new Num(number2));
    }
    public BinaryExpression(double number, String variable) {
        this(new Num(number), new Var(variable));
    }
    public BinaryExpression(String variable, double number) {
        this(new Var(variable), new Num(number));
    }
    public BinaryExpression(String variable1, String variable2) {
        this(new Var(variable1), new Var(variable2));
    }
    public BinaryExpression(Expression expression, String variable) {
        this(expression , new Var(variable));
    }
    public BinaryExpression(double number, Expression expression) {
        this(new Num(number), expression);
    }
    public BinaryExpression(Expression expression, double number) {
        this(expression, new Num(number));
    }
    public BinaryExpression(String variable, Expression expression) {
        this(new Var(variable), expression);
    }

    public Expression getSecond() {
        return second;
    }

    public void setSecond(Expression second) {
        this.second = second;
    }

    public Expression getFirst() {
        return first;
    }

    public void setFirst(Expression first) {
        this.first = first;
    }
    public double evaluate(Map<String, Double> assignment) throws Exception {
        try {
            return operate(first.evaluate(assignment), second.evaluate(assignment));
        } catch (Exception e) {
            throw new Exception(e.getMessage());
        }
    }
    abstract public double operate(double first, double second) throws Exception;

    public List<String> getVariables() {
        java.util.List<String> firstList, secondList;
        firstList = this.first.getVariables();
        secondList = this.second.getVariables();
        for (int i = 0; i < secondList.size(); i++) {
            boolean seen = false;
            for (int j = 0; j < firstList.size(); j++) {
                if (((String) firstList.get(j)).equals((String) secondList.get(i))) {
                    seen = true;
                    break;
                }
            }
            if (!seen) {
                firstList.add(secondList.get(i));
            }
        }
        return firstList;
    }

    public Expression assign(String var, Expression expression) {
        this.first = first.assign(var, expression);
        this.second = second.assign(var, expression);
        return this;
    }

    abstract public String operator();

    public String toString() {
        return "(" + this.first.toString() +
               this.operator() +
               this.second.toString() + ")";
    }
}

Variable class:

import java.util.ArrayList;
import java.util.List;
import java.util.Map;


public class Var implements Expression {
    private String variable;
    /**
     * setting the desired variable.
     * @param variable the variable to set
     */
    public Var(String variable) {
        this.variable = variable;
    }
    /**
     * getting the variable string.
     * @return the variable string
     */
    public String getVariable() {
        return variable;
    }
    /**
     * setting the variable string.
     * @param newVariable the string we want to set.
     */
    public void setVariable(String newVariable) {
        this.variable = newVariable;
    }
    @Override
    public double evaluate(Map<String, Double> assignment) throws Exception {
        if (assignment.containsKey(this.variable)) {
            return assignment.get(this.variable);
        } else {
            throw new Exception("variable wasn't assigned");
        }
    }
    @Override
    public double evaluate() throws Exception {
        throw new Exception("variable wasn't assigned");
    }
    @Override
    public List<String> getVariables() {
        java.util.List<String> singleVariable = new ArrayList<String>();
        singleVariable.add(this.variable);
        return singleVariable;
    }
    @Override
    public Expression assign(String var, Expression expression) {
        if (var.equals(this.variable)) {
            return expression;
        } else {
            return this;
        }
    }
    public String toString() {
        return this.variable;
    }
}

Number class:

import java.util.ArrayList;
import java.util.List;
import java.util.Map;


public class Num implements Expression {
    private double value;
    /**
     * creating a new number.
     * @param number the value to set.
     */
    public Num(double number) {
        this.setValue(number);
    }
    /**
     * getting the number's value.
     * @return the value to set.
     */
    public double getValue() {
        return value;
    }
    /**
     * setting a new number.
     * @param newValue the number to set.
     */
    public void setValue(double newValue) {
        this.value = newValue;
    }
    @Override
    public double evaluate(Map<String, Double> assignment) {
        return getValue();
    }
    @Override
    public double evaluate() {
        return getValue();
    }
    @Override
    public List<String> getVariables() {
        java.util.List<String> emptyList = new ArrayList<String>();
        return emptyList;
    }
    @Override
    public Expression assign(String var, Expression expression) {
        return this;
    }
    public String toString() {
        return Double.toString(this.value);
    }
}

any kind of help is appreciated.

Instaling updated SSL Certificates breaks Java web integration?

We have a .Net WCF service hosted on a Windows 2013 server. The SSL certificate for the service which is exposed via HTTPS was nearing expiration. An updated certificate was generated and applied to the server.

All of our .Net client applications continued to function as normal, but our Java-based applications began malfunctioning. I am told that the server administrators must manually go onto those boxes and update the Java keystores with the newly updated certificate.

This blows me away, if true. All web browsers, .Net applications, etc... handled the SSL certificate change with no issue. How do you prevent issues like this with a Java keystore in the future when the certificate is eventually updated again? Is there any way to have the keystore be more "dynamic" in this regard?

Delete File from Jlist

Don't know what I'm doing wrong here. I'm trying to delete the selected file from my directory but it's only deleting it from the list. Thanks

  private void deletecustButtonActionPerformed(java.awt.event.ActionEvent evt) {
    DefaultListModel model = (DefaultListModel) customerList.getModel();

    int selectedIndex = customerList.getSelectedIndex();
    File customer = new File("Customers/" + selectedIndex);
    if (selectedIndex != 1) {
      customer.delete();
      model.remove(selectedIndex);
    }
  }

Gson How to Avoid Expected BEGIN_ARRAY but was BEGIN_OBJECT?

I am using GSON to parse JSON data into Java and I am running into the error that is stated in the title. I am working with an API that returns the following JSON data :

{
  "STATUS": "SUCCESS",
  "NUM_RECORDS": "5",
  "MESSAGE": "5 records found",
  "AVAILABILITY_UPDATED_TIMESTAMP": "2015-05-03T13:59:08.541-07:00",
  "AVAILABILITY_REQUEST_TIMESTAMP": "2015-05-03T13:59:08.490-07:00",
  "AVL": [
    {
      "TYPE": "ON",
      "BFID": "205052",
      "NAME": "5th St (500-598)",
      "RATES": {
        "RS": [
          {
            "BEG": "12:00 AM",
            "END": "12:00 PM",
            "RATE": "0",
            "RQ": "No charge"
          },
          {
            "BEG": "12:00 PM",
            "END": "6:00 PM",
            "RATE": "5",
            "RQ": "Per hour"
          },
          {
            "BEG": "6:00 PM",
            "END": "12:00 AM",
            "RATE": "0",
            "RQ": "No charge"
          }
        ]
      },
      "PTS": "2",
      "LOC": "-122.4002212834,37.7776161738,-122.3989619795,37.7766113458"
    },
    {
      "TYPE": "ON",
      "BFID": "205042",
      "NAME": "5th St (450-498)",
      "RATES": {
        "RS": {
          "BEG": "12:00 AM",
          "END": "12:00 AM",
          "RATE": "0",
          "RQ": "No charge"
        }
      },
      "PTS": "2",
      "LOC": "-122.4015027158,37.7786330718,-122.4005149869,37.7778485214"
    },
  ]
}

I can see where the problem occurs, the RS field can either contain an array of objects (let's call this object RInfo) or in some cases it will only contain one of that RInfo object that is not contained in an array. I think that the error occurs because GSON is looking for an array but found an object. I am unable to change the structure of the JSON file because it was provided by an API.

I am able to parse the information successfully as long as RS is an array of RInfo objects but in some cases RS contains only one RInfo object so this error occurs.

Is there a way to handle this in GSON?

*Update

I have tried a solution that was linked earlier. Here is what I have from that solution:

class RSDeserializer implements JsonDeserializer<RateInfo[]> {

    @Override
    public RateInfo[] deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context)
            throws JsonParseException
    {


        if (json instanceof JsonArray) {
            System.out.println("fromJson in RSD:" + new Gson().fromJson(json, RateInfo[].class));
            return new Gson().fromJson(json, RateInfo[].class);
        }
        RateInfo rI = context.deserialize(json, RateInfo.class);

        return new RateInfo[] { rI };
    }

}

I have also created a new GsonBuilder as follows

    GsonBuilder gsonBuilder = new GsonBuilder();
    gsonBuilder.registerTypeAdapter(RateInfo[].class, new RSDeserializer());
    Gson gson = gsonBuilder.create();

It doesn't seem like the custom deserializer is ever used because the print statement was never printed out in the console. After that I have tried to deserilize the json using MyOBJ info = gson.fromJson(json, MyOBJ.class); this line gives me the Expected BEGIN_ARRAY but was BEGIN_OBJECT exception.

Cant see Overwrinting Cursor when i create new Line

I'm trying to create an overwriting Cursor. I've got it except when I click an earlier line the caret disappears, then when I hit 'enter' for a new line it appears again.

what should I change in my Code to solve this issue?

here is my Caret Class:

public class Mycaret extends DefaultCaret {

    protected static final int MIN_WIDTH = 8;

    protected DefaultCaret dc = null;

    JTextComponent com = null;

    public Mycaret(int rate, DefaultCaret dc) {

        this.dc = dc;
        super.setBlinkRate(rate);
    }

    protected synchronized void damage(Rectangle r) {

        if (r != null) {

            try {

                JTextComponent comp = getComponent();
                TextUI mapper = comp.getUI();
                char dotChar = 0;
                if(comp.getText().length()>0){
                 dotChar = comp.getText().charAt(comp.getText().length()-1);
                }
                this.com = comp;

                Rectangle r2 = mapper.modelToView(comp, getDot() + 1);

                int width = r2.x - r.x;

                if (width == 0 ) {

                    width = MIN_WIDTH;


                }

                comp.repaint(r.x, r.y, width, r.height);

                this.x = r.x;
                this.y = r.y;
                this.width = width;
                this.height = r.height;

            }

            catch (BadLocationException e) {

            }
        }

    }

    public void paint(Graphics g) {

        char dotChar;

        if (isVisible()) {

            try {

                JTextComponent comp = getComponent();
                TextUI mapper = comp.getUI();

                Rectangle r1 = mapper.modelToView(comp, getDot());
                Rectangle r2 = mapper.modelToView(comp, getDot() + 1);

                g = g.create();
                g.setColor(comp.getForeground());
                g.setXORMode(comp.getBackground());

                int width = r2.x - r1.x;

                dotChar = comp.getText(getDot(), 1).charAt(0);

                if (width == 0  ) {
                    width = MIN_WIDTH;

                }



                g.fillRect(r1.x, r1.y, width, r1.height);
                g.dispose();

            } catch (BadLocationException e) {

            }
        }

    }
}

this is a Sample:

public class MyFrameSample extends JFrame {

    DefaultCaret caret=null;

    public MyFrameSample() {

        JTextArea text = new JTextArea(10,20);
        caret = new DefaultCaret();

        text.setCaret(new Mycaret(500, caret));
        add(text);

        pack();
        setVisible(true);
    }

    public static void main(String[] args) {

        new MyFrameSample();
    }
}

Dynamic Web Project - Project Facets not displaying CDI as a project facet

I'm trying to add CD,I as a project facet to a Dynamic web project. But when clicking on the project facets view there is no CDI option in the Project Facet list as you can see:

enter image description here

I tried following this suggestion in where they said to erase possible conflicting jres, and also the suggestions in here which recommends checking the installed jre's, my view of installed jres is:

intalled jres

I'm at linux mint so I'm also attaching a screenshot of the dir /usr/lib/jvm, in case you guys see any anomaly in it and also it seems my java version is okay: enter image description here

java, libgdx - cant get custom font to appear

i have the following class that is suppose to reference a font and then draw a string to the screen once an event has occured. the class is called like this .

if (grumpface.whiteballoon.getBoundingRectangle().overlaps(spriterect)) {


            gameoverscreen = new GameOverScreen();
        }
        ;

the class it references it this but i still cant get the font to appear any suggestiosns?

class GameOverScreen implements Screen{

    private Stage stage;

    // Called automatically once for init objects
    @Override
    public void show() { 
        stage = new Stage();

       stage.setDebugAll(true); // Set outlines for Stage elements for easy debug

        BitmapFont white = new BitmapFont(Gdx.files.internal("hazey.fnt"), false);
        LabelStyle headingStyle = new LabelStyle(white, Color.BLACK);
        Label gameoverstring = new Label("game ovaaaa!", headingStyle);
        gameoverstring.setPosition(100, 100);
        stage.addActor(gameoverstring);


    }

    // Called every frame so try to put no object creation in it
    @Override
    public void render(float delta) { 
        Gdx.gl.glClearColor(0, 0, 0, 1);
        Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT);


       stage.act(delta);

        stage.draw();



    }

NullPointerException when downloading images for ImageView in android

I am attempting to brush up on my android for a project at work, and it seams that im more out of touch than i first thought.

I am creating an app that uploads pictures to a remote server and then shows these uploads as thumbnails.

The section i am struggling is with downloading the image and applying it to the image view within a list view.

Im receiving a Null Pointer Exception which is never nice.

Im not sure if this is due to me starting a number of ASync tasks (one for each image) or if its something more obvious

Stack Trace

Process: com.example.alex.documentupload, PID: 5788
java.lang.NullPointerException
        at com.example.alex.documentupload.DownloadImageTask.onPostExecute(DownloadImage.java:35)
        at com.example.alex.documentupload.DownloadImageTask.onPostExecute(DownloadImage.java:14)
        at android.os.AsyncTask.finish(AsyncTask.java:632)
        at android.os.AsyncTask.access$600(AsyncTask.java:177)
        at android.os.AsyncTask$InternalHandler.handleMessage(AsyncTask.java:645)
        at android.os.Handler.dispatchMessage(Handler.java:102)
        at android.os.Looper.loop(Looper.java:146)
        at android.app.ActivityThread.main(ActivityThread.java:5748)
        at java.lang.reflect.Method.invokeNative(Native Method)
        at java.lang.reflect.Method.invoke(Method.java:515)
        at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1291)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1107)
        at dalvik.system.NativeStart.main(Native Method)

Android Code Show images Class

package com.example.alex.documentupload;

import java.util.ArrayList;
import java.util.HashMap;

import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;

import android.app.Activity;
import android.app.ProgressDialog;
import android.content.Intent;
import android.os.AsyncTask;
import android.os.Bundle;
import android.view.View;
import android.widget.AdapterView;
import android.widget.Button;
import android.widget.ImageView;
import android.widget.ListAdapter;
import android.widget.ListView;
import android.widget.SimpleAdapter;
import android.widget.TextView;
import android.widget.Toast;

import com.example.alex.documentupload.JSONParser;
import com.example.alex.documentupload.DownloadImageTask;

public class ShowImages extends Activity {
    ListView list;
    TextView ver;
    TextView name;
    TextView api;
    ImageView img;

    Button Btngetdata;
    ArrayList<HashMap<String, String>> oslist = new ArrayList<HashMap<String, String>>();

    //URL to get JSON Array
    private static String url = "http://ift.tt/1E574fc";

    //JSON Node Names
    private static final String TAG_PATH = "path";

    JSONArray android = null;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

        setContentView(R.layout.activity_show_images);
        oslist = new ArrayList<HashMap<String, String>>();

        new JSONParse().execute();

        Btngetdata = (Button)findViewById(R.id.getdata);
        Btngetdata.setOnClickListener(new View.OnClickListener() {

            @Override
            public void onClick(View view) {
                // clear the list before adding more

                //update the list
                new JSONParse().execute();

            }
        });

    }

    private class JSONParse extends AsyncTask<String, String, JSONArray> {
        private ProgressDialog pDialog;
        @Override
        protected void onPreExecute() {
            super.onPreExecute();
            ver = (TextView)findViewById(R.id.vers);
            name = (TextView)findViewById(R.id.name);
            api = (TextView)findViewById(R.id.api);
            img = (ImageView)findViewById(R.id.img);


            pDialog = new ProgressDialog(ShowImages.this);
            pDialog.setMessage("Getting Data ...");
            pDialog.setIndeterminate(false);
            pDialog.setCancelable(true);
            pDialog.show();

        }

        @Override
        protected JSONArray doInBackground(String... args) {

            JSONParser jParser = new JSONParser();

            // Getting JSON from URL
            JSONArray json = jParser.getJSONFromUrl(url);
            return json;
        }
        @Override
        protected void onPostExecute(JSONArray json) {
            pDialog.dismiss();
            try {
                // Getting JSON Array from URL


               android = json;


                for(int i = 0 ; i < android.length(); i++){

                    JSONObject c = android.getJSONObject(i);

                    // Storing  JSON item in a Variable
                    String path = c.getString(TAG_PATH);

                    // Adding value HashMap key => value

                    HashMap<String, String> map = new HashMap<String, String>();

                    map.put(TAG_PATH, path);

                    oslist.add(map);
                    list=(ListView)findViewById(R.id.list);



                    ListAdapter adapter = new SimpleAdapter(ShowImages.this, oslist,
                            R.layout.list_v,
                            new String[] { TAG_PATH }, new int[] {
                            R.id.vers});

                    list.setAdapter(adapter);

                    new DownloadImageTask((ImageView) list.findViewById(R.id.img))
                            .execute("http://ift.tt/1GJcn5E" + path);

//                    list.setOnItemClickListener(new AdapterView.OnItemClickListener() {
//
//                        @Override
//                        public void onItemClick(AdapterView<?> parent, View view,
//                                                int position, long id) {
//                            Toast.makeText(ShowImages.this, "You Clicked at "+oslist.get(+position).get("name"), Toast.LENGTH_SHORT).show();


//                        }
//                    });

                }
            } catch (JSONException e) {
                e.printStackTrace();
            }

        }
    }

    public void loadcamera(View view) {
        // Do something in response to button

        Intent myIntent = new Intent(ShowImages.this, MainActivity.class);
        myIntent.putExtra("dir", "BS"); //Optional parameters
        ShowImages.this.startActivity(myIntent);

    }

}

DownloadImages Class

package com.example.alex.documentupload;

import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.os.AsyncTask;
import android.util.Log;
import android.widget.ImageView;

import java.io.InputStream;

/**
 * Created by Alex on 03/05/2015.
 */
 class DownloadImageTask extends AsyncTask<String, Void, Bitmap> {
    ImageView bmImage;

    public DownloadImageTask(ImageView bmImage) {
        this.bmImage = bmImage;
    }

    protected Bitmap doInBackground(String... urls) {
        String urldisplay = urls[0];
        Bitmap mIcon11 = null;
        try {
            InputStream in = new java.net.URL(urldisplay).openStream();
            mIcon11 = BitmapFactory.decodeStream(in);
        } catch (Exception e) {
            Log.e("Error", e.getMessage());
            e.printStackTrace();
        }
        return mIcon11;
    }

    protected void onPostExecute(Bitmap result) {
        bmImage.setImageBitmap(result);
    }
}

How to replaceAll "" with " " without touching a specific number?

This may look like a duplicate question but I really couldn't find an answer in those. After searching I learnt about regex and matcher but I couldn't come up with a solution. If you could help me I would really appreciate it.

In Java I want to replaceAll "" with " " in a string but only number 10 shouldn't be touched. So I don't want 10 to be like 1 0

Here is a String: String x = "123456789"

If I use this: x.replaceAll(".(?=.)", "$0 ")

I get: "1 2 3 4 5 6 7 8 9"

But if string was: x = "12345678910" How could I get: "1 2 3 4 5 6 7 8 9 10" and it could be like: x = {123104} And once again I need {1 2 3 10 4}

Thank you for checking...

null error when trying to print bridge game

I am getting a java null error on this line when I run main

int rank = cards[i].getRank();

int points = cards[i].getPoints();

I am simply trying to get the countHighCardPoints() point values of the cards in the hand array and add the points to a sum. I am also going to assume my countDistributionPoints() will work if I was not also getting a null on char suit = cards[i].getSuit();

I also have a Card class and a Deck class already made.

Thus my Hand class which I need help on.

public class Hand
{

 //Holds an array of card objects
 private Card [] cards = new Card [13];

/**
 * Constructor takes array of Cards and assigns that parameter to
 * the instance variable
 */
public Hand(Card [] cards)
{
    Card [] hand = cards;
}

/**
 * Looks through each card in hand array and adds its points
 * if the card has any to a sum highPoints
 */
public int countHighCardPoints()
{
    int highPoints = 0;

    for (int i = 0; i < cards.length; i++) {

        int points = cards[i].getPoints();

       highPoints += points;

    }

    return highPoints;
}

/**
 * Counts the number of cards in each suit and will add points
 * for the suits value, so if 3 or more suits zero points,
 * 2 suits 1 point, 1 suit 2 points, 0 suits 3 points
 */
public int countDistributionPoints()
{
    int countPoints = 0;

    for (int i = 0; i < cards.length; i++) {
        //char suit = cards[i].getSuit();

        if (cards[i].getSuit() >= 3)
            countPoints = 0;
        else if (cards[i].getSuit() == 2)
            countPoints++;
        else if (cards[i].getSuit() == 1)
            countPoints += 2;
        else if (cards[i].getSuit() == 0)
            countPoints += 3;
    }

    return countPoints;
}

/**
 * Will print out the hand information in a neat format using a 
 * StringBuilder will print 4 cards containing rank,suit,points each line
 * in order from Clubs,Diamonds,Hearts,Spades if no cards of the suit it 
 * will print a blank line
 */
public String toString()
{
    StringBuilder hand = new StringBuilder();

            //         for (int i = 0; i < cards.length; i++) {
    //             char suit = cards[i].getSuit();

    for (int j = 0; j < 5; j++) {
        if (cards[j].getSuit() == 'C')
            hand.append(cards[j] + "  ");
        else if (j == 4) 
            hand.append("\n");
    }

        for (int j = 0; j < 5; j++) {
            if (cards[j].getSuit() == 'D')
                hand.append(cards[j] + "  ");
            else if (j == 4)
                hand.append("\n");
        }
    // 
    //             for (int j = 0; j < 5; j++) {
    //                 if (cards[j].getSuit() == 'H')
    //                     hand.append(cards[j] + "  ");
    //                 else if (j == 4)
    //                     hand.append("\n");
    //             }
    // 
    //             for (int j = 0; j < 5; j++) {
    //                 if (cards[j].getSuit() == 'S')
    //                     hand.append(cards[j]);
    //                 else if (j == 4)
    //                     hand.append("\n");
    //             }
    //         }


    return hand.toString();
}
}

Deck class for reference

public class Deck
{
//Holds an array of card objects
private Card [] cards  = new Card [52];

//Holds number of cards remaining in deck
private int count;

/**
 * Constructor to fill in card objects in order of suits
 * Clubs,Diamonds,Hearts, and Spades and keep count of remaining
 * cards in deck
 */
public Deck()
{
    //Fills in Club suit
    for (int i = 0; i <= 12; i++) {
        cards[i] = new Card(i+2, 'C');
        count = 52-13;
    }
    //Fills in Diamond suit
    for (int i = 13; i <= 25; i++) {
        cards[i] = new Card(i-13+2, 'D');
        count = 39-13;
    }
    //Fills in Heart suit
    for (int i = 26; i <= 38; i++) {
        cards[i] = new Card(i-26+2, 'H');
        count = 26-13;
    }
    //Fills in Spade suit
    for (int i = 39; i <= 51; i++) {
        cards[i] = new Card(i-39+2, 'S');
        count = 13-13;
    }
}

/**
 * Gets the value for count
 */
public int getCount()
{
    return count;
}

/**
 * The original cards in Card [] cards will be randomly shuffled
 * by Math.random() and positions will be swapped
 */
public void shuffle()
{
    for (int i = 0; i <= 51; i++) {
        int j = (int)(Math.random() * 52);
        int k = (int)(Math.random() * 52);

        //Swaps card positions
        Card temp = cards[j];
        cards[j] = cards[k];
        cards[k] = temp;
    }
}

/**
 * Creates a Card [] arrayOfCards which is 13 cards for each player 
 * and will determine number of cards that was dealt with count.
 */
public Card [] dealThirteenCards()
{
    Card [] arrayOfCards = new Card [13];

    for (int i = 0; i <= 12 && count < 52; i++) {
        arrayOfCards[i] = cards[i];
        count++;
    }

    return arrayOfCards;
}

/**
 * Creates a StringBuilder which will print 13 cards per line
 * containing their rank,suit,points
 */
public String toString()
{
    StringBuilder info = new StringBuilder();

    for (int i = 0; i < 13; i++) {
        info.append(cards[i] + "," + " ");
    }
    info.append("\n");
    for (int i = 13; i < 26; i++) {
        info.append(cards[i] + "," + " ");
    }
    info.append("\n");
    for (int i = 26; i < 39; i++) {
        info.append(cards[i] + "," + " ");
    }
    info.append("\n");
    for (int i = 39; i < 51; i++) {
        info.append(cards[i] + "," + " ");
    }
    //Will exclude a comma because last card printed
    for (int i = 51; i < 52; i++)
        info.append(cards[i]);

    return info.toString();
}
}

I do not understand the logic behind this prime number checker (Java)

I do not understand the logic behind this number checker and I'm wondering if somebody could help me understand it a little bit better.

Here's the code:

I will do my best to comment on what's happening but I do not fully understand it.

//find prime numbers between 2 and 100

class PrimeNumberFinder {
    public static void main(String args[]) {

        int i, j; // declare the integer variables "i" and "j"
        boolean isPrime; // declare the Boolean variable is prime but do not assign value

        // create a for loop that starts at two and stops at 99.
        for (i=2; i < 100 ; i++) {
            isPrime = true; // I do not know why isPrime is set to true here.
            // This is where I get confused badly.. we give the "j" variable a value of two and check to see if it's less than whatever "i" divided by "j" is.             
            // If "i=2" then how would j (which is = 2) be less than or equal to i/j (2/2)? 

            for (j = 2; j <= i/j; j++)
                if ((i%j) == 0) isPrime = false; // If a certain number goes in evenly that isn't 1, or "i" itself, it isn't prime so we set the boolean to false

            if (isPrime) // if true print i
                System.out.println(i + " Is a prime number");


        }
    }
}

As you can see the second for loop and almost everything going on within it confuses me, especially the "j <= i/j" because to me j is always going to be bigger.. and why is "j" even increasing? Can't you just divide it by two and determine whether or not it's prime that way?

Any help is greatly appreciated, thank you for reading.

Any good Android voices I can use for TTS

Any good android TTS voice services I can use. Currently using the built in one TTS. Looking for something that sounds better, less robot-y. Suggestions?

I can't figure out how to put this if statement in my while loop

I'm just staring up coding and I was trying to make a code that would make the user have to guess the special day. It was working but I tried to make it more efficient by adding while loops to keep trying when the user fails rather than having to quit and restart. Instead of trying again, the code just ends when the user gets month 2 and a day above or under 18, here's the code:

import java.util.Scanner;

public class SpecialDay
{
public static void main(String[] args)
{
    int Day, Month;

    Scanner scan = new Scanner(System.in);
    System.out.print ("Welcom to the Special Day guessing game!");
    System.out.print (" Enter the Month: ");
    Month = scan.nextInt();
    System.out.print ("Enter the Day: ");
    Day = scan.nextInt();


    while (Day != 18 && Month != 2)
{

    System.out.print ("Enter the Month: ");
    Month = scan.nextInt();
    System.out.print ("Enter the Day: ");
    Day = scan.nextInt();

}
if (Month == 2 && Day == 18)
    System.out.println ("Nice! You got the Special Day!");
else if (Month >= 2 && Day > 18)
    System.out.println ("That's after the Special Day, try again!");
else if (Month <= 2 && Day < 18)
    System.out.println ("That's before the Special Day, try again!");
}
}

No hate please, I'm a newbie at this.

MailClient Homework

I'm having the following problems and I was wondering if anyone here could help out. The errors are in the following.

Exception in thread "main" java.lang.NullPointerException
at client.Contact.save(Contact.java:35)
at client.Message.save(Message.java:44)
at client.Mailbox.save(Mailbox.java:62)
at client.cmd.Save.run(Save.java:15)
at client.CmdLoop.run(CmdLoop.java:53)
at Main.main(Main.java:41)

Contact.save method. Error appears on "Contact C=nick..."

public void save(AddressBook nick, PrintStream print){
  Contact C=nick.search(NickName);
  if(C!=null)
  {
        print.println(NickName);
  }
  else
  {
       print.println(Email);
  }

Message.save method - Error appear I believe in both to.save and from.save

public void save(AddressBook nick, PrintStream print){
to.save(nick, print);
from.save(nick, print);
print.println(body);
print.println(subject);
print.println(date);}

And lastly, Mailbox.save method - Error appears on "m1.save(nick, myStream)"

public void save(String fileName){
Message m1 = null;
AddressBook nick = null;
File myFile = new File(fileName);
try {
    PrintStream  myStream = new PrintStream(myFile);
    for(int n=0; n < mailbox.size(); n++)
    {
        m1 = mailbox.get(n);
        m1.save(nick, myStream);
    }
} catch (FileNotFoundException e) {System.out.println("Mailbox unable to save to file " + myFile);
    e.printStackTrace();}}

Sorry about formatting, first time using this website.

Refactoring if statement in java

I need some help refactoring this if-statement. I thought of declaring the percentage as constants. I also thought to make a method that includes the code inside the if brackets. What else can i do?

if(totalReceiptsAmount >= getIncome() && totalReceiptsAmount <  0.20 * getIncome())
        setTaxIncrease(getBasicTax() + 0.05 * getBasicTax());
    if(totalReceiptsAmount >=  0.20 * getIncome() && totalReceiptsAmount <  0.40 * getIncome())
        setTaxIncrease(getBasicTax() - 0.05 * getBasicTax());
    if(totalReceiptsAmount >=  0.40 * getIncome() && totalReceiptsAmount <  0.60 * getIncome())
        setTaxIncrease(getBasicTax() - 0.10 * getBasicTax());
    if(totalReceiptsAmount >=  0.60 * getIncome())
        setTaxIncrease(getBasicTax() - 0.15 * getBasicTax());

Java sun.misc.Launcher$AppClassLoader breaking code?

So, I have a classloader, ReflectionClassLoader, which I'm using to dynamicly load JAR files from various places, in order to play with obfuscated code environments.

This works fine in my IDE, and is quite fun to play with, but when I export a setup in Eclipse, I find that my Class Loader is being loaded by the standard URLClassLoader, and a sun.misc.Launcher$AppClassLoader, so loaded twice. Since it stores certain data, like resources, loaded classes, etc, it's completely breaking my system. In eclipse, their both loaded by the sun.misc.Launcher$AppClassLoader.

The second loading appears to be evident at where my custom URL protocol (debugrsrc) is loaded. I've tried getting the System ClassLoader, and reflecting, but that returns the sun.misc.Launcher$AppClassLoader, even though it's not returning that in my main method.

It seems to be completely isolated from the rest of the program. As for an escape, I'm thinking of pulling some Unsafe, although I'd much prefer to just have Sun not mess with ClassLoaders.

Equaling bounding box to another bounding box : Opencv , Android

I am trying to sort bounding boxes and in my algo I have a line in which bounding box of index j is equaling index j+1

 contourRects.get(j) = contourRects.get(j+1);

But it gives an error that left hand side can only be variable.

hashtable that change value by itself

I am writing a java program using HashTable and I have a hard time using it. I have a HashTable object that between initialisation and reading, the values objects change

Since a piece of code is more understandable than a big paragraph, here it is :

   class localDictionnary {
       private Map<Entries, Symbol> dictionnary;
       public LocalDictionnary() {      
           this.dictionnary = new Hashtable<Entre, Symbole>();
       }

       public void check() {
           int displacement= 0;
           for(Entry<Entre, Symbole> e : this.dictionnary.entrySet()){
               e.getValue().setDeplacement(displacement);
               displacement += e.getValue().getTaille();
               System.out.print(e.getValue().getDeplacement() + " ");
           }
           System.out.println("");
           for(Entry<Entre, Symbole> e : this.dictionnary.entrySet())
               System.out.print(e.getValue().getDeplacement() + " ");
       }
   }

The outs of the program :

0 4 8 12 16 20 24 28 32 36 
8 8 32 16 36 28 28 32 36 0

The displacements value are not the same between the first and the second call to println where it obviously should, even if the order has changed

The issue is not due to how HashTable sorts items, and the program is fully sequential so there is no other thread that blow every thing down...

I am not that new writing java program, but I have to say, this is the first time I use Hashtables...

Thanks a lot for your help =P

PS: I am not native english, so forgive me for my mistakes

doesn't progress the radius, but should

I know this is the wrong way to do it, but the lack of help from anyone has caused me to do this. I have drawn 7 circles each with a different radius in the same play each pausing for 300 miliseconds after being drawn so in theory it should look like the circle is expanding as its being drawn, but for some reason its not can someone tell me why or maybe answer this question that has caused me weeks of hardache

public class SplashLaunch extends View{
    Handler cool = new Handler();
    DrawingView v;
    Paint newPaint = new Paint();
    int randomWidthOne = 0;
    int randomHeightOne = 0;
    private float radiusNsix = 10;
    private float radiusNfive = 25;
    private float radiusNfour = 50;
    private float radiusNthree = 100;
    private float radiusNtwo = 150;
    private float radiusNone = 200;
    private float radiusZero = 250;
    private float radiusOne = 300;
    final int redColorOne = Color.RED;
    final int greenColorOne = Color.GREEN;
    private static int lastColorOne;
    ObjectAnimator radiusAnimator;
    private final Random theRandom = new Random();
    public SplashLaunch(Context context) {
        super(context);
        // TODO Auto-generated constructor stub
    }

    private final Runnable circleUpdater = new Runnable() {
        @Override 
        public void run() {
            lastColorOne = theRandom.nextInt(2) == 1 ? redColorOne : greenColorOne;
            newPaint.setColor(lastColorOne); 
            cool.postDelayed(this, 1000);
            invalidate();
        }
    };

    @Override
    protected void onAttachedToWindow(){
        super.onAttachedToWindow();
        cool.post(circleUpdater);
    }
    protected void onDetachedFromWindow(){
        super.onDetachedFromWindow();
        cool.removeCallbacks(circleUpdater);
    }

    @Override
    protected void onDraw(Canvas canvas) {
        // TODO Auto-generated method stub
        super.onDraw(canvas);
        canvas.drawColor(Color.WHITE);
        if(theRandom == null){
            randomWidthOne =(int) (theRandom.nextInt((int) Math.abs(getWidth()-radiusOne/2)) + radiusOne/2f);
            randomHeightOne = (theRandom.nextInt((int)Math.abs((getHeight()-radiusOne/2 + radiusOne/2f))));
        }else {
            randomWidthOne =(int) (theRandom.nextInt((int) Math.abs(getWidth()-radiusOne/2)) + radiusOne/2f);
            randomHeightOne = (theRandom.nextInt((int)Math.abs((getHeight()-radiusOne/2 + radiusOne/2f))));
        }
        canvas.drawCircle(randomWidthOne, randomHeightOne, radiusNsix, newPaint);
        try {
            Thread.sleep(300);
        } catch (InterruptedException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
        canvas.drawCircle(randomWidthOne, randomHeightOne, radiusNfive, newPaint);
        try {
            Thread.sleep(300);
        } catch (InterruptedException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
        canvas.drawCircle(randomWidthOne, randomHeightOne, radiusNfour, newPaint);
        try {
            Thread.sleep(300);
        } catch (InterruptedException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
        canvas.drawCircle(randomWidthOne, randomHeightOne, radiusNthree, newPaint);
        try {
            Thread.sleep(300);
        } catch (InterruptedException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
        canvas.drawCircle(randomWidthOne, randomHeightOne, radiusNtwo, newPaint);
        try {
            Thread.sleep(300);
        } catch (InterruptedException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
        canvas.drawCircle(randomWidthOne, randomHeightOne, radiusNone, newPaint);
        try {
            Thread.sleep(300);
        } catch (InterruptedException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
        canvas.drawCircle(randomWidthOne, randomHeightOne, radiusZero, newPaint);
        try {
            Thread.sleep(300);
        } catch (InterruptedException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
        canvas.drawCircle(randomWidthOne, randomHeightOne, radiusOne, newPaint);
    }




    public void setRadiusOne(float value){
        this.radiusOne = value;
        invalidate();
    }


    public int startAnimation(int animationDuration) {

        if (radiusAnimator == null || !radiusAnimator.isRunning()) {

            // Define what value the radius is supposed to have at specific time values
            Keyframe kf0 = Keyframe.ofFloat(0f, 0f);
            Keyframe kf2 = Keyframe.ofFloat(0.5f, 180f);
            Keyframe kf1 = Keyframe.ofFloat(1f, 360f);

            // If you pass in the radius, it will be calling setRadius method, so make sure you have it!!!!!
            PropertyValuesHolder pvhRotation = PropertyValuesHolder.ofKeyframe("radiusOne", kf0, kf1, kf2);
            radiusAnimator = ObjectAnimator.ofPropertyValuesHolder(this, pvhRotation);
            radiusAnimator.setInterpolator(new LinearInterpolator());
            radiusAnimator.setDuration(animationDuration);
            radiusAnimator.start();
        }
        else {
            Log.d("Circle", "I am already running!");
        }
        return animationDuration;
    }

    public void stopAnimation() {
        if (radiusAnimator != null) {
            radiusAnimator.cancel();
            radiusAnimator = null;
        }
    }

    public boolean getAnimationRunning() {
        return radiusAnimator != null && radiusAnimator.isRunning();
    }

}

how can i dynamically modify an SQL query in Java?

i'm making a Java program that contains a search engine feature to show the records from the database according to different criterias selected by the user out of comboboxes. I need to be able to modify the WHERE conditions of an SQL query according to what the user has selected. If he hasn't selected any value from the comboboxes then the default would be WHERE=1, if he has selected criteria from one combobox then override the variable so the 1 change it to WHERE state=oklahoma for example, and he selects 2 or more just keep concatenating them: WHERE state=oklahoma AND gender=male, and so on with as many comboboxes he sets.

i've tried to do this but i've read there are libraries that can make this easier but i don't know any, if this can be done with a library please name it and show the code to do it please

Java EE The module has not been deployed netbeans 8.0.2 ant project

I use ant project, java ee7, glassfish server 4.1 jdk7 I'm enclosing picture of structure of my code and persistence.xml http://ctrlv.in/568832 http://ctrlv.in/568833 That's my server logs: (I've shorten them)

  Warning:   AS-DEPLOYMENT-00011
java.lang.NoClassDefFoundError: app/dao/DiscountCodeFacadeRemote
    at java.lang.ClassLoader.defineClass1(Native Method)
    at java.lang.ClassLoader.defineClass(ClassLoader.java:800)
    at com.sun.enterprise.loader.ASURLClassLoader.findClass(ASURLClassLoader.java:801)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:425)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:358)

    at org.glassfish.grizzly.http.server.HttpHandler.runService(HttpHandler.java:201)
    at org.glassfish.grizzly.http.server.HttpHandler.doHandle(HttpHandler.java:175)
    at org.glassfish.grizzly.http.server.HttpServerFilter.handleRead(HttpServerFilter.java:235)
    at org.glassfish.grizzly.filterchain.ExecutorResolver$9.execute(ExecutorResolver.java:119)
    at org.glassfish.grizzly.filterchain.DefaultFilterChain.executeFilter(DefaultFilterChain.java:284)
    at org.glassfish.grizzly.filterchain.DefaultFilterChain.executeChainPart(DefaultFilterChain.java:201)
    at org.glassfish.grizzly.filterchain.DefaultFilterChain.execute(DefaultFilterChain.java:133)
    at org.glassfish.grizzly.filterchain.DefaultFilterChain.process(DefaultFilterChain.java:112)
    at org.glassfish.grizzly.ProcessorExecutor.execute(ProcessorExecutor.java:77)
    at org.glassfish.grizzly.nio.transport.TCPNIOTransport.fireIOEvent(TCPNIOTransport.java:561)
    at org.glassfish.grizzly.strategies.AbstractIOStrategy.fireIOEvent(AbstractIOStrategy.java:112)
    at org.glassfish.grizzly.strategies.WorkerThreadIOStrategy.run0(WorkerThreadIOStrategy.java:117)
    at org.glassfish.grizzly.strategies.WorkerThreadIOStrategy.access$100(WorkerThreadIOStrategy.java:56)
    at org.glassfish.grizzly.strategies.WorkerThreadIOStrategy$WorkerThreadRunnable.run(WorkerThreadIOStrategy.java:137)
    at org.glassfish.grizzly.threadpool.AbstractThreadPool$Worker.doWork(AbstractThreadPool.java:565)
    at org.glassfish.grizzly.threadpool.AbstractThreadPool$Worker.run(AbstractThreadPool.java:545)
    at java.lang.Thread.run(Thread.java:745)
Caused by: java.lang.ClassNotFoundException: app.dao.DiscountCodeFacadeRemote
    at com.sun.enterprise.loader.ASURLClassLoader.findClassData(ASURLClassLoader.java:865)
    at com.sun.enterprise.loader.ASURLClassLoader.findClass(ASURLClassLoader.java:742)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:425)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:358)
    ... 60 more

Warning:   AS-DEPLOYMENT-00011
java.lang.NoClassDefFoundError: app/dao/MicroMarketFacadeRemote
    at java.lang.ClassLoader.defineClass1(Native Method)
    at java.lang.ClassLoader.defineClass(ClassLoader.java:800)
    at com.sun.enterprise.loader.ASURLClassLoader.findClass(ASURLClassLoader.java:801)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:425)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:358)
    at com.sun.enterprise.deployment.annotation.impl.ModuleScanner.getElements(ModuleScanner.java:297)
    at com.sun.enterprise.deployment.archivist.Archivist.processAnnotations(Archivist.java:585)
    at com.sun.enterprise.deployment.archivist.Archivist.readAnnotations(Archivist.java:462)
    at com.sun.enterprise.deployment.archivist.Archivist.readAnnotations(Archivist.java:446)
    at com.sun.enterprise.deployment.archivist.Archivist.readRestDeploymentDescriptors(Archivist.java:419)
    at com.sun.enterprise.deployment.archivist.Archivist.readDeploymentDescriptors(Archivist.java:396)
    at com.sun.enterprise.deployment.archivist.Archivist.open(Archivist.java:271)
    at com.sun.enterprise.deployment.archivist.Archivist.open(Archivist.java:280)
    at com.sun.enterprise.deployment.archivist.ApplicationArchivist.readModulesDescriptors(ApplicationArchivist.java:611)
    at com.sun.enterprise.deployment.archivist.ApplicationArchivist.openWith(ApplicationArchivist.java:229)
    at com.sun.enterprise.deployment.archivist.ApplicationFactory.openWith(ApplicationFactory.java:232)
    at org.glassfish.javaee.core.deployment.DolProvider.processDOL(DolProvider.java:193)
    at org.glassfish.javaee.core.deployment.DolProvider.load(DolProvider.java:227)
    at org.glassfish.javaee.core.deployment.DolProvider.load(DolProvider.java:96)
    at com.sun.enterprise.v3.server.ApplicationLifecycle.loadDeployer(ApplicationLifecycle.java:881)
    at com.sun.enterprise.v3.server.ApplicationLifecycle.setupContainerInfos(ApplicationLifecycle.java:821)
    at com.sun.enterprise.v3.server.ApplicationLifecycle.deploy(ApplicationLifecycle.java:377)
    at com.sun.enterprise.v3.server.ApplicationLifecycle.deploy(ApplicationLifecycle.java:219)
    at org.glassfish.deployment.admin.DeployCommand.execute(DeployCommand.java:491)
    at com.sun.enterprise.v3.admin.CommandRunnerImpl$2$1.run(CommandRunnerImpl.java:539)
    at com.sun.enterprise.v3.admin.CommandRunnerImpl$2$1.run(CommandRunnerImpl.java:535)
    at java.security.AccessController.doPrivileged(Native Method)
    at javax.security.auth.Subject.doAs(Subject.java:356)
    at com.sun.enterprise.v3.admin.CommandRunnerImpl$2.execute(CommandRunnerImpl.java:534)
    at com.sun.enterprise.v3.admin.CommandRunnerImpl$3.run(CommandRunnerImpl.java:565)
    at com.sun.enterprise.v3.admin.CommandRunnerImpl$3.run(CommandRunnerImpl.java:557)
    at java.security.AccessController.doPrivileged(Native Method)
    at javax.security.auth.Subject.doAs(Subject.java:356)
    at com.sun.enterprise.v3.admin.CommandRunnerImpl.doCommand(CommandRunnerImpl.java:556)
    at com.sun.enterprise.v3.admin.CommandRunnerImpl.doCommand(CommandRunnerImpl.java:1464)
    at com.sun.enterprise.v3.admin.CommandRunnerImpl.access$1300(CommandRunnerImpl.java:109)
    at com.sun.enterprise.v3.admin.CommandRunnerImpl$ExecutionContext.execute(CommandRunnerImpl.java:1846)
    at com.sun.enterprise.v3.admin.CommandRunnerImpl$ExecutionContext.execute(CommandRunnerImpl.java:1722)
    at com.sun.enterprise.v3.admin.AdminAdapter.doCommand(AdminAdapter.java:534)
    at com.sun.enterprise.v3.admin.AdminAdapter.onMissingResource(AdminAdapter.java:224)
    at org.glassfish.grizzly.http.server.StaticHttpHandlerBase.service(StaticHttpHandlerBase.java:189)
    at com.sun.enterprise.v3.services.impl.ContainerMapper$HttpHandlerCallable.call(ContainerMapper.java:459)
    at com.sun.enterprise.v3.services.impl.ContainerMapper.service(ContainerMapper.java:167)
    at org.glassfish.grizzly.http.server.HttpHandler.runService(HttpHandler.java:201)
    at org.glassfish.grizzly.http.server.HttpHandler.doHandle(HttpHandler.java:175)
    at org.glassfish.grizzly.http.server.HttpServerFilter.handleRead(HttpServerFilter.java:235)
    at org.glassfish.grizzly.filterchain.ExecutorResolver$9.execute(ExecutorResolver.java:119)
    at org.glassfish.grizzly.filterchain.DefaultFilterChain.executeFilter(DefaultFilterChain.java:284)
    at org.glassfish.grizzly.filterchain.DefaultFilterChain.executeChainPart(DefaultFilterChain.java:201)
    at org.glassfish.grizzly.filterchain.DefaultFilterChain.execute(DefaultFilterChain.java:133)
    at org.glassfish.grizzly.filterchain.DefaultFilterChain.process(DefaultFilterChain.java:112)
    at org.glassfish.grizzly.ProcessorExecutor.execute(ProcessorExecutor.java:77)
    at org.glassfish.grizzly.nio.transport.TCPNIOTransport.fireIOEvent(TCPNIOTransport.java:561)
    at org.glassfish.grizzly.strategies.AbstractIOStrategy.fireIOEvent(AbstractIOStrategy.java:112)
    at org.glassfish.grizzly.strategies.WorkerThreadIOStrategy.run0(WorkerThreadIOStrategy.java:117)
    at org.glassfish.grizzly.strategies.WorkerThreadIOStrategy.access$100(WorkerThreadIOStrategy.java:56)
    at org.glassfish.grizzly.strategies.WorkerThreadIOStrategy$WorkerThreadRunnable.run(WorkerThreadIOStrategy.java:137)
    at org.glassfish.grizzly.threadpool.AbstractThreadPool$Worker.doWork(AbstractThreadPool.java:565)
    at org.glassfish.grizzly.threadpool.AbstractThreadPool$Worker.run(AbstractThreadPool.java:545)
    at java.lang.Thread.run(Thread.java:745)
Caused by: java.lang.ClassNotFoundException: app.dao.MicroMarketFacadeRemote
    at com.sun.enterprise.loader.ASURLClassLoader.findClassData(ASURLClassLoader.java:865)
    at com.sun.enterprise.loader.ASURLClassLoader.findClass(ASURLClassLoader.java:742)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:425)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:358)
    ... 60 more

Warning:   AS-DEPLOYMENT-00011
java.lang.NoClassDefFoundError: app/dao/CustomerFacadeRemote
    at java.lang.ClassLoader.defineClass1(Native Method)
    at java.lang.ClassLoader.defineClass(ClassLoader.java:800)
    at com.sun.enterprise.loader.ASURLClassLoader.findClass(ASURLClassLoader.java:801)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:425)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:358)
    at com.sun.enterprise.deployment.annotation.impl.ModuleScanner.getElements(ModuleScanner.java:297)
    at com.sun.enterprise.deployment.archivist.Archivist.processAnnotations(Archivist.java:585)
    at com.sun.enterprise.deployment.archivist.Archivist.readAnnotations(Archivist.java:462)
    at com.sun.enterprise.deployment.archivist.Archivist.readAnnotations(Archivist.java:446)
    at com.sun.enterprise.deployment.archivist.Archivist.readRestDeploymentDescriptors(Archivist.java:419)
    at com.sun.enterprise.deployment.archivist.Archivist.readDeploymentDescriptors(Archivist.java:396)
    at com.sun.enterprise.deployment.archivist.Archivist.open(Archivist.java:271)
    at com.sun.enterprise.deployment.archivist.Archivist.open(Archivist.java:280)
    at com.sun.enterprise.deployment.archivist.ApplicationArchivist.readModulesDescriptors(ApplicationArchivist.java:611)
    at com.sun.enterprise.deployment.archivist.ApplicationArchivist.openWith(ApplicationArchivist.java:229)
    at com.sun.enterprise.deployment.archivist.ApplicationFactory.openWith(ApplicationFactory.java:232)
    at org.glassfish.javaee.core.deployment.DolProvider.processDOL(DolProvider.java:193)
    at org.glassfish.javaee.core.deployment.DolProvider.load(DolProvider.java:227)
    at org.glassfish.javaee.core.deployment.DolProvider.load(DolProvider.java:96)
    at com.sun.enterprise.v3.server.ApplicationLifecycle.loadDeployer(ApplicationLifecycle.java:881)
    at com.sun.enterprise.v3.server.ApplicationLifecycle.setupContainerInfos(ApplicationLifecycle.java:821)
    at com.sun.enterprise.v3.server.ApplicationLifecycle.deploy(ApplicationLifecycle.java:377)
    at com.sun.enterprise.v3.server.ApplicationLifecycle.deploy(ApplicationLifecycle.java:219)
    at org.glassfish.deployment.admin.DeployCommand.execute(DeployCommand.java:491)
    at com.sun.enterprise.v3.admin.CommandRunnerImpl$2$1.run(CommandRunnerImpl.java:539)
    at com.sun.enterprise.v3.admin.CommandRunnerImpl$2$1.run(CommandRunnerImpl.java:535)
    at java.security.AccessController.doPrivileged(Native Method)
    at javax.security.auth.Subject.doAs(Subject.java:356)
    at com.sun.enterprise.v3.admin.CommandRunnerImpl$2.execute(CommandRunnerImpl.java:534)
    at com.sun.enterprise.v3.admin.CommandRunnerImpl$3.run(CommandRunnerImpl.java:565)
    at com.sun.enterprise.v3.admin.CommandRunnerImpl$3.run(CommandRunnerImpl.java:557)
    at java.security.AccessController.doPrivileged(Native Method)
    at javax.security.auth.Subject.doAs(Subject.java:356)
    at com.sun.enterprise.v3.admin.CommandRunnerImpl.doCommand(CommandRunnerImpl.java:556)
    at com.sun.enterprise.v3.admin.CommandRunnerImpl.doCommand(CommandRunnerImpl.java:1464)
    at com.sun.enterprise.v3.admin.CommandRunnerImpl.access$1300(CommandRunnerImpl.java:109)
    at com.sun.enterprise.v3.admin.CommandRunnerImpl$ExecutionContext.execute(CommandRunnerImpl.java:1846)
    at com.sun.enterprise.v3.admin.CommandRunnerImpl$ExecutionContext.execute(CommandRunnerImpl.java:1722)
    at com.sun.enterprise.v3.admin.AdminAdapter.doCommand(AdminAdapter.java:534)
    at com.sun.enterprise.v3.admin.AdminAdapter.onMissingResource(AdminAdapter.java:224)
    at org.glassfish.grizzly.http.server.StaticHttpHandlerBase.service(StaticHttpHandlerBase.java:189)
    at com.sun.enterprise.v3.services.impl.ContainerMapper$HttpHandlerCallable.call(ContainerMapper.java:459)
    at com.sun.enterprise.v3.services.impl.ContainerMapper.service(ContainerMapper.java:167)
    at org.glassfish.grizzly.http.server.HttpHandler.runService(HttpHandler.java:201)
    at org.glassfish.grizzly.http.server.HttpHandler.doHandle(HttpHandler.java:175)
    at org.glassfish.grizzly.http.server.HttpServerFilter.handleRead(HttpServerFilter.java:235)
    at org.glassfish.grizzly.filterchain.ExecutorResolver$9.execute(ExecutorResolver.java:119)
    at org.glassfish.grizzly.filterchain.DefaultFilterChain.executeFilter(DefaultFilterChain.java:284)
    at org.glassfish.grizzly.filterchain.DefaultFilterChain.executeChainPart(DefaultFilterChain.java:201)
    at org.glassfish.grizzly.filterchain.DefaultFilterChain.execute(DefaultFilterChain.java:133)
    at org.glassfish.grizzly.filterchain.DefaultFilterChain.process(DefaultFilterChain.java:112)
    at org.glassfish.grizzly.ProcessorExecutor.execute(ProcessorExecutor.java:77)
    at org.glassfish.grizzly.nio.transport.TCPNIOTransport.fireIOEvent(TCPNIOTransport.java:561)
    at org.glassfish.grizzly.strategies.AbstractIOStrategy.fireIOEvent(AbstractIOStrategy.java:112)
    at org.glassfish.grizzly.strategies.WorkerThreadIOStrategy.run0(WorkerThreadIOStrategy.java:117)
    at org.glassfish.grizzly.strategies.WorkerThreadIOStrategy.access$100(WorkerThreadIOStrategy.java:56)
    at org.glassfish.grizzly.strategies.WorkerThreadIOStrategy$WorkerThreadRunnable.run(WorkerThreadIOStrategy.java:137)
    at org.glassfish.grizzly.threadpool.AbstractThreadPool$Worker.doWork(AbstractThreadPool.java:565)
    at org.glassfish.grizzly.threadpool.AbstractThreadPool$Worker.run(AbstractThreadPool.java:545)
    at java.lang.Thread.run(Thread.java:745)
Caused by: java.lang.ClassNotFoundException: app.dao.CustomerFacadeRemote
    at com.sun.enterprise.loader.ASURLClassLoader.findClassData(ASURLClassLoader.java:865)
    at com.sun.enterprise.loader.ASURLClassLoader.findClass(ASURLClassLoader.java:742)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:425)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:358)
    ... 60 more

Warning:   AS-DEPLOYMENT-00011
java.lang.NoClassDefFoundError: app/dao/DiscountCodeFacadeRemote
    at java.lang.ClassLoader.defineClass1(Native Method)
    at java.lang.ClassLoader.defineClass(ClassLoader.java:800)


    at com.sun.enterprise.loader.ASURLClassLoader.findClass(ASURLClassLoader.java:742)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:425)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:358)
    ... 61 more

Warning:   AS-DEPLOYMENT-00011
java.lang.NoClassDefFoundError: app/dao/MicroMarketFacadeRemote
    at java.lang.ClassLoader.defineClass1(Native Method)
    at java.lang.ClassLoader.defineClass(ClassLoader.java:800)
    at com.sun.enterprise.loader.ASURLClassLoader.findClass(ASURLClassLoader.java:801)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:425)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:358)
    at com.sun.enterprise.deployment.annotation.impl.ModuleScanner.getElements(ModuleScanner.java:297)
    at org.glassfish.apf.impl.AnnotationProcessorImpl.process(AnnotationProcessorImpl.java:132)
    at com.sun.enterprise.deployment.archivist.Archivist.processAnnotations(Archivist.java:626)
    at com.sun.enterprise.deployment.archivist.Archivist.readAnnotations(Archivist.java:462)
    at com.sun.enterprise.deployment.archivist.Archivist.readAnnotations(Archivist.java:446)
    at com.sun.enterprise.deployment.archivist.Archivist.readRestDeploymentDescriptors(Archivist.java:419)
    at com.sun.enterprise.deployment.archivist.Archivist.readDeploymentDescriptors(Archivist.java:396)
    at com.sun.enterprise.deployment.archivist.Archivist.open(Archivist.java:271)
    at com.sun.enterprise.deployment.archivist.Archivist.open(Archivist.java:280)
    at com.sun.enterprise.deployment.archivist.ApplicationArchivist.readModulesDescriptors(ApplicationArchivist.java:611)
    at com.sun.enterprise.deployment.archivist.ApplicationArchivist.openWith(ApplicationArchivist.java:229)
    at com.sun.enterprise.deployment.archivist.ApplicationFactory.openWith(ApplicationFactory.java:232)
    at org.glassfish.javaee.core.deployment.DolProvider.processDOL(DolProvider.java:193)
    at org.glassfish.javaee.core.deployment.DolProvider.load(DolProvider.java:227)
    at org.glassfish.javaee.core.deployment.DolProvider.load(DolProvider.java:96)
    at com.sun.enterprise.v3.server.ApplicationLifecycle.loadDeployer(ApplicationLifecycle.java:881)
    at com.sun.enterprise.v3.server.ApplicationLifecycle.setupContainerInfos(ApplicationLifecycle.java:821)
    at com.sun.enterprise.v3.server.ApplicationLifecycle.deploy(ApplicationLifecycle.java:377)
    at com.sun.enterprise.v3.server.ApplicationLifecycle.deploy(ApplicationLifecycle.java:219)
    at org.glassfish.deployment.admin.DeployCommand.execute(DeployCommand.java:491)
    at com.sun.enterprise.v3.admin.CommandRunnerImpl$2$1.run(CommandRunnerImpl.java:539)
    at com.sun.enterprise.v3.admin.CommandRunnerImpl$2$1.run(CommandRunnerImpl.java:535)
    at java.security.AccessController.doPrivileged(Native Method)
    at javax.security.auth.Subject.doAs(Subject.java:356)
    at com.sun.enterprise.v3.admin.CommandRunnerImpl$2.execute(CommandRunnerImpl.java:534)
    at com.sun.enterprise.v3.admin.CommandRunnerImpl$3.run(CommandRunnerImpl.java:565)
    at com.sun.enterprise.v3.admin.CommandRunnerImpl$3.run(CommandRunnerImpl.java:557)
    at java.security.AccessController.doPrivileged(Native Method)
    at javax.security.auth.Subject.doAs(Subject.java:356)
    at com.sun.enterprise.v3.admin.CommandRunnerImpl.doCommand(CommandRunnerImpl.java:556)
    at com.sun.enterprise.v3.admin.CommandRunnerImpl.doCommand(CommandRunnerImpl.java:1464)
    at com.sun.enterprise.v3.admin.CommandRunnerImpl.access$1300(CommandRunnerImpl.java:109)
    at com.sun.enterprise.v3.admin.CommandRunnerImpl$ExecutionContext.execute(CommandRunnerImpl.java:1846)
    at com.sun.enterprise.v3.admin.CommandRunnerImpl$ExecutionContext.execute(CommandRunnerImpl.java:1722)
    at com.sun.enterprise.v3.admin.AdminAdapter.doCommand(AdminAdapter.java:534)
    at com.sun.enterprise.v3.admin.AdminAdapter.onMissingResource(AdminAdapter.java:224)
    at org.glassfish.grizzly.http.server.StaticHttpHandlerBase.service(StaticHttpHandlerBase.java:189)
    at com.sun.enterprise.v3.services.impl.ContainerMapper$HttpHandlerCallable.call(ContainerMapper.java:459)
    at com.sun.enterprise.v3.services.impl.ContainerMapper.service(ContainerMapper.java:167)
    at org.glassfish.grizzly.http.server.HttpHandler.runService(HttpHandler.java:201)
    at org.glassfish.grizzly.http.server.HttpHandler.doHandle(HttpHandler.java:175)
    at org.glassfish.grizzly.http.server.HttpServerFilter.handleRead(HttpServerFilter.java:235)
    at org.glassfish.grizzly.filterchain.ExecutorResolver$9.execute(ExecutorResolver.java:119)
    at org.glassfish.grizzly.filterchain.DefaultFilterChain.executeFilter(DefaultFilterChain.java:284)
    at org.glassfish.grizzly.filterchain.DefaultFilterChain.executeChainPart(DefaultFilterChain.java:201)
    at org.glassfish.grizzly.filterchain.DefaultFilterChain.execute(DefaultFilterChain.java:133)
    at org.glassfish.grizzly.filterchain.DefaultFilterChain.process(DefaultFilterChain.java:112)
    at org.glassfish.grizzly.ProcessorExecutor.execute(ProcessorExecutor.java:77)
    at org.glassfish.grizzly.nio.transport.TCPNIOTransport.fireIOEvent(TCPNIOTransport.java:561)
    at org.glassfish.grizzly.strategies.AbstractIOStrategy.fireIOEvent(AbstractIOStrategy.java:112)
    at org.glassfish.grizzly.strategies.WorkerThreadIOStrategy.run0(WorkerThreadIOStrategy.java:117)
    at org.glassfish.grizzly.strategies.WorkerThreadIOStrategy.access$100(WorkerThreadIOStrategy.java:56)
    at org.glassfish.grizzly.strategies.WorkerThreadIOStrategy$WorkerThreadRunnable.run(WorkerThreadIOStrategy.java:137)
    at org.glassfish.grizzly.threadpool.AbstractThreadPool$Worker.doWork(AbstractThreadPool.java:565)
    at org.glassfish.grizzly.threadpool.AbstractThreadPool$Worker.run(AbstractThreadPool.java:545)
    at java.lang.Thread.run(Thread.java:745)
Caused by: java.lang.ClassNotFoundException: app.dao.MicroMarketFacadeRemote
    at com.sun.enterprise.loader.ASURLClassLoader.findClassData(ASURLClassLoader.java:833)
    at com.sun.enterprise.loader.ASURLClassLoader.findClass(ASURLClassLoader.java:742)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:425)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:358)
    ... 61 more

Warning:   AS-DEPLOYMENT-00011
java.lang.NoClassDefFoundError: app/dao/CustomerFacadeRemote
    at java.lang.ClassLoader.defineClass1(Native Method)
    at java.lang.ClassLoader.defineClass(ClassLoader.java:800)
    at com.sun.enterprise.loader.ASURLClassLoader.findClass(ASURLClassLoader.java:801)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:425)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:358)
    at com.sun.enterprise.deployment.annotation.impl.ModuleScanner.getElements(ModuleScanner.java:297)
    at org.glassfish.apf.impl.AnnotationProcessorImpl.process(AnnotationProcessorImpl.java:132)
    at com.sun.enterprise.deployment.archivist.Archivist.processAnnotations(Archivist.java:626)
    at com.sun.enterprise.deployment.archivist.Archivist.readAnnotations(Archivist.java:462)
    at com.sun.enterprise.deployment.archivist.Archivist.readAnnotations(Archivist.java:446)
    at com.sun.enterprise.deployment.archivist.Archivist.readRestDeploymentDescriptors(Archivist.java:419)
    at com.sun.enterprise.deployment.archivist.Archivist.readDeploymentDescriptors(Archivist.java:396)
    at com.sun.enterprise.deployment.archivist.Archivist.open(Archivist.java:271)
    at com.sun.enterprise.deployment.archivist.Archivist.open(Archivist.java:280)
    at com.sun.enterprise.deployment.archivist.ApplicationArchivist.readModulesDescriptors(ApplicationArchivist.java:611)
    at com.sun.enterprise.deployment.archivist.ApplicationArchivist.openWith(ApplicationArchivist.java:229)
    at com.sun.enterprise.deployment.archivist.ApplicationFactory.openWith(ApplicationFactory.java:232)
    at org.glassfish.javaee.core.deployment.DolProvider.processDOL(DolProvider.java:193)
    at org.glassfish.javaee.core.deployment.DolProvider.load(DolProvider.java:227)
    at org.glassfish.javaee.core.deployment.DolProvider.load(DolProvider.java:96)
    at com.sun.enterprise.v3.server.ApplicationLifecycle.loadDeployer(ApplicationLifecycle.java:881)
    at com.sun.enterprise.v3.server.ApplicationLifecycle.setupContainerInfos(ApplicationLifecycle.java:821)
    at com.sun.enterprise.v3.server.ApplicationLifecycle.deploy(ApplicationLifecycle.java:377)
    at com.sun.enterprise.v3.server.ApplicationLifecycle.deploy(ApplicationLifecycle.java:219)
    at org.glassfish.deployment.admin.DeployCommand.execute(DeployCommand.java:491)
    at com.sun.enterprise.v3.admin.CommandRunnerImpl$2$1.run(CommandRunnerImpl.java:539)
    at com.sun.enterprise.v3.admin.CommandRunnerImpl$2$1.run(CommandRunnerImpl.java:535)
    at java.security.AccessController.doPrivileged(Native Method)
    at javax.security.auth.Subject.doAs(Subject.java:356)
    at com.sun.enterprise.v3.admin.CommandRunnerImpl$2.execute(CommandRunnerImpl.java:534)
    at com.sun.enterprise.v3.admin.CommandRunnerImpl$3.run(CommandRunnerImpl.java:565)
    at com.sun.enterprise.v3.admin.CommandRunnerImpl$3.run(CommandRunnerImpl.java:557)
    at java.security.AccessController.doPrivileged(Native Method)
    at javax.security.auth.Subject.doAs(Subject.java:356)
    at com.sun.enterprise.v3.admin.CommandRunnerImpl.doCommand(CommandRunnerImpl.java:556)
    at com.sun.enterprise.v3.admin.CommandRunnerImpl.doCommand(CommandRunnerImpl.java:1464)
    at com.sun.enterprise.v3.admin.CommandRunnerImpl.access$1300(CommandRunnerImpl.java:109)
    at com.sun.enterprise.v3.admin.CommandRunnerImpl$ExecutionContext.execute(CommandRunnerImpl.java:1846)
    at com.sun.enterprise.v3.admin.CommandRunnerImpl$ExecutionContext.execute(CommandRunnerImpl.java:1722)
    at com.sun.enterprise.v3.admin.AdminAdapter.doCommand(AdminAdapter.java:534)
    at com.sun.enterprise.v3.admin.AdminAdapter.onMissingResource(AdminAdapter.java:224)
    at org.glassfish.grizzly.http.server.StaticHttpHandlerBase.service(StaticHttpHandlerBase.java:189)
    at com.sun.enterprise.v3.services.impl.ContainerMapper$HttpHandlerCallable.call(ContainerMapper.java:459)
    at com.sun.enterprise.v3.services.impl.ContainerMapper.service(ContainerMapper.java:167)
    at org.glassfish.grizzly.http.server.HttpHandler.runService(HttpHandler.java:201)
    at org.glassfish.grizzly.http.server.HttpHandler.doHandle(HttpHandler.java:175)
    at org.glassfish.grizzly.http.server.HttpServerFilter.handleRead(HttpServerFilter.java:235)
    at org.glassfish.grizzly.filterchain.ExecutorResolver$9.execute(ExecutorResolver.java:119)
    at org.glassfish.grizzly.filterchain.DefaultFilterChain.executeFilter(DefaultFilterChain.java:284)
    at org.glassfish.grizzly.filterchain.DefaultFilterChain.executeChainPart(DefaultFilterChain.java:201)
    at org.glassfish.grizzly.filterchain.DefaultFilterChain.execute(DefaultFilterChain.java:133)
    at org.glassfish.grizzly.filterchain.DefaultFilterChain.process(DefaultFilterChain.java:112)
    at org.glassfish.grizzly.ProcessorExecutor.execute(ProcessorExecutor.java:77)
    at org.glassfish.grizzly.nio.transport.TCPNIOTransport.fireIOEvent(TCPNIOTransport.java:561)
    at org.glassfish.grizzly.strategies.AbstractIOStrategy.fireIOEvent(AbstractIOStrategy.java:112)
    at org.glassfish.grizzly.strategies.WorkerThreadIOStrategy.run0(WorkerThreadIOStrategy.java:117)
    at org.glassfish.grizzly.strategies.WorkerThreadIOStrategy.access$100(WorkerThreadIOStrategy.java:56)
    at org.glassfish.grizzly.strategies.WorkerThreadIOStrategy$WorkerThreadRunnable.run(WorkerThreadIOStrategy.java:137)
    at org.glassfish.grizzly.threadpool.AbstractThreadPool$Worker.doWork(AbstractThreadPool.java:565)
    at org.glassfish.grizzly.threadpool.AbstractThreadPool$Worker.run(AbstractThreadPool.java:545)
    at java.lang.Thread.run(Thread.java:745)
Caused by: java.lang.ClassNotFoundException: app.dao.CustomerFacadeRemote
    at com.sun.enterprise.loader.ASURLClassLoader.findClassData(ASURLClassLoader.java:833)
    at com.sun.enterprise.loader.ASURLClassLoader.findClass(ASURLClassLoader.java:742)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:425)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:358)
    ... 61 more

Severe:   Exception while deploying the app [EnterpriseApplication3]
Severe:   Exception during lifecycle processing
java.lang.IllegalArgumentException: Invalid ejb jar [EnterpriseApplication3-ejb.jar]: it contains zero ejb. 
Note: 
1. A valid ejb jar requires at least one session, entity (1.x/2.x style), or message-driven bean. 
2. EJB3+ entity beans (@Entity) are POJOs and please package them as library jar. 
3. If the jar file contains valid EJBs which are annotated with EJB component level annotations (@Stateless, @Stateful, @MessageDriven, @Singleton), please check server.log to see whether the annotations were processed properly.
    at org.glassfish.ejb.deployment.util.EjbBundleValidator.accept(EjbBundleValidator.java:147)
    at org.glassfish.ejb.deployment.util.EjbBundleValidator.accept(EjbBundleValidator.java:112)
    at com.sun.enterprise.deployment.BundleDescriptor.visit(BundleDescriptor.java:625)
    at org.glassfish.ejb.deployment.descriptor.EjbBundleDescriptorImpl.visit(EjbBundleDescriptorImpl.java:757)


Severe:   Exception while deploying the app [EnterpriseApplication3] : Invalid ejb jar [EnterpriseApplication3-ejb.jar]: it contains zero ejb. 
Note: 
1. A valid ejb jar requires at least one session, entity (1.x/2.x style), or message-driven bean. 
2. EJB3+ entity beans (@Entity) are POJOs and please package them as library jar. 
3. If the jar file contains valid EJBs which are annotated with EJB component level annotations (@Stateless, @Stateful, @MessageDriven, @Singleton), please check server.log to see whether the annotations were processed properly.

How to get the database snapsho of a Managed Entity just beore it is flushed

I wonder if Hibernate could retrieve the original field value of an Entity before updating it?

For example, having the entity

class StkItem {
     private int Qty;
}

After the user enters a new quantity, could I know what is the database value of Qty before saving the new value?

File Processing with Akka?

This is rather a design problem. I don't know how to achieve this in Akka

User Story
- I need to parse big files (> 10 million lines) which look like

2013-05-09 11:09:01 Local4.Debug    172.2.10.111    %MMT-7-715036: Group = 199.19.248.164, IP = 199.19.248.164, Sending keep-alive of type DPD R-U-THERE (seq number 0x7db7a2f3)
2013-05-09 11:09:01 Local4.Debug    172.2.10.111    %MMT-7-715046: Group = 199.19.248.164, IP = 199.19.248.164, constructing blank hash payload
2013-05-09 11:09:01 Local4.Debug    172.2.10.111    %MMT-7-715046: Group = 199.19.248.164, IP = 199.19.248.164, constructing qm hash payload
2013-05-09 11:09:01 Local4.Debug    172.2.10.111    %ASA-7-713236: IP = 199.19.248.164, IKE_DECODE SENDING Message (msgid=61216d3e) with payloads : HDR + HASH (8) + NOTIFY (11) + NONE (0) total length : 84
2013-05-09 11:09:01 Local4.Debug    172.22.10.111   %MMT-7-713236: IP = 199.19.248.164, IKE_DECODE RECEIVED Message (msgid=867466fe) with payloads : HDR + HASH (8) + NOTIFY (11) + NONE (0) total length : 84

  • For each line I need to generate some Event that will be sent to server.

Question
- How can I read this log file efficiently in Akka model? I read that reading a file synchronously is better because of less magnetic tape movement.
- In that case, there could be FileReaderActor per file, that would read each line and send them for processing to lets say EventProcessorRouter and Router may have many actors working on line (from file) and creating Event. There would be 1 Event per line
- I was also thinking of sending Events in batch to avoid too much data transfer in network. In such cases, where shall I keep accumulating these Events? and How would I know if I all Events are generated from inputFile?

Thanks

Hibernate Persistencebag remove element from list

I have two entities:

the first one:

    @Entity
    public class A{

    @OneToMany(mappedBy = "a", targetEntity = B.class, ...)
        @LazyCollection(LazyCollectionOption.FALSE)
        private List<B> b;

getter and setter

    }

and the second one:

@Entity
public class B{

@ManyToOne(targetEntity = A.class, ...)
    @JoinColumn(name = "aId",...)
    private A a;

now i read the data from the database and i want to remove some elements:

List<B> bList = a.getB();
for(B b: bList)
    if(some condiction)
      bList.remove(b)

why i can't? why is bList a persistanceBag and not an ArrayList? How can remove items from bList? why can i see only one item in the debug modus?

Thanks Chees

data not shown in the screen

I have to parse data from my database in an Emulator via J2Me phone so I have a list of information to show in the screen but I got a result -1 for integer fields and Null fo strings, when I display my output it says: java.lang.ArrayIndexOutOfBoundsException: 0, it can never call the first element and this's the code

import Entities.Gerant ;
import Handlers.GerantHandler;
import java.io.DataInputStream;
import javax.microedition.io.Connector;
import javax.microedition.io.HttpConnection;
import javax.microedition.lcdui.Command;
import javax.microedition.lcdui.CommandListener;
import javax.microedition.lcdui.Display;
import javax.microedition.lcdui.Displayable;
import javax.microedition.lcdui.Form;
import javax.microedition.lcdui.List;
import javax.microedition.midlet.*;
import javax.xml.parsers.SAXParser;
import javax.xml.parsers.SAXParserFactory;

public class ShowMidlet extends MIDlet implements CommandListener, Runnable              {
Display disp = Display.getDisplay(this);
Command cmdParse = new Command("Gerants", Command.SCREEN, 0);
Command cmdBack = new Command("Back", Command.BACK, 0);
Gerant[] gerants;
List lst = new List("Gerant", List.IMPLICIT);
Form f = new Form("Accueil");
Form form = new Form("Infos gerants");    
Form loadingDialog = new Form("Please Wait");
StringBuffer sb = new StringBuffer();
public void startApp() {
    f.append("Click ");
    f.addCommand(cmdParse);     
    f.setCommandListener(this);               
    lst.setCommandListener(this);        
    form.addCommand(cmdBack);
    form.setCommandListener(this);        
    disp.setCurrent(f);
}

public void pauseApp() {
}

public void destroyApp(boolean unconditional) {
}

public void commandAction(Command c, Displayable d) {

    if (c == cmdParse) {
        disp.setCurrent(form);
        Thread th = new Thread(this);
        th.start();
    }

    if (c == List.SELECT_COMMAND) {
        form.append("show informations: \n");
        form.append(showGerant(lst.getSelectedIndex()));
        disp.setCurrent(form);
    }

    if (c == cmdBack) {
        disp.setCurrent(f);
    }
}

public void run() {
    try {
        // this will handle our XML
        GerantHandler gerHandler = new GerantHandler();
        // get a parser object
        SAXParser parser = SAXParserFactory.newInstance().newSAXParser();
        // get an InputStream from somewhere (could be HttpConnection, for example)
        HttpConnection hc = (HttpConnection)
                Connector.open("http://localhost/sprintj2me/getXmlGerantsAttributes.php");
        DataInputStream dis = new DataInputStream(hc.openDataInputStream());
        parser.parse(dis, gerHandler);
        // display the result
        gerants = gerHandler.getGerant();

        if (gerants.length > 0) {
            for (int i = 0; i < gerants.length; i++) {
                lst.append(gerants[i].getIdCompte()+" "
                          +gerants[i].getLogin()+" "
                          +gerants[i].getMotDePasse()+" "
                          +gerants[i].getNom()+" "
                          +gerants[i].getPrenom()+" "
                          +gerants[i].getEmail()+" "
                          +gerants[i].getDateNaissance()+" "
                          +gerants[i].getAdresse()+" "
                          +gerants[i].getNumeroTelephone(),  null);
            }
        }

    } catch (Exception e) {
        System.out.println("Exception:" + e.toString());
    }
    disp.setCurrent(lst);
}

private String showGerant(int i) {
    String res = "";
    if (gerants.length > 0) {
        sb.append("* ");
        sb.append(gerants[i].getIdCompte());
        sb.append("\n");

        sb.append("* ");
        sb.append(gerants[i].getLogin());
        sb.append("\n");

        sb.append("* ");
        sb.append(gerants[i].getMotDePasse());
        sb.append("\n");

        sb.append("* ");
        sb.append(gerants[i].getNom());
        sb.append("\n");

        sb.append("* ");
        sb.append(gerants[i].getPrenom());
        sb.append("\n");

        sb.append("* ");
        sb.append(gerants[i].getEmail());
        sb.append("\n");

        sb.append("* ");
        sb.append(gerants[i].getDateNaissance());
        sb.append("\n");

        sb.append("* ");
        sb.append(gerants[i].getAdresse());
        sb.append("\n");

        sb.append("* ");
        sb.append(gerants[i].getNumeroTelephone());
        sb.append("\n");            
    }
    res = sb.toString();
    sb = new StringBuffer("");
    return res;
}

}

Apache spark maven tomcat:run

I want to run Apache Spark from a spring project with multiple maven module. Spring project running correctly without apache spark dependency but when I added spark dependency java.lang.ClassCastException: org.springframework.web.servlet.DispatcherServlet cannot be cast to javax.servlet.Servlet

spark dependencies:

 <dependency>
      <groupId>org.apache.spark</groupId>
      <artifactId>spark-core_2.10</artifactId>
      <version>1.2.0</version>
      <scope>provided</scope>
    </dependency>
    <dependency>
    <groupId>org.apache.spark</groupId>
       <artifactId>spark-mllib_2.10</artifactId>
       <version>1.2.0</version>
      <scope>provided</scope>
    </dependency>
    <dependency>
      <groupId>org.apache.hadoop</groupId>
      <artifactId>hadoop-core</artifactId>
      <version>0.20.2</version>
      <scope>provided</scope>
    </dependency>
   <dependency>
      <groupId>org.apache.hadoop</groupId>
      <artifactId>hadoop-client</artifactId>
      <version>2.5.2</version>
      <scope>provided</scope>
    </dependency>
    <dependency>
      <groupId>org.apache.spark</groupId>
      <artifactId>spark-assembly-jar</artifactId>
      <version>1.3.0</version>
    </dependency>

JavaFX - How to delete a specific Node from an AnchorPane

I'm using SceneBuilder 8.0.0 and JavaFX 8.
I have a Button btn and a Label lbl attached to an AnchorPane ap.
When the application starts, btn and lbl are attached to ap.

How can i delete one of these nodes ? (i only know clear() method which delete all the nodes from ap). thanks.

How do I make my JApplet game to not be blocked by security restrictions?

I have made a very simple game for my students to play using java to review what they have learned. I have put an HTML file containing the JApplet on my website. The problem is that whenever my students go to the website, they can't play the game because the JApplet is blocked for security restrictions. I know that to make it work, you have to change the Java security settings to allow the website, and I how to do it. But my students do not have this knowledge, and don't want all 100 of them to have to go and change the security setting just for my game. Is there a way to make my JApplet game playable?

Delete entity using Hibernate HQL

I'm trying to delete an entity using HQL and it's failing.

    TypedQuery<Seller> query = Seller.entityManager().createQuery(
        "DELETE FROM Seller AS o WHERE o.company=:company AND o.id=:id", Seller.class);
    query.setParameter("company", company);
    query.setParameter("id", id);
    int result = query.executeUpdate();

The stacktrace I'm getting:

Update/delete queries cannot be typed; nested exception is java.lang.IllegalArgumentException: Update/delete queries cannot be typed
    at org.springframework.orm.jpa.EntityManagerFactoryUtils.convertJpaAccessExceptionIfPossible(EntityManagerFactoryUtils.java:296)
    at org.springframework.orm.jpa.aspectj.JpaExceptionTranslatorAspect.ajc$afterThrowing$org_springframework_orm_jpa_aspectj_JpaExceptionTranslatorAspect$1$18a1ac9(JpaExceptionTranslatorAspect.aj:33)
    at com.ahp.core.model.Seller.deleteSeller_aroundBody4(Seller.java:111)
    at com.ahp.core.model.Seller.deleteSeller(Seller.java:1)
    at com.ahp.core.processor.SellerProcessor.delete(SellerProcessor.java:175)
    at com.ahp.core.processor.SellerProcessor.consume(SellerProcessor.java:80)
    at com.ahp.core.processor.SellerProcessor.consume(SellerProcessor.java:1)
    at com.ahp.messaging.processor.AbstractRPCConsumer.onMessage(AbstractRPCConsumer.java:32)
    at org.springframework.amqp.rabbit.listener.adapter.MessageListenerAdapter.onMessage(MessageListenerAdapter.java:228)
    at org.springframework.amqp.rabbit.listener.AbstractMessageListenerContainer.doInvokeListener(AbstractMessageListenerContainer.java:756)
    at org.springframework.amqp.rabbit.listener.AbstractMessageListenerContainer.invokeListener(AbstractMessageListenerContainer.java:679)
    at org.springframework.amqp.rabbit.listener.SimpleMessageListenerContainer.access$001(SimpleMessageListenerContainer.java:82)
    at org.springframework.amqp.rabbit.listener.SimpleMessageListenerContainer$1.invokeListener(SimpleMessageListenerContainer.java:167)
    at org.springframework.amqp.rabbit.listener.SimpleMessageListenerContainer.invokeListener(SimpleMessageListenerContainer.java:1241)
    at org.springframework.amqp.rabbit.listener.AbstractMessageListenerContainer.executeListener(AbstractMessageListenerContainer.java:660)
    at org.springframework.amqp.rabbit.listener.SimpleMessageListenerContainer.doReceiveAndExecute(SimpleMessageListenerContainer.java:1005)
    at org.springframework.amqp.rabbit.listener.SimpleMessageListenerContainer.receiveAndExecute(SimpleMessageListenerContainer.java:989)
    at org.springframework.amqp.rabbit.listener.SimpleMessageListenerContainer.access$700(SimpleMessageListenerContainer.java:82)
    at org.springframework.amqp.rabbit.listener.SimpleMessageListenerContainer$AsyncMessageProcessingConsumer.run(SimpleMessageListenerContainer.java:1103)
    at java.lang.Thread.run(Thread.java:744)
Caused by: java.lang.IllegalArgumentException: Update/delete queries cannot be typed
    at org.hibernate.jpa.spi.AbstractEntityManagerImpl.resultClassChecking(AbstractEntityManagerImpl.java:363)
    at org.hibernate.jpa.spi.AbstractEntityManagerImpl.createQuery(AbstractEntityManagerImpl.java:344)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:606)
    at org.springframework.orm.jpa.ExtendedEntityManagerCreator$ExtendedEntityManagerInvocationHandler.invoke(ExtendedEntityManagerCreator.java:366)
    at com.sun.proxy.$Proxy57.createQuery(Unknown Source)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:606)
    at org.springframework.orm.jpa.SharedEntityManagerCreator$SharedEntityManagerInvocationHandler.invoke(SharedEntityManagerCreator.java:241)
    at com.sun.proxy.$Proxy56.createQuery(Unknown Source)
    ... 18 more

Seller.java was generated by Spring Roo:

@RooJavaBean
@RooToString
@RooJpaActiveRecord
public class Seller {
...

Seller_Roo_Jpa_Entity.aj:

privileged aspect Seller_Roo_Jpa_Entity {

    declare @type: Seller: @Entity;

    @Id
    @GeneratedValue(strategy = GenerationType.AUTO)
    @Column(name = "id")
    private Long Seller.id;

    ...

Seller_Roo_Jpa_ActiveRecord.aj:

privileged aspect Seller_Roo_Jpa_ActiveRecord {

    @PersistenceContext
    transient EntityManager Seller.entityManager;

    ...

I've tried changing the delete method to look like this so that I don't use TypedQuery at all:

import javax.transaction.Transactional;

...

@Transactional
public static Boolean deleteSeller(Company company,  Long id){
    Query query = Seller.entityManager().createQuery(
            "DELETE FROM Seller AS o WHERE o.company=:company AND o.id=:id");
    query.setParameter("company", company);
    query.setParameter("id", id);
    int result = query.executeUpdate();
    return result > 0;
}

... but this is giving me another exception:

org.springframework.dao.InvalidDataAccessApiUsageException: Executing an update/delete query; nested exception is javax.persistence.TransactionRequiredException: Executing an update/delete query
    at org.springframework.orm.jpa.EntityManagerFactoryUtils.convertJpaAccessExceptionIfPossible(EntityManagerFactoryUtils.java:316)
    at org.springframework.orm.jpa.aspectj.JpaExceptionTranslatorAspect.ajc$afterThrowing$org_springframework_orm_jpa_aspectj_JpaExceptionTranslatorAspect$1$18a1ac9(JpaExceptionTranslatorAspect.aj:33)
    ...
Caused by: javax.persistence.TransactionRequiredException: Executing an update/delete query
    at org.hibernate.jpa.spi.AbstractQueryImpl.executeUpdate(AbstractQueryImpl.java:71)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:606)
    at org.springframework.orm.jpa.SharedEntityManagerCreator$DeferredQueryInvocationHandler.invoke(SharedEntityManagerCreator.java:311)
    at com.sun.proxy.$Proxy58.executeUpdate(Unknown Source)
    ... 18 more

My method is annotated with @Transactional, so I don't see how it is not inside a transaction.

This question and this question seems to be using HQL to do a delete query, so it must be possible, what am I missing here?

Maximum count of same digit in array list

Suppose I have an array list of of values {0,1,1,0,1,1,1} Here the maximum repeat of value 1 in continuous sequence is 3. How do I find the maximum count.

 List<String> list = new ArrayList<String>();

for (int i=0;i<5;i++)
{
    System.out.println("Enter value");
    x = in.nextLine();

      list.add(""+x);
}

Map<String, Integer> countMap = new HashMap<>();

for (String word : list) {
    Integer count = countMap.get(word);
    if(count == null) {
        count = 0;
    }
    countMap.put(word, (count.intValue()+1));
}

This gives total count of same value but I need maximum continuous values.