Null pointer..moving
I have to drag and drop counters on a screen, i have to drop them on the rectangle, so i cant drag outside the rectangle. this is the code i have , i have a null pointer at the int current = find(e.getPoint());
its the find method it has the problem with. i dont think the code would work anyway.
so does any1 have any modifications they would make
please help.
thanx
public int find(Point2D p)
for (int i = 0; i < this.rectangles.size(); i++)
Rectangle2D r = (Rectangle2D)rectangles.get(i);
if (r.contains(p)) return i;
return -1;
private class MouseHandler extends MouseAdapter
public void mousePressed(MouseEvent e)
int current = find(e.getPoint());
x = e.getX();
y = e.getY();
private class MouseMotionHandler
implements MouseMotionListener{
public void mouseMoved(MouseEvent e)
if (find(e.getPoint()) == -1)
setCursor(Cursor.getDefaultCursor());
else
setCursor(Cursor.getPredefinedCursor
(Cursor.CROSSHAIR_CURSOR));
public void mouseDragged(MouseEvent e)
if (current != null)
x = e.getX();
y = e.getY();
repaint();
I doubt that e is null, so it must be something in the find method that throws a NullPointerException.
My guess is that either you have null values in rectangles or rectangles itself is null.
Similar Messages
-
Can't Find Null Pointer Exception
Hey, guys! I've spent a couple of hours trying to figure this out, and I've been unable. When I run my program, I get a long list of errors that basically says I have a NullPointerException at Line 160 in LevelRenderer. I can't figure out what is null after tons of analyzing and experimenting, so I was wondering if one of you could assist me with this.
First, here is the runtime error code:
Game Update Error: java.lang.NullPointerException
Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException
at LevelRenderer.paint(LevelRenderer.java:160)
at javax.swing.RepaintManager.paintDirtyRegions(RepaintManager.java:796)
at javax.swing.RepaintManager.paintDirtyRegions(RepaintManager.java:713)
at javax.swing.RepaintManager.seqPaintDirtyRegions(RepaintManager.java:6
93)
at javax.swing.SystemEventQueueUtilities$ComponentWorkRequest.run(System
EventQueueUtilities.java:125)
at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:209)
at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:641)
at java.awt.EventQueue.access$000(EventQueue.java:84)
at java.awt.EventQueue$1.run(EventQueue.java:602)
at java.awt.EventQueue$1.run(EventQueue.java:600)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.AccessControlContext$1.doIntersectionPrivilege(AccessCo
ntrolContext.java:87)
at java.awt.EventQueue.dispatchEvent(EventQueue.java:611)
at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThre
ad.java:269)
at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.
java:184)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThre
ad.java:174)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:169)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:161)
at java.awt.EventDispatchThread.run(EventDispatchThread.java:122)Here's the code for the classes that are relevant to the issue. The runtime code is pointing me to the paint method's call of myLevel.drawLevel(gr, 0, 0):
Here's the class that is giving me the error:
/* This class's job is to render a level object.
* The class will keep track of the top left coordinate of the space in which the player is moving
* and how far the right side of the screen is. It will then draw the player always in the center
* of the screen and allow the player to move the character. The character will animate with calls
* to the Player class and also detect collision against the character. If there are collisions, then the
* player will either fall or be unable to move. It will keep the screen image a little bit rendered
* beyond the screen so that when the player moves, it will be able to still be visible until the next tile
* is reached. It will update the screen every time the player moves and reference the level's collision
* map for all of the collisions.
import java.awt.*;
import java.awt.event.*;
import java.awt.image.*;
import java.io.*;
import javax.imageio.*;
import javax.swing.JFrame;
import javax.swing.*;
import java.util.Random;
import java.awt.Color;
public class LevelRenderer extends JFrame
// CONSTANTS
private final int TILE_SIZE = 14;
private final int SCREEN_WIDTH = 1280;
private final int SCREEN_HEIGHT = 768;
// END OF CONSTANTS
// will be used as a buffer before everything is drawn to the screen
private BufferedImage buffer;
// character object
private Player myPlayer;
// level object
private Level myLevel;
// screen object
private Screen s;
// graphics object of the buffer
private Graphics gr;
// boolean to determine when to end the game
private boolean endGame;
// CONSTRUCTOR
public LevelRenderer()
setPreferredSize(new Dimension(1280, 768));
setFocusable(true);
requestFocus();
setResizable(false);
addKeyListener( new KeyAdapter()
public void keyPressed(KeyEvent e)
processKey(e);
public void keyReleased(KeyEvent e)
processRelease(e);
buffer = new BufferedImage(1280, 768, BufferedImage.TYPE_INT_ARGB);
buffer.createGraphics();
gr = buffer.getGraphics();
myPlayer = new Player();
Level myLevel = new Level("obstaclemap");
endGame = false;
// method to simply load an image from a path
public static BufferedImage loadImage(String ref)
BufferedImage bimg = null;
try
bimg = ImageIO.read(new File(ref));
catch (Exception e)
e.printStackTrace();
return bimg;
// Run method for class
public void run(DisplayMode dm)
setBackground(Color.WHITE);
s = new Screen();
try
s.setFullScreen(dm, this);
catch (Exception ex)
System.out.println("Error creating rendered tiles!");
while (!endGame)
try
Thread.sleep(2);
catch (Exception ex)
System.err.println("Error: " + ex);
try
myPlayer.animatePlayer();
myLevel.renderLevel();
catch (NullPointerException ex)
System.err.println("Game Update Error: " + ex);
try
repaint();
catch (Exception ex)
System.err.println("Repaint Error: " + ex);
s.restoreScreen();
// method to draw the tiles on the screen
public void paint(Graphics g)
// draw the level and then the player
myLevel.drawLevel(gr, 0, 0);
myPlayer.drawPlayer(gr, (SCREEN_WIDTH / 2) - TILE_SIZE / 2, (SCREEN_HEIGHT / 2) - TILE_SIZE);
g.drawImage(buffer, 0, 0, null);
// method to handle inputs and adjust the player accordingly
public void processKey(KeyEvent e)
int keyCode = e.getKeyCode();
boolean moved = false;
int xDisplace, yDisplace;
// termination key
if (keyCode == KeyEvent.VK_ESCAPE)
endGame = true;
// 1 - up
// 2 - left
// 3 - right
// 4 - down
// 5 - jump
if (keyCode == KeyEvent.VK_UP)
try
myPlayer.updatePlayer(0);
myLevel.updateLevel(0);
catch (Exception ex)
System.err.println("Error: " + ex);
if (keyCode == KeyEvent.VK_LEFT)
try
myPlayer.updatePlayer(1);
myLevel.updateLevel(1);
catch (Exception ex)
System.err.println("Error: " + ex);
if (keyCode == KeyEvent.VK_RIGHT)
try
myPlayer.updatePlayer(2);
myLevel.updateLevel(2);
catch (Exception ex)
System.err.println("Error: " + ex);
if (keyCode == KeyEvent.VK_DOWN)
try
myPlayer.updatePlayer(3);
myLevel.updateLevel(3);
catch (Exception ex)
System.err.println("Error: " + ex);
if (keyCode == KeyEvent.VK_SPACE)
try
myPlayer.updatePlayer(4);
myLevel.updateLevel(4);
catch (Exception ex)
System.err.println("Error: " + ex);
// method to handle inputs and adjust the player accordingly
public void processRelease(KeyEvent e)
int keyCode = e.getKeyCode();
boolean moved = false;
int xDisplace, yDisplace;
// 1 - up
// 2 - left
// 3 - right
// 4 - down
// 5 - jump
if (keyCode == KeyEvent.VK_UP)
try
myPlayer.updatePlayer(0);
catch (Exception ex)
System.err.println("Error: " + ex);
if (keyCode == KeyEvent.VK_LEFT)
try
myPlayer.updatePlayer(5);
catch (Exception ex)
System.err.println("Error: " + ex);
if (keyCode == KeyEvent.VK_RIGHT)
try
myPlayer.updatePlayer(6);
catch (Exception ex)
System.err.println("Error: " + ex);
if (keyCode == KeyEvent.VK_DOWN)
try
myPlayer.updatePlayer(3);
catch (Exception ex)
System.err.println("Error: " + ex);
if (keyCode == KeyEvent.VK_SPACE)
try
myPlayer.updatePlayer(4);
catch (Exception ex)
System.err.println("Error: " + ex);
}And then here's the other class that is calling the drawLevel method that the compiler is pointing me in the direction of (where it's saying the NullPointerException is stemming from):
/* The purpose of this class will be to load and manage a level, including its camera. */
import java.awt.image.*;
import java.io.*;
import javax.imageio.*;
import java.awt.*;
public class Level
// CONSTANTS
private final int TILE_SIZE = 14;
private final int SCREEN_WIDTH = 1280;
private final int SCREEN_HEIGHT = 768;
// END OF CONSTANTS
// stores the pixel image of the current level
private BufferedImage levelImage;
// stores the width and height of the level
private int width, height;
// stores the name of the level
private String levelName;
// stores collision map for level
private LevelCollisions myCollisions;
// stores the tile types in an array as assigned by colors
private int levelTiles[][];
// image used as the sheet for the level's tiles
private BufferedImage tileSheet;
// image array used to store the different tiles
private BufferedImage[] tiles;
// the image which represents the current view of the level
private BufferedImage cameraImage;
// Graphics context of the camera image
private Graphics cameraG;
// variables to represent the level's offset from the top left corner while moving
private int offsetX, offsetY;
// variables to represent the level's pixel map coordinate
private int coordX, coordY;
// STATIC COLOR VARIABLES
private static final int SPACE_COLOR = 0xFF000000;
private static final int WALL_COLOR = 0xFFFFFFFF;
// END OF STATIC COLOR VARIABLES
// CONSTRUCTOR
public Level(String level)
// load level image and collision map
levelName = level;
levelImage = loadImage(level + ".png");
myCollisions = new LevelCollisions(level + "Collision");
levelTiles = loadLevel();
// create blank camera canvas
cameraImage = new BufferedImage(1280, 768, BufferedImage.TYPE_INT_ARGB);
cameraImage.createGraphics();
cameraG = cameraImage.getGraphics();
// offsets start at 0
offsetX = offsetY = 0;
// coordinate starts at bottom right
coordX = 700;
coordY = 400;
// fill tile images
tileSheet = loadImage("obstacletiles.png");
tiles = splitImage(tileSheet, 1, 2);
this.renderLevel();
// method to load the color values into an array
public int[][] loadLevel()
height = levelImage.getHeight();
width = levelImage.getWidth();
int levelValues[][] = new int[width][height];
// fill array with color values layer by layer
for (int y = 0; y < height; y++)
for (int x = 0; x < width; x++)
levelValues[x][y] = levelImage.getRGB(x, y);
return levelValues;
// method to get the tile color from a given tile
public int getTile(int x, int y)
return levelTiles[x][y];
// method to draw the current camera view of the level on the screen
public void drawLevel(Graphics gr, int x, int y)
gr.drawImage(cameraImage, x, y, null);
// method to render the actual image before drawing it
public void renderLevel()
// keeps track of graphics coordinate
int x, y;
// keeps track of tile to draw
int tileX, tileY;
tileY = coordY;
// draw all the tiles based on offsets, layer by layer
for (y = offsetY; y < SCREEN_HEIGHT + offsetY; y += TILE_SIZE)
tileX = coordX;
for (x = offsetX; x < SCREEN_WIDTH + offsetX; x += TILE_SIZE)
// determine which tile to draw based on tile color in array
switch (this.getTile(tileX, tileY))
case SPACE_COLOR:
cameraG.drawImage(tiles[0], x, y, null);
break;
case WALL_COLOR:
cameraG.drawImage(tiles[1], x, y, null);
break;
tileX++;
// steps to take in case of an offset
if (offsetX > 0)
if (offsetX < 0)
if (offsetY < 0)
if (offsetY > 0)
// method to update the level's current position for the camera
public void updateLevel(int input)
switch (input)
// up
case 0:
break;
// left
case 1:
// update offset to the left if not too far left
if (coordX > 30)
offsetX--;
// if a tile has been moved, then offset becomes 0 and coordX is decreased
if (offsetX <= -TILE_SIZE)
offsetX = 0;
coordX--;
break;
// right
case 2:
// update offset to the right if not too far right
if (coordX < width - 30)
offsetX++;
// if a tile has been moved, then offset becomes 0 and coordX is increased
if (offsetX >= TILE_SIZE)
offsetX = 0;
coordX++;
break;
// down
case 3:
break;
// jump
case 4:
break;
// method to simply load an image from a path
public static BufferedImage loadImage(String ref)
BufferedImage bimg = null;
try
bimg = ImageIO.read(new File(ref));
catch (Exception e)
e.printStackTrace();
return bimg;
// method to create a tile array for tile sets
public static BufferedImage[] splitImage(BufferedImage img, int cols, int rows)
int w = img.getWidth() / cols;
int h = img.getHeight() / rows;
int num = 0;
BufferedImage imgs[] = new BufferedImage[w * h];
for (int y = 0; y < rows; y++)
for (int x = 0; x < cols; x++)
imgs[num] = new BufferedImage(w, h, img.getType());
Graphics2D g = imgs[num].createGraphics();
g.drawImage(img, 0, 0, w, h, w * x, h * y, w * x + w, h * y + h, null);
g.dispose();
num++;
return imgs;
// image-loading method that will also alpha the color key for each tile
public static BufferedImage makeColorTransparent(String ref, int color)
BufferedImage image = loadImage(ref);
BufferedImage dimg = new BufferedImage(image.getWidth(), image.getHeight(), BufferedImage.TYPE_INT_ARGB);
Graphics2D g = dimg.createGraphics();
g.setComposite(AlphaComposite.Src);
g.drawImage(image, null, 0, 0);
g.dispose();
for (int i = 0; i < dimg.getHeight(); i++)
for (int j = 0; j < dimg.getWidth(); j++)
if (dimg.getRGB(j, i) == color)
dimg.setRGB(j, i, 0x8F1C1C);
return dimg;
}Sorry for the long post, but since there are several objects involved in what could be the error, I didn't want to leave anything out of this one. Help is greatly appreciated! Thank you guys very much.
Colton
Edited by: coltonoscopy on Oct 2, 2011 11:57 PMException in thread "AWT-EventQueue-0" java.lang.NullPointerException
at LevelRenderer.paint(LevelRenderer.java:160)
// method to draw the tiles on the screen
public void paint(Graphics g)
// draw the level and then the player
myLevel.drawLevel(gr, 0, 0);
myPlayer.drawPlayer(gr, (SCREEN_WIDTH / 2) - TILE_SIZE / 2, (SCREEN_HEIGHT / 2) - TILE_SIZE);
g.drawImage(buffer, 0, 0, null);
}So one of those three lines is line 160, and whichever line it is, is dereferencing a null pointer. So one of 'myLevel', 'myPlayer', or 'g' is null. Probably not 'g' as you received it as a parameter from Swing. Pretty much cuts it down.
There's nothing here you couldn't have worked out for yourself. The line number was all you needed. -
Null Pointer Exception, don't know why...
Hi everyone,
This may well be really simple, but it's driving me crazy...
The program puts lots of panels into other panels and when a combo box is set to a certain value the number of panels alters.
Here is some of the code:
* Fourth User
// First user main panel
pn_u4 = new JPanel();
pn_u4.setLayout( new BorderLayout(5,5) );
pn_u4.setPreferredSize( new Dimension(800,80) );
pn_u4.setBackground(Color.WHITE);
// First user top panel that goes into the
// main panel North
pn_u4T = new JPanel();
pn_u4T.setLayout( new BorderLayout(5,5) );
pn_u4T.setPreferredSize( new Dimension(800,40) );
pn_u4T.setBackground(Color.WHITE);
// First user bottom panel that goes into the
// main panel South
pn_u4B = new JPanel();
pn_u4B.setLayout( new BorderLayout(5,5) );
pn_u4B.setPreferredSize( new Dimension(800,40) );
pn_u4B.setBackground(Color.WHITE);
// First user top panel left, goes into the
// top panel West
pn_u4TL = new JPanel();
pn_u4TL.setLayout( new FlowLayout() );
pn_u4TL.setPreferredSize( new Dimension(400,40) );
pn_u4TL.setBackground(Color.WHITE);
lbl_u4Name = new JLabel("Name");
lbl_u4Name.setFont( new Font("Times New Roman",Font.PLAIN,17) );
tf_u4Name = new JTextField(28);
pn_u4TL.add(lbl_u4Name);
pn_u4TL.add(tf_u4Name);
// First user top panel right, goes into the
// top panel East
pn_u4TR = new JPanel();
pn_u4TR.setLayout( new FlowLayout() );
pn_u4TR.setPreferredSize( new Dimension(400,40) );
pn_u4TR.setBackground(Color.WHITE);
lbl_u4ID = new JLabel("GNAS ID");
lbl_u4ID.setFont( new Font("Times New Roman",Font.PLAIN,17) );
tf_u4ID = new JTextField(28);
pn_u4TR.add(lbl_u4ID);
pn_u4TR.add(tf_u4ID);
pn_u4T.add(pn_u4TL, BorderLayout.WEST);
pn_u4T.add(pn_u4TR, BorderLayout.EAST);
// First user bottom panel left, goes into the
// bottom panel West
pn_u4BL = new JPanel();
pn_u4BL.setLayout( new FlowLayout() );
pn_u4BL.setPreferredSize( new Dimension(400,40) );
pn_u4BL.setBackground(Color.WHITE);
lbl_u4Round = new JLabel("Round Name");
lbl_u4Round.setFont( new Font("Times New Roman",Font.PLAIN,17) );
tf_u4Round = new JTextField(24);
pn_u4BL.add(lbl_u4Round);
pn_u4BL.add(tf_u4Round);
// First user bottom panel right, goes into the
// bottom panel East
pn_u4BR = new JPanel();
pn_u4BR.setLayout( new FlowLayout() );
pn_u4BR.setPreferredSize( new Dimension(400,40) );
pn_u4BR.setBackground(Color.WHITE);
lbl_u4Bow = new JLabel("Bow Type ");
lbl_u4Bow.setFont( new Font("Times New Roman",Font.PLAIN,17) );
cb_u4Bow = new JComboBox();
cb_u4Bow.addActionListener(this);
cb_u4Bow.addItem(" Compound ");
cb_u4Bow.addItem(" Long Bow ");
cb_u4Bow.addItem(" Recurve ");
pn_u4BR.add(lbl_u4Bow);
pn_u4BR.add(cb_u4Bow);
pn_u4B.add(pn_u4BL, BorderLayout.WEST);
pn_u4B.add(pn_u4BR, BorderLayout.EAST);
pn_u4.add(pn_u4T, BorderLayout.NORTH);
pn_u4.add(pn_u4B, BorderLayout.SOUTH);
//pn_u3u4.add(pn_u4, BorderLayout.NORTH);
pn_2.add(pn_u1u2, BorderLayout.NORTH);
pn_2.add(pn_u3u4, BorderLayout.SOUTH);
//initialWindow.add(pn_topAll);//BorderLayout.NORTH);
initialWindow.add(pn_topAll, BorderLayout.NORTH);
initialWindow.add(pn_2, BorderLayout.CENTER);
pack(); There are a total of four users, but too much code to paste here,
Now there's the event listener:
public void actionPerformed(ActionEvent e)
if (e.getSource() == cb_noOfPeople)
if(cb_noOfPeople.getSelectedItem() == " 1 ")
*** if(pn_u3u4.getComponentCount() > 0)
pn_u3u4.remove(pn_u3);
pn_u3u4.remove(pn_u4);
else
if(pn_u1u2.getComponentCount() == 2)
pn_u1u2.remove(pn_u2);
else
initialWindow.repaint();
initialWindow.validate();
else if(cb_noOfPeople.getSelectedItem() == " 2 ")
if(pn_u3u4.getComponentCount() > 0)
pn_u3u4.remove(pn_u3);
pn_u3u4.remove(pn_u4);
else
pn_u1u2.add(pn_u2, BorderLayout.SOUTH);
initialWindow.repaint();
initialWindow.validate();
else if(cb_noOfPeople.getSelectedItem() == " 3 ")
if(pn_u3u4.getComponentCount() == 2)
pn_u3u4.remove(pn_u4);
else
pn_u1u2.add(pn_u2, BorderLayout.SOUTH);
pn_u3u4.add(pn_u3, BorderLayout.NORTH);
initialWindow.repaint();
initialWindow.validate();
else if(cb_noOfPeople.getSelectedItem() == " 4 ")
pn_u1u2.add(pn_u2, BorderLayout.SOUTH);
pn_u3u4.add(pn_u3, BorderLayout.NORTH);
pn_u3u4.add(pn_u4, BorderLayout.SOUTH);
initialWindow.repaint();
initialWindow.validate();
else
}Everything works until it reaches:
*** if(pn_u3u4.getComponentCount() > 0)
pn_u3u4.remove(pn_u3);
pn_u3u4.remove(pn_u4);
else
if(pn_u1u2.getComponentCount() == 2)
pn_u1u2.remove(pn_u2);
else
}(please ignore the three stars, just to indicate where that code was)
Wihout the above bit of code inplace everything works fine, I can change the value of the combo box and things are removed and added, but when I add the above if statements to the value "1" area, i get the null pointer, which doesn't make sence to me.
Exception in thread "main" java.lang.NullPointerException
at InitialScreen.actionPerformed(InitialScreen.java:601)
Thanks for help in advance (I can provide all 600 lines of code if needed)
VictoriaYour actionListener for your cb_noOfPeople is being fired before the rest of the components are being initialized. I just moved the addition of the actionListener to right before the pack() statement to ensure that all of your variables get initialized and it works like a charm. Here you go:
import javax.swing.*;
import javax.swing.event.*;
import java.awt.*;
import java.awt.event.*;
import java.lang.*;
import java.util.*;
* @author Victoria
* @version v1.01
* Start date 29th Nov 06
class InitialScreen extends JFrame implements ActionListener
Container initialWindow;
JLabel titleBar, lbl_noOfUsers, lbl_u1Name, lbl_u1ID, lbl_u1Bow, lbl_u1Round, lbl_u2Name, lbl_u2ID, lbl_u2Bow, lbl_u2Round, lbl_u3Name, lbl_u3ID, lbl_u3Round, lbl_u3Bow, lbl_u4Name, lbl_u4ID, lbl_u4Round, lbl_u4Bow;
JComboBox cb_noOfPeople, cb_u1Bow, cb_u2Bow, cb_u3Bow, cb_u4Bow;
JTextField tf_u1Name, tf_u1ID, tf_u1Round, tf_u2Name, tf_u2ID, tf_u2Round, tf_u3Name, tf_u3ID, tf_u3Round, tf_u4Name, tf_u4ID, tf_u4Round, tf_compDate, tf_compTime, tf_compID;
JPanel pn_1, pn_2, pn_3, pn_u1u2, pn_u3u4, pn_top, pn_top2, pn_top3, pn_topAll, pn_u1, pn_u1T, pn_u1TL, pn_u1TR, pn_u1B, pn_u1BL, pn_u1BR, pn_u2, pn_u2T, pn_u2TL, pn_u2TR, pn_u2B, pn_u2BL, pn_u2BR, pn_u3, pn_u3T, pn_u3TL, pn_u3TR, pn_u3B, pn_u3BL, pn_u3BR, pn_u4, pn_u4T, pn_u4TL, pn_u4TR, pn_u4B, pn_u4BL, pn_u4BR, pn_shootInfo, pn_button;
JButton but_go, but_reset, but_exit;
* Constructor for the initial screen
public InitialScreen()
// Create a window pane called initial Window
// and set it to a preferred size of 800x600
initialWindow = getContentPane();
initialWindow.setLayout( new BorderLayout(5,5) );
setPreferredSize( new Dimension(800,600) );
initialWindow.setBackground(Color.WHITE);
//pn_1 = new JPanel();
//pn_1.setLayout( new BorderLayout(5,5) );
//pn_1.setPreferredSize( new Dimension(800,40) );
//pn_1.setBackground(Color.WHITE);
pn_2 = new JPanel();
pn_2.setLayout( new BorderLayout(5,5) );
pn_2.setPreferredSize( new Dimension(800,40) );
pn_2.setBackground(Color.WHITE);
//pn_3 = new JPanel();
//pn_3.setLayout( new BorderLayout(5,5) );
//pn_3.setPreferredSize( new Dimension(800,40) );
//pn_3.setBackground(Color.WHITE);
// First top panel just houese the label that
// says what the program is and fill in info
pn_top = new JPanel();
pn_top.setLayout( new BorderLayout(5,5) );
pn_top.setPreferredSize( new Dimension(800,40) );
pn_top.setBackground(Color.WHITE);
titleBar = new JLabel("Archery Scoring Program - Please fill in the following information \n ", JLabel.CENTER);
titleBar.setFont( new Font("Times New Roman",Font.PLAIN,20) );
//pn_top.add(titleBar, BorderLayout.NORTH);
//pn_top.add(lbl_noOfUsers, BorderLayout.WEST);
//pn_top.add(cb_noOfPeople, BorderLayout.EAST);
pn_top.add(titleBar);
// Second panel contains the how many people
// ComboBox
pn_top2 = new JPanel();
pn_top2.setLayout(new FlowLayout());
pn_top2.setPreferredSize( new Dimension(360,40) );
pn_top2.setBackground(Color.WHITE);
lbl_noOfUsers = new JLabel("No of members shooting on this target");
lbl_noOfUsers.setFont( new Font("Times New Roman",Font.PLAIN,17) );
cb_noOfPeople = new JComboBox();
//cb_noOfPeople.addActionListener(this);
cb_noOfPeople.addItem(" 1 ");
cb_noOfPeople.addItem(" 2 ");
cb_noOfPeople.addItem(" 3 ");
cb_noOfPeople.addItem(" 4 ");
pn_top2.add(lbl_noOfUsers);
pn_top2.add(cb_noOfPeople);
// Third panel contains nothing but alligns
// the second panel correctly
pn_top3 = new JPanel();
pn_top3.setLayout( new FlowLayout() );
pn_top3.setPreferredSize( new Dimension(440,40) );
pn_top3.setBackground(Color.WHITE);
// Last top panel contains all the previous
// top panels and adds the other top
// panels to it
pn_topAll = new JPanel();
pn_topAll.setLayout( new BorderLayout(5,5) );
//pn_topAll.setPreferredSize( new Dimension(450,100) );
pn_topAll.setBackground(Color.WHITE);
pn_topAll.add(pn_top, BorderLayout.NORTH);
pn_topAll.add(pn_top2, BorderLayout.WEST);
pn_topAll.add(pn_top3, BorderLayout.EAST);
pn_u1u2 = new JPanel();
pn_u1u2.setLayout( new BorderLayout(5,5) );
pn_u1u2.setPreferredSize( new Dimension(800,160) );
pn_u1u2.setBackground(Color.WHITE);
* First User
* As long as the if statement is correctly working
* The first user panel will be added upon load
* User two, three and four will be added depending on
* the value of the combobox which asks how many
* users are shooting on the target
// First user main panel
pn_u1 = new JPanel();
pn_u1.setLayout( new BorderLayout(5,5) );
pn_u1.setPreferredSize( new Dimension(800,80) );
pn_u1.setBackground(Color.WHITE);
// First user top panel that goes into the
// main panel North
pn_u1T = new JPanel();
pn_u1T.setLayout( new BorderLayout(5,5) );
pn_u1T.setPreferredSize( new Dimension(800,40) );
pn_u1T.setBackground(Color.WHITE);
// First user bottom panel that goes into the
// main panel South
pn_u1B = new JPanel();
pn_u1B.setLayout( new BorderLayout(5,5) );
pn_u1B.setPreferredSize( new Dimension(800,40) );
pn_u1B.setBackground(Color.WHITE);
// First user top panel left, goes into the
// top panel West
pn_u1TL = new JPanel();
pn_u1TL.setLayout( new FlowLayout() );
pn_u1TL.setPreferredSize( new Dimension(400,40) );
pn_u1TL.setBackground(Color.WHITE);
lbl_u1Name = new JLabel("Name");
lbl_u1Name.setFont( new Font("Times New Roman",Font.PLAIN,17) );
tf_u1Name = new JTextField(28);
pn_u1TL.add(lbl_u1Name);
pn_u1TL.add(tf_u1Name);
// First user top panel right, goes into the
// top panel East
pn_u1TR = new JPanel();
pn_u1TR.setLayout( new FlowLayout() );
pn_u1TR.setPreferredSize( new Dimension(400,40) );
pn_u1TR.setBackground(Color.WHITE);
lbl_u1ID = new JLabel("GNAS ID");
lbl_u1ID.setFont( new Font("Times New Roman",Font.PLAIN,17) );
tf_u1ID = new JTextField(28);
pn_u1TR.add(lbl_u1ID);
pn_u1TR.add(tf_u1ID);
pn_u1T.add(pn_u1TL, BorderLayout.WEST);
pn_u1T.add(pn_u1TR, BorderLayout.EAST);
// First user bottom panel left, goes into the
// bottom panel West
pn_u1BL = new JPanel();
pn_u1BL.setLayout( new FlowLayout() );
pn_u1BL.setPreferredSize( new Dimension(400,40) );
pn_u1BL.setBackground(Color.WHITE);
lbl_u1Round = new JLabel("Round Name");
lbl_u1Round.setFont( new Font("Times New Roman",Font.PLAIN,17) );
tf_u1Round = new JTextField(24);
pn_u1BL.add(lbl_u1Round);
pn_u1BL.add(tf_u1Round);
// First user bottom panel right, goes into the
// bottom panel East
pn_u1BR = new JPanel();
pn_u1BR.setLayout( new FlowLayout() );
pn_u1BR.setPreferredSize( new Dimension(400,40) );
pn_u1BR.setBackground(Color.WHITE);
lbl_u1Bow = new JLabel("Bow Type ");
lbl_u1Bow.setFont( new Font("Times New Roman",Font.PLAIN,17) );
cb_u1Bow = new JComboBox();
cb_u1Bow.addActionListener(this);
cb_u1Bow.addItem(" Compound ");
cb_u1Bow.addItem(" Long Bow ");
cb_u1Bow.addItem(" Recurve ");
pn_u1BR.add(lbl_u1Bow);
pn_u1BR.add(cb_u1Bow);
pn_u1B.add(pn_u1BL, BorderLayout.WEST);
pn_u1B.add(pn_u1BR, BorderLayout.EAST);
pn_u1.add(pn_u1T, BorderLayout.NORTH);
pn_u1.add(pn_u1B, BorderLayout.SOUTH);
pn_u1u2.add(pn_u1, BorderLayout.NORTH);
* Second User
// First user main panel
pn_u2 = new JPanel();
pn_u2.setLayout( new BorderLayout(5,5) );
pn_u2.setPreferredSize( new Dimension(800,80) );
pn_u2.setBackground(Color.WHITE);
// First user top panel that goes into the
// main panel North
pn_u2T = new JPanel();
pn_u2T.setLayout( new BorderLayout(5,5) );
pn_u2T.setPreferredSize( new Dimension(800,40) );
pn_u2T.setBackground(Color.WHITE);
// First user bottom panel that goes into the
// main panel South
pn_u2B = new JPanel();
pn_u2B.setLayout( new BorderLayout(5,5) );
pn_u2B.setPreferredSize( new Dimension(800,40) );
pn_u2B.setBackground(Color.WHITE);
// First user top panel left, goes into the
// top panel West
pn_u2TL = new JPanel();
pn_u2TL.setLayout( new FlowLayout() );
pn_u2TL.setPreferredSize( new Dimension(400,40) );
pn_u2TL.setBackground(Color.WHITE);
lbl_u2Name = new JLabel("Name");
lbl_u2Name.setFont( new Font("Times New Roman",Font.PLAIN,17) );
tf_u2Name = new JTextField(28);
pn_u2TL.add(lbl_u2Name);
pn_u2TL.add(tf_u2Name);
// First user top panel right, goes into the
// top panel East
pn_u2TR = new JPanel();
pn_u2TR.setLayout( new FlowLayout() );
pn_u2TR.setPreferredSize( new Dimension(400,40) );
pn_u2TR.setBackground(Color.WHITE);
lbl_u2ID = new JLabel("GNAS ID");
lbl_u2ID.setFont( new Font("Times New Roman",Font.PLAIN,17) );
tf_u2ID = new JTextField(28);
pn_u2TR.add(lbl_u2ID);
pn_u2TR.add(tf_u2ID);
pn_u2T.add(pn_u2TL, BorderLayout.WEST);
pn_u2T.add(pn_u2TR, BorderLayout.EAST);
// First user bottom panel left, goes into the
// bottom panel West
pn_u2BL = new JPanel();
pn_u2BL.setLayout( new FlowLayout() );
pn_u2BL.setPreferredSize( new Dimension(400,40) );
pn_u2BL.setBackground(Color.WHITE);
lbl_u2Round = new JLabel("Round Name");
lbl_u2Round.setFont( new Font("Times New Roman",Font.PLAIN,17) );
tf_u2Round = new JTextField(24);
pn_u2BL.add(lbl_u2Round);
pn_u2BL.add(tf_u2Round);
// First user bottom panel right, goes into the
// bottom panel East
pn_u2BR = new JPanel();
pn_u2BR.setLayout( new FlowLayout() );
pn_u2BR.setPreferredSize( new Dimension(400,40) );
pn_u2BR.setBackground(Color.WHITE);
lbl_u2Bow = new JLabel("Bow Type ");
lbl_u2Bow.setFont( new Font("Times New Roman",Font.PLAIN,17) );
cb_u2Bow = new JComboBox();
cb_u2Bow.addActionListener(this);
cb_u2Bow.addItem(" Compound ");
cb_u2Bow.addItem(" Long Bow ");
cb_u2Bow.addItem(" Recurve ");
pn_u2BR.add(lbl_u2Bow);
pn_u2BR.add(cb_u2Bow);
pn_u2B.add(pn_u2BL, BorderLayout.WEST);
pn_u2B.add(pn_u2BR, BorderLayout.EAST);
pn_u2.add(pn_u2T, BorderLayout.NORTH);
pn_u2.add(pn_u2B, BorderLayout.SOUTH);
//pn_u1u2.add(pn_u2, BorderLayout.SOUTH);
pn_u3u4 = new JPanel();
pn_u3u4.setLayout( new BorderLayout(5,5) );
pn_u3u4.setPreferredSize( new Dimension(800,160) );
pn_u3u4.setBackground(Color.WHITE);
* Third User
// First user main panel
pn_u3 = new JPanel();
pn_u3.setLayout( new BorderLayout(5,5) );
pn_u3.setPreferredSize( new Dimension(800,80) );
pn_u3.setBackground(Color.WHITE);
// First user top panel that goes into the
// main panel North
pn_u3T = new JPanel();
pn_u3T.setLayout( new BorderLayout(5,5) );
pn_u3T.setPreferredSize( new Dimension(800,40) );
pn_u3T.setBackground(Color.WHITE);
// First user bottom panel that goes into the
// main panel South
pn_u3B = new JPanel();
pn_u3B.setLayout( new BorderLayout(5,5) );
pn_u3B.setPreferredSize( new Dimension(800,40) );
pn_u3B.setBackground(Color.WHITE);
// First user top panel left, goes into the
// top panel West
pn_u3TL = new JPanel();
pn_u3TL.setLayout( new FlowLayout() );
pn_u3TL.setPreferredSize( new Dimension(400,40) );
pn_u3TL.setBackground(Color.WHITE);
lbl_u3Name = new JLabel("Name");
lbl_u3Name.setFont( new Font("Times New Roman",Font.PLAIN,17) );
tf_u3Name = new JTextField(28);
pn_u3TL.add(lbl_u3Name);
pn_u3TL.add(tf_u3Name);
// First user top panel right, goes into the
// top panel East
pn_u3TR = new JPanel();
pn_u3TR.setLayout( new FlowLayout() );
pn_u3TR.setPreferredSize( new Dimension(400,40) );
pn_u3TR.setBackground(Color.WHITE);
lbl_u3ID = new JLabel("GNAS ID");
lbl_u3ID.setFont( new Font("Times New Roman",Font.PLAIN,17) );
tf_u3ID = new JTextField(28);
pn_u3TR.add(lbl_u3ID);
pn_u3TR.add(tf_u3ID);
pn_u3T.add(pn_u3TL, BorderLayout.WEST);
pn_u3T.add(pn_u3TR, BorderLayout.EAST);
// First user bottom panel left, goes into the
// bottom panel West
pn_u3BL = new JPanel();
pn_u3BL.setLayout( new FlowLayout() );
pn_u3BL.setPreferredSize( new Dimension(400,40) );
pn_u3BL.setBackground(Color.WHITE);
lbl_u3Round = new JLabel("Round Name");
lbl_u3Round.setFont( new Font("Times New Roman",Font.PLAIN,17) );
tf_u3Round = new JTextField(24);
pn_u3BL.add(lbl_u3Round);
pn_u3BL.add(tf_u3Round);
// First user bottom panel right, goes into the
// bottom panel East
pn_u3BR = new JPanel();
pn_u3BR.setLayout( new FlowLayout() );
pn_u3BR.setPreferredSize( new Dimension(400,40) );
pn_u3BR.setBackground(Color.WHITE);
lbl_u3Bow = new JLabel("Bow Type ");
lbl_u3Bow.setFont( new Font("Times New Roman",Font.PLAIN,17) );
cb_u3Bow = new JComboBox();
cb_u3Bow.addActionListener(this);
cb_u3Bow.addItem(" Compound ");
cb_u3Bow.addItem(" Long Bow ");
cb_u3Bow.addItem(" Recurve ");
pn_u3BR.add(lbl_u3Bow);
pn_u3BR.add(cb_u3Bow);
pn_u3B.add(pn_u3BL, BorderLayout.WEST);
pn_u3B.add(pn_u3BR, BorderLayout.EAST);
pn_u3.add(pn_u3T, BorderLayout.NORTH);
pn_u3.add(pn_u3B, BorderLayout.SOUTH);
//pn_u3u4.add(pn_u3, BorderLayout.NORTH);
* Fourth User
// First user main panel
pn_u4 = new JPanel();
pn_u4.setLayout( new BorderLayout(5,5) );
pn_u4.setPreferredSize( new Dimension(800,80) );
pn_u4.setBackground(Color.WHITE);
// First user top panel that goes into the
// main panel North
pn_u4T = new JPanel();
pn_u4T.setLayout( new BorderLayout(5,5) );
pn_u4T.setPreferredSize( new Dimension(800,40) );
pn_u4T.setBackground(Color.WHITE);
// First user bottom panel that goes into the
// main panel South
pn_u4B = new JPanel();
pn_u4B.setLayout( new BorderLayout(5,5) );
pn_u4B.setPreferredSize( new Dimension(800,40) );
pn_u4B.setBackground(Color.WHITE);
// First user top panel left, goes into the
// top panel West
pn_u4TL = new JPanel();
pn_u4TL.setLayout( new FlowLayout() );
pn_u4TL.setPreferredSize( new Dimension(400,40) );
pn_u4TL.setBackground(Color.WHITE);
lbl_u4Name = new JLabel("Name");
lbl_u4Name.setFont( new Font("Times New Roman",Font.PLAIN,17) );
tf_u4Name = new JTextField(28);
pn_u4TL.add(lbl_u4Name);
pn_u4TL.add(tf_u4Name);
// First user top panel right, goes into the
// top panel East
pn_u4TR = new JPanel();
pn_u4TR.setLayout( new FlowLayout() );
pn_u4TR.setPreferredSize( new Dimension(400,40) );
pn_u4TR.setBackground(Color.WHITE);
lbl_u4ID = new JLabel("GNAS ID");
lbl_u4ID.setFont( new Font("Times New Roman",Font.PLAIN,17) );
tf_u4ID = new JTextField(28);
pn_u4TR.add(lbl_u4ID);
pn_u4TR.add(tf_u4ID);
pn_u4T.add(pn_u4TL, BorderLayout.WEST);
pn_u4T.add(pn_u4TR, BorderLayout.EAST);
// First user bottom panel left, goes into the
// bottom panel West
pn_u4BL = new JPanel();
pn_u4BL.setLayout( new FlowLayout() );
pn_u4BL.setPreferredSize( new Dimension(400,40) );
pn_u4BL.setBackground(Color.WHITE);
lbl_u4Round = new JLabel("Round Name");
lbl_u4Round.setFont( new Font("Times New Roman",Font.PLAIN,17) );
tf_u4Round = new JTextField(24);
pn_u4BL.add(lbl_u4Round);
pn_u4BL.add(tf_u4Round);
// First user bottom panel right, goes into the
// bottom panel East
pn_u4BR = new JPanel();
pn_u4BR.setLayout( new FlowLayout() );
pn_u4BR.setPreferredSize( new Dimension(400,40) );
pn_u4BR.setBackground(Color.WHITE);
lbl_u4Bow = new JLabel("Bow Type ");
lbl_u4Bow.setFont( new Font("Times New Roman",Font.PLAIN,17) );
cb_u4Bow = new JComboBox();
cb_u4Bow.addActionListener(this);
cb_u4Bow.addItem(" Compound ");
cb_u4Bow.addItem(" Long Bow ");
cb_u4Bow.addItem(" Recurve ");
pn_u4BR.add(lbl_u4Bow);
pn_u4BR.add(cb_u4Bow);
pn_u4B.add(pn_u4BL, BorderLayout.WEST);
pn_u4B.add(pn_u4BR, BorderLayout.EAST);
pn_u4.add(pn_u4T, BorderLayout.NORTH);
pn_u4.add(pn_u4B, BorderLayout.SOUTH);
//pn_u3u4.add(pn_u4, BorderLayout.NORTH);
pn_2.add(pn_u1u2, BorderLayout.NORTH);
pn_2.add(pn_u3u4, BorderLayout.SOUTH);
//initialWindow.add(pn_topAll);//BorderLayout.NORTH);
initialWindow.add(pn_topAll, BorderLayout.NORTH);
initialWindow.add(pn_2, BorderLayout.CENTER);
// Boolean tests, to see if the combobox
// has been set, and if so how many panels to
// add to the initialWindow panel
if(u1 == true)
//initialWindow.add(pn_u1);
if(u2 == true)
pn_u1u2.add(pn_u2, BorderLayout.SOUTH);
//initialWindow.add(pn_u2);
initialWindow.repaint();
initialWindow.validate();
if(u3 == true)
pn_u3u4.add(pn_u3, BorderLayout.NORTH);
//initialWindow.add(pn_u3);
if(u4 == true)
pn_u3u4.add(pn_u4, BorderLayout.SOUTH);
//initialWindow.add(pn_u4);
cb_noOfPeople.addActionListener(this);
pack();
* Event listener for the initial screen
* Items it's listening to are:
* Combo Box - cb_noOfPoeple
* quit button
* login button
* reset button
public void actionPerformed(ActionEvent e)
if (e.getSource() == cb_noOfPeople)
if(cb_noOfPeople.getSelectedItem() == " 1 ")
if(pn_u3u4.getComponentCount() > 0)
pn_u3u4.remove(pn_u3);
pn_u3u4.remove(pn_u4);
else
if(pn_u1u2.getComponentCount() == 2)
pn_u1u2.remove(pn_u2);
else
initialWindow.repaint();
initialWindow.validate();
else if(cb_noOfPeople.getSelectedItem() == " 2 ")
if(pn_u3u4.getComponentCount() > 0)
pn_u3u4.remove(pn_u3);
pn_u3u4.remove(pn_u4);
else
pn_u1u2.add(pn_u2, BorderLayout.SOUTH);
initialWindow.repaint();
initialWindow.validate();
else if(cb_noOfPeople.getSelectedItem() == " 3 ")
if(pn_u3u4.getComponentCount() == 2)
pn_u3u4.remove(pn_u4);
else
pn_u1u2.add(pn_u2, BorderLayout.SOUTH);
pn_u3u4.add(pn_u3, BorderLayout.NORTH);
initialWindow.repaint();
initialWindow.validate();
else if(cb_noOfPeople.getSelectedItem() == " 4 ")
pn_u1u2.add(pn_u2, BorderLayout.SOUTH);
pn_u3u4.add(pn_u3, BorderLayout.NORTH);
pn_u3u4.add(pn_u4, BorderLayout.SOUTH);
initialWindow.repaint();
initialWindow.validate();
else
public static void main(String[] argv) { new InitialScreen().setVisible(true); }
} -
Null pointer exception when using CFCs on Solaris
I am running Apache 2.0.52 and my web root is /htdocs. I have
a multi-server installation of CF 7.0.2 on another partition:
/apps/jrun4. Regular CFM files work fine; however, I receive the
"The system has attempted to use an undefined value..." (null
pointer) error whenever I attempt to use a CFC from within a CFM
file or if I try to use Application.cfc -- Application.cfm works
fine.
For instance...I created two files in /htdocs/test: Test.cfc
and tester.cfm
Test.cfc contains:
<cfcomponent>
<cfset str = "Test">
</cfcomponent>
tester.cfm contains:
<cfset temp = createObject("component", "Test")>
When I run tester.cfm I get the error. I had some success
when I created a mapping in CF Admin called /tester, pointing to
/htdocs/test. I then changed the code in tester.cfm to:
<cfset temp = createObject("component", "tester.Test")>
And it worked! I also tried creating a CFC on the same
partition as the CF install (/apps) and then referencing it in the
tester.cfm code. That works too! However, that's a bandaid solution
and half of one at that. If I try to use Application.cfc anywhere
within /htdocs (web root), I get the null pointer error.
Additionally, I have another server setup identically except
for one difference: the web root is /apps/htdocs (same partition as
CF). Everything works fine on it. Has anyone experienced this
behavior before? Any ideas besides moving /htdocs to /apps/htdocs?
Is this a known issue that the web root must reside on the same
partition as the CF install?I am running Apache 2.0.52 and my web root is /htdocs. I have
a multi-server installation of CF 7.0.2 on another partition:
/apps/jrun4. Regular CFM files work fine; however, I receive the
"The system has attempted to use an undefined value..." (null
pointer) error whenever I attempt to use a CFC from within a CFM
file or if I try to use Application.cfc -- Application.cfm works
fine.
For instance...I created two files in /htdocs/test: Test.cfc
and tester.cfm
Test.cfc contains:
<cfcomponent>
<cfset str = "Test">
</cfcomponent>
tester.cfm contains:
<cfset temp = createObject("component", "Test")>
When I run tester.cfm I get the error. I had some success
when I created a mapping in CF Admin called /tester, pointing to
/htdocs/test. I then changed the code in tester.cfm to:
<cfset temp = createObject("component", "tester.Test")>
And it worked! I also tried creating a CFC on the same
partition as the CF install (/apps) and then referencing it in the
tester.cfm code. That works too! However, that's a bandaid solution
and half of one at that. If I try to use Application.cfc anywhere
within /htdocs (web root), I get the null pointer error.
Additionally, I have another server setup identically except
for one difference: the web root is /apps/htdocs (same partition as
CF). Everything works fine on it. Has anyone experienced this
behavior before? Any ideas besides moving /htdocs to /apps/htdocs?
Is this a known issue that the web root must reside on the same
partition as the CF install? -
Null pointer - need help!
Hi All,
I have a problem and I am not sure what to do.
I need to swap the sql queries below based on the status being passed into the method. However, when I try to set the query in an if statement - the line:
rs = state.executeQuery(query);will not compile. I get a cannot resolve symbol error message on query.
If I try to move the lines:
state = conn.createStatement();
rs = state.executeQuery(query);into the if statement - The line:
while(rs.next()) {will give me a null pointer.
So could someone give me an idea on how I could swap my query in and not get these errors? I really dont know what to do!
Thanks,
punnk
public Tool findReportLabel(String newID, Tool tool, String status) {
int colCount = tool.getColumns();
String fields = null;
ArrayList reportLabels = new ArrayList();
System.out.println("FIND REPORT LABEL - " + status);
try {
this.conn = database.SybaseDAO.grabConnection();
if(status == "due") {
String query = "SELECT * FROM MT."+newID+"_WEB_HEADERS WHERE ID='5'";
System.out.println("HITS - DUE");
if(status == "wait") {
String query = "SELECT * FROM MT."+newID+"_WEB_HEADERS WHERE ID='6'";
System.out.println("HITS - WAIT");
state = conn.createStatement();
rs = state.executeQuery(query);
while(rs.next()) {
for (int x = 0; x < colCount; x++ ) {
fields = rs.getString("Header"+(x+1));
reportLabels.add(fields);
tool.setReportLabels(reportLabels);
rs.close();
rs = null;
state.close();
state = null;
conn.close();
conn = null;
} catch(SQLException e) { System.out.println("3Failed to connect: " + e);
} finally {
return tool;
}I need to swap the sql queries below based on the status being passed into
the method. However, when I try to set the query in an if statement - the line:
rs = state.executeQuery(query);that is because query is decalred in the if block...
do something like this
Statement stm = null;
ResultSet res = null;
String sql = null;
try{
if(status == "due") {
sql = "SELECT * FROM MT."+newID+"_WEB_HEADERS WHERE ID='5'";
else if(status == "wait") {
sql = "SELECT * FROM MT."+newID+"_WEB_HEADERS WHERE ID='6'";
this.conn = database.SybaseDAO.grabConnection();
stm = conn.createStatement();
res = stm.executeQuery(sql);
while (res.next()){
// do something
catch (Exception e){
e.printStackTrace();
finally{
try{ res.close(); } catch (Exception ee){}
try{ stm.close(); } catch (Exception ee){}
} -
Null pointer error if not started with 1st in string
hi, this little pratice is about building a simple shopping cart. the TOAD.JSP will display the item list and quantity, user could check item and input the quantity that they want. if the user input larger quantity than database, servlet will sent the back to TOAD.jsp and show message. now it works if selected from 1 item, but if selected 2nd or 3rd, it will have null pointer error over here:
for(int i=0; i<ItemList.size(); i++)
newit = (ItemBean)ItemList.get(i);
if (item != null && item.equals(newit.getItem()) )
%>
<tr>
<td ><input type="checkbox" name = "item" value="<%= newit.getItem() %>"><b><%= newit.getItem() %> </b><br></td>
<td><input type=text name="<%= newit.getItem() %>Qty" value="<%= orderQty%>"></td>
</tr>
<tr><td colspan = 2>
<font size="3" color="red">
The item <%= newit.getItem() %> is NOT available in stock</font>
</td>
</tr>
<%
} else {
%>
<tr>
<td ><input type="checkbox" name = "item" value="<%= newit.getItem() %>"><b><%= newit.getItem() %> </b><br></td>
<td><b><input type=text name="<%= newit.getItem() %>Qty" value="<%= newit.getQty()%>"></b> </td>
</tr>
<%
%>
thanks for your time!You have prvided unsufficent information and poorly formatted code and as such no meaningful answer can given you at present.
But here is the best that one can guess at.
You have a null somewhere.
Is it coming from this code? I am going to say no.
Where does it come from? I don't know.
Where should you look? In the code that does processing to see what happens when yuo have more than one item.
What should you do next? Start putting in some debugging and tracing statements to see where you are heading off into the null abyss. -
Adding a new UDF throws a null pointer exception and modifying user.xml
Hello,
I have a two part question.
i. I am trying to add a UDF (using Advanced>User Configuration..Attributes) to a fully configured OIM i.e. oim with reconciliation and provisioning from and to resources but it throws a null pointer exception. Look at the log, I see
===============Excerpt form the log file==========
[2012-01-26T11:28:14.447-05:00] [oim_server1] [NOTIFICATION] [] [oracle.iam.platform.authz.impl] [tid: [ACTIVE].ExecuteThread: '3' for queue: 'weblogic.kernel.Default (self-tuning)'] [userId: xelsysadm] [ecid: 0000JKQq8vZ8dpC5nFk3yZ1Evvpt000LzY,0] [APP: oim#11.1.1.3.0] [dcid: c62f3a4b80d21e6f:ef93519:134587d39c4:-7ffd-0000000000022a3e] [[
---Stack Trace Begins[[This is not an exception. For debugging purposes]]---
oracle.iam.platform.authz.impl.OESAuthzServiceImpl.doCheckAccess(OESAuthzServiceImpl.java:210)
oracle.iam.platform.authz.impl.OESAuthzServiceImpl.hasAccess(OESAuthzServiceImpl.java:188)
oracle.iam.platform.authz.impl.OESAuthzServiceImpl.hasAccess(OESAuthzServiceImpl.java:180)
oracle.iam.platform.authz.impl.AuthorizationServiceImpl.hasAccess(AuthorizationServiceImpl.java:173)
oracle.iam.configservice.impl.ConfigManagerImpl.checkAuthorization(ConfigManagerImpl.java:1899)
oracle.iam.configservice.impl.ConfigManagerImpl.addAttribute(ConfigManagerImpl.java:177)
oracle.iam.configservice.api.ConfigManagerEJB.addAttributex(Unknown Source)
... 21 lines skipped..
oracle.iam.configservice.api.ConfigManager_5u0nrx_ConfigManagerRemoteImpl.addAttributex(ConfigManager_5u0nrx_ConfigManagerRemoteImpl.java:864)
... 13 lines skipped..
oracle.iam.configservice.api.ConfigManagerDelegate.addAttribute(Unknown Source)
oracle.iam.configservice.agentry.config.CreateAttributeActor.perform(CreateAttributeActor.java:266)
oracle.iam.consoles.faces.mvc.canonic.Model.perform(Model.java:547)
oracle.iam.consoles.faces.mvc.admin.Model.perform(Model.java:324)
oracle.iam.consoles.faces.mvc.canonic.Controller.doPerform(Controller.java:255)
oracle.iam.consoles.faces.mvc.canonic.Controller.doSelectAction(Controller.java:178)
oracle.iam.consoles.faces.event.NavigationListener.processAction(NavigationListener.java:97)
... 24 lines skipped..
oracle.iam.platform.auth.web.PwdMgmtNavigationFilter.doFilter(PwdMgmtNavigationFilter.java:115)
... weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:56)
oracle.iam.platform.auth.web.OIMAuthContextFilter.doFilter(OIMAuthContextFilter.java:100)
... 15 lines skipped..
weblogic.work.ExecuteThread.run(ExecuteThread.java:173)
---Stack Tracefor this call Ends---
[2012-01-26T11:28:14.447-05:00] [oim_server1] [NOTIFICATION] [IAM-1010010] [oracle.iam.platform.authz.impl] [tid: [ACTIVE].ExecuteThread: '3' for queue: 'weblogic.kernel.Default (self-tuning)'] [userId: xelsysadm] [ecid: 0000JKQq8vZ8dpC5nFk3yZ1Evvpt000LzY,0] [APP: oim#11.1.1.3.0] [dcid: c62f3a4b80d21e6f:ef93519:134587d39c4:-7ffd-0000000000022a3e] [arg: 1] [arg: null] [arg: USER_MANAGEMENT_CONFIG] [arg: CREATE_ATTRIBUTE] ********** Entering the Authorization Segment with parameters:: LoggedInUserId = 1, target resourceID = null, Feature = USER_MANAGEMENT_CONFIG, Action = CREATE_ATTRIBUTE **********
[2012-01-26T11:28:14.448-05:00] [oim_server1] [NOTIFICATION] [IAM-1010021] [oracle.iam.platform.authz.impl] [tid: [ACTIVE].ExecuteThread: '3' for queue: 'weblogic.kernel.Default (self-tuning)'] [userId: xelsysadm] [ecid: 0000JKQq8vZ8dpC5nFk3yZ1Evvpt000LzY,0] [APP: oim#11.1.1.3.0] [dcid: c62f3a4b80d21e6f:ef93519:134587d39c4:-7ffd-0000000000022a3e] [arg: [InternalObligation: name: noop, values: [true], convertToObligation: false, InternalObligation: name: noop, values: [true], convertToObligation: false]] Validating the Internal Obligations: [InternalObligation: name: noop, values: [true], convertToObligation: false, InternalObligation: name: noop, values: [true], convertToObligation: false]
[2012-01-26T11:28:14.448-05:00] [oim_server1] [NOTIFICATION] [IAM-1010022] [oracle.iam.platform.authz.impl] [tid: [ACTIVE].ExecuteThread: '3' for queue: 'weblogic.kernel.Default (self-tuning)'] [userId: xelsysadm] [ecid: 0000JKQq8vZ8dpC5nFk3yZ1Evvpt000LzY,0] [APP: oim#11.1.1.3.0] [dcid: c62f3a4b80d21e6f:ef93519:134587d39c4:-7ffd-0000000000022a3e] ---------- The list of Internal Obligation is satisfied, returning TRUE ----------
[2012-01-26T11:28:14.448-05:00] [oim_server1] [NOTIFICATION] [IAM-1010026] [oracle.iam.platform.authz.impl] [tid: [ACTIVE].ExecuteThread: '3' for queue: 'weblogic.kernel.Default (self-tuning)'] [userId: xelsysadm] [ecid: 0000JKQq8vZ8dpC5nFk3yZ1Evvpt000LzY,0] [APP: oim#11.1.1.3.0] [dcid: c62f3a4b80d21e6f:ef93519:134587d39c4:-7ffd-0000000000022a3e] [arg: Decision :PERMIT\nObligations from policy: ] ********** Exiting the Authorization Segment with result Decision :PERMIT[[
=============Excerpt ends==============
Is there a reason why this is and how do I get by it.
ii. Can I just add the field directly within the MDS>file/user.xml? Would there be an issue with changing an existing attribute metadata using the user.xml?Pradeep thank you for your response. it was helpful. However, I also found the responses to both my questions.
i. The null pointer exception was due to using a complex query I was using in the LOV query. I tried a simple query and that worked fine.
ii. For modifying the user defined attributes one can consult the following forum post:
OIM 11g - Change UDF Field Type form String to LOV
Thanks -
REG : Null Pointer Exception for RFC values
Hi All,
I am facing peculiar erro in code.I need to check the null entries in SAP server then it should be replaced by space and if not null then should be replaced by the value in backend.But it is throwing null pointer exception
I am using equalsignore case(null) and trim for space.
I am not getting why its is throwing null pointer exception.Kindly advise
Regards,
AnupamaHi
Use
String f = null ;
if(f!==null)
Wdcomponent.getMessageManager.ReportException ("this will cause null pointer exception "+ f.length());
Better to give it any Constant like
priveate static final String NULL_CHECK = "DEL_VAL12";
rather than space ,at the time of chceking see if it has DEL_VAL12 if true then put the actual data else let it be there.
Best Regards
Satish Kumar -
Why am I receiving Null pointer Exception Error.
why am I receiving Null pointer Exception Error.
Hi I am developing a code for login screen. There is no syntex error as such ut I am receving the aove mentioned error. Can some one please help me ??
------------ Main.java------------------
import java.io.*;
import java.awt.*;
import java.awt.event.*;
import java.sql.*;
public class Main implements ActionListener
Frame mainf;
MenuBar mb;
MenuItem List,admitform,inquiry,exit,helpn;
Menu newm,update,help;
Inquiry iq;
Admit ad;
// HosHelp hp;
Howuse hu;
Register reg;
Main()
mainf=new Frame(" Engg College V/S Mumbai University ");
mb=new MenuBar();
newm=new Menu(" New ");
update=new Menu(" Update ");
help=new Menu(" Help ");
List=new MenuItem("List");
admitform=new MenuItem("Admit");
inquiry=new MenuItem("Inquiry");
exit=new MenuItem("Exit");
helpn=new MenuItem("How to Use?");
newm.add(List);
newm.add(admitform);
newm.add(inquiry);
newm.add(exit);
help.add(helpn);
mb.add(newm);
mb.add(update);
mb.add(help);
mainf.setMenuBar(mb);
exit.addActionListener(this);
List.addActionListener(this);
inquiry.addActionListener(this);
admitform.addActionListener(this);
helpn.addActionListener(this);
mainf.setSize(400,300);
mainf.setVisible(true);
public void actionPerformed(ActionEvent ae)
if (ae.getSource()==List)
reg=new Register();
if(ae.getSource()==inquiry)
iq=new Inquiry();
if(ae.getSource()==admitform)
ad=new Admit();
if(ae.getSource()==helpn)
hu=new Howuse();
if(ae.getSource()==exit)
mainf.setVisible(false);
public static void main(String args[])
new Main();
-------------Register.java---------------------------
import java.awt.*;
import java.awt.event.*;
import java.sql.*;
public class Register implements ActionListener//,ItemListener
Label id,name,login,pass,repass;
Button ok,newu,cancel,check;
Button vok,iok,lok,mok,sok; //buttons for dialog boxes
TextField idf,namef,loginf,passf,repassf;
Dialog valid,invlog,less,mismat,acucreat;
Frame regis;
Checkbox admin,limit;
CheckboxGroup type;
DBconnect db;
Register()
db=new DBconnect();
regis=new Frame("Registeration Form");
type=new CheckboxGroup();
admin=new Checkbox("Administrator",type,true);
limit=new Checkbox("Limited",type,false);
id=new Label("ID :");
name=new Label("Name :");
login=new Label("Login :");
pass=new Label("Password :");
repass=new Label("Retype :");
idf =new TextField(20); idf.setEnabled(false);
namef=new TextField(30); namef.setEnabled(false);
loginf=new TextField(30); loginf.setEnabled(false);
passf=new TextField(30); passf.setEnabled(false);
repassf=new TextField(30); repassf.setEnabled(false);
ok=new Button("OK"); ok.setEnabled(false);
newu=new Button("NEW");
cancel=new Button("Cancel");
check=new Button("Check Login"); check.setEnabled(false);
vok=new Button("OK");
iok=new Button("OK");
lok=new Button("OK");
mok=new Button("OK");
sok=new Button("OK");
valid=new Dialog(regis,"Login name is valid !");
invlog=new Dialog(regis,"Login name already exist!");
less=new Dialog(regis,"Password is less than six characters !");
mismat=new Dialog(regis,"password & retyped are not matching !");
acucreat=new Dialog(regis,"You have registered successfully !");
regis.setLayout(null);
// regis.setBackground(Color.orange);
valid.setLayout(new FlowLayout());
invlog.setLayout(new FlowLayout());
less.setLayout(new FlowLayout());
mismat.setLayout(new FlowLayout());
acucreat.setLayout(new FlowLayout());
id.setBounds(35,50,80,25); //(left,top,width,hight)
idf.setBounds(125,50,40,25);
name.setBounds(35,85,70,25);
namef.setBounds(125,85,150,25);
login.setBounds(35,120,80,25);
loginf.setBounds(125,120,80,25);
check.setBounds(215,120,85,25);
pass.setBounds(35,155,80,25);
passf.setBounds(125,155,80,25);
repass.setBounds(35,190,80,25);
repassf.setBounds(125,190,80,25);
admin.setBounds(35,225,100,25);
limit.setBounds(145,225,100,25);
ok.setBounds(45,265,70,25);
newu.setBounds(135,265,70,25);
cancel.setBounds(225,265,70,25);
passf.setEchoChar('*');
repassf.setEchoChar('*');
regis.add(id);
regis.add(idf);
regis.add(name);
regis.add(namef);
regis.add(login);
regis.add(loginf);
regis.add(check);
regis.add(pass);
regis.add(passf);
regis.add(repass);
regis.add(repassf);
regis.add(ok);
regis.add(newu);
regis.add(cancel);
regis.add(admin);
regis.add(limit);
valid.add(vok);
invlog.add(iok);
less.add(lok);
mismat.add(mok);
acucreat.add(sok);
ok.addActionListener(this);
newu.addActionListener(this);
check.addActionListener(this);
cancel.addActionListener(this);
// limit.addItemListener(this);
//admin.addItemListener(this);
vok.addActionListener(this);
iok.addActionListener(this);
lok.addActionListener(this);
mok.addActionListener(this);
sok.addActionListener(this);
regis.setLocation(250,150);
regis.setSize(310,300);
regis.setVisible(true);
public void actionPerformed(ActionEvent ae)
if(ae.getSource()==check)
try{
String s2=loginf.getText();
ResultSet rs=db.s.executeQuery("select* from List");
while(rs.next())
if(s2.equals(rs.getString(2).trim()))
// invlog.setBackground(Color.orange);
invlog.setLocation(250,150);
invlog.setSize(300,100);
cancel.setEnabled(false);
ok.setEnabled(false);
check.setEnabled(false);
invlog.setVisible(true);
break;
else
// valid.setBackground(Color.orange);
valid.setLocation(250,150);
valid.setSize(300,100);
cancel.setEnabled(false);
ok.setEnabled(false);
check.setEnabled(false);
valid.setVisible(true);
}catch(Exception e)
e.printStackTrace();
if(ae.getSource()==newu)
try{
ResultSet rs=db.s.executeQuery("select max(ID) from List");
while(rs.next())
String s1=rs.getString(1).trim();
int i=Integer.parseInt(s1);
i++;
String s2=""+i;
idf.setText(s2);
newu.setEnabled(false);
namef.setText(""); namef.setEnabled(true);
loginf.setText(""); loginf.setEnabled(true);
passf.setText(""); passf.setEnabled(true);
repassf.setText(""); repassf.setEnabled(true);
ok.setEnabled(true);
check.setEnabled(true);
}catch(Exception e)
e.printStackTrace();
if(ae.getSource()==ok)
try
String s1=idf.getText();
String s2=loginf.getText();
String s3=passf.getText();
String s4=repassf.getText();
int x=Integer.parseInt(s1);
int t;
if(type.getSelectedCheckbox()==admin)
t=1;
else
t=0;
ResultSet rs=db.s1.executeQuery("select* from List");
while(rs.next())
if(s2.equals(rs.getString(2).trim()))
invlog.setBackground(Color.orange);
invlog.setLocation(250,150);
invlog.setSize(300,100);
cancel.setEnabled(false);
ok.setEnabled(false);
check.setEnabled(false);
invlog.setVisible(true);
break;
else
if (s3.length()<6)
less.setBackground(Color.orange);
less.setLocation(250,150);
less.setSize(300,100);
ok.setEnabled(false);
cancel.setEnabled(false);
check.setEnabled(false);
less.setVisible(true);
else if(!(s3.equals(s4)))
mismat.setBackground(Color.orange);
mismat.setLocation(250,150);
mismat.setSize(300,100);
ok.setEnabled(false);
cancel.setEnabled(false);
check.setEnabled(false);
mismat.setVisible(true);
else
db.s1.execute("insert into User values("+x+",'"+s2+"','"+s3+"',"+t+")");
acucreat.setBackground(Color.orange);
acucreat.setLocation(250,150);
acucreat.setSize(300,100);
regis.setVisible(false);
acucreat.setVisible(true);
}//else
}//while
} //try
catch(Exception e1)
// e1.printStackTrace();
if (ae.getSource()==cancel)
regis.setVisible(false);
if (ae.getSource()==vok)
ok.setEnabled(true);
cancel.setEnabled(true);
check.setEnabled(true);
valid.setVisible(false);
if (ae.getSource()==iok)
ok.setEnabled(true);
cancel.setEnabled(true);
check.setEnabled(true);
invlog.setVisible(false);
if (ae.getSource()==lok)
less.setVisible(false);
cancel.setEnabled(true);
ok.setEnabled(true);
check.setEnabled(true);
if (ae.getSource()==mok)
mismat.setVisible(false);
cancel.setEnabled(true);
ok.setEnabled(true);
check.setEnabled(true);
if (ae.getSource()==sok)
acucreat.setVisible(false);
ok.setEnabled(false);
newu.setEnabled(true);
regis.setVisible(true);
public static void main(String args[])
new Register();
-----------DBConnect.java------------------------------------
import java.sql.*;
public class DBconnect
Statement s,s1;
Connection c;
public DBconnect()
try
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
c=DriverManager.getConnection("jdbc:odbc:Sonal");
s=c.createStatement();
s1=c.createStatement();
catch(Exception e)
e.printStackTrace();
----------Login.java----------------
import java.awt.*;
import java.awt.event.*;
import java.sql.*;
public class Login implements ActionListener
Frame log;
Label login,pass;
TextField loginf,passf;
Button ok,cancel;
Dialog invalid;
Button iok;
Register reg;
DBconnect db;
Main m;
Login()
db=new DBconnect();
log=new Frame();
log.setLocation(250,210);
login=new Label("Login :");
pass=new Label("Password :");
loginf=new TextField(20);
passf=new TextField(20);
passf.setEchoChar('*');
ok=new Button("OK");
// newu=new Button("New User");
cancel=new Button("CANCEL");
iok=new Button(" OK ");
invalid=new Dialog(log,"Invalid User!");
//log.setBackground(Color.cyan);
//log.setForeground(Color.black);
log.setLayout(null);
// iok.setBackground(Color.gray);
invalid.setLayout(new FlowLayout());
login.setBounds(35,50,70,25); //(left,top,width,hight)
loginf.setBounds(105,50,100,25);
pass.setBounds(35,85,70,25);
passf.setBounds(105,85,70,25);
ok.setBounds(55,130,70,25);
// newu.setBounds(85,120,80,25);
cancel.setBounds(145,130,70,25);
log.add(login);
log.add(loginf);
log.add(pass);
log.add(passf);
log.add(ok);
// log.add(newu);
log.add(cancel);
invalid.add(iok);//,BorderLayout.CENTER);
ok.addActionListener(this);
// newu.addActionListener(this);
cancel.addActionListener(this);
iok.addActionListener(this);
log.setSize(300,170);
log.setVisible(true);
public void actionPerformed(ActionEvent a)
if(a.getSource()==ok)
try{
String l=loginf.getText();
String p=passf.getText();
ResultSet rs=db.s.executeQuery("select * from List");
while(rs.next())
if(l.equals(rs.getString(2).trim())&& p.equals(rs.getString(3).trim()))
String tp=rs.getString(4).trim();
int tp1=Integer.parseInt(tp);
log.setVisible(false);
if(tp1==1)
m=new Main();
// m.List.setEnabled(true);
else
m=new Main();
m.List.setEnabled(false);
break;
else
invalid.setBackground(Color.orange);
invalid.setSize(300,100);
invalid.setLocation(250,210);
cancel.setEnabled(false);
ok.setEnabled(false);
invalid.setVisible(true);
}catch(Exception e1)
e1.printStackTrace();
if (a.getSource()==cancel)
log.setVisible(false);
if (a.getSource()==iok)
invalid.setVisible(false);
loginf.setText("");
passf.setText("");
cancel.setEnabled(true);
ok.setEnabled(true);
public static void main(String[] args)
new Login();
-------------inquiry.java---------------------------------
import java.awt.*;
import java.awt.event.*;
import java.util.*;
import java.util.Date;
import java.text.*;
import java.sql.*;
public class Inquiry implements ActionListener
Frame inqry;
Label name,addr;
TextField namef,addrf;
Button ok,cancel,dok;
Dialog invalid;
Frame result; //Result of the inquiry....
Label lrname,lraddr,lward,lrdate,lcdate;
TextField rname,raddr,ward,rdate,cdate;
Date d;
DateFormat df;
Button rok,rcancel;
Dialog success;
Button rdok;
DBconnect db;
Inquiry()
db=new DBconnect();
inqry=new Frame("Inquiry Form");
inqry.setLayout(null);
inqry.setBackground(Color.cyan);
name=new Label(" NAME ");
addr=new Label("ADDRESS");
namef=new TextField(20);
addrf=new TextField(20);
ok=new Button("OK");
cancel=new Button("CANCEL");
dok=new Button("OK");
invalid=new Dialog(inqry,"Invalid Name or Address !");
invalid.setSize(300,100);
invalid.setLocation(300,180);
invalid.setBackground(Color.orange);
invalid.setLayout(new FlowLayout());
result=new Frame(" INQUIRY RESULT "); //Result Window......
result.setLayout(null);
result.setBackground(Color.cyan);
lcdate=new Label(" DATE ");
lrname=new Label(" NAME ");
lraddr=new Label(" ADDRESS ");
lward=new Label(" WARD ");
lrdate=new Label(" ADMIT-DATE ");
cdate=new TextField(10);
rname=new TextField(20);
rname.setEnabled(false);
raddr=new TextField(20);
raddr.setEnabled(false);
ward=new TextField(20);
ward.setEnabled(false);
rdate=new TextField(10);
rdate.setEnabled(false);
cdate=new TextField(20);
d=new Date();
df=DateFormat.getDateInstance(DateFormat.MEDIUM,Locale.KOREA);
cdate.setText(df.format(d));
cdate.setEnabled(false);
rok=new Button(" OK ");
rcancel=new Button("CANCEL");
name.setBounds(40,50,50,25);
namef.setBounds(120,50,130,25);
addr.setBounds(40,100,60,25);
addrf.setBounds(120,100,80,25);
ok.setBounds(60,145,70,25);
cancel.setBounds(140,145,70,25);
lcdate.setBounds(200,50,60,25); //Result Window......
cdate.setBounds(270,50,80,25);
lrname.setBounds(35,85,70,25);
rname.setBounds(140,85,180,25);
lraddr.setBounds(35,120,80,25);
raddr.setBounds(140,120,100,25);
lward.setBounds(35,155,80,25);
ward.setBounds(140,155,100,25);
lrdate.setBounds(30,190,80,25);
rdate.setBounds(140,190,80,25);
rok.setBounds(70,240,70,25);
rcancel.setBounds(170,240,70,25);
inqry.add(name);
inqry.add(namef);
inqry.add(addr);
inqry.add(addrf);
inqry.add(ok);
inqry.add(cancel);
invalid.add(dok);
result.add(lcdate); //Result Window......
result.add(cdate);
result.add(lrname);
result.add(rname);
result.add(lraddr);
result.add(raddr);
result.add(lward);
result.add(ward);
result.add(lrdate);
result.add(rdate);
result.add(rok);
result.add(rcancel);
ok.addActionListener(this);
cancel.addActionListener(this);
dok.addActionListener(this);
rok.addActionListener(this); //Result Window......
rcancel.addActionListener(this);
inqry.setSize(280,180);
inqry.setLocation(300,180);
inqry.setVisible(true);
result.setSize(400,280); //Result Window......
result.setLocation(200,150);
result.setVisible(false);
public void actionPerformed(ActionEvent ae)
if(ae.getSource()==ok)
try
String nm=namef.getText();
String ad=addrf.getText();
inqry.setVisible(false);
ResultSet rs=db.s.executeQuery("select * from Billinformation");
while(rs.next())
String nm1=rs.getString(2).trim();
String ad1=rs.getString(3).trim();
int k=0;
if((nm1.equals(nm))&&(ad1.equals(ad)))
String adm=rs.getString(5).trim();
String wr=rs.getString(6).trim();
String bd=rs.getString(8).trim();
String wrb=wr+"-"+bd;
result.setVisible(true);
rname.setText(nm1);
raddr.setText(ad1);
ward.setText(wrb);
rdate.setText(adm);
k=1;
break;
}//if
else if(k==1)
invalid.setVisible(true);
}//while
}//try
catch(Exception e)
e.printStackTrace();
} //getsource ==ok
if(ae.getSource()==cancel)
inqry.setVisible(false);
if(ae.getSource()==rok) //Result Window......
namef.setText("");
addrf.setText("");
result.setVisible(false);
inqry.setVisible(true);
if(ae.getSource()==rcancel)
result.setVisible(false);
if(ae.getSource()==dok)
namef.setText("");
addrf.setText("");
invalid.setVisible(false);
inqry.setVisible(true);
public static void main(String args[])
new Inquiry();
PLease Help me !!
I need this urgently.can you explain what your program tries to do... and
at where it went wrong..Sir,
We are trying to make an project where we can make a person register in our data base & after which he/she can search for other user.
The logged in user can modify his/her own data but can view other ppl's data.
We are in a phase of registering the user & that's where we are stuck. The problem is that after the login screen when we hit register (OK- button) the data are not getting entered in the data base.
Can u please help me??
I am using "jdk1.3' - studnet's edition.
I am waiting for your reply.
Thanks in advance & yr interest. -
Null pointer exception and servlet
I cant figure out why i am getting a null pointer exception. this works if i keep my form output in the same class as my driving servlet. All i did was break off the html display to a new form and i get a null pointer exception.
this is just an excerpt. no reason to post the whole form.
Here are my two classes...
import java.io.*;
import javax.servlet.*;
import javax.servlet.http.*;
import java.util.*;
import java.text.*;
import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.parsers.*;
import org.w3c.dom.Document;
import org.w3c.dom.DOMException;
import org.w3c.dom.Element;
public class myServlet extends HttpServlet
implements SingleThreadModel {
displayScreen myAddressBook;
HttpServletRequest request;
HttpServletResponse response;
String displayForm = "DISPLAYFORM";
String addForm = "ADDFORM";
String editForm = "EDITFORM";
// get function
public void doGet(HttpServletRequest request, HttpServletResponse response)
throws IOException, ServletException
request = this.request;
response = this.response;
displayScreen myAddressBook = new displayScreen(this.request,this.response);
myAddressBook.sendAddressBook(request,response,false,displayForm);
public void doPost(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
errorMsg = "";
errCount=0;
//stores address book in hashmap. Not currently using Address Book object
request = this.request;
response = this.response;
if ((request.getParameterValues("submit")[0].equals("Next")))
myAddressBook.sendAddressBook(request,response,false,displayForm);
import java.io.*;
import javax.servlet.*;
import javax.servlet.http.*;
import java.util.*;
import java.text.*;
import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.parsers.*;
public class displayScreen {
int errCount;
String errorMsg;
String displayForm = "DISPLAYFORM";
String addForm = "ADDFORM";
String editForm = "EDITFORM";
HttpServletRequest request;
HttpServletResponse response;
displayScreen (HttpServletRequest request, HttpServletResponse response) {
request = this.request;
response = this.response;
public void sendAddressBook (HttpServletRequest request, HttpServletResponse response,boolean FileError,String formType)
throws ServletException, IOException {
request = this.request;
response = this.response;
response.setContentType("text/html"); /*****/ I GET A NULL POINTER EXCEPTION RIGHT HERE!!!!!!
}anyway to write the system.err to an html screen with
a servlet?Why would you ask that? Surely you should have asked "Any way to write a stack trace to an HTML screen from a servlet?"
And in fact there is. I am sure you have not yet looked up the Exception class and the versions of its printStackTrace() method. But when you do, you will see that there are printStackTrace(PrintStream) and printStackTrace(PrintWriter). And you know how to write HTML (or text in general) to the servlet response so that it shows up in the client's browser, right? I will let you figure out how to put those things together. -
Null Pointer Exception and Illegal Arguement when ran with Wireless Toolkit
The following code throws a null pointer exception after it tried to initialize the textBox. I am not sure if there is something I am not importing, or if it's just because I'm sick and my head is cloudy. :-}.
I am using Wireless Toolkit 2.2 and Java 5.0
Anyhelp would be appreicated. Thank You.
import javax.microedition.midlet.*;
import javax.microedition.lcdui.*;
public class TacticalTestMain extends MIDlet implements CommandListener {
private Display display;
private Form formMain;
private TextBox tbHelp; //Text Box for help Command
private Command cmExit; //A button to exit midLet
private Command cmBack; //Go "back" to main form
private Command cmHelp; //Ask for help
public TacticalTestMain()
display = Display.getDisplay(this);
formMain = new Form("Tactical Survey Program");
cmExit = new Command("Exit", Command.SCREEN, 1);
cmBack = new Command("Back", Command.BACK, 1);
cmHelp = new Command("Help", Command.HELP, 1);
formMain.addCommand(cmExit);
formMain.addCommand(cmBack);
formMain.addCommand(cmHelp);
formMain.setCommandListener(this);
System.out.println("Before Create Text Box");
//Create the help textBox with a max of 25 charecters
tbHelp = new TextBox("HeLp", "You can press the back button", 25, 0);
tbHelp.addCommand(cmBack);
tbHelp.setCommandListener(this);
System.out.println("AfTER Create Text Box");
}//end constructor
public void startApp()
System.out.println("Inside StartApp()");
display.setCurrent(formMain);
}//end startApp()
public void pauseApp()
}//end pauseApp
public void destroyApp(boolean unconditional)
notifyDestroyed();
}//end destroyApp()
//Check to see if the exit button was selected
public void commandAction(Command c, Displayable d)
System.out.println("Inside commandAction()");
String sLabel = c.getLabel();
if(sLabel.equals("Exit"))
destroyApp(true);
Errors from the KToolbar:
Running with storage root DefaultColorPhone
Before Create Text Box
Unable to create MIDlet TacticalTestMain
java.lang.IllegalArgumentException
at javax.microedition.lcdui.TextField.setChars(+105)
at javax.microedition.lcdui.TextField.setString(+27)
at javax.microedition.lcdui.TextField.<init>(+134)
at javax.microedition.lcdui.TextBox.<init>(+74)
at TacticalTestMain.<init>(+134)
at java.lang.Class.runCustomCode(+0)
at com.sun.midp.midlet.MIDletState.createMIDlet(+19)
at com.sun.midp.midlet.Selector.run(+22)
Execution completed.
743701 bytecodes executed
23 thread switches
741 classes in the system (including system classes)
4071 dynamic objects allocated (120440 bytes)
2 garbage collections (91412 bytes collected)Hi zoya,
Here is the problem:
tbHelp = new TextBox("HeLp", "You can press the back button", 25, 0);
This line declares a maximum textbox size of 25 but in reality he is declaring a textbox of size 29.
Thats why it is throwing the illegal argument.
happy coding :) -
Null Pointer and cache problem
Simple program...reads 4 images from html and prints them on the page. That all works, but when observing the java console, a "Null Pointer Exception" error pops up after a while. I believe it has something to do with the cache. Is there any way you can see to avoid this error showing in the java console? What in tarnation could be causing this?
Here is the snip from the consol:
Java(TM) Plug-in: Version 1.4.1_02
Using JRE version 1.4.1_02 Java HotSpot(TM) Client VM
User home directory = C:\WINDOWS
Proxy Configuration: Browser Proxy Configuration
c: clear console window
f: finalize objects on finalization queue
g: garbage collect
h: display this help message
l: dump classloader list
m: print memory usage
o: trigger logging
p: reload proxy configuration
q: hide console
r: reload policy configuration
s: dump system properties
t: dump thread list
v: dump thread stack
x: clear classloader cache
0-5: set trace level to <n>
Trace level set to 5: basic, net, security, ext, liveconnect ... completed.
Logging set to : true ... completed.
Cache size is: 52022779 bytes, cleanup is necessary
Apr 29, 2005 4:40:02 PM sun.plugin.usability.PluginLogger log
INFO: Cache size is: 52022779 bytes, cleanup is necessary
java.lang.NullPointerException
at sun.plugin.cache.CacheFile.getFileType(CacheFile.java:81)
at sun.plugin.cache.CacheFile.before(CacheFile.java:127)
at sun.plugin.cache.CleanupThread$1.compare(CleanupThread.java:204)
at java.util.Arrays.mergeSort(Arrays.java:1237)
at java.util.Arrays.mergeSort(Arrays.java:1244)
at java.util.Arrays.mergeSort(Arrays.java:1245)
at java.util.Arrays.mergeSort(Arrays.java:1244)
at java.util.Arrays.mergeSort(Arrays.java:1245)
at java.util.Arrays.mergeSort(Arrays.java:1244)
at java.util.Arrays.mergeSort(Arrays.java:1244)
at java.util.Arrays.sort(Arrays.java:1185)
at sun.plugin.cache.CleanupThread.getFilesInCache(CleanupThread.java:200)
at sun.plugin.cache.CleanupThread.cleanCache(CleanupThread.java:122)
at sun.plugin.cache.CleanupThread.run(CleanupThread.java:93)
Here is a snip of the html page:
<applet code="jewelry3custom.class" align="baseline"
width="750" height="300" >
<param name="image1" value="web-heart-musician-4.jpg">
<param name="image2" value="web-circle-musician-4.jpg">
<param name="image3" value="web-oval-musician-4.jpg">
<param name="image4" value="web-rectangle-musician-4.jpg">
<param name="BackGround" value="FFFFFF">
<param name="Steps" value="277">
<param name="Speed" value="16">
</applet>Here is the java program:
* Created on Apr 25, 2005 7:16:27 AM
import java.awt.*;
import java.awt.image.*;
import java.util.*;
import java.applet.*;
import java.awt.event.*;
import java.awt.event.MouseEvent;
public class jewelry3custom extends Applet implements MouseListener
Image imag1, imag2, imag3, imag4;
public void init()
imag1 = getImage(getDocumentBase(), getParameter("image1"));
imag2 = getImage(getDocumentBase(), getParameter("image2"));
imag3 = getImage(getDocumentBase(), getParameter("image3"));
imag4 = getImage(getDocumentBase(), getParameter("image4"));
public void paint(Graphics g)
g.drawImage(imag1,10,10,100,100,this);
g.drawImage(imag2,120,10,100,100,this);
g.drawImage(imag3,230,10,100,100,this);
g.drawImage(imag4,340,10,100,100,this);
public void mouseClicked(MouseEvent event){
public void mousePressed(MouseEvent event){
public void mouseReleased(MouseEvent event){
public void mouseEntered(MouseEvent event){
public void mouseExited(MouseEvent event){
}Those database defaults are only applied when you use an INSERT statement that specifies a list of columns excluding the ones with defaults. Presumably your persistence code always sets all columns when it does an INSERT, so the defaults won't apply. You'll have to find the way to set the defaults in the persistence layer, not in the database.
-
Using ExecuteWithParams and getting a null pointer error
I'm new to Webcenter and have a question about using ExecuteWithParams. I want to know if anyone experienced a null pointer exception when using it. I was using the example from the followng page to create a parameter form to filter an adf table.
http://www.oracle.com/technology/products/jdev/tips/muench/screencasts/threesearchpages/threesearchforms_partthree.html?_template=/ocom/technology/content/print
I created the named bind variable in the View Object editor, changed the query and dragged the ExecuteWithParams Operation onto my page. However, when I go to run the page I get the following error:
javax.faces.el.EvaluationException: java.lang.NullPointerException at com.sun.faces.el.ValueBindingImpl.getValue(ValueBindingImpl.java:190) at com.sun.faces.el.ValueBindingImpl.getValue(ValueBindingImpl.java:143) at oracle.adf.view.faces.bean.FacesBeanImpl.getProperty(FacesBeanImpl.java:55) at oracle.adfinternal.view.faces.renderkit.core.xhtml.LabelAndMessageRenderer.getLabel(LabelAndMessageRenderer.java:618) at oracle.adfinternal.view.faces.renderkit.core.xhtml.LabelAndMessageRenderer.encodeAll(LabelAndMessageRenderer.java:157) at oracle.adfinternal.view.faces.renderkit.core.xhtml.InputLabelAndMessageRenderer.encodeAll(InputLabelAndMessageRenderer.java:94) at oracle.adfinternal.view.faces.renderkit.core.CoreRenderer.encodeEnd(CoreRenderer.java:169) at oracle.adf.view.faces.component.UIXComponentBase.encodeEnd(UIXComponentBase.java:624) at oracle.adfinternal.view.faces.renderkit.core.CoreRenderer.encodeChild(CoreRenderer.java:246) at oracle.adfinternal.view.faces.renderkit.core.xhtml.PanelFormRenderer.encodeColumnChild(PanelFormRenderer.java:275) at oracle.adfinternal.view.faces.renderkit.core.xhtml.PanelFormRenderer.renderColumn(PanelFormRenderer.java:251) at oracle.adfinternal.view.faces.renderkit.core.xhtml.PanelFormRenderer._renderColumns(PanelFormRenderer.java:545) at oracle.adfinternal.view.faces.renderkit.core.xhtml.PanelFormRenderer._encodeChildren(PanelFormRenderer.java:153) at oracle.adfinternal.view.faces.renderkit.core.xhtml.PanelFormRenderer.encodeAll(PanelFormRenderer.java:69) at oracle.adfinternal.view.faces.renderkit.core.CoreRenderer.encodeEnd(CoreRenderer.java:169) at oracle.adf.view.faces.component.UIXComponentBase.encodeEnd(UIXComponentBase.java:624) at oracle.adfinternal.view.faces.uinode.UIComponentUINode._renderComponent(UIComponentUINode.java:317) at oracle.adfinternal.view.faces.uinode.UIComponentUINode.render(UIComponentUINode.java:262) at oracle.adfinternal.view.faces.uinode.UIComponentUINode.render(UIComponentUINode.java:239) at oracle.adfinternal.view.faces.ui.composite.ContextPoppingUINode$ContextPoppingRenderer.render(ContextPoppingUINode.java:224) at oracle.adfinternal.view.faces.ui.BaseUINode.render(BaseUINode.java:346) at oracle.adfinternal.view.faces.ui.BaseUINode.render(BaseUINode.java:301) at oracle.adfinternal.view.faces.ui.BaseRenderer.renderChild(BaseRenderer.java:412) at oracle.adfinternal.view.faces.ui.BaseRenderer.renderNamedChild(BaseRenderer.java:384) at oracle.adfinternal.view.faces.ui.laf.base.desktop.PageHeaderLayoutRenderer.renderContent(PageHeaderLayoutRenderer.java:259) at oracle.adfinternal.view.faces.ui.BaseRenderer.render(BaseRenderer.java:81) at oracle.adfinternal.view.faces.ui.laf.base.xhtml.XhtmlLafRenderer.render(XhtmlLafRenderer.java:69) at oracle.adfinternal.view.faces.ui.BaseUINode.render(BaseUINode.java:346) at oracle.adfinternal.view.faces.ui.BaseUINode.render(BaseUINode.java:301) at oracle.adfinternal.view.faces.ui.BaseRenderer.renderChild(BaseRenderer.java:412) at oracle.adfinternal.view.faces.ui.BaseRenderer.renderIndexedChild(BaseRenderer.java:330) at oracle.adfinternal.view.faces.ui.BaseRenderer.renderIndexedChild(BaseRenderer.java:222) at oracle.adfinternal.view.faces.ui.BaseRenderer.renderContent(BaseRenderer.java:129) at oracle.adfinternal.view.faces.ui.BaseRenderer.render(BaseRenderer.java:81) at oracle.adfinternal.view.faces.ui.laf.base.xhtml.XhtmlLafRenderer.render(XhtmlLafRenderer.java:69) at oracle.adfinternal.view.faces.ui.BaseUINode.render(BaseUINode.java:346) at oracle.adfinternal.view.faces.ui.BaseUINode.render(BaseUINode.java:301) at oracle.adfinternal.view.faces.ui.composite.UINodeRenderer.renderWithNode(UINodeRenderer.java:90) at oracle.adfinternal.view.faces.ui.composite.UINodeRenderer.render(UINodeRenderer.java:36) at oracle.adfinternal.view.faces.ui.laf.oracle.desktop.PageLayoutRenderer.render(PageLayoutRenderer.java:76) at oracle.adfinternal.view.faces.uinode.UIXComponentUINode.renderInternal(UIXComponentUINode.java:177) at oracle.adfinternal.view.faces.uinode.UINodeRendererBase.encodeEnd(UINodeRendererBase.java:53) at oracle.adf.view.faces.component.UIXComponentBase.encodeEnd(UIXComponentBase.java:624) at oracle.adfinternal.view.faces.renderkit.RenderUtils.encodeRecursive(RenderUtils.java:54) at oracle.adfinternal.view.faces.renderkit.core.CoreRenderer.encodeChild(CoreRenderer.java:242) at oracle.adfinternal.view.faces.renderkit.core.CoreRenderer.encodeAllChildren(CoreRenderer.java:265) at oracle.adfinternal.view.faces.renderkit.core.xhtml.PanelPartialRootRenderer.renderContent(PanelPartialRootRenderer.java:65) at oracle.adfinternal.view.faces.renderkit.core.xhtml.BodyRenderer.renderContent(BodyRenderer.java:117) at oracle.adfinternal.view.faces.renderkit.core.xhtml.PanelPartialRootRenderer.encodeAll(PanelPartialRootRenderer.java:147) at oracle.adfinternal.view.faces.renderkit.core.xhtml.BodyRenderer.encodeAll(BodyRenderer.java:60) at oracle.adfinternal.view.faces.renderkit.core.CoreRenderer.encodeEnd(CoreRenderer.java:169) at oracle.adf.view.faces.component.UIXComponentBase.encodeEnd(UIXComponentBase.java:624) at javax.faces.webapp.UIComponentTag.encodeEnd(UIComponentTag.java:645) at javax.faces.webapp.UIComponentTag.doEndTag(UIComponentTag.java:568) at oracle.adf.view.faces.webapp.UIXComponentTag.doEndTag(UIXComponentTag.java:100) at mdssys.viewcontroller._public__html._SoluminaOrderStatus_jspx._jspService(_SoluminaOrderStatus_jspx.java:943) [SRC:/mdssys/ViewController/public_html/SoluminaOrderStatus.jspx:4] at com.orionserver[Oracle Containers for J2EE 10g (10.1.3.3.0) ].http.OrionHttpJspPage.service(OrionHttpJspPage.java:59) at oracle.jsp.runtimev2.JspPageTable.compileAndServe(JspPageTable.java:724) at oracle.jsp.runtimev2.JspPageTable.service(JspPageTable.java:414) at oracle.jsp.runtimev2.JspServlet.internalService(JspServlet.java:594) at oracle.jsp.runtimev2.JspServlet.service(JspServlet.java:518) at javax.servlet.http.HttpServlet.service(HttpServlet.java:856) at com.evermind[Oracle Containers for J2EE 10g (10.1.3.3.0) ].server.http.ResourceFilterChain.doFilter(ResourceFilterChain.java:65) at oracle.mds.jsp.MDSJSPFilter.doFilter(Unknown Source) at com.evermind[Oracle Containers for J2EE 10g (10.1.3.3.0) ].server.http.ServletRequestDispatcher.invoke(ServletRequestDispatcher.java:623) at com.evermind[Oracle Containers for J2EE 10g (10.1.3.3.0) ].server.http.ServletRequestDispatcher.forwardInternal(ServletRequestDispatcher.java:370) at com.evermind[Oracle Containers for J2EE 10g (10.1.3.3.0) ].server.http.ServletRequestDispatcher.unprivileged_forward(ServletRequestDispatcher.java:287) at com.evermind[Oracle Containers for J2EE 10g (10.1.3.3.0) ].server.http.ServletRequestDispatcher.access$100(ServletRequestDispatcher.java:51) at com.evermind[Oracle Containers for J2EE 10g (10.1.3.3.0) ].server.http.ServletRequestDispatcher$2.oc4jRun(ServletRequestDispatcher.java:193) at oracle.oc4j.security.OC4JSecurity.doPrivileged(OC4JSecurity.java:283) at com.evermind[Oracle Containers for J2EE 10g (10.1.3.3.0) ].server.http.ServletRequestDispatcher.forward(ServletRequestDispatcher.java:198) at com.sun.faces.context.ExternalContextImpl.dispatch(ExternalContextImpl.java:346) at com.sun.faces.application.ViewHandlerImpl.renderView(ViewHandlerImpl.java:152) at oracle.adfinternal.view.faces.application.ViewHandlerImpl.renderView(ViewHandlerImpl.java:157) at com.sun.faces.lifecycle.RenderResponsePhase.execute(RenderResponsePhase.java:107) at com.sun.faces.lifecycle.LifecycleImpl.phase(LifecycleImpl.java:245) at com.sun.faces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:137) at javax.faces.webapp.FacesServlet.service(FacesServlet.java:214) at com.evermind[Oracle Containers for J2EE 10g (10.1.3.3.0) ].server.http.ResourceFilterChain.doFilter(ResourceFilterChain.java:65) at oracle.adfinternal.view.faces.webapp.AdfFacesFilterImpl._invokeDoFilter(AdfFacesFilterImpl.java:228) at oracle.adfinternal.view.faces.webapp.AdfFacesFilterImpl._doFilterImpl(AdfFacesFilterImpl.java:197) at oracle.adfinternal.view.faces.webapp.AdfFacesFilterImpl.doFilter(AdfFacesFilterImpl.java:123) at oracle.adf.view.faces.webapp.AdfFacesFilter.doFilter(AdfFacesFilter.java:103) at com.evermind[Oracle Containers for J2EE 10g (10.1.3.3.0) ].server.http.EvermindFilterChain.doFilter(EvermindFilterChain.java:15) at oracle.adf.model.servlet.ADFBindingFilter.doFilter(ADFBindingFilter.java:162) at com.evermind[Oracle Containers for J2EE 10g (10.1.3.3.0) ].server.http.ServletRequestDispatcher.invoke(ServletRequestDispatcher.java:621) at com.evermind[Oracle Containers for J2EE 10g (10.1.3.3.0) ].server.http.ServletRequestDispatcher.forwardInternal(ServletRequestDispatcher.java:370) at com.evermind[Oracle Containers for J2EE 10g (10.1.3.3.0) ].server.http.HttpRequestHandler.doProcessRequest(HttpRequestHandler.java:871) at com.evermind[Oracle Containers for J2EE 10g (10.1.3.3.0) ].server.http.HttpRequestHandler.processRequest(HttpRequestHandler.java:453) at com.evermind[Oracle Containers for J2EE 10g (10.1.3.3.0) ].server.http.HttpRequestHandler.serveOneRequest(HttpRequestHandler.java:221) at com.evermind[Oracle Containers for J2EE 10g (10.1.3.3.0) ].server.http.HttpRequestHandler.run(HttpRequestHandler.java:122) at com.evermind[Oracle Containers for J2EE 10g (10.1.3.3.0) ].server.http.HttpRequestHandler.run(HttpRequestHandler.java:111) at oracle.oc4j.network.ServerSocketReadHandler$SafeRunnable.run(ServerSocketReadHandler.java:260) at oracle.oc4j.network.ServerSocketAcceptHandler.procClientSocket(ServerSocketAcceptHandler.java:239) at oracle.oc4j.network.ServerSocketAcceptHandler.access$700(ServerSocketAcceptHandler.java:34) at oracle.oc4j.network.ServerSocketAcceptHandler$AcceptHandlerHorse.run(ServerSocketAcceptHandler.java:880) at com.evermind[Oracle Containers for J2EE 10g (10.1.3.3.0) ].util.ReleasableResourcePooledExecutor$MyWorker.run(ReleasableResourcePooledExecutor.java:298) at java.lang.Thread.run(Thread.java:595)Caused by: java.lang.NullPointerException at oracle.adf.model.binding.DCVariableImpl.resolveSourceVariable(DCVariableImpl.java:64) at oracle.adf.model.binding.DCVariableImpl.resolveResourceProperty(DCVariableImpl.java:142) at oracle.jbo.common.VariableImpl.getLabel(VariableImpl.java:800) at oracle.jbo.uicli.binding.JUCtrlValueBinding.getLabel(JUCtrlValueBinding.java:1384) at oracle.jbo.uicli.binding.JUCtrlValueBinding.internalGet(JUCtrlValueBinding.java:1726) at oracle.adfinternal.view.faces.model.binding.FacesCtrlAttrsBinding.internalGet(FacesCtrlAttrsBinding.java:156) at oracle.adf.model.binding.DCControlBinding.get(DCControlBinding.java:649) at com.sun.faces.el.PropertyResolverImpl.getValue(PropertyResolverImpl.java:79) at oracle.adfinternal.view.faces.model.FacesPropertyResolver.getValue(FacesPropertyResolver.java:92) at com.sun.faces.el.impl.ArraySuffix.evaluate(ArraySuffix.java:187) at com.sun.faces.el.impl.ComplexValue.evaluate(ComplexValue.java:171) at com.sun.faces.el.impl.ExpressionEvaluatorImpl.evaluate(ExpressionEvaluatorImpl.java:263) at com.sun.faces.el.ValueBindingImpl.getValue(ValueBindingImpl.java:160) ... 97 more
Can anyone help me with this?Please, post your question on JDeveloper forum (JDeveloper and ADF
-
Null Pointer exception returned when object is not null!
I've isolated the problem and cut down the code to the minimum. Why do I get a null pointer exception when the start method is called, when the object objJTextField is not null at this point???? I'm really stuck here, HELP!
(two small java files, save as BasePage.java and ExtendedPage.java and then run ExtendedPage)
first file
~~~~~~~
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
public abstract class BasePage extends JFrame implements ActionListener
private JPanel objJPanel = null;
public BasePage()
setSize(300,200);
Container objContentPane = getContentPane();
objJPanel = new JPanel();
createObjects();
createPage();
// Add panels to content pane
objContentPane.add(objJPanel);
public void addComponentToPage(JComponent objJComponent)
objJPanel.add(objJComponent);
public void addButtonToPage(JButton objJButton)
objJButton.addActionListener(this);
objJPanel.add(objJButton);
public void actionPerformed(ActionEvent objActionEvent)
System.out.println("Action performed");
userDefinedButtonClicked(objActionEvent.getActionCommand());
// overide
public abstract void createObjects();
public abstract void createPage();
public abstract void userDefinedButtonClicked(String sActionCommand);
file 2
~~~~
import javax.swing.*;
public class ExtendedPage extends BasePage
private JTextField objJTextField = null;
private JButton objJButtonBrowse = null;
public ExtendedPage()
super();
public void createObjects()
objJTextField = new JTextField(20);
objJButtonBrowse = new JButton("Start");
objJButtonBrowse.setActionCommand("START");
public void createPage()
addComponentToPage(objJTextField);
addButtonToPage(objJButtonBrowse);
public void userDefinedButtonClicked(String sActionCommand)
if ((sActionCommand != null) && (sActionCommand.equals("START")) )
start();
private void start()
objJTextField.setText("Doesn't work");
public static void main(String[] args)
ExtendedPage objEP = new ExtendedPage();
objEP.show();Hello ppaulf,
Your problem is in your ExtendedPage.java file. You can fix this by changing the line
private JTextField objJTextField = null;to:
private JTextField objJTextField = new JTextField();This creates a proper instance.
Good luck,
Ming
Developer Technical Support
http://www.sun.com/developers/support -
JAX-WS Client throws NULL Pointer Exception in NW 7.1 SP3 and higher
All,
My JAX-WS client is throwing an exception when attempting to create a client to connect to the calculation service. The exception is coming out of the core JAX-WS classes that are part of NetWeaver. (see exception below)
Caused by: java.lang.NullPointerException
at com.sap.engine.services.webservices.espbase.client.jaxws.core.SAPServiceDelegate.createDispatchContextExistingPort(SAPServiceDelegate.java:440)
at com.sap.engine.services.webservices.espbase.client.jaxws.core.SAPServiceDelegate.createDispatchContext(SAPServiceDelegate.java:475)
at com.sap.engine.services.webservices.espbase.client.jaxws.core.SAPServiceDelegate.createDispatch(SAPServiceDelegate.java:492)
at com.sap.engine.services.webservices.espbase.client.jaxws.core.SAPServiceDelegate.createDispatch(SAPServiceDelegate.java:484)
at javax.xml.ws.Service.createDispatch(Service.java:166)
I have done some research and it appears that as of NetWeaver 7.1 SP3 SAP stopped using the SUN JAX-WS runtime and implemented their own SAP JAX-WS runtime. I also took the time to decompile the jar file that contained the SAPServiceDelegate class which is throwing the null pointer exception. (see method from SAPServiceDelegate below)
private ClientConfigurationContext createDispatchContextExistingPort(QName portName, JAXBContext jaxbContext)
BindingData bindingData;
InterfaceMapping interfaceMap;
InterfaceData interfaceData;
bindingData = clientServiceCtx.getServiceData().getBindingData(portName);
if(bindingData == null)
throw new WebServiceException((new StringBuilder()).append("Binding data '").append(portName.toString()).append("' is missing!").toString());
QName bindingQName = new QName(bindingData.getBindingNamespace(), bindingData.getBindingName());
interfaceMap = getInterfaceMapping(bindingQName, clientServiceCtx);
interfaceData = getInterfaceData(interfaceMap.getPortType());
ClientConfigurationContext result = DynamicServiceImpl.createClientConfiguration(bindingData, interfaceData, interfaceMap, null, jaxbContext, getClass().getClassLoader(), clientServiceCtx, new SOAPTransportBinding(), false, 1);
return result;
WebserviceClientException x;
x;
throw new WebServiceException(x);
The exception is being throw on the line where the interfaceMap.getPortType() is being passed into the getInterfaceData method. I checked the getInterfaceMapping method which returns the interfaceMap (line above the line throwing the exception). This method returns NULL if an interface cannot be found. (see getInterfaceMapping method below)
public static InterfaceMapping getInterfaceMapping(QName bindingQName, ClientServiceContext context)
InterfaceMapping interfaces[] = context.getMappingRules().getInterface();
for(int i = 0; i < interfaces.length; i++)
if(bindingQName.equals(interfaces<i>.getBindingQName()))
return interfaces<i>;
return null;
What appears to be happening is that the getInterfaceMapping method returns NULL then the next line in the createDispatchContextExistingPort method attempts to call the getPortType() method on a NULL and throws the Null Pointer Exception.
I have included the code we use to create a client below. It works fine on all the platforms we support with the exception of NetWeaver 7.1 SP3 and higher (I already checked SP5 as well)
//Create URL for service WSDL
URL serviceURL = new URL(null, wsEndpointWSDL);
//create service qname
QName serviceQName = new QName(targetNamespace, "WSService");
//create port qname
QName portQName = new QName(targetNamespace, "WSPortName");
//create service
Service service = Service.create(serviceURL, serviceQName);
//create dispatch on port
serviceDispatch = service.createDispatch(portQName, Source.class, Service.Mode.PAYLOAD);
What do I need to change in order to create a JAX-WS dispatch client on top of the SAP JAX-WS runtime?Hi Guys,
I am getting the same error. Any resolution or updates on this.
Were you able to fix this error.
Thanks,
Yomesh
Maybe you are looking for
-
Will my dual 500 go faster? Harddrive & external hard drive issues
I need some advise, please! I have a Dual 500 MHz PowerPC G4. Memory: 1.38 GB SDRAM. Harddrive 40GB The memory slots are a follows: 256MB 128MB 512MB 512MB 1. I would like to speed things up as it is sooo slooow! If I replace the 2 smaller cards with
-
Should files be securely deleted if using File Vault?
Do I need to "shred" or in someway securely delete files and mail that sit in File Vault? I am new to the MacOS and I am not sure where deleted files/mail go. If they don't leave the Home Folder it should be ok but if they somehow are relocated outsi
-
Problem with loading a project from other system
Hi! I am tring to load a project that being done on logic with audiowerk card on other computer. I can open the project but when I am choosing a channel and changing the sound-card name to my card (core audio) I can hear the sund but all the plug-ins
-
Photoshop file size Discrepancy
Hey Guys. I have a photoshop file which while editing states what I believe is the flat/layered file sizes down the bottom left of the screen of 116.7M/255.4M. But when I save the file Finder shows the file size as being 1.53GB. Is this normal? What
-
Quicktime application not responding after screen recording.
After taping video gameplay of a heavily modded Fallout: New Vegas, pressing the stop button makes the application stop responding altogether. Causing me to force quit as it saves only a couple seconds. It worked for awhile for about four recordings