Un-understandable exception
Hi, I am getting the following error when requesting a .jsp:
type Exception report
message
description The server encountered an internal error () that prevented it from fulfilling this request.
exception
org.apache.jasper.JasperException: com.eclinck.web.UserBean.setContactNumber(Ljava/lang/String)V
at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:248)
I can find absolutely no reason for this problem. Here is my code (first the .jsp segment)
statement = connection.getConnection().createStatement();
result = statement.executeQuery(sql);
if (result.next()) {
System.out.println("User Found in db");
user.setUserName(result.getString("username"));
user.setEmail(result.getString("email"));
user.setPassword(result.getString("password"));
user.setCompanyName(result.getString("name"));
user.setContactNumber(result.getString("contact_number"));
user.setID(result.getString("token_owner_id"));
user.setCountry(result.getString("country"));
user.setAddress(result.getString("address"));
user.setCity(result.getString("city"));
user.setState(result.getString("state"));
user.setZip(result.getString("zip"));
user.setLogged(true);
response.sendRedirect("profile.jsp");
} It is only at the setContactNumber() method, and any method thereafter that the error occurs. The bean code is right, with all the methods set(x) accepting String parameters. Even when I hard code string (instead of retrieving from db) I still get the same error on any method except the first four.
any help would be appreciated
thx
brenda
Sorry, the rest of the post is:
It is only at the setContactNumber() method, and any method thereafter that the error occurs. The bean code is right, with all the methods set(x) accepting String parameters. Even when I hard code string (instead of retrieving from db) I still get the same error on any method except the first four.
here is the bean code:
public void setUserName(String tempName) {
this.userName = tempName;
public void setEmail(String tempEmail) {
this.email = tempEmail;
public void setCompanyName(String tempCompany) {
this.companyName = tempCompany;
public void setPassword(String tempPassword) {
this.password = tempPassword;
public void setCountry(String tempCountry) {
this.country = tempCountry;
public void setContactNumber(String tempNumber) {
this.contactNumber = tempNumber;
public void setID(String tempID) {
this.ID = tempID;
public void setCity(String city) {
this.city = city;
public void setState(String state) {
this.state = state;
public void setZip(String zip) {
this.zip = zip;
public void setAddress(String address) {
this.address = address;
public void setLogged(boolean tempLogged) {
this.logged = tempLogged;
all the variable (except boolean tempLogged) are declared private String...
Any help ?
thx
brenda
Similar Messages
-
some basic questions regarding exceptions handling:
* I have some types of exceptions which are not code related but i want to handle them seperately. They include class instantion failure, could not get database connection etc. Their handling in all cases will be same (log it and send to Administrator). I was thinking about creating a seperate exception "InfrastructureFailureException" which will be thrown whenever such errors happens. But I am not sure this is a good idea. The reason is that in a logical-unit-of-work this type of exception can be thrown more than once. That means I have to use more than one try block. For example to get a Connection is a 2 step process:
try {
// get Connection Manager
} catch (InfrastructureFailureException ife) {
try {
// get Connection from Connection Manager
} catch (InfrastructureFailureException ife) {
Is there any better approach?
* i have defined a retrieve exception for each domain object, which is thrown by each retrieval operation. So I have a EmployeeNotFoundException which is thrown by getEmployeeById(int employeeId) DAO method. Similarly I have a DepartmenNotFoundException which is thrown by getDepartmentById(int deptId) DAO method.
Now I am thinking the above exceptions can be grouped as they belong to retrieve. So create a RetrieveFailedException and use it as a parent of the above exceptions. Is it a good idea?
I am also thinking about applying the same logic for INSERT and UPDATE (InsertFailedException and UpdateFailedException will be used as parents)
* Suppose an exception is thrown. I am having problems deciding which method to let handle this exception in the call stack.
Thanks>>
However, for those who do develop applications,you
will either use a library (in which case it willbe
exceptionally relevant, pardon the pun). Or youwill
develop your own exceptions. Often I develop one for large applications.
Sometimes I develop one or two for a single layer.
Never more.
A library that does that is probably doing something
wrong.
An application that developes many is probably doing
something wrong as well. In my experience, that
happens because the developers are applying the
standards of library developement to application
developement.
Libraries are developed to serve the needs of
different users and with the intent that they will be
definitely be used in ways that the library
developers did not anticipate. Application are
developed to meet very specific guidelines. The
goals of both are different. Thus the goals and
functionality of each are different.
I agree. However, I make a distinction (see below) in types of exceptions. What the OP referred to are what I implement as 'unchecked' exceptions. These also seem to comport with your conception of an exception: that they
are truly exceptional. Truly exceptional circumstances are generally not recoverable. The unchecked data access framework of Spring is an excellent example of this. As these resembled the OP's original needs, I pointed out that library. In an actual application, I would use the library, customizing these exceptions to my own needs, or simply catching them in a front controller to display an error message to the user.
In either case, seeing
how an established library was constructed should
give you ideas on how your own exceptions might be
classified. I doubt it. Unless you are a library developer.
See above.
Data access exceptions are data access
exceptions. You may not need something asfull-blown
as Spring's data access exceptions, butundoubtedly
you will use at least a few.Yes - a few.
That having been said, in real applications, the
majority of important exceptions will be your
checked, business/model exceptions. Concentrateyour
efforts there. Worrying about whether I shoulduse
java.io.IOException or
com.foo.exception.NetworkException will distractyou
from the exceptions you actually need to write.In real applications, at least the ones that I have
worked on, exceptions are exactly that exceptions.
They are not anticipated, they are not expected and
d in normal operations they should never occur. They
do not need to be classified because any such
classification would suggest that they are
correctable when in reality, because they are
exceptions, they are not.
The customer help desk doesn't care whether the
database is down, or if there is a duplicate
insertion error, nor that the type specifier
definition is missing in a table. All of them means
that the customer service person can not do their job
and all mean that they have to call someone else who
will have to fix it. And to the person that fixes it
seperate exceptions will have gain no benifit if
there are multiple exceptions or one.
Exactly. This is why they are unchecked and intercepted only at a front controller level to display a generic error page to the user, and potentially issue a page for support or entry into a log file.
Additionally application developers often,
incorrectly, use exception hierarchies in such a way
that it completely destroys the information needed to
actually fix the problem in the first place, because
they end up throwing away the original exception
because they found a "better" one to return.However, I disagree with your notion of 'exceptional' exceptions. This is not in any way to say my way is 'correct', but rather to simply explain it.
Any time I read a business requirement that has an abnormal path of exceution (balance below zero, user account not found, accessing the flux capacitor on an even-numbered day of the month, etc.), I create a checked, business exception for that use case. It has an English-readable name, and any business user would be able to understand what that exception is for.
When developing the application, these exceptions ensure that all expected business exceptions are accounted for. It also reminds me of what abnormal paths of execution the business users have specified. Any business service should handle the possible business exceptions involved in a given call.
The remainder of exceptions are 'exceptional' exceptions. These I leave as unchecked. Sometimes I use a library or framework ala Spring, especially for data access or XML parsing or other general failure possibilities. Other times, when none are available, I create my own. However, they are always unchecked.
- Saish -
Understanding Exception handler activity
All,
I created 2 view activities in my adfc-config.xml and established a navigation flow between them. The flow happens on click of a button on view1. I have defined an exception handler activity to show unhanded error that may arise. On click of the button in the view1, AM IMPL methods gets called and this is the code
public void newPage(){
int k = 5/0; //expecting the error handler activity to get invoked here
} When i click on the button, i get the exception however the page associated with exception handler is not getting invoked. I want the exception handler page to be shown for error and not the default popups. How do we do that?
thnks
Jdev 11.1.1.5No, this is only one possibility...
checkout Andrejus blog about exception handling http://andrejusb-samples.blogspot.com/2011/03/jdevadf-sample-exception-handler-for_19.html and of cause the docs http://download.oracle.com/docs/cd/E24382_01/web.1112/e16182/taskflows_complex.htm#BACJCBIC
Timo -
Applets & Stupid Un-understandable exceptions
here is the problem...
I got test.java, an applet, which I can compile without any problem...(I'm using Sun ONE Studio 4)
but when I try to execute it, it says "Applet not initialized" and the following message appears in the outpout window :
java.lang.ClassCastException
at sun.applet.AppletPanel.createApplet(AppletPanel.java:567)
at sun.applet.AppletPanel.runLoader(AppletPanel.java:496)
at sun.applet.AppletPanel.run(AppletPanel.java:293)
at java.lang.Thread.run(Thread.java:536)
the applet doesn't even go in the init() method
however, if I open test.html, which has the applet on the page, it loads without any problem...
I'd only like to know what this ClassCastException can be related to...Here's my guess: your class doesn't actually subclass java.applet.Applet. The browser and/or appletviewer instantiates your class and tries to assign it to a variable of type Applet, but since you didn't actually subclass Applet, you get a ClassCastException.
I think the error message "Applet not initialized" refers to the general process of creating an initializing an applet for use, not necessarily to the code in your init() method. -
Each exception class in its own file????
Hi, I am still quite new to java, and I don't fully understand exceptions. Could you please tell me if for each exception class you require do you have to have a a seperate file. e.g. I'm creating my own array exceptions classes.
The following is the structure:
** The base array exceptions class
public class arrayException extends Exception {
public arrayException () { super(); }
public arrayException (String s) { super(s); }
** The outofboundsArrayException
public class outofboundsArrayException extends arrayException {
public outofboundsArrayException ()
{ super("Number entered is out of bounds"); }
public outofboundsArrayException (String s)
{ super(s); }
** The fullArrayExceptiom
public class fullArrayException extends arrayException {
public fullArrayException ()
{ super("The array is full"); }
public fullArrayException (String s)
{ super(s); }
So will the three classes above need their own file.
I wanted to also know what the super does. I thought when the exception was raised, the text message in the super method is outputted, but i've tested that and it doesn't output (e.g. the error message "The array is full" doesn't output). The only thing that outputs is what you put in the catch part.
Thank You very Much!Could you please tell me if
for each exception class you require do you have to
have a a seperate file.Yes. Exception classes are like any other public class in Java, in that it must be in its own file with the standard naming conventions.
I wanted to also know what the super does. I thought
when the exception was raised, the text message in
the super method is outputted, but i've tested that
and it doesn't outputsuper([0,]...[n]) calls a constructor in the superclass of your current class matching the signature super([0,]...[n]). In this particular case, the Exception's message property is being set by the parent constructor. If you were to leave out super([0,]...[n]), the default no-arg constructor of the superclass would be invoked, and the message would not be set.
Use the getMessage() method of the Exception class to return the message value in later references to your object. -
void jButtonRun_actionPerformed(ActionEvent e) {
readMyLog();
void readMyLog() {
try {
connectionDB(); //error
}// end try
catch (IOException e) {
}// end catch
}// end readMyLog
void connectionDB() throws ClassNotFoundException
try
Class.forName ("sun.jdbc.odbc.JdbcOdbcDriver");
I am using JBuilder7. I get an error message while calling the method connectionDB().
I was told to add a 'throws ClassNotFoundException' in method redaMyLog() and a try/catch
statement while calling connectionDB().
But now I get a 'ClassNotFoundException:must be caught or declared to be thrown' at readMyLog().
If I put a ClassNotFoundException or FileNotFoundException in void jButtonRun_actionPerformed(ActionEvent e),
an error occur at void readMyLog();Class or interface expected.
If i continue errors are propagated everywhere in the application.
Can someone sort out this problem for me plz.Apologies if this reply is too dumbed-down. I'm not sure how much you understand exceptions:
If a method might throw an exception, you are required to write 'throws <MyExceptionClass>' statement before the start of the curly braces. This is in order that any part of your program which calls that method knows that it might get an exception back from it, and then can handle it.
In using try/catch blocks, you are stating that the bit of code inside the 'try' block might generate an exception from a method call. In the 'catch' section, you place a catch statement for each type of exception which you may receive, so that you can handle each type differently.
However, all exceptions descend from the Exception class, so you can handle all exceptions by just using this base class.
Your code:
try {
connectionDB();
} catch (IOException e) {
}is saying that inside the try block, an IOException might occur, and you also have a routine to handle one in the catch section. However, the connectionDB throws a ClassNotFoundException, which is NOT an IOException. Therefore, you should have another catch statement for this exception:
try {
connectionDB();
} catch (IOException e) {
} catch (ClassNotFoundException e) {
System.err.println("Ooops! A ClassNotFoundException occurred!");
}Alternatively, if you wish to handle any exception the same, you can do this:
try {
connectionDB();
} catch (Exception e) {
System.err.println("Ooops! An Exception occurred!");
}The 'Class or interface expected' problem is saying that your code is incorrectly structured. You will find the problem is too many or too few opening or closing braces, or braces in the wrong places. Read through your code and check this. -
While passing SQLERRM into a variable. Exception is not being caught. Am I missing something?
create or replace procedure schema1.proc1 (p_sequence number)
v_status_flag varchar2(1000);
begin
v_status_flag := 'INITIAL';
begin
schema2.proc2 (p_sequence, v_status_flag);
exception
when others then
v_status_flag := 'ERROR--';
end;
insert into temp1(status)
values (v_status_flag);
end;
select * from temp1;
ERROR--
create or replace procedure schema1.proc1 (p_sequence number)
v_status_flag varchar2(1000);
begin
v_status_flag := 'INITIAL';
begin
schema2.proc2 (p_sequence, v_status_flag);
exception
when others then
v_status_flag := 'Error--'|| SQLERRM;
end;
insert into temp1(status)
values (v_status_flag);
end;
select * from temp1;
INITIALavish16 wrote:
Thanks Manik, sorry I missed commit.No, the problem isn't that you missed Commit. The actual problem lies in the way you are handling exceptions.
This way, you will never understand if there was any exception during execution of your stored program. Needless to say, exceptions must be propogated to the Parent callers after logging appropriate Error messages in your tables.
Below is a sample way of doing so:
create or replace procedure logError(err_code in number, err_msg in varchar2)
is
declare
pragma autonomous_transaction;
begin
insert into error_table(err_code, err_msg);
commit;
end;
create or replace procedure schema1.proc1 (p_sequence number)
v_status_flag varchar2(1000);
begin
v_status_flag := 'INITIAL';
begin
schema2.proc2 (p_sequence, v_status_flag);
exception
when others then
log_errors(sqlerrcode, sqlerrm);
raise;
end;
end;
/Similar exception handling needs to be performed in Proc2 as well, as this ensures the exception is Caught, Logged and then propogated further in calling hierarchy.
I hope this helps understanding Exception handling. Also read a nice demonstration and explanation by BluShadow on Exception handling {message:id=2718301} -
IndexOutOfBounds Exception using ArrayList running in a Thread
Hi, I am a beginner in Java. While I am studying I became interested in Game Developing. So I tried to create a game like Space Shooting. Although the design and the ship lives are not yet finished it should run. Here is my whole code.
import java.applet.Applet;
import java.applet.AudioClip;
import java.awt.*;
import java.awt.event.KeyAdapter;
import java.awt.event.KeyEvent;
import java.io.File;
import java.net.MalformedURLException;
import java.net.URL;
import java.util.ArrayList;
import java.util.Random;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.swing.ImageIcon;
import javax.swing.JFrame;
class Ship
int x,y,lives;
long score,lastExplodeDisplay;
public Ship()
x = 307;
y = 444;
lives = 3;
score = lastExplodeDisplay = 0;
public void move(int xDir)
x = x + xDir;
class Asteroid
int x,y,speed;
Random asteroidGenerator;
int explodeMode;
long lastExplodeDisplay;
public Asteroid()
asteroidGenerator = new Random();
x = asteroidGenerator.nextInt(600) + 10;
y = asteroidGenerator.nextInt(1250) + 100;
y = y * -1;
speed = 1;
explodeMode = 0;
lastExplodeDisplay = 0;
class Star
int x,y,speed,radius,colorChooser;
Color color;
Random starGenerator;
public Star()
starGenerator = new Random();
x = (starGenerator.nextInt(620) + 10);
y = (starGenerator.nextInt(460) + 10);
speed = starGenerator.nextInt(2) + 1;
radius = (starGenerator.nextInt(3));
colorChooser = starGenerator.nextInt(200);
if(colorChooser % 3 == 0)
color = Color.YELLOW;
else if(colorChooser % 4 == 0)
color = Color.BLUE;
else if(colorChooser % 5 == 0)
color = Color.RED;
else
color = Color.WHITE;
class Shot
int x,y,speed;
public Shot(int position)
x = position + 3;
y = 440;
speed = 7;
public class Main extends JFrame implements Runnable{
private Image dbImage, ship,shot,asteroid,explode,shield;
private Graphics dbg;
private ImageIcon i;
private Font stageFont;
long lastShot, start;
AudioClip shoot;
String scoreShow;
int lastAsteroidPosition;
Ship ship1 = new Ship();
Star[] stars = new Star[200];
ArrayList<Shot> shots = new ArrayList<Shot>();
ArrayList<Asteroid> asteroids = new ArrayList<Asteroid>();
ArrayList<Asteroid> exploded = new ArrayList<Asteroid>();
boolean[] keys = new boolean[3];
private boolean shipDestroyed,continued,shielded;
private int ex;
public class ActionList extends KeyAdapter{
public void keyPressed(KeyEvent e)
int keyCode = e.getKeyCode();
if(keyCode == e.VK_A)
keys[0] = true;
if(keyCode == e.VK_D)
keys[1] = true;
if(keyCode == e.VK_Y)
keys[2] = true;
if(keyCode == e.VK_F2 && !continued)
continued = true;
shipDestroyed = false;
ex = 0;
shielded = true;
start = System.currentTimeMillis();
/*if(keyCode == e.VK_A)
if(ship1.x <= 15)
ship1.x = 15;
else
ship1.x -= 5;
if(keyCode == e.VK_D)
if(ship1.x >= 589)
ship1.x = 589;
else
ship1.x += 5;
if(keyCode == e.VK_Y)
Shot newShot = new Shot(ship1.x);
shots.add(newShot);
public void keyReleased(KeyEvent e)
int keyCode = e.getKeyCode();
if(keyCode == e.VK_A)
keys[0] = false;
if(keyCode == e.VK_D)
keys[1] = false;
if(keyCode == e.VK_Y)
keys[2] = false;
public Main()
createStars();
addKeyListener(new ActionList());
setSize(640,480);
setTitle("Shoot by Takeshi®");
setResizable(false);
setVisible(true);
setBackground(Color.BLACK);
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
i = new ImageIcon("C:/Documents and Settings/dioNisio.OWLCITY/My Documents/NetBeansProjects/GamePractice/src/ship1.png");
ship = i.getImage();
i = new ImageIcon("C:/Documents and Settings/dioNisio.OWLCITY/My Documents/NetBeansProjects/GamePractice/src/shot.png");
shot = i.getImage();
i = new ImageIcon("C:/Documents and Settings/dioNisio.OWLCITY/My Documents/NetBeansProjects/GamePractice/src/asteroid.png");
asteroid = i.getImage();
i = new ImageIcon("C:/Documents and Settings/dioNisio.OWLCITY/My Documents/NetBeansProjects/GamePractice/src/shield.png");
shield = i.getImage();
stageFont = new Font("Courier New",Font.BOLD,20);
lastAsteroidPosition = 0;
scoreShow = "0000000000";
shielded = true;
try
URL sound = new URL("file:///C:/Documents%20and%20Settings/dioNisio.OWLCITY/My%20Documents/NetBeansProjects/GamePractice/src/laserfast.au");
shoot = Applet.newAudioClip(sound);
catch(MalformedURLException e)
System.out.print(""+e.getMessage());
continued = true;
createAsteroids();
@Override
public void run()
start = System.currentTimeMillis();
while(true)
if((System.currentTimeMillis() - start) >= 5000)
shielded = false;
animateStars();
animateAsteroids();
animateExplosion();
animateShots();
if(continued)
animateShip();
createShot();
try {
Thread.sleep(5);
} catch (InterruptedException ex) {
Logger.getLogger(Main.class.getName()).log(Level.SEVERE, null, ex);
public static void main(String[] args)
Main newMain = new Main();
Thread t1 = new Thread(newMain);
t1.start();
@Override
public void paint(Graphics g)
dbImage = createImage(getWidth(), getHeight());
dbg = dbImage.getGraphics();
paintComponent(dbg);
g.drawImage(dbImage, 0, 0, this);
repaint();
public void paintComponent(Graphics g)
g.setColor(Color.WHITE);
for(int c = 0; c < 200; c++)
g.setColor(stars[c].color);
g.fillOval(stars[c].x, stars[c].y, (stars[c].radius * 2), (stars[c].radius * 2));
for(int c = 0; c < asteroids.size(); c++)
g.drawImage(asteroid,asteroids.get(c).x, asteroids.get(c).y, this);
for(int c = 0; c < exploded.size(); c++)
i = new ImageIcon("C:/Documents and Settings/dioNisio.OWLCITY/My Documents/NetBeansProjects/GamePractice/src/e"+(exploded.get(c).explodeMode+1)+".png");
explode = i.getImage();
g.drawImage(explode,exploded.get(c).x, exploded.get(c).y, this);
if(exploded.get(c).explodeMode < 14)
g.setColor(Color.white);
g.drawString("50",exploded.get(c).x, exploded.get(c).y);
for(int c = 0; c < shots.size(); c++)
g.drawImage(shot,shots.get(c).x, shots.get(c).y, this);
if(!shipDestroyed)
g.drawImage(ship, ship1.x, ship1.y, this);
if(shielded)
g.drawImage(shield, ship1.x - 15, ship1.y - 15 , this);
else
if(ex<14)
i = new ImageIcon("C:/Documents and Settings/dioNisio.OWLCITY/My Documents/NetBeansProjects/GamePractice/src/e"+(ex+1)+".png");
explode = i.getImage();
g.drawImage(explode,ship1.x, ship1.y, this);
if((System.currentTimeMillis() - ship1.lastExplodeDisplay) >= 250)
ex++;
ship1.lastExplodeDisplay = System.currentTimeMillis();
if(!continued)
g.setColor(Color.WHITE);
g.drawString("PRESS F2 TO CONTINUE",470,50);
g.setColor(Color.WHITE);
g.setFont(stageFont);
g.drawString("STAGE 1",20,50);
g.setColor(Color.RED);
for(int c = 0; c < ship1.lives; c++)
g.drawString("♥",120+(c*10),50);
g.setColor(Color.WHITE);
g.drawString(""+ship1.score, 20, 70);
public void animateStars()
for(int c = 0; c < 200; c++)
if(stars[c].y >= 460)
stars[c].y = 0;
else
stars[c].y += stars[c].speed;
public void animateShots() {
boolean xTargeted = false, yTargeted = false, destroyed = false;
for(int c = 0; c < shots.size() ; c++)
for(int j = 0; j < asteroids.size(); j++)
if(((shots.get(c).x >= asteroids.get(j).x) && (shots.get(c).x < (asteroids.get(j).x + 30))) || (((shots.get(c).x + 30) >= asteroids.get(j).x) && ((shots.get(c).x + 30) < (asteroids.get(j).x + 30))))
xTargeted = true;
if((asteroids.get(j).y + 30 - shots.get(c).y) > 0)
yTargeted = true;
if(xTargeted && yTargeted)
exploded.add(asteroids.get(j));
asteroids.remove(j);
ship1.score += 50;
destroyed = true;
xTargeted = false;
yTargeted = false;
if(destroyed)
shots.remove(c);
destroyed = false;
else if(shots.get(c).y <=0)
shots.remove(c);
else
shots.get(c).y -= shots.get(c).speed;
public void animateAsteroids() {
boolean xTargeted = false;
boolean yTargeted = false;
boolean sxTargeted = false;
boolean syTargeted = false;
for(int c = 0; c < asteroids.size() ; c++)
if(shielded)
if(((ship1.x - 15 >= asteroids.get(c).x) && (ship1.x - 15 < (asteroids.get(c).x + 30))) || ((((ship1.x - 15) + 64) >= asteroids.get(c).x) && (((ship1.x - 15) + 64) < (asteroids.get(c).x + 30))))
sxTargeted = true;
if((asteroids.get(c).y + 30 - ship1.y) > 0)
syTargeted = true;
if(sxTargeted && syTargeted)
exploded.add(asteroids.get(c));
asteroids.remove(c);
sxTargeted = false;
syTargeted = false;
else
if(((ship1.x >= asteroids.get(c).x) && (ship1.x < (asteroids.get(c).x + 30))) || (((ship1.x + 30) >= asteroids.get(c).x) && ((ship1.x + 30) < (asteroids.get(c).x + 30))))
xTargeted = true;
if((asteroids.get(c).y + 30 - ship1.y) > 0)
yTargeted = true;
if(xTargeted && yTargeted)
asteroids.remove(c);
shipDestroyed = true;
continued = false;
ship1.lives --;
xTargeted = false;
yTargeted = false;
if(asteroids.get(c).y >=480)
asteroids.remove(c);
else
asteroids.get(c).y += asteroids.get(c).speed;
public void animateShip()
if(keys[0] && !keys[1])
if(ship1.x <= 15)
ship1.x = 15;
else
ship1.x -= 5;
else if(!keys[0] && keys[1])
if(ship1.x >= 589)
ship1.x = 589;
else
ship1.x += 5;
public final void createStars()
for(int c = 0; c < 200; c++)
stars[c] = new Star();
public void createShot()
if(keys[2] && System.currentTimeMillis() - lastShot >= 150)
Shot newShot = new Shot(ship1.x);
shots.add(newShot);
lastShot = System.currentTimeMillis();
shoot.play();
public final void createAsteroids()
boolean verifiedGeneration = false;
Asteroid newAsteroid = null;
for(int c = 0; c < 100; c++)
newAsteroid = new Asteroid();
if((newAsteroid.y - lastAsteroidPosition) < 500)
newAsteroid.y -= (500 - (lastAsteroidPosition - newAsteroid.y));
asteroids.add(newAsteroid);
lastAsteroidPosition = newAsteroid.y;
public void animateExplosion()
for(int c = 0; c< exploded.size(); c++)
if(exploded.get(c).y >= 480)
exploded.remove(c);
else
exploded.get(c).y += exploded.get(c).speed;
if((System.currentTimeMillis() - exploded.get(c).lastExplodeDisplay) >= 150)
exploded.get(c).explodeMode++;
exploded.get(c).lastExplodeDisplay = System.currentTimeMillis();
}So when I freshly run the program it works fine, but after a few shots and collisions with asteroids, the program throws an IndexOutOfBoundsException and I don't know where to trace it. I am beginning to think that the problem lies in my ArrayList. Here is a link to the program screenshot.
Any help would be greatly appreciated.
Thanks!
Edited by: 893284 on Oct 26, 2011 4:59 AMFirst of all, put your program code between tags. Nobody's going to read unformatted code.
Secondly, IOOBE is a very simple to understand exception. You're accessing a collection beyond its limits.
Thirdly, the stacktrace will tell you where this happens. If you have multiple threads involved, you might need appropriate synchronization in there. -
Calling a third-party library from JNI-enabled C++ code
Hi everyone,
I have some existing C++ application code that extracts data from a file in a special format (HDF5). This code uses a static library (third party) to decode the file format. I would like to wrap this application code in a JNI wrapper so that I can call the code from Java. So I have a situation like this:
Java front end -> application code (C++) -> static library (C++)
I have compiled JNI headers and modified the application code accordingly. I created a shared library by bundling the application code together with the static library (using gcc 3.2.2 on Red Hat Linux 9):
g++ -shared hdf5_jni.cc -o libhdf5_jni.so -I<include path> -L<static library path> -lhdf5
(the <static library path> contains the static library libhdf5.a). This creates a shared library which contains the application code and the relevant bits of the static library.
When I call the Java front end, the shared library (libhdf5_jni.so) is correctly found and accessed. However, I get an UnsatisfiedLinkError which I don't understand:
Exception in thread "main" java.lang.UnsatisfiedLinkError: <blah>/lib/libhdf5_jni.so: <blah>/lib/libhdf5_jni.so: undefined symbol: _Z4formPKcz
at java.lang.ClassLoader$NativeLibrary.load(Native Method)
at java.lang.ClassLoader.loadLibrary0(ClassLoader.java:1560)
at java.lang.ClassLoader.loadLibrary(ClassLoader.java:1485)
... etc
I have no idea what the undefined symbol "_Z4formPKcz" represents. It's not part of the application code or the static library.
Here's some more info that might help diagnosis:
1) The problem seems to be due to the approach of having a three-step process (Java code calling bespoke shared library which includes unmodified 3rd-party code). I get an identical error (including the mysterious "_Z4formPKcz" symbol) when trying to do something similar with a different 3rd-party static library.
2) When I simply have Java code calling C++ code which I have written myself (no calls to static library methods), I have no problems, i.e. there doesn't seem to be a problem with the way I set up the JNI wrappers or the application code, or in the way I create the shared library.
3) When I simply have C++ code calling the static libraries (i.e. no Java wrapper) I have no problems, i.e. there doesn't seem to be a problem with the application code or the static libraries.
4) The static libraries were compiled from source using the same compiler that I used to compile the application code.
5) I'm using J2SDK 1.4.2 on Red Hat Linux 9, although I've tried other versions of the SDK and had the same problem.
I've done a lot of web searches on the "_Z4formPKcz" symbol and have turned up absolutely nothing (zero Google hits!).
Any help would be very much appreciated.
Thanks, JonThanks chrisswhite,
I should have mentioned that I tried this too and it didn't solve the problem. You're right though, I should be compiling with -fPIC anyway.
Jon -
Problem with Time Machine backup (Snow Leopard)
Hello everyone.
So today I was doing a backup and my external hard drive fell off the tabel and disconnected itself mid-back up. Now I am getting this error when I attempt to do the backup again,
"This backup is too large for the backup disk. The backup requires 349.79GB but only 319.30GB are available."
This is understandable, except for the fact that my HD on my MPB is only 320BG.
I tried look online and I read that I should try to reset Time machine by deleting the File, com.apple.TimeMachine.plist. I tried to look, but this file does not exist on my computer.
Does anyone have any ideas as how to fix this?
Any help would be greatly appreciated.
Thank you.BDAqua wrote:
The great Pondini seems to be the resident TM master... I don't use it & consider it the worst Backup outside of no backup at all, but check this out...
http://web.me.com/pondini/Time_Machine/Troubleshooting.html
Hi,
Just for future reference, I've moved my site to http://pondini.org, since Apple is dropping web hosting in June.
Both sites are active now; after a few days, I'll put redirect notices on the old one, then leave it there until it goes "poof." -
Why my mac os x v 10.3.9 cannot be updated to tiger version?
Hi everyone
Previously i had updated my mac os x 10.3.9 to tiger os x 10.4 by inserting the dvd i had received with its purchase, & everything was updated fine with no problem.
Recently i reinstalled & erased everything with the software install and restore I had received when I had purchased Powerbook g4.
Now, when I insert Mac os x 10.4 install disk by keeping down the c key as I am told to do so, takes me to the install screene fine, but when I click restart key, after sometime a black sceene appears with some jeberish things i don't understand except in one line I am asked to turn off the power. When I do that I manage to go back to my original version of mac os x. So I am unable to use the new features of tiger. Can any one tell me what i am doing wrong and help me how to sort out this? thank you, faruk.My appology to you, ali & others if I was unable to clearly identify the process of installation. this is what has happened:
1. In november 2004 I bought a powerbook g4 directly from apple which came with two software install and restore with apple label on them: 2004 apple Computer, Inc
[on them you can see Mac label and say: To start up from Mac os x on this dvd, hold down the c key as the computer startup. Under this line you see: Mac os x version 10.3.4, aht version2.2, dvd version1.0: 691-5096-a]. I used 10.3.4 version to install the files. Subsequently, I updated it and became 10.3.9.
2. This year, 2007, I purchased Mac OS version 10.4.10 to add more features. With the tow mac os x install disks I upgraded v10.3.9, all was well and fine until now.
3. The computer was running low in memory and was crowded with files I didn't want. So I used
mac os x v10.3.4 (the original sofware install and restore) and erased everything following the instructions. What was installed had only the orginal features only. So I decided to use mac os version 10.4.10. Instead of getting the new features, now I get kernel panic as you have noticed. The computer runs ok but without the new features of v10. 4.10 although I see some strange behavior in safari (which suddenly crash for no obvious reason. Thank for your assistance. I just wonder if you or the v 5 could solve this problem. -
Using JavaCompiler Class for Debugging Info Only
Hello everyone,
Before I get started into the problem, I'll tell you what it is I'd like to do. I'm building an educational applet that'll allow students learning Java programming to write code on a Web page. My goal is to simulate a compiler environment without having it actually compile code (i.e. I want to tell them if there are any syntactic errors in their code). I've searched around the Web quite a bit for how to do this, and I thought I had something by using the JavaCompiler class. It works perfectly in a command-line version I've developed, but in the applet, when I invoke the compiler, the applet freezes. I've isolated it to the compiler call itself. Here is the init method (yes, I know it's a better idea to do the hard work and GUI building in a separate class; but right now, I'm just checking if it all works).
@Override
public void init()
output = new JTextArea(5, 30);
this.getContentPane().add(output);
PrintWriter out = new PrintWriter(new TextAreaWriter(output));
out.print("Hello!");
JavaCompiler compiler = ToolProvider.getSystemJavaCompiler();
String program = "class Test{" + " public static void main (String [] args){"
+ " System.out.printl (\"Hello, World\");"
+ " System.out.println (args.length);" + " }" + "}";
Iterable<? extends JavaFileObject> fileObjects;
fileObjects = getJavaSourceFromString(program);
compiler.getTask(null, null, null, getOptions(), null, fileObjects).call();
If I exclude the bold line of code, the applet runs. Otherwise it hangs and does nothing. I imagine this has something to do with the execution environment, permissions, etc. If you'd like to see more of the code I'm using, let me know.
My questions are these: is there an easier way to go about this? Is there a way to invoke the compiler to get its output only, WITHOUT directly compiling a class? Is there a Magic Library designed for this that I've somehow overlooked? I know JDB only works on already-compiled class files; there's a tool called Checkstyle that seems to be more for formatting and subtle issues of style (hence, the name) than actual error checking (not to mention, it requires compiled code as well).
Any thoughts would be greatly appreciated, all. :) Let me know if you need more info.>
I checked the console after the freeze; it's handing me a NullPointerException for that line, which would be understandable except all of the arguments to call() can deal with null values. ( http://download.oracle.com/javase/6/docs/api/javax/tools/JavaCompiler.html )
From the javadoc for ToolProvider.getSystemJavaCompiler():
Returns:
the compiler provided with this platform or null if no compiler is providedSo it's definitely possible that compiler.getTask(null, null, null, getOptions(), null, fileObjects) returns null.
Indeed that's what I would expect from a browser's JVM (which includes only a JRE, and not a JDK).
Edited by: jduprez on Apr 29, 2011 2:56 PM
Ah, ah, I missed your latest edit while I was reading the API Javadoc :o)
Glad you found out! -
Button alignment issue - it should inherit I think
HI,
I'm on DW CS4 on an intel Mac. I've got a sticking point with an Email button that runs a mailto link. This button seems to only center correctly in IE 6. (For my site, I'm using templates from the Dreamweaver CSS templates that I've customized for my own use. )
The 'Container' which this button is in, is set to text-align:center and I've put 'text-align:center' into the button's attributes. And yet in Firefox and Safari and IE 7, the button hangs left every time.
http://www.frankbright.com/Contact.htm
I have tried setting a rather large left margin for the button, but then it looks fine in the other browsers and it looks all screwy in IE 6.0.
Is there a happy ending to this dilemma? I do appreciate any help if anyone could offer some,
Many Thanks, Frank B.
BTW, I am now - thanks to DW CS4 templates - table-free in my site (with one understandable exception: a DW-generated web gallery table; maybe some day on that one). If I can do it, anyone can! I have to brag somewhere or sometime on this, so it's right now I guess.It may be that those browsers are interpreting your image as...an image...not as text, so text-align is not applying. If you give your image a display: block; then a margin: 0 auto; it will center in your space.
Good job getting free of the tables...DW layouts are a nice help in that direction, and good learning aids at the same time.
Beth -
I don't know how to use this function, anybody could do me the favor?
VSIZE(x), if x is integer type, how to confirm the result?
Other type of x is easy to understand, except integer.I would start here http://linux-cjk.net/ and get on the mailing list. The devs can give you a real answer.
-
Hi
My oracle db version is 11g R1/AIX5.3
how following plsql code can be re-written for better performance
CREATE OR REPLACE PROCEDURE CSCOMMON.POST_SEQ_PROCESS
AS
-- Declare variables to hold sequenced infomration.
pragma autonomous_transaction;
V_RECORD_ID POST_SEQUENCING_PROCESS.RECORD_ID%TYPE;
V_RECEIVED POST_SEQUENCING_PROCESS.RECEIVED%TYPE;
V_PROCESS_NAME POST_SEQUENCING_PROCESS.PROCESS_NAME%TYPE;
V_PROCESS_ID POST_SEQUENCING_PROCESS.PROCESS_ID%TYPE;
V_PROCESS_SEQ POST_SEQUENCING_PROCESS.PROCESS_SEQ%TYPE;
V_RECEIVER POST_SEQUENCING_PROCESS.RECEIVER%TYPE;
V_RECEIVER_ID POST_SEQUENCING_PROCESS.RECEIVER_ID%TYPE;
V_RECEIVER_SEQ POST_SEQUENCING_PROCESS.RECEIVER_SEQ%TYPE;
V_SENDER POST_SEQUENCING_PROCESS.SENDER%TYPE;
V_SENDER_ID POST_SEQUENCING_PROCESS.SENDER_ID%TYPE;
V_MESSAGE_ID POST_SEQUENCING_PROCESS.MESSAGE_ID%TYPE;
V_INSTANCE_ID POST_SEQUENCING_PROCESS.INSTANCE_ID%TYPE;
V_STATUS POST_SEQUENCING_PROCESS.STATUS%TYPE;
V_STEP_ID POST_SEQUENCING_PROCESS.STEP_ID%TYPE;
V_INTERNAL_ID POST_SEQUENCING_PROCESS.INTERNAL_ID%TYPE;
V_LOCK_ID POST_SEQUENCING_PROCESS.LOCK_ID%TYPE;
V_ERROR_HANDLING POST_SEQUENCING_PROCESS.ERROR_HANDLING%TYPE;
V_STARTED POST_SEQUENCING_PROCESS.STARTED%TYPE;
V_WARNINGS POST_SEQUENCING_PROCESS.WARNINGS%TYPE;
V_DOCUMENTTYPE_NAME POST_SEQUENCING_PROCESS.DOCUMENTTYPE_NAME%TYPE;
V_DOCUMENTTYPE_ID POST_SEQUENCING_PROCESS.DOCUMENTTYPE_ID%TYPE;
V_DOCUMENTTYPE_SEQ POST_SEQUENCING_PROCESS.DOCUMENTTYPE_SEQ%TYPE;
v_current VARCHAR2 (600);
v_sql_error VARCHAR2 (600);
lv_count NUMBER;
CURSOR c_first500
IS
SELECT RECORD_ID,
RECEIVED,
PROCESS_NAME,
PROCESS_ID,
PROCESS_SEQ,
RECEIVER,
RECEIVER_ID,
RECEIVER_SEQ,
SENDER,
SENDER_ID,
MESSAGE_ID,
INSTANCE_ID,
STATUS,
STEP_ID,
INTERNAL_ID,
LOCK_ID,
ERROR_HANDLING,
STARTED,
WARNINGS,
DOCUMENTTYPE_NAME,
DOCUMENTTYPE_ID,
DOCUMENTTYPE_SEQ
FROM ( SELECT RECORD_ID,
RECEIVED,
PROCESS_NAME,
PROCESS_ID,
PROCESS_SEQ,
RECEIVER,
RECEIVER_ID,
RECEIVER_SEQ,
SENDER,
SENDER_ID,
MESSAGE_ID,
INSTANCE_ID,
STATUS,
STEP_ID,
INTERNAL_ID,
LOCK_ID,
ERROR_HANDLING,
STARTED,
WARNINGS,
DOCUMENTTYPE_NAME,
DOCUMENTTYPE_ID,
DOCUMENTTYPE_SEQ
FROM CSCOMMON.SEQUENCING_PROCESS
ORDER BY RECEIVED)
WHERE ROWNUM < 101;
P_RAND NUMBER;
V_LID NUMBER;
BEGIN
v_current := 'BEFORE CURSOR OPENING';
SELECT COUNT (*) INTO lv_count FROM POST_SEQUENCING_PROCESS;
OPEN c_first500;
LOOP
SELECT CSCOMMON.SEQ_LID_SEQUENCING_PROCESS_NU.NEXTVAL
INTO V_LID
FROM DUAL;
UPDATE CSCOMMON.SEQUENCING_PROCESS A
SET A.LOCK_ID = V_LID ,
A.STATUS = 1,
A.STARTED = SYSDATE,
A.WARNINGS = 0
WHERE NOT EXISTS
(SELECT 1
FROM CSCOMMON.SEQUENCING_PROCESS B
WHERE ( (A.RECEIVER_ID = B.RECEIVER_ID
AND A.RECEIVER_SEQ = 1)
OR (A.PROCESS_ID = B.PROCESS_ID
AND A.PROCESS_SEQ = 1)
OR (A.DOCUMENTTYPE_ID = B.DOCUMENTTYPE_ID
AND A.DOCUMENTTYPE_SEQ = 1))
AND (A.ERROR_HANDLING = 0 OR B.STATUS != 4)
AND B.RECORD_ID < A.RECORD_ID)
AND A.STATUS = 2
AND 1024 =
(SELECT WM1.STATUS
FROM WMLOG610.WMPROCESS WM1,
( SELECT MAX (AUDITTIMESTAMP) AUDITTIMESTAMP,
INSTANCEID
FROM WMLOG610.WMPROCESS WM2
WHERE INSTANCEID IN
(SELECT INSTANCE_ID
FROM CSCOMMON.SEQUENCING_PROCESS where rownum<101)
GROUP BY INSTANCEID
ORDER BY instanceid) WM2
WHERE A.INSTANCE_ID = WM1.INSTANCEID
AND WM1.INSTANCEID = WM2.INSTANCEID
AND WM1.AUDITTIMESTAMP = WM2.AUDITTIMESTAMP
AND ROWNUM = 1)
AND A.LOCK_ID IS NULL
AND A.DOCUMENTTYPE_NAME != 'FxHaulage';
commit;
FETCH c_first500
INTO V_RECORD_ID,
V_RECEIVED,
V_PROCESS_NAME,
V_PROCESS_ID,
V_PROCESS_SEQ,
V_RECEIVER,
V_RECEIVER_ID,
V_RECEIVER_SEQ,
V_SENDER,
V_SENDER_ID,
V_MESSAGE_ID,
V_INSTANCE_ID,
V_STATUS,
V_STEP_ID,
V_INTERNAL_ID,
V_LOCK_ID,
V_ERROR_HANDLING,
V_STARTED,
V_WARNINGS,
V_DOCUMENTTYPE_NAME,
V_DOCUMENTTYPE_ID,
V_DOCUMENTTYPE_SEQ;
EXIT WHEN c_first500%NOTFOUND;
BEGIN
v_current := 'INSERT INTO POST_SEQUENCING_PROCESS';
IF (lv_count = 0)
THEN
INSERT INTO POST_SEQUENCING_PROCESS (RECORD_ID,
RECEIVED,
PROCESS_NAME,
PROCESS_ID,
PROCESS_SEQ,
RECEIVER,
RECEIVER_ID,
RECEIVER_SEQ,
SENDER,
SENDER_ID,
MESSAGE_ID,
INSTANCE_ID,
STATUS,
STEP_ID,
INTERNAL_ID,
LOCK_ID,
ERROR_HANDLING,
STARTED,
WARNINGS,
DOCUMENTTYPE_NAME,
DOCUMENTTYPE_ID,
DOCUMENTTYPE_SEQ)
SELECT *
FROM cscommon.sequencing_process A
WHERE lock_id IS NOT NULL
AND A.DOCUMENTTYPE_NAME != 'FxHaulage' order by lock_id;
commit;
INSERT INTO CSCOMMON.PRE_SEQUENCING_PROCESS
(SELECT * FROM CSCOMMON.POST_SEQUENCING_PROCESS);
commit;
DELETE FROM CSCOMMON.POST_SEQUENCING_PROCESS;
COMMIT;
v_current := 'DELETE FROM SEQUENCING_PROCESS';
DELETE FROM CSCOMMON.SEQUENCING_PROCESS
WHERE LOCK_ID IS NOT NULL
AND DOCUMENTTYPE_NAME != 'FxHaulage';
COMMIT;
ELSE
RETURN;
END IF;
END;
END LOOP;
CLOSE c_first500;
COMMIT;
EXCEPTION
WHEN OTHERS
THEN
v_sql_error := SQLERRM || ' - ' || v_current;
ROLLBACK;
END;
/May be by using forall /bulk collections
Thanks
RajYou need to understand transactional consistency. Not only are your commits
slowing things down, they are not good for maintaining transactional consistency.
Ask yourself what would happen if there was a problem in your procedure after
the first commit? How would you recover from that with some records
updated but the rest of your procedure not having been run?
In general you should only have one commit at the topmost level. By that I mean if
there is a program that kicks of other ones and is the 'master' controller, that
should be the one that decides to commit or rollback the whole transaction.
Also you need to understand exception handling. Your exception processing is dangeroulsly wrong.
Remove it.
Finally, try and do this processing without using cursor loops: pure (set-based) SQL is much faster than
slow cursor based PL/SQL and SQL together.
Maybe you are looking for
-
I lose memory from Macbook's hard drive after syncing iPhone
Today I synced my iPhone. My Macbook Pro had about 6 gigs of free space when I synced. During the sync, a message popped up saying my "Startup Disk" was low. I checked my memory usage after the sync and my 6 gigs of free space had shrunk down to less
-
IPod Classic 120Gb freezes when connecting
I have a new iPod Classic 120 GB and about every other time when I connect to my PC to sync the iPod freezes. I have to reset the iPod in order to get it to work again. Is there a fix for this?
-
Mail to be triggered when IDOC fails
Hello experts, I have created a responsibility and added list of user to it. I have been to WE20 and assigned responsibility to one of the logical system and message type "ORDERS". Whenever an IDOC with message type "ORDERS" fail, respective persons
-
Restrict Query display to TopN with Group BY
Hello Experts, I have a query on a multiprovider that display the following results Plant Product Date Qty ABC Mat001 07/03/2007 35 ABC Mat001 07/05/2007 20 ABC Mat001 07/09/2007
-
Photoshop Element 7 Multi Processor Support?
Will we have multiprocessor support across the entire feature set of PSE 7? I haven't seen that as part of the feature set of the new product. Today, we experience diminished functionality by having to turn off multi-processor support in order to get