JAVA EXPERTS kindly chip-in

class Test
Test t=new Test();
class TestA
public static void main(String[] args)
Test t=new Test();
I'm getting a run-time error in above code that is
Exception in Thread "Main" java.lang.StackOverflowError
while the following code is working very fine, inspite of that I am doing almost the same thing in the following code too. Only the difference is that, in the following code I'm instantiating the class from inside the static initializer block whereas in the above code I'm doing this from inside a class-level normal block.
class Test
static
Test t=new Test();
Test()
System.out.println("Inside Test's Default Constructor");
class TestA
public static void main(String[] args)
Test t=new Test();
output:
Inside Test's Default Constructor
Inside Test's Default Constructor
I'm struggling to find the reason behind this.
so, calling Java Experts to help me please.

duffymo wrote:
%! How's life?Caleb, so good to see your name here.
Happy Father's Day! I'm going to have an afternoon of kayaking with my wife and daughters. It'll be fantastic.
Personally, I don't think there's anything wrong with throwing in a few System.out.println()s to do a quick, down and dirty debug. I do it all the time, actually.The key words there are "quick, down and dirty debug". I do too, but I take them out when I solve the problem.
I wouldn't advise putting trace System.out calls in constructors as a "best practice". That's what I responded to.
%Happy Father's Day to you as well! I just got back from a camping trip with the wife and kids! It was fantastic. One of the best trips I've had in a long time.
Where are you going kayaking?
I didn't realize that they were calling that a "best practice." I whole-heartedly agree.

Similar Messages

  • Can any Java expert help me? Urgent.

    I create a table---CourseDB in adatabase to store the Student ID ( student identification number) and the grades of the courses that they took.
    The structure of the table---CourseDB is:
    StudentID
    GradeofCourse1
    GradeofCourse2
    GradeofCourse3
    GradeofCourseN
    Here GradeofCourse1 means the grade of course 1, that the student obtained. GradeofCourse2, GradeofCourse3, GradeofCourseN have the same meaning.
    I want to use the following query to count the students
    who get g1 in course 1, and g2 in course 2, ......and gn in
    course n.
    Select COUNT(*)
    From CourseDB
    Where GradeofCourse1=g1 AND GradeofCourse2= g2
    ......AND GradeofCourseN=gn
    Here g1, g2,......,gn are grade, the values are: A,B,C,D.
    I want to consider all the possible combination of g1,g2,...,gn.
    The students take all the n courses:Course 1, Course 2,...., Course n, and may get A,B,C, or D in the n courses.
    For example:
    g1=A,g2=B,g3=C,.....,gn=D
    ( This means that the student gets A in Course 1, gets B in Course 2, gets C in Course 3,....., gets D in Course n. Many students may have the same situation. I want to know how many are the students?)
    Or:
    g1=B,g2=C,g3=D,......,gn=A
    To make the problem clear, I give a detail example:
    For example, there are two courses: course 1, course 2.
    I want to know how many stuent get "A" in course 1 and
    get "B" in course 2 at the same time.
    And I want to know all the grade combination of the two courses:
    course 1 course 2
    A A
    A B
    A C
    A D
    B A
    B B
    B C
    B D
    C A
    C B
    C C
    C D
    D A
    D B
    D C
    D D
    So that's 16 total combinations(4^2).
    My question is in the code how I can assign the values(A,B,C,D)
    to g1,g2,g3,.....,gn conveniently.
    The following "nested for loop" can solve the problem ( for example, there are 6 courses):
    for (char class1 = 'A'; class1 <= 'D'; class1++)
    for (char class2 = 'A'; class1 <= 'D'; class2++)
    for (char class3 = 'A'; class1 <= 'D'; class3++)
    for (char class4 = 'A'; class1 <= 'D'; class4++)
    for (char class5 = 'A'; class1 <= 'D'; class5++)
    for (char class6 = 'A'; class1 <= 'D'; class6++)
    select count(*)
    from CourseDB
    where GradeofCourse1=class1 AND GradeofCourse2 = class2 AND GradeofCourse3 = class3
    ....AND GradeofCourse6=class6
    But the problem is that in the "Where GradeofCourse1=class1 AND
    GradeofCourse2= class2 ......AND GradeofCourse6=class6" of the
    Query, the number of courses is not fixed, maybe six, maybe three,
    maybe four, so the depth of "nested for loop" can not be fixed.
    Can any Java expert give me some suggestions?
    Thanks in advance.
    Jack

    Jack,
    When you posted this on the other forum, it was quite a different question, but it has mutated to this point now. I believe what you want to do can be done with what MS Access calls a crosstab query and you can completely leave Java and any other programming language out of it. If you need to know how to do a crosstab query please take it to another forum.

  • Java Experts please help - SimpleDateFormat.format reduces date by a day !!

    Hi,
    I am facing a very weird problem with SimpleDateFormat class. The input Date to SimpleDateFormat.format method is getting reduced by ONE DAY. This problem is happening at random and is not reproducible at will. Any help/pointers to resolve this issue is very much appreciated !!.
    Code is similar to the following code lines
    input = "2003-11-01 00:00:00.000000000";
    output = 31-Oct-2003 (strange !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!)
    import java.sql.Connection;
    import java.sql.SQLException;
    import java.sql.Timestamp;
    import java.text.DateFormatSymbols;
    import java.text.ParseException;
    import java.text.SimpleDateFormat;
    import java.util.Date;
    import java.util.Hashtable;
    import java.util.Locale;
    import java.util.TimeZone;
    import java.util.SimpleTimeZone;
    public class DateTester {
    /** Default constructor for Util.
    public DateTester() {
    private static String replace(String pattern, String from, String to) {
    return replace(pattern, from, to, null);
    private static String replace(String pattern, String from, String to, String notFrom) {
    StringBuffer sb = new StringBuffer();
    boolean finished = false;
    int index = pattern.indexOf(from);
    if (index < 0) return pattern;
    do {
    if (notFrom == null ||
    notFrom.length() + index > pattern.length() ||
    !pattern.substring(index, index + notFrom.length()).equals(notFrom)) {
    sb.append(pattern.substring(0, index));
    sb.append(to);
    sb.append(pattern.substring(index + from.length()));
    finished = true;
    } else index = pattern.indexOf(from, index + from.length());
    while (!finished && index >= 0);
    if (!finished) return pattern;
    return sb.toString();
    public static void main(String[] argv) {
              String pattern = "DD-MON-YYYY";
    System.out.println("original pattern =" + pattern);
    pattern = replace(pattern, "FM", "");
    pattern = replace(pattern, "AD", "G");
    pattern = replace(pattern, "A.D.", "G");
    pattern = replace(pattern, "BC", "G");
    pattern = replace(pattern, "B.C.", "G");
    pattern = replace(pattern, "AM", "a");
    pattern = replace(pattern, "A.M.", "a");
    pattern = replace(pattern, "PM", "a");
    pattern = replace(pattern, "P.M.", "a");
    pattern = pattern.replace('\"', '\t');
    pattern = pattern.replace('\'', '\"');
    pattern = pattern.replace('\t', '\'');
    pattern = replace(pattern, "DDD", "DDD");
    pattern = replace(pattern, "DAY", "dd");
    pattern = replace(pattern, "DD", "dd", "DDD");
    pattern = replace(pattern, "HH24", "HH");
    pattern = replace(pattern, "HH12", "KK");
    pattern = replace(pattern, "IW", "ww");
    pattern = replace(pattern, "MI", "mm");
    pattern = replace(pattern, "MM", "MM", "MMM");
    pattern = replace(pattern, "MONTH", "MMMMM");
    pattern = replace(pattern, "MON", "MMM");
    pattern = replace(pattern, "SS", "ss");
    pattern = replace(pattern, "WW", "ww");
    pattern = replace(pattern, "W", "W");
    pattern = replace(pattern, "YYYY", "yyyy");
    pattern = replace(pattern, "YYY", "yyy");
    pattern = replace(pattern, "YY", "yy");
    pattern = replace(pattern, "Y", "y");
    pattern = replace(pattern, "RRRR", "yyyy");
    pattern = replace(pattern, "RRR", "yyy");
    pattern = replace(pattern, "RR", "yy");
    pattern = replace(pattern, "R", "y");
    System.out.println("converted pattern =" + pattern);
    String origDate = "2003-11-01 00:00:00.000000000";
    System.out.println("original date =" + origDate);
    Timestamp origTimeStamp = Timestamp.valueOf(origDate);
    SimpleDateFormat sdf = new SimpleDateFormat(pattern, Locale.getDefault());
    sdf.setLenient(false);
    String formattedDate = sdf.format((Date) origTimeStamp);
    System.out.println("formatted date =" + formattedDate);
    Thanks a lot for your time !

    Your code is too hard to read for me to look at it in great detail. When you post code, please use [code] and [/code] tags as described in Formatting Help on the message entry page. It makes it much easier to read.
    However, I'm guessing it's a TimeZone issue. The midnight on 11/1 that you're setting is probably getting converted to GMT somewhere before the Date object is created. If you're in the U.S., then that's afternoon or evening on 10/31.
    Try:
    * Starting with a time that's later in the day on 11/1.
    * Formatting your date to include time and timezone when you print it. (Just for testing--you can put it back once you understand what's going on
    * Reading the Calendar, Timzone, Date, etc. APIs closely.
    * Reading any tutorials or texts you can find on the subject.
    * Writing a bunch of very small and simple tests to get an understanding of how this all fits together.
    Date/Time/TZ handling in Java is kinda tricky.

  • Java experts on offsetTop and OffsetLeft

    Hi Guys Need ur help ...........
    The web page Html code has <table> tags and if we have to find the largest table among them we need to find the table with the largest height and largest width but height attribute is usually not given with the <table> tag and they say that offsetTop and OffsetLeft can be used to find the largest <table>
    So all java experts in this field plz help me out in this regard.Any small help would be appreciated.........
    Plz help me out guysssssss

    java != javascript

  • A small Java Problem for java Experts

    Hi Guys...
    I have a small problem with my program...
    Tha program I am using consist of several frames where one invokes the other in row.
    These are the classes I am using:
    the FIRST class://THIS CLASS IS NOT COMPLETE
    import java.io.*;
    import java.awt.*;
    import java.awt.event.*;
    import javax.swing.*;
    * LabelDemo.java is a 1.4 application that needs one other file:
    * images/middle.gif
    public class CSVloader extends JPanel implements ActionListener {
         ImageIcon icon ;
         JLabel label;
    JButton theButton1;
    JButton saveButton;
    JButton displayButton;
    JButton displayStyleButton;
    JFileChooser fc;
    final boolean shouldFill = true;
    final boolean shouldWeightX = true;
    public CSVloader() {
    GridBagLayout gridbag = new GridBagLayout();
    GridBagConstraints c = new GridBagConstraints();
    setLayout(gridbag);
    if (shouldFill) {
    //natural height, maximum width
    c.fill = GridBagConstraints.HORIZONTAL;
    theButton1 = new JButton("Choose source File");
    theButton1.addActionListener(this);
    if (shouldWeightX) {
    c.weightx = 0.5;
    c.gridx = 0;
    c.gridy = 0;
    gridbag.setConstraints(theButton1, c);
    add(theButton1);
    displayStyleButton = new JButton("CSV Display style");
    displayStyleButton.addActionListener(this);
    c.gridx = 0;
    c.gridy = 2;
    gridbag.setConstraints(displayStyleButton, c);
    add(displayStyleButton);
    displayButton = new JButton("Display");
    displayButton.addActionListener(this);
    c.gridx = 1;
    c.gridy = 0;
    gridbag.setConstraints(displayButton, c);
    add(displayButton);
    saveButton = new JButton("Save");
    saveButton.addActionListener(this);
    c.gridx = 0;
    c.gridy = 1;
    gridbag.setConstraints(saveButton, c);
    add(saveButton);
    icon = new ImageIcon("c:/applets/CSVlogo.gif");
    //Create the first label.
    label = new JLabel(icon);
    c.ipady = 45; //make this component tall
    c.weightx = 0.0;
    c.gridwidth = 1;
    c.gridx = 1;
    c.gridy = 1;
    gridbag.setConstraints(label, c);
    add(label);
    fc = new JFileChooser();
    public Dimension getDimension(int hight, int width) {
    Dimension theDimension = new Dimension(hight,width);
    return theDimension;
    public void actionPerformed(ActionEvent e) {
    //Handle open button action.
    if (e.getSource() == theButton1) {
    int returnVal = fc.showOpenDialog(CSVloader.this);
    if (returnVal == JFileChooser.APPROVE_OPTION) {
    File file = fc.getSelectedFile();
    //This is where a real application would open the file.
    //Handle save button action.
    } else
    if (e.getSource() == displayButton) {
         try {
    Runtime.getRuntime().exec("cmd /c start " + "c:\\applets\\displayData.html");
    catch(IOException io)
    System.err.println("Caught IOException: " +
         io.getMessage());
    }else
    if (e.getSource() == displayStyleButton)
    JFrame.setDefaultLookAndFeelDecorated(true);
    //Create and set up the window.
    JFrame frame = new JFrame("Display Style");
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    //Create and set up the content pane.
    DisplayStyle newContentPane = new DisplayStyle();
    newContentPane.setOpaque(true); //content panes must be opaque
    frame.setContentPane(newContentPane);
    //Display the window.
    frame.pack();
    frame.setVisible(true);
    else
    if (e.getSource() == saveButton) {
         int returnVal = fc.showOpenDialog(CSVloader.this);
    if (returnVal == JFileChooser.APPROVE_OPTION) {
    File saveFile = fc.getSelectedFile();
    //This is where a real application would open the file.
    public static void main(String[] args) {
    //Make sure we have nice window decorations.
    JFrame.setDefaultLookAndFeelDecorated(true);
    //Create and set up the window.
    JFrame frame = new JFrame("LabelDemo");
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    //Create and set up the content pane.
    CSVloader newContentPane = new CSVloader();
    newContentPane.setBackground(Color.WHITE);
    newContentPane.setOpaque(true);
    frame.setContentPane(newContentPane);
    //Display the window.
    frame.pack();
    frame.setVisible(true);
    // Runtime.getRuntime().exec("cmd /c start " + "....\\docs\\index.html");
    this is the SECOND class:
    import java.awt.*;
    import java.awt.event.*;
    import javax.swing.*;
    public class DisplayStyle extends JPanel implements ActionListener{
         public static final int FIRST_OPTION = 0;
         public static final int SECOND_OPTION = 1;
         public static final int THIRD_OPTION = 2;
         public static final int THE_BUTTON_OPTION =3;
    public static final int ERROR = -1;
         public int selectedOption = ERROR;
         static String table = "Table";
         static String tableNoBorders = "Table without Borders";
         static String highlightedTable = "Highlighted Table without Borders";
         public JRadioButton theTable;
         public JRadioButton theTable2;
         public JRadioButton theTable3;
         public JButton theButton;
         public String theName;
         public DisplayStyle ()
         theTable = new JRadioButton(table);
         theTable.setActionCommand(""+ FIRST_OPTION);
         theTable.addActionListener(this);
         theTable.setMnemonic(KeyEvent.VK_B);     
    theTable.setSelected(true);
    theTable2 = new JRadioButton(tableNoBorders);
    theTable2.setActionCommand(""+ SECOND_OPTION);
         theTable2.addActionListener(this);
         theTable2.setMnemonic(KeyEvent.VK_B);     
    theTable3 = new JRadioButton(highlightedTable);
    theTable3.setActionCommand(""+ THIRD_OPTION);
         theTable3.addActionListener(this);
         theTable3.setMnemonic(KeyEvent.VK_B);     
    theButton = new JButton("OK");
    theButton.setActionCommand(""+ THE_BUTTON_OPTION);
    theButton.addActionListener(this);
         ButtonGroup group = new ButtonGroup();
    group.add(theTable);
    group.add(theTable2);
    group.add(theTable3);
    JLabel theLabel = new JLabel("Choose the style of Display");
    JPanel radioPanel = new JPanel(new GridLayout(0, 1));
    radioPanel.add(theLabel);
    radioPanel.add(theTable);
    radioPanel.add(theTable2);
    radioPanel.add(theTable3);
    radioPanel.add(theButton);
    add(radioPanel, BorderLayout.LINE_START);
         public void actionPerformed (ActionEvent e) {
         if(e.getSource() == theButton)
         JFrame.setDefaultLookAndFeelDecorated(true);
    //Create and set up the window.
    JFrame frame1 = new JFrame("The Format");
    frame1.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    Formats newFormat = new Formats();
    newFormat.setOpaque(true); //content panes must be opaque
    frame1.setContentPane(newFormat);
    //Display the window.
    frame1.pack();
    frame1.setVisible(true);
         selectedOption = Integer.parseInt(e.getActionCommand().trim());
         public DisplayStyle getInstance(){
              return this;      
    this is the THIRD class:
    mport java.awt.*;
    import java.awt.event.*;
    import javax.swing.*;
    public class Formats extends JPanel implements ActionListener{
         public static final int FIRST_OPTION = 0;
         public static final int SECOND_OPTION = 1;
         public static final int THIRD_OPTION = 2;
         public static final int FOURTH_OPTION = 4;
         public static final int THE_BUTTON_OPTION =3;
    public static final int ERROR = -1;
         public int selectedOption = ERROR;
         static String standardFormat = "Date first";
         static String timeFirstFormat = "Time First";
         static String typeFirstFormat = "Type of call first";
         static String extFirstFormat = "Extension first";
         public JButton theButton;
         public JRadioButton theStandardButton1 ;
         public JRadioButton theTimeButton;
         public JRadioButton theTypeButton;
         public JRadioButton theExtButton ;
         public Formats()
    theStandardButton1 = new JRadioButton(standardFormat);
         theStandardButton1.setMnemonic(KeyEvent.VK_B);     
    theStandardButton1.setSelected(true);
         theTimeButton = new JRadioButton(timeFirstFormat);
         theTimeButton.setMnemonic(KeyEvent.VK_B);     
    theTypeButton = new JRadioButton(typeFirstFormat);
         theTypeButton .setMnemonic(KeyEvent.VK_B);     
    theExtButton = new JRadioButton(extFirstFormat);
         theExtButton.setMnemonic(KeyEvent.VK_B);     
         ButtonGroup group = new ButtonGroup();
    group.add(theStandardButton1);
    group.add(theTimeButton);
    group.add(theTypeButton);
    group.add(theExtButton);
    JLabel newLabel = new JLabel("Choose the Format type for the data to be displayed");
    theButton = new JButton("OK");
    theButton.addActionListener(this);
    theButton.setActionCommand("" + THE_BUTTON_OPTION);
    JPanel radioPanel = new JPanel(new GridLayout(0, 1));
    radioPanel.add(newLabel);
    radioPanel.add(theStandardButton1);
    radioPanel.add(theTimeButton);
    radioPanel.add(theTypeButton);
    radioPanel.add(theExtButton);
    radioPanel.add(theButton);
    add(radioPanel, BorderLayout.LINE_START);      
         public void actionPerformed (ActionEvent e) {
         if(e.getSource() == theButton)
         JFrame.setDefaultLookAndFeelDecorated(true);
    //Create and set up the window.
    JFrame frame = new JFrame("The Font");
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    TableFonts newFont = new TableFonts();
    newFont.setOpaque(true); //content panes must be opaque
    frame.setContentPane(newFont);
    //Display the window.
    frame.pack();
    frame.setVisible(true);
         selectedOption = Integer.parseInt(e.getActionCommand().trim());
         public Formats getInstance(){
              return this;      
    and the last class:
    import java.awt.*;
    import java.awt.event.*;
    import javax.swing.*;
    public class TableFonts extends JPanel implements ActionListener{
         static String standardFont = "Standard Font";
         static String boldFont = "Bold Font";
         static String italicFont = "Italic Font";
         static String monospaceFont = "Monospace Font";
         public      JRadioButton theStandardButton ;
         public JRadioButton theBoldButton;
         public JRadioButton theItalicButton;
         public JRadioButton theMonospaceButton ;
         public TableFonts()
    theStandardButton = new JRadioButton(standardFont);
         theStandardButton.setMnemonic(KeyEvent.VK_B);     
    theStandardButton.setSelected(true);
         theBoldButton = new JRadioButton(boldFont);
         theBoldButton.setMnemonic(KeyEvent.VK_B);     
    theItalicButton = new JRadioButton(italicFont);
         theItalicButton .setMnemonic(KeyEvent.VK_B);     
    theMonospaceButton = new JRadioButton(monospaceFont);
         theMonospaceButton.setMnemonic(KeyEvent.VK_B);     
         ButtonGroup group = new ButtonGroup();
    group.add(theStandardButton);
    group.add(theBoldButton);
    group.add(theItalicButton);
    group.add(theMonospaceButton);
    theStandardButton.addActionListener(this);
    theBoldButton.addActionListener(this);
    theItalicButton.addActionListener(this);
    theMonospaceButton.addActionListener(this);
    JLabel newLabel = new JLabel("Choose the correct font for the data to be displayed");
    JPanel radioPanel = new JPanel(new GridLayout(0, 1));
    radioPanel.add(newLabel);
    radioPanel.add(theStandardButton);
    radioPanel.add(theBoldButton);
    radioPanel.add(theItalicButton);
    radioPanel.add(theMonospaceButton);
    add(radioPanel, BorderLayout.LINE_START);
         public void actionPerformed(ActionEvent e) {
    The problem I am getting is the Number format exception when the OK button of the class Formats is clicked...
    here is the error I am getting:
    java.lang.NumberFormatException: For input string: "OK"
    at java.lang.NumberFormatException.forInputString(NumberFormatException.
    java:48)
    at java.lang.Integer.parseInt(Integer.java:426)
    at java.lang.Integer.parseInt(Integer.java:476)
    at Formats.actionPerformed(Formats.java:80)
    at javax.swing.AbstractButton.fireActionPerformed(AbstractButton.java:17
    64)
    at javax.swing.AbstractButton$ForwardActionEvents.actionPerformed(Abstra
    ctButton.java:1817)
    at javax.swing.DefaultButtonModel.fireActionPerformed(DefaultButtonModel
    .java:419)
    at javax.swing.DefaultButtonModel.setPressed(DefaultButtonModel.java:257
    at javax.swing.plaf.basic.BasicButtonListener.mouseReleased(BasicButtonL
    istener.java:245)
    at java.awt.Component.processMouseEvent(Component.java:5134)
    at java.awt.Component.processEvent(Component.java:4931)
    at java.awt.Container.processEvent(Container.java:1566)
    at java.awt.Component.dispatchEventImpl(Component.java:3639)
    at java.awt.Container.dispatchEventImpl(Container.java:1623)
    at java.awt.Component.dispatchEvent(Component.java:3480)
    at java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:3450
    at java.awt.LightweightDispatcher.processMouseEvent(Container.java:3165)
    at java.awt.LightweightDispatcher.dispatchEvent(Container.java:3095)
    at java.awt.Container.dispatchEventImpl(Container.java:1609)
    at java.awt.Window.dispatchEventImpl(Window.java:1590)
    at java.awt.Component.dispatchEvent(Component.java:3480)
    at java.awt.EventQueue.dispatchEvent(EventQueue.java:450)
    at java.awt.EventDispatchThread.pumpOneEventForHierarchy(EventDispatchTh
    read.java:197)
    at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThre
    ad.java:150)
    at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:144)
    at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:136)
    at java.awt.EventDispatchThread.run(EventDispatchThread.java:99)
    COULD YOU GUYS PLEASE TELL ME HOW TO GET AROUND THIS PROBLEM:
    THANKS...

    It's in this line:
    selectedOption = Integer.parseInt(e.getActionCommand().trim());
    Kind regards,
      Levi
    PS. have you noticed the [code][code[i]] tags?

  • Hire a java expert for java proxy server.

    hello,
    i need a expert java programmer to hire for a simple java proxy project please contact me if you are intrested please leave me a message for more info.

    http://localhost:7021/sbresource?PROXY/MySample/MyJMSProxyService is the WSDL URL of the proxy.
    Transport is is picked by the client from wsdl.
    As far as the documentation of client generation is there, there is no change.
    But meanwhile I have started working on sending the message directly to queue. JMSProxy is getting called. May be I will first run the proxy this way and then try troubleshooting the java client.
    Regards
    Ashwani

  • URGENT!! all the JAVA EXPERTS plssss help me!!

    thanks for replying me....i m actually doing a coursework that i have to submit by next monday 29/4/2002. and i havent finish it yet.... ok .. finally i have finish level 1, now i m doing level two...
    my program in level 2 should :
    a.) Allow the user to specify certain criteria for a room that they wish to book on a particular day. e.g. X number of people, video conferencing, your program should find an appropriate room for them that is free on that day.
    b.) Allow the user to add more rooms to the system and make these available to the user to book.
    c.) Allow a user to attempt to delete a room. The room will only be deleted if it has no bookings.
    d.) Allow the user to ask the system to find the minimum fit room free e.g.
    * the smallest room to hold X people that has a connection to the internet.
    * if the user requests a room for 40 people and there are rooms free for 50 and 60 people, then
    it will allocate them the room for 50.
    i really donno how to do....pls help me....
    there is something wrong in the METHOD --> AddDeleteRoom()
    and i donno how to code the AddNewRoom()
    i need to add more rooms into my array
    u can download these coding .....i got three files, 1 is the main class call CC.java, another 1 is the class filewhich is Rooms.java and the third file is CC.html file.
    dont worry, u can save all the coding in here.... i try b4 it can run.....
    <<save as CC.java>>
    import java.awt.*;
    import java.awt.event.*;
    import javax.swing.event.*;
    import javax.swing.JApplet;
    import javax.swing.*;
    import javax.swing.border.*;
    import javax.swing.JOptionPane;
    public class CC extends JApplet implements ActionListener,ItemListener
    JPanel pnlPane = new JPanel();
    JPanel pnlChoise = new JPanel();
    JPanel pnlButton2 = new JPanel();
    JPanel pnlRoomDisplay = new JPanel();
    JPanel pnlRoom = new JPanel();
    JPanel pnlDisplay = new JPanel();
    JPanel pnlClear = new JPanel();
    JButton btnDisplay = new JButton("Display");
    JButton btnBookRoom = new JButton("Book Room");
    JButton btnDelBookRoom = new JButton("Delete Booking");
    JButton btnDelRoom = new JButton("Delete Room");
    JButton btnAddNewRoom = new JButton("Add New Room");
    JButton btnClear = new JButton("Clear");
    JButton btnRoomQuery = new JButton("Room Query");
    Rooms []room = new Rooms[11];
    String[] Days = {"Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "Sunday"};
    int [][] book = new int[11][7];
    public int R, D;
    JLabel lblRoomName = new JLabel();
    JLabel lblCapacity = new JLabel();
    JLabel lblInternet = new JLabel();
    JLabel lblVideo = new JLabel();
    JLabel lblStatus = new JLabel();
    JComboBox cDays= new JComboBox(Days);
    JComboBox cRooms = new JComboBox();
    JTextField txtRoomName1 = new JTextField();
    JTextField txtCapacity1 = new JTextField();
    JCheckBox chkInternet = new JCheckBox("Internet Connection");
    JCheckBox chkVideo = new JCheckBox("Video Conferencing");
    JTextArea txtDisplay = new JTextArea("*****Rooms Detail*****" + "\n",12,30);
    public void init()
    pnlPane.add(pnlChoise);
    pnlPane.add(pnlButton2);
    pnlPane.add(pnlRoomDisplay);
    pnlPane.add(pnlRoom);
    pnlPane.add(pnlDisplay);
    pnlPane.add(pnlClear);
    pnlPane.setBorder(new TitledBorder(new BevelBorder(BevelBorder.RAISED),"Room Booking System"));
    setContentPane(pnlPane);
    AddChoisePanel();
    AddButton2Panel();
    AddRoomDisplayPanel();
    AddRoomPanel();
    AddDisplayAreaPanel();
    AddClearPanel();
    public void AddChoisePanel()
    pnlChoise.setLayout(new GridLayout(1,3,5,5));
    room[0]=new Rooms("Barrington","15","No","Yes");
    room[1]=new Rooms("Carlton","25","Yes","No");
    room[2]=new Rooms("Debyshire","35","No","No");
    room[3]=new Rooms("Edwards","30","Yes","Yes");
    room[4]=new Rooms("Farley","70","Yes","No");
    room[5]=new Rooms("Goodwin","80","Yes","Yes");
    room[6]=new Rooms("Harlow","90","No","Yes");
    room[7]=new Rooms("IlFord","85","No","No");
    for (int i=0; i<8; i++)
    cRooms.addItem(room.rName);
    pnlChoise.add(cRooms);
    pnlChoise.add(cDays);
    pnlChoise.add(btnRoomQuery);
    btnRoomQuery.addActionListener(this);
    cRooms.addItemListener(this);
    public void AddButton2Panel()
    pnlButton2.setLayout(new GridLayout(1,2,5,5));
    pnlButton2.add(btnBookRoom);
    pnlButton2.add(btnDelBookRoom);
    btnDelBookRoom.addActionListener(this);
    btnBookRoom.addActionListener(this);
    public void AddRoomDisplayPanel()
    pnlRoomDisplay.setLayout(new GridLayout(6,2,5,2));
    pnlRoomDisplay.add(new JLabel("Room Name" ));
    pnlRoomDisplay.add(lblRoomName);
    pnlRoomDisplay.add(new JLabel("Room Capacity"));
    pnlRoomDisplay.add(lblCapacity);
    pnlRoomDisplay.add(new JLabel("Internet Connection"));
    pnlRoomDisplay.add(lblInternet);
    pnlRoomDisplay.add(new JLabel("Video Conferencing"));
    pnlRoomDisplay.add(lblVideo);
    pnlRoomDisplay.add(new JLabel("Room Status"));
    pnlRoomDisplay.add(lblStatus);
    pnlRoomDisplay.setBorder(new TitledBorder(new BevelBorder(BevelBorder.LOWERED),"Rooms Detail"));
    pnlRoomDisplay.add(btnDelRoom);
    btnDelRoom.addActionListener(this);
    public void AddRoomPanel()
    pnlRoom.setLayout(new GridLayout(6,2,2,2));
    pnlRoom.setBorder(new TitledBorder(new BevelBorder(BevelBorder.LOWERED),"Add New Rooms"));
    pnlRoom.add(new Label("Room Name"));
    pnlRoom.add(txtRoomName1);
    pnlRoom.add(new Label("Capacity"));
    pnlRoom.add(txtCapacity1);
    pnlRoom.add(chkInternet);
    pnlRoom.add(new Label(""));
    pnlRoom.add(chkVideo);
    pnlRoom.add(new Label(""));
    pnlRoom.add(new Label(""));
    pnlRoom.add(new Label(""));
    pnlRoom.add(btnAddNewRoom);
    btnAddNewRoom.addActionListener(this);
    public void AddDisplayAreaPanel()
    pnlDisplay.setLayout(new GridLayout(1,1));
    //pnlDisplay.setBorder(new TitledBorder(new BevelBorder(BevelBorder.LOWERED),"Rooms Detail"));
    Border pnlDisplayBorder = BorderFactory.createTitledBorder("Rooms Detail");
    pnlDisplay.setBorder(pnlDisplayBorder);
    pnlDisplay.add(txtDisplay);
    public void AddClearPanel()
    pnlClear.setLayout(new GridLayout(1,1));
    pnlClear.add(btnClear);
    btnClear.addActionListener(this);
    public void actionPerformed(ActionEvent event)
    //to call RoomQuery function
    if (event.getSource() == btnRoomQuery){
    AddRoomQuery(); }
    else
    //to call DeleteBookRoom function
    if (event.getSource() == btnDelBookRoom){
    AddDeleteBookRoom(); }
    else
         //to call DeleteRoom function
    if (event.getSource() == btnDelRoom){
              AddDeleteRoom(); }     
         else
         //to call AddNewRoom function
         if (event.getSource() == btnAddNewRoom){
                   AddNewRoom(); }
              else
              //to call ClearTextArea function
                   if (event.getSource() == btnClear){
                   AddClearTextArea(); }
              else
                   //to call BookRoom function
                   if (event.getSource() == btnBookRoom){
                        AddBookRoom(); }
    public void AddRoomQuery()
    R= (int) cRooms.getSelectedIndex();
    D = (int) cDays.getSelectedIndex();
    JOptionPane.showMessageDialog(null, R + " " + D);
    txtDisplay.setText(" *************** Room Status For "+ Days[D] + " *************** " + "\n");
    txtDisplay.append("Rooms" + "\t\t " + " Status");
    for (int t=0; t< (int) cRooms.getItemCount(); t++)
    {  JOptionPane.showMessageDialog(null," is" + cRooms.getItemCount());
    if (book[t][D]==0)
    txtDisplay.append("\n" + ">>" + room[t].rName);
    txtDisplay.append("\t\t " + " Room is Available");
    else
         if (book[t][D]==1)
    txtDisplay.append("\n" + ">>" + room[t].rName);
         txtDisplay.append("\t\t " + " Room Booked");
    JOptionPane.showMessageDialog(null, "end " );
    public void AddDeleteBookRoom()
    R = (int) cRooms.getSelectedIndex();
    D = (int) cDays.getSelectedIndex();
    if(book[R][D] == 1)
    txtDisplay.setText("*****Rooms Detail*****" + "\n" + "Room is Available" + "\n");
    book[R][D] = 0;
    else
    txtDisplay.setText("*****Rooms Detail*****" + "\n" + "Room Available"+ "\n");
         book[R][D] = 0;
    public void AddDeleteRoom()
    R = (int) cRooms.getSelectedIndex();
    D = (int) cDays.getSelectedIndex();
    JOptionPane.showMessageDialog(null,"Room selected index " + R);
    int intCount =(int) cRooms.getSelectedIndex();
    if (intCount != -1)
    if(book[R][D] == 0 )
    JOptionPane.showMessageDialog(null,"Room "+room[intCount].rName + " had Deleted");
    cRooms.removeItemAt(intCount);
    int i;
    for( i=intCount;i< cRooms.getItemCount();i++)
    JOptionPane.showMessageDialog(null,"Room "+room[i+1].rName + "to");      
    room[i]=new Rooms(room[i+1]);
    JOptionPane.showMessageDialog(null,"Room "+ room[i].rName );
    //cRooms.getSelectedIndex());
    // intCount--;
    else
    if(book[R][D] == 1 )
    JOptionPane.showMessageDialog(null,"Room "+room[intCount].rName+" Can Not be Delete");
    else
    JOptionPane.showMessageDialog(null,"Select A Room To be Delete ");
    public void AddNewRoom()
    JOptionPane.showMessageDialog(null,"Add new room");
    public void AddClearTextArea()
    txtDisplay.setText("*****Rooms Detail*****" + "\n");
    public void AddBookRoom()
    R= (int) cRooms.getSelectedIndex();
    D = (int) cDays.getSelectedIndex();
    if(book[R][D] == 0)
    txtDisplay.setText("*****Rooms Detail*****" + "\n" + "Room is Booked" + "\n");
    book[R][D] = 1;
    else
    txtDisplay.setText("*****Rooms Detail*****" + "\n" + "Room Not Available"+ "\n");
         book[R][D] = 1;
    public void itemStateChanged(ItemEvent itv)
    if( itv.getSource() == cRooms )
    R = (int) cRooms.getSelectedIndex();
    lblRoomName.setText(room[R].rName);
    lblCapacity.setText(room[R].rCapacity);
    lblInternet.setText(room[R].rInternet);
    lblVideo.setText(room[R].rVideo);
    // lblStatus.setText(room[R].rStatus);
    <<save as Rooms.java>>
    public class Rooms
    String rName;
    String rCapacity;
    String rInternet;
    String rVideo;
    // String rStatus;
    Rooms(String a, String b, String c, String d)//, String e)
    rName = a;
    rCapacity = b;
    rInternet = c;
    rVideo = d;
    // rStatus = e;
    Rooms(Rooms r)
    rName = r.rName;
    rCapacity = r.rCapacity;
    rInternet = r.rInternet;
    rVideo = r.rVideo;
    // rStatus = r.e;
    <<saves as CC.html>>
    <html>
    <body>
    <Applet code = CC.class
    width = 600
         height = 510>
    </Applet>
    </body>
    </html>

    The important thing is to put the related functionality in the class Room and not everywhere in the class CC.
    The types of the data member in the class Room are also very important to reflect exactly what they should store.
    Here I post a new version of your files as example of how we can improve your version. It does not implement all the functionality you will need but it is a first step.
    Serge
    import java.awt.*;
    import java.awt.event.*;
    import javax.swing.event.*;
    import javax.swing.JApplet;
    import javax.swing.*;
    import javax.swing.border.*;
    import javax.swing.JOptionPane;
    import java.util.LinkedList;
    public class CC extends JApplet implements ActionListener, ItemListener {
        JPanel pnlPane = new JPanel();
        JPanel pnlChoise = new JPanel();
        JPanel pnlButton2 = new JPanel();
        JPanel pnlRoomDisplay = new JPanel();
        JPanel pnlRoom = new JPanel();
        JPanel pnlDisplay = new JPanel();
        JPanel pnlClear = new JPanel();
        JButton btnDisplay = new JButton("Display");
        JButton btnBookRoom = new JButton("Book Room");
        JButton btnDelBookRoom = new JButton("Delete Booking");
        JButton btnDelRoom = new JButton("Delete Room");
        JButton btnAddNewRoom = new JButton("Add New Room");
        JButton btnClear = new JButton("Clear");
        JButton btnRoomQuery = new JButton("Room Query");
        LinkedList roomList = new LinkedList();
        String[] Days = {"Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "Sunday"};
        public int R, D;
        JLabel lblRoomName = new JLabel();
        JLabel lblCapacity = new JLabel();
        JLabel lblInternet = new JLabel();
        JLabel lblVideo = new JLabel();
        JLabel lblStatus = new JLabel();
        JComboBox cDays = new JComboBox(Days);
        JComboBox cRooms = new JComboBox();
        JTextField txtRoomName1 = new JTextField();
        JTextField txtCapacity1 = new JTextField();
        JCheckBox chkInternet = new JCheckBox("Internet Connection");
        JCheckBox chkVideo = new JCheckBox("Video Conferencing");
        JTextArea txtDisplay = new JTextArea("*****Rooms Detail*****" + "\n", 12, 30);
        public void init() {
            pnlPane.add(pnlChoise);
            pnlPane.add(pnlButton2);
            pnlPane.add(pnlRoomDisplay);
            pnlPane.add(pnlRoom);
            pnlPane.add(pnlDisplay);
            pnlPane.add(pnlClear);
            pnlPane.setBorder(new TitledBorder(new BevelBorder(BevelBorder.RAISED), "Room Booking System"));
            setContentPane(pnlPane);
            AddChoisePanel();
            AddButton2Panel();
            AddRoomDisplayPanel();
            AddRoomPanel();
            AddDisplayAreaPanel();
            AddClearPanel();
        public void AddChoisePanel() {
            pnlChoise.setLayout(new GridLayout(1, 3, 5, 5));
            Room[]room = new Room[8];
            room[0] = new Room("Barrington", "15", false, true);
            room[1] = new Room("Carlton", "25", true, false);
            room[2] = new Room("Debyshire", "35", false, false);
            room[3] = new Room("Edwards", "30", true, true);
            room[4] = new Room("Farley", "70", true, false);
            room[5] = new Room("Goodwin", "80", true, true);
            room[6] = new Room("Harlow", "90", false, true);
            room[7] = new Room("IlFord", "85", false, false);
            for (int i = 0; i < 8; i++) {
                cRooms.addItem(room.getName());
    roomList.add(room[i]);
    pnlChoise.add(cRooms);
    pnlChoise.add(cDays);
    pnlChoise.add(btnRoomQuery);
    btnRoomQuery.addActionListener(this);
    cRooms.addItemListener(this);
    public void AddButton2Panel() {
    pnlButton2.setLayout(new GridLayout(1, 2, 5, 5));
    pnlButton2.add(btnBookRoom);
    pnlButton2.add(btnDelBookRoom);
    btnDelBookRoom.addActionListener(this);
    btnBookRoom.addActionListener(this);
    public void AddRoomDisplayPanel() {
    pnlRoomDisplay.setLayout(new GridLayout(6, 2, 5, 2));
    pnlRoomDisplay.add(new JLabel("Room Name"));
    pnlRoomDisplay.add(lblRoomName);
    pnlRoomDisplay.add(new JLabel("Room Capacity"));
    pnlRoomDisplay.add(lblCapacity);
    pnlRoomDisplay.add(new JLabel("Internet Connection"));
    pnlRoomDisplay.add(lblInternet);
    pnlRoomDisplay.add(new JLabel("Video Conferencing"));
    pnlRoomDisplay.add(lblVideo);
    pnlRoomDisplay.add(new JLabel("Room Status"));
    pnlRoomDisplay.add(lblStatus);
    pnlRoomDisplay.setBorder(new TitledBorder(new BevelBorder(BevelBorder.LOWERED), "Rooms Detail"));
    pnlRoomDisplay.add(btnDelRoom);
    btnDelRoom.addActionListener(this);
    public void AddRoomPanel() {
    pnlRoom.setLayout(new GridLayout(6, 2, 2, 2));
    pnlRoom.setBorder(new TitledBorder(new BevelBorder(BevelBorder.LOWERED), "Add New Rooms"));
    pnlRoom.add(new Label("Room Name"));
    pnlRoom.add(txtRoomName1);
    pnlRoom.add(new Label("Capacity"));
    pnlRoom.add(txtCapacity1);
    pnlRoom.add(chkInternet);
    pnlRoom.add(new Label(""));
    pnlRoom.add(chkVideo);
    pnlRoom.add(new Label(""));
    pnlRoom.add(new Label(""));
    pnlRoom.add(new Label(""));
    pnlRoom.add(btnAddNewRoom);
    btnAddNewRoom.addActionListener(this);
    public void AddDisplayAreaPanel() {
    pnlDisplay.setLayout(new GridLayout(1, 1));
    //pnlDisplay.setBorder(new TitledBorder(new BevelBorder(BevelBorder.LOWERED),"Rooms Detail"));
    Border pnlDisplayBorder = BorderFactory.createTitledBorder("Rooms Detail");
    pnlDisplay.setBorder(pnlDisplayBorder);
    pnlDisplay.add(txtDisplay);
    public void AddClearPanel() {
    pnlClear.setLayout(new GridLayout(1, 1));
    pnlClear.add(btnClear);
    btnClear.addActionListener(this);
    public void actionPerformed(ActionEvent event) {
    //to call RoomQuery function
    if (event.getSource() == btnRoomQuery) {
    AddRoomQuery();
    } else {
    //to call DeleteBookRoom function
    if (event.getSource() == btnDelBookRoom) {
    AddDeleteBookRoom();
    } else {
    //to call DeleteRoom function
    if (event.getSource() == btnDelRoom) {
    AddDeleteRoom();
    } else {
    //to call AddNewRoom function
    if (event.getSource() == btnAddNewRoom) {
    AddNewRoom();
    } else {
    //to call ClearTextArea function
    if (event.getSource() == btnClear) {
    AddClearTextArea();
    } else {
    //to call BookRoom function
    if (event.getSource() == btnBookRoom) {
    AddBookRoom();
    public void AddRoomQuery() {
    R = (int) cRooms.getSelectedIndex();
    D = (int) cDays.getSelectedIndex();
    // JOptionPane.showMessageDialog(null, R + " " + D);
    txtDisplay.setText(" *************** Room Status For " + Days[D] + " *************** " + "\n");
    txtDisplay.append("Rooms" + "\t\t " + " Status");
    Room aRoom = (Room)roomList.get(R);
    for (int t = 0; t < (int) cRooms.getItemCount(); t++) {
    // JOptionPane.showMessageDialog(null, " is" + cRooms.getItemCount());
    aRoom = (Room)roomList.get(t);
    txtDisplay.append("\n" + ">>" + aRoom.getName());
    if (aRoom.isBooked(D)) {
    txtDisplay.append("\t\t " + " Room Booked");
    } else {
    txtDisplay.append("\t\t " + " Room is Available");
    // JOptionPane.showMessageDialog(null, "end ");
    public void AddDeleteBookRoom() {
    R = (int) cRooms.getSelectedIndex();
    D = (int) cDays.getSelectedIndex();
    Room aRoom = (Room)roomList.get(R);
    aRoom.checkOut(D);
    txtDisplay.setText("*****Rooms Detail*****" + "\n" + "Room is Available" + "\n");
    public void AddDeleteRoom() {
    R = (int) cRooms.getSelectedIndex();
    D = (int) cDays.getSelectedIndex();
    // JOptionPane.showMessageDialog(null, "Room selected index " + R);
    int intCount = (int) cRooms.getSelectedIndex();
    Room aRoom = (Room)roomList.get(R);
    if (intCount != -1) {
    if (aRoom.isBooked() == false) {
    JOptionPane.showMessageDialog(null, "Room " + ((Room)roomList.get(intCount)).getName() + " had Deleted");
    cRooms.removeItemAt(intCount);
    roomList.remove(intCount);
    } else {
    JOptionPane.showMessageDialog(null, "Room " + ((Room)roomList.get(intCount)).getName() + " Can Not be Delete");
    } else {
    JOptionPane.showMessageDialog(null, "Select A Room To be Delete ");
    public void AddNewRoom() {
    String rName = txtRoomName1.getText();
    String rCapacity = txtCapacity1.getText();
    boolean rInternet = chkInternet.isSelected();
    boolean rVideo = chkVideo.isSelected();
    Room nRoom = new Room(rName,rCapacity,rInternet,rVideo);
    cRooms.addItem(rName);
    int i = cRooms.getItemCount();
    roomList.add(nRoom);
    public void AddClearTextArea() {
    txtDisplay.setText("*****Rooms Detail*****" + "\n");
    public void AddBookRoom() {
    R = (int) cRooms.getSelectedIndex();
    D = (int) cDays.getSelectedIndex();
    Room aRoom = (Room)roomList.get(R);
    if (aRoom.reserve(D) == 0) {
    txtDisplay.setText("*****Rooms Detail*****" + "\n" + "Room is Booked" + "\n");
    } else {
    txtDisplay.setText("*****Rooms Detail*****" + "\n" + "Room Not Available" + "\n");
    public void itemStateChanged(ItemEvent itv) {
    if (itv.getSource() == cRooms) {
    R = (int) cRooms.getSelectedIndex();
    Room aRoom = (Room)roomList.get(R);
    lblRoomName.setText(aRoom.getName());
    lblCapacity.setText(String.valueOf(aRoom.getCapacity()));
    lblInternet.setText(aRoom.getInternet());
    lblVideo.setText(aRoom.getVideo());
    // lblStatus.setText(aRoom.rStatus);
    public class Room {
    public final String YES = "Yes";
    public final String NO = "No";
    private String rName = null;
    private int rCapacity = 0;
    private boolean rInternet = false;
    private boolean rVideo = false;
    private boolean [] booked = { false, false, false, false, false, false, false };
    Room(String name, String capacity, boolean hasInternet, boolean hasVideo)
    rName = new String(name);
    rCapacity = Integer.parseInt(capacity);
    rInternet = hasInternet;
    rVideo = hasVideo;
    public int reserve(int day) {
    if (booked[day] == true)
    return -1;
    booked[day] = true;
    return 0;
    public void checkOut(int day) {
    booked[day] = false;
    public boolean isBooked() {
    for (int i = 0; i < booked.length; i++)
    if (booked[i] == true)
    return true;
    return false;
    public boolean isBooked(int day) {
    return booked[day];
    public String getName() {
    return rName;
    public int getCapacity() {
    return rCapacity;
    public String getInternet() {
    if (rInternet == false)
    return NO;
    return YES;
    public String getVideo() {
    if (rVideo == false)
    return NO;
    return YES;
    public boolean matchCriterias(boolean hasInternet, boolean hasVideo) {
    if ((hasInternet == rInternet) && (hasVideo == rVideo))
    return true;
    return false;

  • Phantom Context lookup or Is "java:" some kind of keyword ? ? ?

    I'm attempting to implement my own Context for capturing performance information out of a third party applications. I've run into a strange problem where the method call doesn't aways work even though the signature appears to be correct, with the only diffence being is the contents of the String that is passed in as a parameter. If the string starts with "java:" the method is not called. In the example below only "lookup [my-ruleHome]" is printed, I'd have expected "lookup [java:comp/UserTransaction]" to be printed as well.
    package com.blah;
    import javax.naming.*;
    import java.util.Hashtable;
    public class MyContext implements Context {
        Context realProviderCtx = null; 
        public MyContext (Hashtable env) throws NamingException {
          env.put(Context.INITIAL_CONTEXT_FACTORY, "weblogic.jndi.WLInitialContextFactory");
          realProviderCtx = new InitialContext(env);
        public Object lookup(String name) throws NamingException {
           System.out.println("lookup [" + name + "]");
           return realProviderCtx.lookup(name);
    package com.blah;
    import java.io.*;
    // Packages for Servlets
    import javax.servlet.*;
    import javax.servlet.http.*;
    import java.util.Collection;
    import java.util.Iterator;
    import java.util.Properties;
    import java.util.Vector;
    import javax.naming.Context;
    import javax.naming.InitialContext;
    import javax.ejb.FinderException;
    import javax.naming.NamingException;
    import java.rmi.RemoteException;
    import javax.rmi.PortableRemoteObject;
    import javax.transaction.UserTransaction;
    import javax.ejb.CreateException;
    import javax.ejb.RemoveException;
    public class SomeServlet extends HttpServlet {
      public void init(ServletConfig config) throws ServletException {
        super.init(config);
      * Method to process HTTP GET requests.
      public void doGet(HttpServletRequest p_req, HttpServletResponse p_res)
                                            throws ServletException, IOException {
         Collection rules = getRules();
         //  Do something here to display a webpage
      public Collection getRules() {
        Collection rules = null;
        Properties env = new Properties();
        env.put(Context.INITIAL_CONTEXT_FACTORY, "blah.MyInitialContextFactory");
        env.put(Context.PROVIDER_URL, "t3://app-dev-01.blah.com:7003");                                                                           
        try
          Context cntx = new InitialContext(env);
          UserTransaction ut = (UserTransaction) cntx.lookup( "java:comp/UserTransaction" );
          ut.begin();
          RuleHome ruleHome = (RuleHome) cntx.lookup("my-ruleHome");
          rules = ruleHome.findAll();
          ut.commit();
        catch (NamingException ne)
           System.out.println("NamingException " + ne.toString());
           ne.printStackTrace();
        catch (FinderException fe)
           System.out.println("FinderException " + fe.toString());
        catch (java.rmi.RemoteException re) {
           System.out.println("RemoteException " + re.toString());
        } catch (javax.transaction.NotSupportedException nse) {
           System.out.println("NotSupportedException " + nse.toString());
        } catch (javax.transaction.RollbackException re) {
           System.out.println("RollbackException " + re.toString());
        } catch (javax.transaction.SystemException se) {
           System.out.println("SystemException " + se.toString());
        } catch (javax.transaction.HeuristicMixedException hme) {
           System.out.println("HeuristicMixedException " + hme.toString());
        } catch (javax.transaction.HeuristicRollbackException hre) {
           System.out.println("HeuristicRollbackException " + hre.toString());
        return rules;
    }

    I think I figured out my own issue. InitialContext is actually wrappering my context. Based on the documentation in http://java.sun.com/j2se/1.4.1/docs/api/javax/naming/InitialContext.html anything before the ":" is the scheme InitialContext's lookup method will use a different context provider based on the scheme and that's why my method was not being executed. Apparently the context provider for the scheme "java" was receiving the method call.

  • Resource manager experts, kindly advise!

    Hi All,
    Currently our database server (with 8 CPUS) is having 2 database 'A' and 'B'. Database 'A' has no problem as it's a small instance with not much users. However, for database 'B', the online users encounter slowness frequently as some reports are generating at that time as well. As such, we would like to limit reporting schema to 20% of the CPU, online users 60% and the remaining 20% to the rest of the schemas.
    However for our case, since there are 2 databases in the server, using resource manager ALONE for database 'B' won't helps right? As 2 databases are sharing the 8 CPU, we are unsure how will resource manager work in this case in percentage allocation since only the problem database will be using resource manager adding up 100% of CPU Allocation.
    Anything needed to be configured in OS level? Kindly advise as i do not have much system admin exposure.
    OS: AIX 5.3
    DB 10.2.0.3
    thanks

    This is probably a conversation you want to have with your AIX admins. Any high end Unix is going to have some ability to partition the system to prevent one user's processes from overwhelming the system. But these tools may require additional licensing, may require substantial configuration, may require changes to your Oracle setup (i.e. the two databases may need to be in different homes owned by different users), etc. The AIX folks would be the ones to have this conversation with.
    A 30-second Google search turns up [this discussion of partition load manager in AIX|http://publib.boulder.ibm.com/infocenter/systems/index.jsp?topic=/iphat/iphbkconfigureplm.htm] that seems like it may be what you want.
    Justin

  • Pls help.. Java Expert

    1)how do i increase the value of month??
    example : 21-3-03 translate to 21-3-03
    2)how do i update this value to my database by sql statement??
    yup.. thanks in advance!!!

    >
    I almost felt like lifting a finger to help, just for
    a moment, and then I saw that you haven't thanked or
    rewarded anyone who replied to your last 5 questions.
    Hit and run questioning, so to speak.Good point: http://forum.java.sun.com/thread.jsp?thread=372885&forum=31&message=1582967

  • Java expert help me. A NullPointerException !!! I can't solve it.

    I have complied 3 files (SerialBean.java;SerialBuffer.java;ReaderSerial.java) as my package successfully, it is named serial. The package extends javax.comm.*; I wanna do some serial work.
    Then I maked an application :SerialExample1
    --------------------------------------code----------------------------------
    ----------------------------SerialExmaple1.java-----------------------------
    import serial.*;
    import java.io.*;
    import javax.comm.*;
    public class SerialExample1
    public static void main(String args[])
    SerialBean sB=new SerialBean(1);
    sB.Initialize();
    sB.WritePort("Hi,Chrono");
    sB.ClosePort();
    It is good enough to deliver the String "Hi,Chrono".
    Then I maked another windows application :SerialExample2
    ------------------------------------code-------------------------------------
    -----------------------------Frame1.java-------------------------------------
    import java.awt.*;
    import java.awt.event.*;
    import javax.swing.*;
    import com.borland.jbcl.layout.*;
    import serial.*;
    import java.io.*;
    import javax.comm.*;
    public class Frame1 extends JFrame
    private JPanel contentPane;
    private XYLayout xYLayout1 = new XYLayout();
    private Button button1 = new Button();
    private TextField textField1 = new TextField();
    private SerialBean sB=new SerialBean(1);
    //Construct the frame
    public Frame1()
    enableEvents(AWTEvent.WINDOW_EVENT_MASK);
    try
    jbInit();
    catch(Exception e)
    e.printStackTrace();
    //Component initialization
    private void jbInit() throws Exception
    //setIconImage(Toolkit.getDefaultToolkit().createImage(Frame1.class.getResource("[Your Icon]")));
    contentPane = (JPanel) this.getContentPane();
    button1.setLabel("button1");
    button1.addActionListener(new Frame1_button1_actionAdapter(this));
    contentPane.setLayout(xYLayout1);
    this.setSize(new Dimension(400, 300));
    this.setTitle("Frame Title");
    textField1.setText("textField1");
    contentPane.add(button1, new XYConstraints(54, 52, -1, -1));
    contentPane.add(textField1, new XYConstraints(195, 57, -1, -1));
    //Overridden so we can exit when window is closed
    protected void processWindowEvent(WindowEvent e)
    super.processWindowEvent(e);
    if (e.getID() == WindowEvent.WINDOW_CLOSING)
    System.exit(0);
    void button1_actionPerformed(ActionEvent e)
    sB.Initialize();
    sB.WritePort("Hi Chrono");
    sB.ClosePort();
    class Frame1_button1_actionAdapter implements java.awt.event.ActionListener
    private Frame1 adaptee;
    Frame1_button1_actionAdapter(Frame1 adaptee)
    this.adaptee = adaptee;
    public void actionPerformed(ActionEvent e)
    adaptee.button1_actionPerformed(e);
    ---------------------------SerialExample2.java--------------------------------
    import javax.swing.UIManager;
    import java.awt.*;
    public class SerialExample2
    private boolean packFrame = false;
    //Construct the application
    public SerialExample2()
    Frame1 frame = new Frame1();
    //Validate frames that have preset sizes
    //Pack frames that have useful preferred size info, e.g. from their layout
    if (packFrame)
    frame.pack();
    else
    frame.validate();
    //Center the window
    Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
    Dimension frameSize = frame.getSize();
    if (frameSize.height > screenSize.height)
    frameSize.height = screenSize.height;
    if (frameSize.width > screenSize.width)
    frameSize.width = screenSize.width;
    frame.setLocation((screenSize.width - frameSize.width) / 2, (screenSize.height - frameSize.height) / 2);
    frame.setVisible(true);
    //Main method
    public static void main(String[] args)
    try
    UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
    catch(Exception e)
    e.printStackTrace();
    new SerialExample2();
    It is a bad code!!! I compiled them seccessfully but It can't work .The java system gave
    some wrong messages
    Exception occurred during event dispatching:java.lang.NullPointerException     at serial.SerialBean.WritePort(SerialBean.java:115)     at Frame1.button1_actionPerformed(Frame1.java:66)     at Frame1_button1_actionAdapter.actionPerformed(Frame1.java:82)     at java.awt.Button.processActionEvent(Button.java:329)     at java.awt.Button.processEvent(Button.java:302)     at java.awt.Component.dispatchEventImpl(Component.java:2593)     at java.awt.Component.dispatchEvent(Component.java:2497)     at java.awt.EventQueue.dispatchEvent(EventQueue.java:339)     at java.awt.EventDispatchThread.pumpOneEventForHierarchy(EventDispatchThread.java:131)     at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:98)     at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:93)     at java.awt.EventDispatchThread.run(EventDispatchThread.java:85)-----------------------------------------------------------------------------------
    I tried to debug it in Frame1.java:66 and SerialBean.java:115 but I can not find any error.
    How to deal with it?
    Here are the code about package serial
    -----------------------------------code--------------------------------------------
    ----------------------------SerialBean.java----------------------------------------
    package serial;
    import java.io.*;
    import java.util.*;
    import javax.comm.*;
    * This bean provides some basic functions to implement full dulplex
    * information exchange through the srial port.
    public class SerialBean
    static String PortName;
    CommPortIdentifier portId;
    SerialPort serialPort;
    static OutputStream out;
    static InputStream in;
    SerialBuffer SB;
    ReadSerial RT;
    * Constructor
    * @param PortID the ID of the serial to be used. 1 for COM1,
    * 2 for COM2, etc.
    public SerialBean(int PortID)
    PortName = "COM" + PortID;
    * This function initialize the serial port for communication. It startss a
    * thread which consistently monitors the serial port. Any signal capturred
    * from the serial port is stored into a buffer area.
    public int Initialize()
    int InitSuccess = 1;
    int InitFail = -1;
    try
    portId = CommPortIdentifier.getPortIdentifier(PortName);
    try
    serialPort = (SerialPort)
    portId.open("Serial_Communication", 2000);
    } catch (PortInUseException e)
    return InitFail;
    //Use InputStream in to read from the serial port, and OutputStream
    //out to write to the serial port.
    try
    in = serialPort.getInputStream();
    out = serialPort.getOutputStream();
    } catch (IOException e)
    return InitFail;
    //Initialize the communication parameters to 9600, 8, 1, none.
    try
    serialPort.setSerialPortParams(9600,
    SerialPort.DATABITS_8,
    SerialPort.STOPBITS_1,
    SerialPort.PARITY_NONE);
    } catch (UnsupportedCommOperationException e)
    return InitFail;
    } catch (NoSuchPortException e)
    return InitFail;
    // when successfully open the serial port, create a new serial buffer,
    // then create a thread that consistently accepts incoming signals from
    // the serial port. Incoming signals are stored in the serial buffer.
    SB = new SerialBuffer();
    RT = new ReadSerial(SB, in);
    RT.start();
    // return success information
    return InitSuccess;
    * This function returns a string with a certain length from the incomin
    * messages.
    * @param Length The length of the string to be returned.
    public String ReadPort(int Length)
    String Msg;
    Msg = SB.GetMsg(Length);
    return Msg;
    * This function sends a message through the serial port.
    * @param Msg The string to be sent.
    public void WritePort(String Msg)
    int c;
    try
    for (int i = 0; i < Msg.length(); i++)
    out.write(Msg.charAt(i));
    } catch (IOException e) {}
    * This function closes the serial port in use.
    public void ClosePort()
    RT.stop();
    serialPort.close();
    ----------------------------ReadSerial.java--------------------------------------
    package serial;
    import java.io.*;
    * This class reads message from the specific serial port and save
    * the message to the serial buffer.
    public class ReadSerial extends Thread
    private SerialBuffer ComBuffer;
    private InputStream ComPort;
    * Constructor
    * @param SB The buffer to save the incoming messages.
    * @param Port The InputStream from the specific serial port.
    public ReadSerial(SerialBuffer SB, InputStream Port)
    ComBuffer = SB;
    ComPort = Port;
    public void run()
    int c;
    try
    while (true)
    c = ComPort.read();
    ComBuffer.PutChar(c);
    } catch (IOException e) {}
    ------------------------------SerialBuffer.java-------------------------------------
    package serial;
    public class SerialBuffer
    private String Content = "";
    private String CurrentMsg, TempContent;
    private boolean available = false;
    private int LengthNeeded = 1;
    * This function returns a string with a certain length from the incomin
    * messages.
    * @param Length The length of the string to be returned.
    public synchronized String GetMsg(int Length)
    LengthNeeded = Length;
    notifyAll();
    if (LengthNeeded > Content.length())
    available = false;
    while (available == false)
    try
    wait();
    } catch (InterruptedException e) { }
    CurrentMsg = Content.substring(0, LengthNeeded);
    TempContent = Content.substring(LengthNeeded);
    Content = TempContent;
    LengthNeeded = 1;
    notifyAll();
    return CurrentMsg;
    * This function stores a character captured from the serial port to the
    * buffer area.
    * @param t The char value of the character to be stored.
    public synchronized void PutChar(int c)
    Character d = new Character((char) c);
    Content = Content.concat(d.toString());
    if (LengthNeeded < Content.length())
    available = true;
    notifyAll();
    Help me !!!

    First thing to say is that you really should check if the initialisation was successful in
    button1_actionPerformed()You should be checking the return value on the SerialBean Initialize() method. If the initialisation has failed, then the null pointer exception will be thrown because there will be no stream to write to.
    I would also recommend rewriting the catches in the SerialBean Initialize() method to dump the stack trace from the caught exception and any additional information that the exception holds for example:
    } catch (PortInUseException e) {
        e.printStackTrace();
        return InitFail;
    }This will give you a lot more information to work with if it is an initialisation problem.

  • Please Help with JtextArea!! Need advice from Java expert!

    Hi, I need something VERY simple, and it is unbelievable I'm looking for a solution for so long! I really hope some of you java-gurus can help me out. Here's the thing:
    1. Make a Jframe
    2. Add a JTextArea and use a transparent color (e.g. 0.1f,0.1f,0.1f,0.1f)
    3. loop a setText method to display a constantly varying text, e.g. the time in milliseconds
    I simply can't do it in any way if I use transparency. Without transparency it works with no problems.
    I am on Mac, and I have checked out this site:
    http://www.curious-creature.org/2007/04/10/translucent-swing-windows-on-mac-os-x/
    but I can't figure out how the guy who wrote the code made it work on mac (he didn't add the full code and the imports). I already tried to contact him, but no answer...
    so PLEEEEASE take 5 minutes to write a very small example of how to manage a varying text on a transparent window.
    Thanks a lot in advance
    Lele

    -> did you maybe check out the link I posted?
    Yes, I did which is why I asked the question are you trying to create a transparent JFrame so that the desktop image is displayed in the frame? To my knowledge this feature (if it works) is a Mac only feature and does not work on windows. If this is what you are trying to do then I have no idea how to do it and will not respond any more.
    -> the GPS coordinates are displayed on top of the moving map, with no visible background
    I guess I have trouble understanding what this is - "a map with no background"?
    Is the map just not an image (ie. a JLabel with an ImageIcon) placed in a scrollpane? Then as the map moves you change the viewport position so it looks like the map is moving? Then you can simply add a label containing the GPS coordinates on top of the label representing the map.
    -> have you considered using a JLabel in an OverlayLayout?
    Right which is what I was thinking. Something simple like:
    import java.awt.*;
    import java.awt.event.*;
    import javax.swing.*;
    public class LabelMap extends JFrame
         public LabelMap()
              JLabel map = new JLabel(new ImageIcon("yourMap.jpg"));
              getContentPane().add(new JScrollPane(map));
              JLabel point = new JLabel();
              point.setLocation(50, 50);
              point.setText(point.getLocation().toString());
              Dimension d = point.getPreferredSize();
              point.setSize(d.width, d.height);
              point.setFocusable(true);
              map.add(point);
              KeyListener kl = new KeyAdapter()
                   public void keyPressed(KeyEvent e)
                        JLabel point = (JLabel)e.getSource();
                        Point p = point.getLocation();
                        if (e.getKeyCode() == KeyEvent.VK_UP)
                             p.y -= 5;
                        else if (e.getKeyCode() == KeyEvent.VK_DOWN)
                             p.y += 5;
                        else if (e.getKeyCode() == KeyEvent.VK_LEFT)
                             p.x -= 5;
                        else if (e.getKeyCode() == KeyEvent.VK_RIGHT)
                             p.x += 5;
                        point.setLocation(p);
                        point.setText(p.getLocation().toString());
                        Dimension d = point.getPreferredSize();
                        point.setSize(d.width, d.height);
              point.addKeyListener(kl);
         public static void main(String[] args)
              LabelMap frame = new LabelMap();
              frame.setDefaultCloseOperation( EXIT_ON_CLOSE );
              frame.setSize(300, 300);
              frame.setLocationRelativeTo( null );
              frame.setVisible(true);
    }In the above example you can scroll the image and dynamically move the text using the arrow keys.

  • Any Java experts,please help this Newbie.

    Hey,any one of you knows how do you call a program from a button?
    For example,I created a chat program and peer to peer share Program,and I want to join them together.
    By clicking on a button on the peer to peer share program,the chat program would open in a new window.
    Please Help Me!
    Thanks alot.

    Hi here is the complete example for you how you can call the other java classes in your main java class. Hope it will give you the idea. If still you have problems do write to me at [email protected]
    * SixFrame.java
    * Created on July 15, 2003, 10:26 AM
    * @author sandeep
    import javax.swing.*;
    import java.awt.event.*;
    import java.awt.*;
    public class SixFrame extends JFrame implements ActionListener{
    JButton btn[] = new JButton[6]; // this no will vary as per you requirements
    /** Creates a new instance of SixFrame */
    public SixFrame() {
    JPanel pan = new JPanel();
    for(int i=0;i<btn.length;i++){
    btn[i] = new JButton((i+1)+"");
    btn.addActionListener(this);
    pan.add(btn[i]);
    getContentPane().add(pan,BorderLayout.CENTER);
    setSize(300,300);
    setVisible(true);
    /** Invoked when an action occurs.
    public void actionPerformed(ActionEvent e) {
    String comm = e.getActionCommand();
    if(comm.equals("1")){
    new FrameOne("One");
    }else if(comm.equals("2")){
    new FrameTwo("Two");
    }else if(comm.equals("3")){
    new FrameThree("Three");
    }else if(comm.equals("4")){
    new FrameFour("Four");
    }else if(comm.equals("5")){
    new FrameFive("Five");
    }else if(comm.equals("6")){
    new FrameSix("Six");
    public static void main(String args[]){
    new SixFrame();
    class FrameOne extends JFrame{
    FrameOne(String str){
    super(str);
    setSize(200,200);
    setVisible(true);
    class FrameTwo extends JFrame{
    FrameTwo(String str){
    super(str);
    setSize(200,200);
    setVisible(true);
    class FrameThree extends JFrame{
    FrameThree(String str){
    super(str);
    setSize(200,200);
    setVisible(true);
    class FrameFour extends JFrame{
    FrameFour(String str){
    super(str);
    setSize(200,200);
    setVisible(true);
    class FrameFive extends JFrame{
    FrameFive(String str){
    super(str);
    setSize(200,200);
    setVisible(true);
    class FrameSix extends JFrame{
    FrameSix(String str){
    super(str);
    setSize(200,200);
    setVisible(true);

  • Any java experts pls help me in converting attribute to XML formats

    Pls help me oh my god i am a newbie here and i am given this project.
    I had just written a XML doc. which looks like this
    <ConsumerTransfer>
    <TransactionId>
    123:123
    </TransactionId>
    <Billingoption>
    cash
    </Billingoption>
    </ConsumerTransfer>
    I need to make this to attributes like
    private String TransactionId()
    private String BillingOption()
    and so on.....
    I need to convert this attributes to XML format
    can any show me an example or the source codes for this
    Really, I appreciate it.
    JimmyKnot

    For such node level operations I think that DOM would be a good idea. So here you go. Look for some nice tutorial for DOM and you got it.
    salut

  • StuckThreadMaxTime related errors in logs.

    Hi,
    I have already posted this in one of the threads:
    Re: Stuck Thread
    But there was no response. So creating a thread for it to garner more interest. If deemed inappropriate then request moderator to remove this post.
    We are doing this on HP machines. The same does not appear in the Linux. HP machines usually are a little slower (This is my personal observation only). So maybe it is taking more time for thread to do the work. In meantime this 600 sec limit is breached.
    This this what I see in server logs:
    <Dec 6, 2010 4:27:41 AM EST> <Notice> <WebLogicServer> <BEA-000365> <Server state changed to RUNNING>
    <Dec 6, 2010 4:27:41 AM EST> <Notice> <WebLogicServer> <BEA-000360> <Server started in RUNNING mode>
    <Dec 6, 2010 4:39:41 AM EST> <Error> <WebLogicServer> <BEA-000337> <[STUCK] ExecuteThread: '23' for queue: 'weblogic.kernel.Default (self-tuning)' has been busy for "610" seconds working on the request "weblogic.common.internal.RMIBootServiceImpl", which is more than the configured time (StuckThreadMaxTime) of "600" seconds. Stack trace:
    weblogic.security.service.internal.DataSourceManager.getConnection(DataSourceManager.java:322)
    weblogic.security.service.internal.NamedSQLConnectionLookupServiceImpl.getConnection(NamedSQLConnectionLookupServiceImpl.java:75)
    sun.reflect.GeneratedMethodAccessor86.invoke(Unknown Source)
    sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    java.lang.reflect.Method.invoke(Method.java:597)
    weblogic.security.service.internal.Delegator$MyInvocationHandler.invoke(Delegator.java:49)
    $Proxy7.getConnection(Unknown Source)
    weblogic.security.providers.authentication.DBMSDatabaseConnectionPoolImpl.getRawConnection(DBMSDatabaseConnectionPoolImpl.java:131)
    weblogic.security.providers.authentication.DBMSPluggableRuntimeDatabaseConnectionPoolImpl.checkoutConnection(DBMSPluggableRuntimeDatabaseConnectionPoolImpl.java:23)
    weblogic.security.providers.authentication.shared.DBMSAtnLoginModuleImpl.login(DBMSAtnLoginModuleImpl.java:227)
    com.bea.common.security.internal.service.LoginModuleWrapper$1.run(LoginModuleWrapper.java:110)
    java.security.AccessController.doPrivileged(Native Method)
    com.bea.common.security.internal.service.LoginModuleWrapper.login(LoginModuleWrapper.java:106)
    sun.reflect.GeneratedMethodAccessor91.invoke(Unknown Source)
    sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    java.lang.reflect.Method.invoke(Method.java:597)
    javax.security.auth.login.LoginContext.invoke(LoginContext.java:769)
    javax.security.auth.login.LoginContext.access$000(LoginContext.java:186)
    javax.security.auth.login.LoginContext$4.run(LoginContext.java:683)
    java.security.AccessController.doPrivileged(Native Method)
    javax.security.auth.login.LoginContext.invokePriv(LoginContext.java:680)
    javax.security.auth.login.LoginContext.login(LoginContext.java:579)
    com.bea.common.security.internal.service.JAASLoginServiceImpl.login(JAASLoginServiceImpl.java:113)
    sun.reflect.GeneratedMethodAccessor89.invoke(Unknown Source)
    sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    java.lang.reflect.Method.invoke(Method.java:597)
    com.bea.common.security.internal.utils.Delegator$ProxyInvocationHandler.invoke(Delegator.java:57)
    $Proxy15.login(Unknown Source)
    weblogic.security.service.internal.WLSJAASLoginServiceImpl$ServiceImpl.login(WLSJAASLoginServiceImpl.java:89)
    com.bea.common.security.internal.service.JAASAuthenticationServiceImpl.authenticate(JAASAuthenticationServiceImpl.java:82)
    sun.reflect.GeneratedMethodAccessor87.invoke(Unknown Source)
    sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    java.lang.reflect.Method.invoke(Method.java:597)
    com.bea.common.security.internal.utils.Delegator$ProxyInvocationHandler.invoke(Delegator.java:57)
    $Proxy33.authenticate(Unknown Source)
    weblogic.security.service.WLSJAASAuthenticationServiceWrapper.authenticate(WLSJAASAuthenticationServiceWrapper.java:40)
    weblogic.security.service.PrincipalAuthenticator.authenticate(PrincipalAuthenticator.java:348)
    weblogic.common.internal.RMIBootServiceImpl.authenticate(RMIBootServiceImpl.java:109)
    weblogic.common.internal.RMIBootServiceImpl_WLSkel.invoke(Unknown Source)
    weblogic.rmi.internal.BasicServerRef.invoke(BasicServerRef.java:667)
    weblogic.rmi.internal.BasicServerRef$1.run(BasicServerRef.java:522)
    weblogic.security.acl.internal.AuthenticatedSubject.doAs(AuthenticatedSubject.java:363)
    weblogic.security.service.SecurityManager.runAs(SecurityManager.java:146)
    weblogic.rmi.internal.BasicServerRef.handleRequest(BasicServerRef.java:518)
    weblogic.rmi.internal.wls.WLSExecuteRequest.run(WLSExecuteRequest.java:118)
    weblogic.work.ExecuteThread.execute(ExecuteThread.java:207)
    weblogic.work.ExecuteThread.run(ExecuteThread.java:176)
    There is really no way of logging on to the console to try to change "StuckThreadMaxTime" parameter. The servers are started and shutdown automatically with help of a script.
    Anyplace I can increase this "600 seconds" timeout other than the GUI?
    Is it really issue of "StuckThreadMaxTime" or something more sinister is going underneath.
    Experts kindly chip in with your comments.

    Hi,
    Thanks for the reply.
    I tried dbping but I dont thing I got it right.
    bash-4.0$ java -classpath wlserver_10.3/server/lib/weblogic.jar utils.dbping ORACLE_THIN scott tiger XXXX.us.oracle.com:2XXXX:X15yXXXX
    Error encountered:
    java.sql.SQLRecoverableException: IO Error: Got minus one from a read call
    at oracle.jdbc.driver.T4CConnection.logon(T4CConnection.java:419)
    at oracle.jdbc.driver.PhysicalConnection.<init>(PhysicalConnection.java:538)
    at oracle.jdbc.driver.T4CConnection.<init>(T4CConnection.java:228)
    at oracle.jdbc.driver.T4CDriverExtension.getConnection(T4CDriverExtension.java:32)
    at oracle.jdbc.driver.OracleDriver.connect(OracleDriver.java:521)
    at java.sql.DriverManager.getConnection(DriverManager.java:582)
    at java.sql.DriverManager.getConnection(DriverManager.java:154)
    at utils.dbping.main(dbping.java:204)
    Caused by: oracle.net.ns.NetException: Got minus one from a read call
    at oracle.net.ns.Packet.receive(Packet.java:296)
    at oracle.net.ns.NSProtocol.connect(NSProtocol.java:295)
    at oracle.jdbc.driver.T4CConnection.connect(T4CConnection.java:1056)
    at oracle.jdbc.driver.T4CConnection.logon(T4CConnection.java:308)
    ... 7 more
    Some more info.
    In files i saw:
    JDBCConnectionPoolParams.CapacityIncrement" value="1"
    JDBCConnectionPoolParams.InitialCapacity" value="1"
    JDBCConnectionPoolParams.MaxCapacity" value="2"
    I changed them to:
    JDBCConnectionPoolParams.CapacityIncrement" value="2"
    JDBCConnectionPoolParams.InitialCapacity" value="20"
    JDBCConnectionPoolParams.MaxCapacity" value="80"
    But I still get the same errors. Further looking into the server logs I found that it waits for getting a connection again and again.
    This is one more worrying thing I am seeing in the server log. It repeats quite often in the log before the struckThreadMaxTime thing happens:
    ####<Dec 9, 2010 5:16:29 AM EST> <Info> <Common> <lchp40.us.oracle.com> <admin> <[ACTIVE] ExecuteThread: '33' for queue: 'weblogic.kernel.Default (self-tuning)'> <<anonymous>> <> <> <1291889789377> <BEA-000627> <*Reached maximum capacity of pool "ORADataSource", making "0" new resource instances instead of "1"*.>
    Also I see number of threads increasing.
    Starts off like:
    ####<Dec 9, 2010 5:04:57 AM EST> <Debug> <SecurityAtn> <lchp40.us.oracle.com> <admin> <[ACTIVE] ExecuteThread: '0' for queue: 'weblogic.kernel.Default (self-tuning)'> <<WLS Kernel>> <> <> <1291889097594> <BEA-000000> <getting connection>
    ####<Dec 9, 2010 5:05:26 AM EST> <Debug> <SecurityAtn> <lchp40.us.oracle.com> <admin> <[ACTIVE] ExecuteThread: '8' for queue: 'weblogic.kernel.Default (self-tuning)'> <<WLS Kernel>> <> <> <1291889126599> <BEA-000000> <getting connection>
    and goes on increasing till I see something like this:
    ####<Dec 9, 2010 5:17:39 AM EST> <Debug> <SecurityAtn> <lchp40.us.oracle.com> <admin> <[ACTIVE] ExecuteThread: '179' for queue: 'weblogic.kernel.Default (self-tuning)'> <<WLS Kernel>> <> <> <1291889859008> <BEA-000000> <getting connection>
    ####<Dec 9, 2010 5:17:43 AM EST> <Debug> <SecurityAtn> <lchp40.us.oracle.com> <admin> <[ACTIVE] ExecuteThread: '180' for queue: 'weblogic.kernel.Default (self-tuning)'> <<WLS Kernel>> <> <> <1291889863028> <BEA-000000> <getting connection>
    ####<Dec 9, 2010 5:17:25 AM EST> <Error> <WebLogicServer> <lchp40.us.oracle.com> <admin> <[STANDBY] ExecuteThread: '180' for queue: 'weblogic.kernel.Default (self-tuning)'> <<WLS Kernel>> <> <> <129188984569
    9> <BEA-000337> <[STUCK] ExecuteThread: '0' for queue: 'weblogic.kernel.Default (self-tuning)' has been busy for "627" seconds working on the request "weblogic.common.internal.RMIBootServiceImpl", which is m
    ore than the configured time (StuckThreadMaxTime) of "600" seconds. Stack trace:
    tests.functional.security.dbms.common.utils.DBMSSQLSlowSubPlugin.lookupUserGroups(DBMSSQLSlowSubPlugin.java:186)
    weblogic.security.providers.authentication.DBMSPluggableRuntimeQueryImpl.executeMemberGroups(DBMSPluggableRuntimeQueryImpl.java:109)
    weblogic.security.providers.authentication.shared.DBMSAtnLoginModuleImpl.findMemberGroupsUnlimited(DBMSAtnLoginModuleImpl.java:831)
    weblogic.security.providers.authentication.shared.DBMSAtnLoginModuleImpl.findMemberGroupsInternal(DBMSAtnLoginModuleImpl.java:899)
    weblogic.security.providers.authentication.shared.DBMSAtnLoginModuleImpl.findMemberGroups(DBMSAtnLoginModuleImpl.java:742)
    weblogic.security.providers.authentication.shared.DBMSAtnLoginModuleImpl.addGroupsFromDBMS(DBMSAtnLoginModuleImpl.java:526)
    weblogic.security.providers.authentication.shared.DBMSAtnLoginModuleImpl.login(DBMSAtnLoginModuleImpl.java:341)
    com.bea.common.security.internal.service.LoginModuleWrapper$1.run(LoginModuleWrapper.java:110)
    java.security.AccessController.doPrivileged(Native Method)
    com.bea.common.security.internal.service.LoginModuleWrapper.login(LoginModuleWrapper.java:106)
    sun.reflect.GeneratedMethodAccessor91.invoke(Unknown Source)
    sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    java.lang.reflect.Method.invoke(Method.java:597)
    javax.security.auth.login.LoginContext.invoke(LoginContext.java:769)
    javax.security.auth.login.LoginContext.access$000(LoginContext.java:186)
    javax.security.auth.login.LoginContext$4.run(LoginContext.java:683)
    java.security.AccessController.doPrivileged(Native Method)
    javax.security.auth.login.LoginContext.invokePriv(LoginContext.java:680)
    javax.security.auth.login.LoginContext.login(LoginContext.java:579)
    com.bea.common.security.internal.service.JAASLoginServiceImpl.login(JAASLoginServiceImpl.java:113)
    sun.reflect.GeneratedMethodAccessor89.invoke(Unknown Source)
    sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    java.lang.reflect.Method.invoke(Method.java:597)
    com.bea.common.security.internal.utils.Delegator$ProxyInvocationHandler.invoke(Delegator.java:57)
    $Proxy15.login(Unknown Source)
    weblogic.security.service.internal.WLSJAASLoginServiceImpl$ServiceImpl.login(WLSJAASLoginServiceImpl.java:89)
    com.bea.common.security.internal.service.JAASAuthenticationServiceImpl.authenticate(JAASAuthenticationServiceImpl.java:82)
    sun.reflect.GeneratedMethodAccessor87.invoke(Unknown Source)
    sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    java.lang.reflect.Method.invoke(Method.java:597)
    com.bea.common.security.internal.utils.Delegator$ProxyInvocationHandler.invoke(Delegator.java:57)
    $Proxy33.authenticate(Unknown Source)
    weblogic.security.service.WLSJAASAuthenticationServiceWrapper.authenticate(WLSJAASAuthenticationServiceWrapper.java:40)
    weblogic.security.service.PrincipalAuthenticator.authenticate(PrincipalAuthenticator.java:348)
    weblogic.common.internal.RMIBootServiceImpl.authenticate(RMIBootServiceImpl.java:109)
    weblogic.common.internal.RMIBootServiceImpl_WLSkel.invoke(Unknown Source)
    weblogic.rmi.internal.BasicServerRef.invoke(BasicServerRef.java:667)
    weblogic.rmi.internal.BasicServerRef$1.run(BasicServerRef.java:522)
    weblogic.security.acl.internal.AuthenticatedSubject.doAs(AuthenticatedSubject.java:363)
    weblogic.security.service.SecurityManager.runAs(SecurityManager.java:146)
    weblogic.rmi.internal.BasicServerRef.handleRequest(BasicServerRef.java:518)
    weblogic.rmi.internal.wls.WLSExecuteRequest.run(WLSExecuteRequest.java:118)
    weblogic.work.ExecuteThread.execute(ExecuteThread.java:207)
    weblogic.work.ExecuteThread.run(ExecuteThread.java:176)
    Sorry if it sounds confusing. All this is new to me. And I am rather desperate for any pointers.
    Edited by: I_Kept_walking on Dec 9, 2010 3:00 AM

Maybe you are looking for