Statement NullPointerException

I have a class that contains the following 2 methods;
public void accessDatabase()
     try
          Class.forName("oracle.jdbc.driver.OracleDriver");
          connection = DriverManager.getConnection("jdbc:oracle:thin:@ELLP102615:1521:PE9I", USER,PASSWORD);
     }// End of Try Statement.
     catch(Exception e) {}// End of Catch Statement.
}// End of accessDatabase Method.
public Vector readCourse(Vector v)
     try
          statement = connection.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_UPDATABLE);
          String query = "SELECT COURSE_CODE "+
          "FROM COURSE";
          results = statement.executeQuery(query);
          while(results.next())
               v.add(results.getString("COURSE_CODE"));
          }// End of While Statement.
     }// End of Try Statement.
     catch(SQLException sqle) {}// End of Catch Statement.
     return v;
}// End of readCourse Method.
From another class, I open the connection using the accessDatabase method which works great. However, when I try to use the second method, a nullpointerexception is thrown because of the statement. Any idea what's wrong with it?? I apoloize to those who don't like the way I posted my code since I still don't have a clue as to how to do it like others...

Well, you're catching the Exception when you're creating your statement, but aren't doing anything at all to let you know if something has gone wrong. What's to say that a SQLException isn't occuring when you try to establish your connection, and thus your connection is never established. In this case, your connection object would be null, and would throw the NullPointerException when createStatement() is called.
Why not print out your exception at the very least in order to see what's happening inside that accessDatabase() method.

Similar Messages

  • Problems in running sound

    Dear all,
    I test many times on my program
    When the audioClip.play() method is called,
    it states nullpointerexception
    but when i check the link, it is correct
    Is that load it from the buffer and the audioclip are got by the .wav file?
    I do the same thing but it cannot run.
    Thanks

    No more answers, you already have four threads about that.

  • ESS: java.lang.NullPointerException in Salary Statement

    Hi All,
    We have configured ESS salary stament but getting the following Exception when we click on Salary Statement,
    Please help us out in this:-
    java.lang.NullPointerException
         at com.sap.pcuigp.tracking.BTrackingComp.isValuePackSystem(BTrackingComp.java:290)
         at com.sap.pcuigp.tracking.BTrackingComp.onInit(BTrackingComp.java:206)
         at com.sap.pcuigp.tracking.wdp.InternalBTrackingComp.onInit(InternalBTrackingComp.java:173)
         at com.sap.pcuigp.tracking.BTrackingCompInterface.onInit(BTrackingCompInterface.java:115)
         at com.sap.pcuigp.tracking.wdp.InternalBTrackingCompInterface.onInit(InternalBTrackingCompInterface.java:124)
         at com.sap.pcuigp.tracking.wdp.InternalBTrackingCompInterface$External.onInit(InternalBTrackingCompInterface.java:198)
         at com.sap.pcuigp.xssfpm.wd.FPMComponent$FPM.attachComponentToUsage(FPMComponent.java:922)
         at com.sap.pcuigp.xssfpm.wd.FPMComponent$FPM.attachComponentToUsage(FPMComponent.java:891)
         at com.sap.pcuigp.xssfpm.wd.FPMComponent$FPMProxy.attachComponentToUsage(FPMComponent.java:1084)
         at com.sap.pcuigp.xssutils.pernr.FcEmployeeServices.onInit(FcEmployeeServices.java:219)
         at com.sap.pcuigp.xssutils.pernr.wdp.InternalFcEmployeeServices.onInit(InternalFcEmployeeServices.java:249)
         at com.sap.pcuigp.xssutils.pernr.FcEmployeeServicesInterface.onInit(FcEmployeeServicesInterface.java:135)
         at com.sap.pcuigp.xssutils.pernr.wdp.InternalFcEmployeeServicesInterface.onInit(InternalFcEmployeeServicesInterface.java:183)
         at com.sap.pcuigp.xssutils.pernr.wdp.InternalFcEmployeeServicesInterface$External.onInit(InternalFcEmployeeServicesInterface.java:243)
         at com.sap.pcuigp.xssfpm.wd.FPMComponent$FPM.attachComponentToUsage(FPMComponent.java:922)
         at com.sap.pcuigp.xssfpm.wd.FPMComponent$FPM.attachComponentToUsage(FPMComponent.java:891)
         at com.sap.pcuigp.xssfpm.wd.FPMComponent$FPMProxy.attachComponentToUsage(FPMComponent.java:1084)
         at com.sap.xss.hr.rem2.selection.VcRem2Selection.onInit(VcRem2Selection.java:228)
         at com.sap.xss.hr.rem2.selection.wdp.InternalVcRem2Selection.onInit(InternalVcRem2Selection.java:249)
         at com.sap.xss.hr.rem2.selection.VcRem2SelectionInterface.onInit(VcRem2SelectionInterface.java:161)
         at com.sap.xss.hr.rem2.selection.wdp.InternalVcRem2SelectionInterface.onInit(InternalVcRem2SelectionInterface.java:144)
         at com.sap.xss.hr.rem2.selection.wdp.InternalVcRem2SelectionInterface$External.onInit(InternalVcRem2SelectionInterface.java:220)
         at com.sap.pcuigp.xssfpm.wd.FPMComponent.doProcessEvent(FPMComponent.java:564)
         at com.sap.pcuigp.xssfpm.wd.FPMComponent.doEventLoop(FPMComponent.java:438)
         at com.sap.pcuigp.xssfpm.wd.FPMComponent.wdDoInit(FPMComponent.java:196)
         at com.sap.pcuigp.xssfpm.wd.wdp.InternalFPMComponent.wdDoInit(InternalFPMComponent.java:110)
         at com.sap.tc.webdynpro.progmodel.generation.DelegatingComponent.doInit(DelegatingComponent.java:108)
         at com.sap.tc.webdynpro.progmodel.controller.Controller.initController(Controller.java:215)
         at com.sap.tc.webdynpro.progmodel.controller.Controller.init(Controller.java:200)
         at com.sap.tc.webdynpro.clientserver.cal.ClientComponent.init(ClientComponent.java:430)
         at com.sap.tc.webdynpro.clientserver.cal.ClientApplication.init(ClientApplication.java:362)
         at com.sap.tc.webdynpro.clientserver.session.ApplicationSession.initApplication(ApplicationSession.java:756)
         at com.sap.tc.webdynpro.clientserver.session.ApplicationSession.doProcessing(ApplicationSession.java:291)
         at com.sap.tc.webdynpro.clientserver.session.ClientSession.doApplicationProcessingPortal(ClientSession.java:733)
         at com.sap.tc.webdynpro.clientserver.session.ClientSession.doApplicationProcessing(ClientSession.java:668)
         at com.sap.tc.webdynpro.clientserver.session.ClientSession.doProcessing(ClientSession.java:250)
         at com.sap.tc.webdynpro.clientserver.session.RequestManager.doProcessing(RequestManager.java:149)
         at com.sap.tc.webdynpro.clientserver.session.core.ApplicationHandle.doProcessing(ApplicationHandle.java:73)
         at com.sap.tc.webdynpro.portal.pb.impl.AbstractApplicationProxy.sendDataAndProcessActionInternal(AbstractApplicationProxy.java:869)
         at com.sap.tc.webdynpro.portal.pb.impl.AbstractApplicationProxy.create(AbstractApplicationProxy.java:229)
         at com.sap.portal.pb.PageBuilder.updateApplications(PageBuilder.java:1344)
         at com.sap.portal.pb.PageBuilder.createPage(PageBuilder.java:356)
         at com.sap.portal.pb.PageBuilder.init(PageBuilder.java:549)
         at com.sap.portal.pb.PageBuilder.wdDoRefresh(PageBuilder.java:593)
         at com.sap.portal.pb.PageBuilder$1.doPhase(PageBuilder.java:865)
         at com.sap.tc.webdynpro.clientserver.window.WindowPhaseModel.processPhaseListener(WindowPhaseModel.java:755)
         at com.sap.tc.webdynpro.clientserver.window.WindowPhaseModel.doPortalDispatch(WindowPhaseModel.java:717)
         at com.sap.tc.webdynpro.clientserver.window.WindowPhaseModel.processRequest(WindowPhaseModel.java:136)
         at com.sap.tc.webdynpro.clientserver.window.WebDynproWindow.processRequest(WebDynproWindow.java:335)
         at com.sap.tc.webdynpro.clientserver.cal.AbstractClient.executeTasks(AbstractClient.java:143)
         at com.sap.tc.webdynpro.clientserver.session.ApplicationSession.doProcessing(ApplicationSession.java:321)
         at com.sap.tc.webdynpro.clientserver.session.ClientSession.doApplicationProcessing(ClientSession.java:684)
         at com.sap.tc.webdynpro.clientserver.session.ClientSession.doProcessing(ClientSession.java:250)
         at com.sap.tc.webdynpro.clientserver.session.RequestManager.doProcessing(RequestManager.java:149)
         at com.sap.tc.webdynpro.serverimpl.defaultimpl.DispatcherServlet.doContent(DispatcherServlet.java:62)
         at com.sap.tc.webdynpro.serverimpl.defaultimpl.DispatcherServlet.doPost(DispatcherServlet.java:53)
         at javax.servlet.http.HttpServlet.service(HttpServlet.java:760)
         at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
         at com.sap.engine.services.servlets_jsp.server.HttpHandlerImpl.runServlet(HttpHandlerImpl.java:401)
         at com.sap.engine.services.servlets_jsp.server.HttpHandlerImpl.handleRequest(HttpHandlerImpl.java:266)
         at com.sap.engine.services.httpserver.server.RequestAnalizer.startServlet(RequestAnalizer.java:386)
         at com.sap.engine.services.httpserver.server.RequestAnalizer.startServlet(RequestAnalizer.java:364)
         at com.sap.engine.services.httpserver.server.RequestAnalizer.invokeWebContainer(RequestAnalizer.java:1039)
         at com.sap.engine.services.httpserver.server.RequestAnalizer.handle(RequestAnalizer.java:265)
         at com.sap.engine.services.httpserver.server.Client.handle(Client.java:95)
         at com.sap.engine.services.httpserver.server.Processor.request(Processor.java:175)
         at com.sap.engine.core.service630.context.cluster.session.ApplicationSessionMessageListener.process(ApplicationSessionMessageListener.java:33)
         at com.sap.engine.core.cluster.impl6.session.MessageRunner.run(MessageRunner.java:41)
         at com.sap.engine.core.thread.impl3.ActionObject.run(ActionObject.java:37)
         at java.security.AccessController.doPrivileged(Native Method)
         at com.sap.engine.core.thread.impl3.SingleThread.execute(SingleThread.java:104)
         at com.sap.engine
    thanks & regards...
    Gaurav Makin
    Edited by: Gaurav Makin on Jan 6, 2010 9:19 AM
    Edited by: Gaurav Makin on Jan 6, 2010 9:20 AM

    Gaurav, the NullPointerException is common error, mostly caused by bad information in master data or any missing customizing.
    I suggest you first check this application with another users to discard errors in master data.
    Next, check the customizing for salary statement; are you maintaining HRFOR feature? If you're using HRFORM, check if Form is active in HRFORMS transaction.
    Then please tell us if you solved the issue.
    Regards

  • Java.lang.NullPointerException with and update statement

    Hello,
    I'm getting this exception:
    java.lang.NullPointerException
         phaseone.AlbumModel.updateImageTrackerAlbums(AlbumModel.java:313)
         phaseone.AlbumModel.processRequest(AlbumModel.java:228)
         phaseone.AlbumModel.doGet(AlbumModel.java:522)
         javax.servlet.http.HttpServlet.service(HttpServlet.java:690)
         javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
    I have an open method called before this one that connects me to the database. It works fine and have it working with a bunch of other methods but this one gives me this exception. i've even hard coded the variable 'user' and 'albumNumber' with information that exists in the database. i can't see where this logical error is coming from. I appreciate the help. I've been on this for 3 1/2 hour going blind. thanks!!
    public boolean updateImageTrackerAlbums(String user, int albumNumber){
              PreparedStatement pstmt = null;
              boolean pass = false;
              String query = "update imagetracker set totalalbums = ? where username = ?";
              try{
              pstmt = conn.prepareStatement(query);
              pstmt.setInt(1, albumNumber);
              pstmt.setString(2, user);
             int x = pstmt.executeUpdate();
             if (x >= 1){
             pass = true;
              }catch(SQLException e){
                e.printStackTrace();
                return pass;
              }finally{
              DBUtil.closePreparedStatment(pstmt);
              return pass;
              }

    code3 wrote:
    The exception is pointing to this:
    pstmt = conn.prepareStatement(query);
    Do you understand anyway when a NullPointerException would be thrown? It will be thrown if you try to access/invoke an object reference which is actually null.
    Connection conn = null;
    pstmt = conn.prepareStatement(query); // Throws NPE because conn is null.

  • NullPointerException at com.mysql.jdbc.Statement.executeQuery

    hi,
    i use mysql, mm-mysql driver. In code, 4 different types of queries are present i use 4 kind of threads that retrive data from database (for each type of query) every 5 secs.Code sometimes works and sometimes throws null pointer exception.Although i used different result sets for each type of query, problem still remains. what can i do? what is the exact source of problem?
    thanx in advance
    hELin

    GuiSample.java :
    public class ThreadIncoming implements Runnable
    private boolean suspend; // Flag indicating that we should suspend the loop
    private Thread thread;
    public ThreadIncoming()
    start();
    public void start()
    thread = new Thread(this);
    suspend = false;
    thread.start();
    public void suspend()
    // Set the suspend flag - when the run loop comes back round it will check this and wait
    suspend = true;
    public synchronized void resume()
    // Unset the suspend flag - the call to notify will wake up the waiting Thread which will then continue
    suspend = false;
    notify();
    public void stop()
    thread = null;
    resume(); // Call resume in case stop is called while waiting
    public void run()
    if (queryApp != null && queryApp.isConnected() ) {
    while(Thread.currentThread() == thread) {
    if (filterIncomingRuns)
    suspend();
    if(suspend) {
    // Check whether the suspend flag is set - get the current Thread to wait if it is
    synchronized(this)
    while(suspend) {
    try {
    wait();
    catch (Exception e1) {
    e1.printStackTrace();
    try
    fillAlarmTable();
    Thread.sleep(5000);
    catch(InterruptedException e)
    private void fillAlarmTable() {
    queryApp.getTable(logAlarmTable);
    ...//END OF GuiSample.java
    In this class, the thread type used is above shown. Every thread's task is to retrive data from DB and insert it into jtable's in GuiSample.java...
    QueryDB.java: where DB operation are done
    getTable(jtable theTable) {
    stmt = connection.createStatement();
    if (theTable.getModel().getClass().getName().equals("LogAlarmTableModel")) {
    rsAlarm = stmt.executeQuery(sql);
    displayRS(rsAlarm,theTable);
    else if ....
    stmt.close();
    i tried to write some part of the code..waiting for ur advice. thanx
    hELin

  • Getting java.lang.NullpointerException while closing resultset aft using it

    Hi,
    I kindly request to share your ideas reg. my problem.
    I am opening a database connection using connection pool and i am using two or more resultsets and statement objects.I am closing these objects at the end of their usage.But i am getting java.lang.NullpointerException when i close them(if i don't close them it works fine). what might be the reason. Had i did any thing wrong in the code.
    please view the code
    public String storeNewConnection(String CIRCLE,String DIVISION,String SUB_DIVISION,String SECTION,String CONSUMER_NAME,String FATHER_NAME,String STREET_NAME,String DOOR_NO,String TOWN_CITY,String LAND_MARK,String PINCODE,String STDCODE,String PHONE_NO,String EMAIL,String NEIGHBOUR_SCNO,String DOCUMENT_CODE,String LT_APR_NO,String year1,String month1,String day1,String PCBNO,String CONSUMER_STATUS,String SOCIAL_GROUP,String CATEGORY_SUPPLY,String LOCATION_PREMISES,String PURPOSE_OF_SUPPLY,String DURATION,String LOAD_TYPE,String CONNECTED_LOAD,String CONTRACTED_LOAD,String APPLICATION_FEE,String DEVELOPMENT_CHARGES,String SECURITY_DEPOSIT,String ADDL_SECURITY_DESPOSIT,String DEPOSITED_THRU,String DD_CHEQUE_DETAILS,String year2,String month2,String day2,String REMARKS,String POLE_NO)
              int count=0;
              Statement st=null;
              ResultSet rs=null,rs1=null,rs2=null,rs3=null;
              PreparedStatement pst=null;
              String result="",query="",sysDate="",sysDate2="";
              String reg_no = "";
              try
                   st=con.createStatement();
                   //Check dates with sys date
                   String date1 =null;                    
                   String date2 =null;
                   if(! (year1.equals("") || month1.equals("") || day1.equals("")) )
                        date1=day1+"-"+month1+"-"+year1;
                        rs2=st.executeQuery("select round(to_date('"+date1+"','dd-Mon-yyyy')-to_date(sysdate,'dd-Mon-yy')) from dual");
                        rs2.next();
                        if(rs2.getInt(1) != 0)
                             return "false";                              
                   if(! (year2.equals("") || month2.equals("") || day2.equals("")) )
                        date2=day2+"-"+month2+"-"+year2;
                        rs3=st.executeQuery("select round(to_date('"+date2+"','dd-Mon-yyyy')-to_date(sysdate,'dd-Mon-yy')) from dual");
                        rs3.next();
                        if(rs3.getInt(1) != 0)
                             return "false";     
                   rs1=st.executeQuery("select to_char(sysdate,'yyyyMONdd'),to_char(sysdate,'dd-Mon-yyyy') from dual");
                   rs1.next();
                   sysDate=rs1.getString(1);
                   sysDate2=rs1.getString(2);
                   rs=st.executeQuery("select max(SERIAL_NO) from NEW_CONNECTIONS where to_char(sysdate,'yyyy') = to_char(REG_DATE,'yyyy') and to_char(sysdate,'mm') = to_char(REG_DATE,'mm') and SUB_DIVISION_CODE = "+SUB_DIVISION+" and DIVISION_CODE = "+DIVISION+" and CIRCLE_CODE = "+CIRCLE+" ");
                   if(rs.next())
                        count = rs.getInt(1);
                        count++;                              
                   else
                        count=1;
                   query="insert into NEW_CONNECTIONS ( "+
                        " REG_NO,SERIAL_NO,REG_DATE,CIRCLE_CODE,DIVISION_CODE,SUB_DIVISION_CODE,SECTION_CODE, "+
                        " CONSUMER_NAME,FATHER_NAME,STREET_NAME,DOOR_NO,TOWN_CITY,LAND_MARK,PINCODE, "+
                        " STDCODE,PHONE_NO,EMAIL,NEIGHBOUR_SCNO,DOCUMENT_CODE,LT_APR_NO,LT_APR_DATE, "+
                        " PCBNO,CONSUMER_STATUS,SOCIAL_GROUP,CATEGORY_SUPPLY,LOCATION_PREMISES,PURPOSE_OF_SUPPLY,"+
                        " DURATION,LOAD_TYPE,CONNECTED_LOAD,CONTRACTED_LOAD,APPLICATION_FEE,DEVELOPMENT_CHARGES, "+
                        " SECURITY_DEPOSIT,ADDL_SECURITY_DEPOSIT,DEPOSITED_THRU,DD_CHEQUE_DETAILS,DD_CHEQUE_DATE,REMARKS,APPLICATION_STATUS,POLE_NO) "+
                        " values(?,?,'"+sysDate2+"',?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)";
                   pst = con.prepareStatement(query);
                   String cnt ="";
                   if(count <= 9)
                        cnt="0000";
                   else if(count <= 99)
                        cnt="000";
                   else if(count <= 999)
                        cnt="00";
                   else if(count <= 9999)
                        cnt="0";
                   cnt+=Integer.toString(count);
                   reg_no = CIRCLE+DIVISION+SUB_DIVISION+SECTION+"N"+cnt+sysDate;               
                   int serial_no =count;
                   int pin = 0;
                   if(!PINCODE.equals(""))
                        pin =Integer.parseInt(PINCODE);
                   int std = 0;
                   if(!STDCODE.equals(""))
                        std = Integer.parseInt(STDCODE);
                   int status = Integer.parseInt(CONSUMER_STATUS);
                   int social_group = Integer.parseInt(SOCIAL_GROUP);
                   int supply = Integer.parseInt(CATEGORY_SUPPLY);
                   int location = Integer.parseInt(LOCATION_PREMISES);
                   int purpose = Integer.parseInt(PURPOSE_OF_SUPPLY);
                   int duration = Integer.parseInt(DURATION);
                   int laod_type = Integer.parseInt(LOAD_TYPE);
                   float conn_load = Float.parseFloat(CONNECTED_LOAD);
                   int cont_load = 0;
                   if(!CONTRACTED_LOAD.equals(""))
                        cont_load =Integer.parseInt(CONTRACTED_LOAD);
                   int app_fee = Integer.parseInt(APPLICATION_FEE);
                   int dev_chg = Integer.parseInt(DEVELOPMENT_CHARGES);
                   int sec_dep = Integer.parseInt(SECURITY_DEPOSIT);
                   int addl_sec_dep = 0;     
                   if(!ADDL_SECURITY_DESPOSIT.equals(""))
                        addl_sec_dep =Integer.parseInt(ADDL_SECURITY_DESPOSIT);
                   int dep_thru = Integer.parseInt(DEPOSITED_THRU);          
                   pst.setString(1,reg_no);
                   pst.setInt(2,serial_no);
                   pst.setString(3,CIRCLE);
                   pst.setString(4,DIVISION);
                   pst.setString(5,SUB_DIVISION);
                   pst.setString(6,SECTION);
                   pst.setString(7,CONSUMER_NAME);
                   pst.setString(8,FATHER_NAME);
                   pst.setString(9,STREET_NAME);
                   pst.setString(10,DOOR_NO);
                   pst.setString(11,TOWN_CITY);
                   pst.setString(12,LAND_MARK);
                   pst.setInt(13,pin);
                   pst.setInt(14,std);
                   pst.setString(15,PHONE_NO);
                   pst.setString(16,EMAIL);
                   pst.setString(17,NEIGHBOUR_SCNO);
                   pst.setString(18,DOCUMENT_CODE);
                   pst.setString(19,LT_APR_NO);
                   pst.setString(20,date1);
                   pst.setString(21,PCBNO);
                   pst.setInt(22,status);
                   pst.setInt(23,social_group);
                   pst.setInt(24,supply );
                   pst.setInt(25,location);
                   pst.setInt(26,purpose);
                   pst.setInt(27,duration);
                   pst.setInt(28,laod_type);
                   pst.setFloat(29,conn_load );
                   pst.setInt(30,cont_load);
                   pst.setInt(31,app_fee);
                   pst.setInt(32,dev_chg);
                   pst.setInt(33,sec_dep);
                   pst.setInt(34,addl_sec_dep);
                   pst.setInt(35,dep_thru );
                   pst.setString(36,DD_CHEQUE_DETAILS);
                   pst.setString(37,date2);
                   pst.setString(38,REMARKS);
                   pst.setInt(39,1);
                   pst.setString(40,POLE_NO);
                   pst.executeUpdate();
                   result=reg_no;                                   
                   rs.close();
                   rs=null;
                   rs1.close();
                   rs1=null;
                   rs2.close();
                   rs2=null;
                   rs3.close();
                   rs3=null;
                   st.close();
                   st=null;
                   pst.close();
                   pst=null;
              catch(Exception e)
                   e.printStackTrace();
                   result="false";
                   return result;
              finally
                   if (rs != null)
                        try
                             rs.close();
                        catch (SQLException e)
                        rs = null;
                   if (rs1 != null)
                        try
                             rs1.close();
                        catch (SQLException e)
                        rs1 = null;
                   if (rs2 != null)
                        try
                             rs2.close();
                        catch (SQLException e)
                        rs2 = null;
                   if (rs3 != null)
                        try
                             rs3.close();
                        catch (SQLException e)
                        rs3 = null;
                   if (st != null)
                        try
                             st.close();
                        catch (SQLException e)
                        st = null;
                   if (pst != null)
                        try
                             pst.close();
                        catch (SQLException e)
                        pst = null;
              return result;
    Also plz help me to improve the code if necessary so that it will work fine for multiple users
    thaks & regards
    Prasanth.C

    Thanks a lot.
    i replaced the code below
    if (rs != null)
                        try
                             rs.close();
                        catch (SQLException e)
                        rs = null;
                   if (rs1 != null)
                        try
                             rs1.close();
                        catch (SQLException e)
                        rs1 = null;
                   if (rs2 != null)
                        try
                             rs2.close();
                        catch (SQLException e)
                        rs2 = null;
                   if (rs3 != null)
                        try
                             rs3.close();
                        catch (SQLException e)
                        rs3 = null;
                   if (st != null)
                        try
                             st.close();
                        catch (SQLException e)
                        st = null;
                   if (pst != null)
                        try
                             pst.close();
                        catch (SQLException e)
                        pst = null;
    instead of blindly closing the resultsets and statements
    now it works fine.
    One more thing, is my code structurally correct, i mean the variables, try...catch blocks,results,statements,database connections and overall coding. whether it looks like professional code.
    thaks & regards,
    Prasanth.C

  • Closing the Statement returned from ResultSet.getStatement does not work

    With the ORACLE JDBC driver, I have discovered (the hard way) that it is essential to explictly close a Statement object after use. (http://www.orafaq.com/node/758 was useful here).
    Failure to do so leaves the Cursor open and eventually your application will fail with the ORA-01000 Too Many Cursors error.
    That works well if your code still has access to the Statement object which it created when it has finished with the results from executing the Statement.
    But, I've inherited some code where this is not the case. The results in the form of a ResultSet are passed through a few layers before it is eventually processed and can then be closed. The original Statement object is no longer available.
    I thought then that the solution would be use the ResultSet.getStatement method and to close that Statement.
    BUT that doesn't seem to work. The number of cursors continues to go up.
    Any ideas, anyone?
    (I'm using ojdbc6.jar and ORACLE 10g Express.)
    Edited by: Termind on 22-Jul-2010 10:00

    Copied in second message as first gets unreadable...
    eclipse.buildId=I20070625-1500
    java.version=1.5.0_18
    java.vendor=Sun Microsystems Inc.
    BootLoader constants: OS=win32, ARCH=x86, WS=win32, NL=de_DE
    Command-line arguments:  -os win32 -ws win32 -arch x86 -data D:\Dokumente\Projekte\workspace
    Error
    Tue Sep 29 11:30:49 CEST 2009
    Unhandled event loop exception
    java.lang.NullPointerException
    at org.eclipse.jpt.db.internal.ForeignKey.getReferencedTable(ForeignKey.java:104)
    at org.eclipse.jpt.gen.internal.GenTable.addReferencedTablesTo(GenTable.java:106)
    at org.eclipse.jpt.gen.internal.GenScope.buildReferencedTables(GenScope.java:169)
    at org.eclipse.jpt.gen.internal.GenScope.configureManyToManyRelations(GenScope.java:81)
    at org.eclipse.jpt.gen.internal.GenScope.initialize(GenScope.java:46)
    at org.eclipse.jpt.gen.internal.GenScope.<init>(GenScope.java:33)
    at org.eclipse.jpt.gen.internal.PackageGenerator.<init>(PackageGenerator.java:48)
    at org.eclipse.jpt.gen.internal.PackageGenerator.generateEntities(PackageGenerator.java:38)
    at org.eclipse.jpt.ui.internal.generic.EntitiesGenerator$GenerateEntitiesRunnable.run(EntitiesGenerator.java:129)
    at org.eclipse.core.internal.resources.Workspace.run(Workspace.java:1797)
    at org.eclipse.core.internal.resources.Workspace.run(Workspace.java:1779)

  • I require assistance w/r/t nullpointerexception!

    Hi there, thanks for taking the time to read this. I'm a beginning Java programming student and I've unfortunately reached an impasse on a program given my level of knowledge. I've spent the last couple of hours attempting to diagnose this problem, so I will now try to articulate it rather than spewing tons of code (I assume this method is more helpful?)
    I am creating a program in which a Course object has, as a private data field, an array of Student objects. Once outside of the constructor which allocates the 10 student objects to the reference variable (studentlist), I find it impossible to accomplish anything when I try to reference a particular student object within the array of student objects within the course object.
    I am particularly interested in setting a specific student object within the array of students (i.e. studentlist[something]) to "point" to a specific student object that a separate method retrieved.
    Essentially, this is my problem:
    I am attempting to access an element of the array of student objects (a data field within my Course class), which has already been allocated via constructor, inside a behavior method of the Course class itself.
    A simple statement within the particular method of the Course class such as: "studentlist[0] = new Student()'" and also "studentlist[numofstudents] = student;" (student being the retrieved object reference variable, accounted for in terms of possessing desired info) gives me the evil NullPointerException. I'm simply at a loss and quite frustrated, so any advice will be of help. Thank you!

    A simple statement within the particular method of the Course class such
    as: "studentlist[0] = new Student()'" and also "studentlist[numofstudents] = student;"
    (student being the retrieved object reference variable, accounted for in terms of
    possessing desired info) gives me the evil NullPointerException.Be careful that in your Course constructor you don't declare and initialise another array. This will leave the instance variable still null.class Course {
            // the array in question
        private Student[] studentlist;
        Course() {
                // good
            studentlist = new Student[10];
                // bad - this new variable will "go out of scope"
                // when the constructor has finished
            //Student[] studentlist = new Student[10];
        // methods involving studentlist...
    }This is just a guess of course. For a more certain answer you will have to post some code! The trick is to leave out the code that doesn't have a direct bearing on your problem - but still include enough to show what the problem is.
    (A little point: studentlist[numofstudents] suffers from another problem if numofstudents has its obvious meaning. Java arrays are zero based, so the largest valid index is numofstudents-1.)
    Edited by: pbrockway2 on Nov 11, 2007 2:48 PM

  • Can't figure out where NullPointerException is coming from

    I will attach the code I have below. It is almost entirely done but i am getting a NullPointerException that is driving me nuts, and I can't figure out were it is coming from.
    Help is greatly appreciated.
    First code:
    import java.util.Scanner;
    import java.io.*;
    import java.util.Random;
    import java.util.Collection;
    public class DistributionPlagiarist
         public static void main(String[] args) throws IOException
              Scanner keyboard = new Scanner(System.in);
              int keyLength=0, phraseLength=0, numberOfPhrases=0;
              String inputFileName="", keepReadingFromFile="", theFile="";
              FrequencyLibrary text = new DenseFrequencyLibrary();
              if(args.length != 4)
                   System.out.println("The command line arguments you entered do not match what is needed.  Please try again.");
                   System.exit(0);
              for(int count=0; count<args.length; count++)
                   keyLength = Integer.parseInt(args[0]);
                   phraseLength = Integer.parseInt(args[1]);
                   numberOfPhrases = Integer.parseInt(args[2]);
                   inputFileName = args[3];
              if(keyLength < 0)
                   while(keyLength < 0)
                        System.out.print("The length of the key (" + keyLength + ")" + " you entered is less than zero.\nPlease enter another key length: ");
                        keyLength = keyboard.nextInt();
                        System.out.println();
              if(phraseLength < 0)
                   while(phraseLength < 0)
                        System.out.print("The desired length of the phrase (" + phraseLength + ")" + " you entered is less than zero.\nPlease enter another phrase length: ");
                        keyLength = keyboard.nextInt();
                        System.out.println();
              if(numberOfPhrases <= 0)
                   while(numberOfPhrases <= 0)
                        System.out.print("The desired number of phrases (" + keyLength + ")" + " you entered is not applicable.\nPlease choose another number: ");
                        keyLength = keyboard.nextInt();
                        System.out.println();
              File file=new File(inputFileName);
              boolean exists = file.exists();
              if (exists == false)
                   while(exists == false)
                        System.out.println("The file you are searching for does not exist.  Please place it in this programs directory.");
                        System.out.print("Please re-enter the file name: ");
                        inputFileName = keyboard.nextLine();
                        file=new File(inputFileName);
                        exists = file.exists();
              int count=keyLength, start=0, stop=0;
              FileReader freader = new FileReader(inputFileName);
              BufferedReader inputFile = new BufferedReader(freader);
              while(keepReadingFromFile != null)
                   keepReadingFromFile = inputFile.readLine();
                   if(keepReadingFromFile == null)
                        break;
                   else
                        theFile = theFile + keepReadingFromFile;
              while(count < theFile.length())
                   String name = theFile.substring(start, keyLength+stop);
                   char singleCharacter = theFile.charAt(count);
                   text.add(name, singleCharacter);
                   start++;
                   stop++;
                   count++;
              int countNumberOfPhrases=0;
              while(numberOfPhrases > 0)
                   countNumberOfPhrases++;
                   String phrase = randomphrase(text, phraseLength, keyLength);
                   System.out.println("Phrase " + countNumberOfPhrases + ":\n" + phrase);
                   numberOfPhrases--;
         private static String randomphrase(FrequencyLibrary textLibrary, int phraseLengthToMake, int startLength)
              String startString="";
              char characterToAdd=' ';
              startLength++;
              Random generator = new Random();
              int sizeOfLibrary=textLibrary.size()/2, randomInt = generator.nextInt(sizeOfLibrary+1), value=0;
              Collection<String> stringNames = textLibrary.makeStringCollection();
              for(String stringFromCollection : stringNames)
                   if(randomInt == value)
                        startString = stringFromCollection;
                   value++;
              String thePhrase = new String(startString);
              System.out.println("INITIAL START:" + startString + "TTTT");
              int substringStart=1;
              while(startLength < phraseLengthToMake)
                   characterToAdd = textLibrary.randomUniformChoose(startString);
                   thePhrase = thePhrase + characterToAdd;
                   System.out.println("CHARACTER:" + characterToAdd + "TTTT");
                   System.out.println("PHRASE:" + thePhrase + "TTTT");
                   startString = thePhrase.substring(substringStart, thePhrase.length());
                   boolean answer = textLibrary.contains(startString);
                   System.out.println(answer);
                   System.out.println("NEW STRING:" + startString + "TTTT");
                   startLength++;
                   substringStart++;
              return thePhrase;
    }Second code:
    import java.util.Collection;
    import java.util.HashMap;
    public class DenseFrequencyLibrary implements FrequencyLibrary
         private HashMap<String, MultiSetOfChar> bookTitleAndCharacterAndIntegerHashMap = new HashMap<String, MultiSetOfChar>();
         private MultiSetOfChar keyAndValuePairs = new DenseMultiSetOfChar();
          * Creates a new DenseFrequencyLibrary with all the essential things clear;
         DenseFrequencyLibrary()
              bookTitleAndCharacterAndIntegerHashMap.clear();
          * Input the value from the creation of the DensneMultiSetOfChar into a HashMap.  If the key
          * already exists then the value associated with it is updated by one.
          * @param character a char to be used in forming the HashMap
          * @return characterMap
         private HashMap<String, MultiSetOfChar> inputIntoMap(String name, char character)
              if(!bookTitleAndCharacterAndIntegerHashMap.containsKey(name))
                   keyAndValuePairs = new DenseMultiSetOfChar(character);
              else
                   keyAndValuePairs.add(character);
              this.bookTitleAndCharacterAndIntegerHashMap.put(name, keyAndValuePairs); //input character and value
              return bookTitleAndCharacterAndIntegerHashMap; //return the new HashMap
          * Returns the number of books in the library.
          * @return |b|, ie the number of books in b
        public int size()
             int numberOfBooks=bookTitleAndCharacterAndIntegerHashMap.size();
             return numberOfBooks;
         * Searches the library for an occurrence of a given book
         * @param target the name of a book to be searched for in the library
         * @return true if and only if the argument is already a book title in the library.
        public boolean contains(String target)
             boolean bookIsInLibrary=false;
             if(bookTitleAndCharacterAndIntegerHashMap.containsKey(target))
                  bookIsInLibrary = true;
             return bookIsInLibrary;
         * Returns the MultiSetOfChar that represents the occurrences of the individual characters
         * in the text of the book indicated by the argument.
         * @param target
         * @return MultiSetOfChar
        public MultiSetOfChar getFrequencies(String target)
             MultiSetOfChar frequencyMultiSetOfChar = bookTitleAndCharacterAndIntegerHashMap.get(target);
             return frequencyMultiSetOfChar;
         * Modifies the character occurrences associated with name to include one more occurrence of element.
         * @param name string of the name of the book
         * @param element character to add to the specified book
        public void add(String name, char element)
             bookTitleAndCharacterAndIntegerHashMap = inputIntoMap(name, element);
         * Modifies the character occurrences associated with name to include one less occurrence of element.
         * @param name string of the name of the book
         * @param element character to be removed from the specified book
         * @return true if and only if the book is modified.
        public boolean remove(String name, char element)
             boolean characterWasRemovedFromBook=false;
             //if the target character is in the map then remove it
              if(bookTitleAndCharacterAndIntegerHashMap.containsKey(name))
                   MultiSetOfChar keyAndValuePairs = bookTitleAndCharacterAndIntegerHashMap.get(name);
                   keyAndValuePairs.remove(element);
                   characterWasRemovedFromBook = true; //set answer to true because the HashMap was changed
              else //target does not exist in the HashMap
                   characterWasRemovedFromBook = false; //set answer to false because the HashMap was not changed
             return characterWasRemovedFromBook;
         * Returns a random character, chosen from the same distribution as the characters appear in the book.
         * For example, if 5% of the characters in "Alice in Wonderland" are an 'A', then this method should
         * return an 'A' about 5% of the time.
         * @param name string of the name of the book to search through and remove a character
         * @return true if and only if the argument is already a book title in the library.
         public char randomUniformChoose(String name)
            MultiSetOfChar keyAndValuePairs = bookTitleAndCharacterAndIntegerHashMap.get(name);
            char randomCharacter = keyAndValuePairs.randomUniformChoose();
              return randomCharacter; //return the random character pulled out
         public Collection<String> makeStringCollection()
              Collection<String> stringCollection = bookTitleAndCharacterAndIntegerHashMap.keySet();
              return stringCollection;
    }Third code:
    import java.util.HashMap;
    import java.util.Set;
    import java.util.Collection;
    import java.util.Random;
    * DenseMultiSetOfChar implements MultiSetOfChar.
    * @mathmodel b is a finite multiset
    * @mathdef
    *  |b| is the cardinality of b
    *  ||c,b|| is the number of occurrences of element c in b
    * @author Kyle Hiltner
    public class DenseMultiSetOfChar implements MultiSetOfChar
         private char characterInput=' ';
         private HashMap<Character, Integer> characterMap = new HashMap<Character, Integer>();
          * Create a new DenseMultiSetOfChar with zero argument
         DenseMultiSetOfChar()
              characterMap.clear(); //clear static HashMap
          * Create a new DenseMultiSetOfChar with the passed in value.
          * @param newChar character input to be added to the HashMap
         DenseMultiSetOfChar(char newChar)
              this.characterInput = newChar; //set characterInput to the value passed in
              characterMap = inputIntoMap(this.characterInput); //call private procedure to add characterInput to HashMap
          * Input the value from the creation of the DensneMultiSetOfChar into a HashMap.  If the key
          * already exists then the value associated with it is updated by one.
          * @param character a char to be used in forming the HashMap
          * @return characterMap
         private HashMap<Character, Integer> inputIntoMap(char character)
              //if the character is not in the HashMap then add it with the starting value of 1
              if(!characterMap.containsKey(character))
                   characterMap.put(character, 1); //input character and value
              else //character does exist
                   int value = characterMap.get(character); //get the value for the specified key
                   value++; //increase the value so as to show that another character was added
                   characterMap.put(character, value); //place the character and new value in the HashMap
              return characterMap; //return the new HashMap
          * Returns the number of elements in this multiset (ie its cardinality).
          * Note that since multisets can include duplicates, the cardinality may be
          * larger than the number of distinct elements. Also, the total number of
          * items in the multiset is bounded above by Integer.MAX_VALUE.
          * @return |b|, ie the cardinality of b
         public int getCardinality()
              int totalElementsInMap=0;
              Collection<Integer> integerCollection = characterMap.values(); //create a collection for easy iteration
              //iterate through each value in the HashMap and compute the total number of elements in the HashMap
              for(Integer valueFromCollection : integerCollection)
                   totalElementsInMap = totalElementsInMap + valueFromCollection; //compute new value of total values
              return totalElementsInMap; //return the final total value
          * Returns the number of occurrences of a given element in the multiset. A
          * simple identity relating getElementCount and getCardinality is that the
          * sum of getElementCount for each char is equal to the cardinality of the
          * set.
          * @param target
          *            char to be counted in the multiset
          * @return ||target,b||, ie the number of occurrences of target in b
         public int getElementCount(char target)
              int numberOfGivenCharacters=0; //set initial value
              //if the HashMap contains the target character then numberOfGivenCharacters is set to the value
              if(characterMap.containsKey(target))
                   numberOfGivenCharacters = characterMap.get(target); //set numberOfGivenCharacters to the value assigned to the target character
              return numberOfGivenCharacters; //return the value for the target character
          * Returns a set such that every element in the multiset is in the set (but
          * no duplicates). The cardinality of the returned set must be less than or
          * equal to |b|. The cardinality of the two are equal if and only if b
          * contains no duplicate elements.
          * @return a set of Character, s, such that: <br />
          *         (for all (Character)i in s : (char)i in b) and <br />
          *         (for all (char)i in b : (Character)i in s)
         public Set<Character> getElementSet()
              Set<Character> characterSet = characterMap.keySet(); //create a Set from the keys of characters in the HashMap     
              return characterSet; //return the character Set
          * Adds a single element to the multiset. This operation always increases
          * the cardinality of the multiset by 1, assuming that the maximum capacity
          * of Integer.MAX_VALUE has not been reached.
          * @param item
          *            the char to be added to b
          * @requires |b| < Integer.MAX_VALUE
          * @alters b
          * @ensures b = #b union {item}
         public void add(char item)
              characterMap = inputIntoMap(item); //call the private method to add new character (item) to the HashMap
          * Removes the target, if it is present in the multiset. The method returns
          * true if and only if it changes the multiset.
          * @param target
          *            the char to be removed
          * @alters b
          * @ensures (target not in #b) ==> (b = #b) <br />
          *          (target in #b) ==> (b union {target} = #b)
          * @return target in #b
         public boolean remove(char target)
              boolean answer=false; //set initial value to false
              //if the target character is in the map then remove it
              if(characterMap.containsKey(target))
                   int value = characterMap.get(target); //find the value associated with the target character
                   //if the value is 1 call remove from the HashMap and remove key and value
                   if(value == 1)
                        characterMap.remove(target); //remove key and value from the HashMap
                   else //value is greater than 1
                        value--; //decrease value to show removal
                        characterMap.put(target, value); //replace target character with new value back into the HashMap
                   answer = true; //set answer to true because the HashMap was changed
              else //target does not exist in the HashMap
                   answer = false; //set answer to false because the HashMap was not changed
              return answer; //return answer
          * Returns a char chosen randomly based on the contents of the multiset.
          * This operation does not remove the char from the multiset or change the
          * multiset in any way. In particular, the cardinality of the multiset is
          * the same before and after this method.
          * <p>
          * Characters should be returned with a random distribution equal to the
          * distribution of characters in the multiset. That is, for a character that
          * appears N times in a multiset of cardinality M, the probability of that
          * character being returned is N / M. For example, a multiset that contains
          * only the character 'a', possibly many times, would always result in an
          * 'a' being generated. On the other hand, a multiset with an equal number
          * of 'a' and 'b' elements would return an 'a' approximately half the time
          * and a 'b' the other half.
          * @requires |b| >= 1
          * @return char c with probability p, where: <br />
          *         p = ||c,b|| / |b|
         public char randomUniformChoose()
              char randomCharacter=' ';
              Random generator = new Random();
              int totalElementsInMap=0;
              Collection<Integer> integerCollection = characterMap.values(); //create a collection for easy iteration
              //iterate through each value in the HashMap and compute the total number of elements in the HashMap. 
              //Do this in case a remove call was made
              for(Integer valueFromCollection : integerCollection)
                   totalElementsInMap = totalElementsInMap + valueFromCollection; //compute new value of total values
              int randomInt = generator.nextInt(totalElementsInMap+1), lowerValue=0, upperValue=0;
              Collection<Character> keyCollection = characterMap.keySet();
              //iterate through each value in the HashMap and compute the total number of elements in the HashMap
              for(Character keyFromCollection : keyCollection)
                 upperValue = upperValue + characterMap.get(keyFromCollection);
                 if(randomInt == upperValue)
                      randomCharacter = keyFromCollection;
                 if(randomInt >= lowerValue && randomInt <= upperValue)
                      randomCharacter = keyFromCollection;
                 lowerValue = upperValue + 1;
              return randomCharacter; //return the random character pulled out
    }The Error:
    Exception in thread "main" java.lang.NullPointerException
         at DenseFrequencyLibrary.randomUniformChoose(DenseFrequencyLibrary.java:137)
         at DistributionPlagiarist.randomphrase(DistributionPlagiarist.java:146)
         at DistributionPlagiarist.main(DistributionPlagiarist.java:112)I will attempt to explain what this does in as few words as possible. For a breakdown of the lab go urlhttp://www.cse.ohio-state.edu/~paolo/teaching/494MJ/labs/lab8.shtml{url}. If you don't feel like reading that: THe program reads in some command line arguments. From there it reads from the file provided in the command line and creates "keys" from the specified length. From there I need to create a phrase of the specified length. If i am supposed to create more then one then i do. That is pretty much it. I can't figure out where (really why) the NullPointerException error is coming from.
    Help is appreciated!!

    Post the actual error text (copy and paste, don't "interpret" it) here.
    It should include a stack trace which references a line number of the program -
    unless you suppressed the trace, in which case change your error handling
    so that the trace is produced.
    Identify which program line in your post the error is pointing to so that we can match
    the error with your program, since your post doesn't have line numbers..
    Edited by: ChuckBing on Nov 16, 2007 7:19 PM
    Also - posting large amounts of code (as you did) will reduce the chance of anyone helping

  • Using a Switch statement for Infix to Prefix Expressions

    I am stuck on the numeric and operator portion of the switch statement...I have the problem also figured out in an if/else if statement and it works fine, but the requirements were for the following algorithm:
    while not end of expression
    switch next token of expression
    case space:
    case left parenthesis:
    skip it
    case numeric:
    push the string onto the stack of operands
    case operator:
    push the operator onto the stack of operators
    case right parenthesis:
    pop two operands from operand stack
    pop one operator from operator stack
    form a string onto operand stack
    push the string onto operand stack
    pop the final result off the operand stack
    I know that typically case/switch statement's can only be done via char and int's. As I said I am stuck and hoping to get some pointers. This is for a homework assignment but I am really hoping for a few pointers. I am using a linked stack class as that was also the requirements. Here is the code that I have:
       import java.io.*;
       import java.util.*;
       import java.lang.*;
    /*--------------------------- PUBLIC CLASS INFIXTOPREFIX --------------------------------------*/
    /*-------------------------- INFIX TO PREFIX EXPRESSIONS --------------------------------------*/
        public class infixToPrefix {
          private static LinkedStack operators = new LinkedStack();
          private static LinkedStack operands = new LinkedStack();
            // Class variable for keyboard input
          private static BufferedReader stdin = new BufferedReader(new InputStreamReader(System.in));
             // Repeatedly reads in infix expressions and evaluates them
           public static void main(String[] args) throws IOException {
          // variables
             String expression, response = "y";
          // obtain input of infix expression from user
             while (response.charAt(0) == 'y') {
                System.out.println("Enter a parenthesized infix expression.");          // prompt the user
                System.out.println("Example: ( ( 13 + 2 ) * ( 10 + ( 8 / 3 ) ) )");
                System.out.print("Or as: ((13+2)*(10+(8/3))):  ");
                expression = stdin.readLine();     // read input from the user
             // output prefix expression and ask user if they would like to continue          
                System.out.println("The Prefix expression is: " + prefix(expression));     // output expression
                System.out.println("Evaluate another? y or n: ");          // check with user for anymore expressions
                response = stdin.readLine();     // read input from user
                if (response.charAt(0) == 'n') {          // is user chooses n, output the statement
                   System.out.println("Thank you and have a great day!");
                }     // end if statement
             }     // end while statement
          }     // end method main
       /*------------- CONVERSION OF AN INFIX EXPRESSION TO A PREFIX EXPRESSION ------------*/ 
       /*--------------------------- USING A SWITCH STATEMENT ------------------------------*/
           private static String prefix(String expression) {
                // variables
             String symbol, operandA, operandB, operator, stringA, outcome;
               // initialize tokenizer
             StringTokenizer tokenizer = new StringTokenizer(expression, " +-*/() ", true);     
             while (tokenizer.hasMoreTokens()) {
                symbol = tokenizer.nextToken();     // initialize symbol     
                switch (expression) {
                   case ' ':
                      break;     // accounting for spaces
                   case '(':
                      break;     // skipping the left parenthesis
                   case (Character.isDigit(symbol.charAt(0))):      // case numeric
                      operands.push(symbol);                                   // push the string onto the stack of operands
                      break;
                   case (!symbol.equals(" ") && !symbol.equals("(")):     // case operator
                      operators.push(symbol);                                             // push the operator onto the stack of operators
                      break;
                   case ')':
                      operandA = (String)operands.pop();     // pop off first operand
                      operandB = (String)operands.pop();     // pop off second operand
                      operator = (String)operators.pop();     // pop off operator
                      stringA = operator + " " + operandB + " " + operandA;          // form the new string
                      operands.push(stringA);
                      break;
                }     // end switch statement
             }     // end while statement
             outcome = (String)operands.pop();     // pop off the outcome
             return outcome;     // return outcome
          }     // end method prefix
       }     // end class infixToPrefixAny help would be greatly appreciated!

    so, i did what flounder suggested:
             char e = expression.charAt(0);
             while (tokenizer.hasMoreTokens()) {
                symbol = tokenizer.nextToken();     // initialize symbol     
                switch (e) {
                   case ' ':
                      break;     // accounting for spaces
                   case '(':
                      break;     // skipping the left parenthesis
                   case '0':
                   case '1':
                   case '2':
                   case '3':
                   case '4':
                   case '5':
                   case '6':
                   case '7':
                   case '8':
                   case '9':
                      operands.push(symbol);     // push the string onto the stack of operands
                      break;                               // case numeric
                   case '+':
                   case '-':
                   case '*':
                   case '/':
                      operators.push(symbol);     // push the operator onto the stack of operators
                      break;                               // case operator
                   case ')':
                      operandA = (String)operands.pop();     // pop off first operand
                      operandB = (String)operands.pop();     // pop off second operand
                      operator = (String)operators.pop();     // pop off operator
                      stringA = operator + " " + operandB + " " + operandA;          // form the new string
                      operands.push(stringA);
                      break;
                   default:
                }     // end switch statement
             }     // end while statement
             outcome = (String)operands.pop();     // pop off the outcome
             return outcome;     // return outcomeafter this, I am able to compile the code free of errors and I am able to enter the infix expression, however, the moment enter is hit it provides the following errors:
    Exception in thread "main" java.lang.NullPointerException
         at LinkedStack$Node.access$100(LinkedStack.java:11)
         at LinkedStack.pop(LinkedStack.java:44)
         at infixToPrefix.prefix(infixToPrefix.java:119)
         at infixToPrefix.main(infixToPrefix.java:59)
    Any ideas as to why? I am still looking through seeing if I can't figure it out, but any suggestions? Here is the linked stack code:
        public class LinkedStack {
       /*--------------- LINKED LIST NODE ---------------*/
           private class Node {
             private Object data;
             private Node previous;
          }     // end class node
       /*--------------  VARIABLES --------------*/
          private Node top;
      /*-- Push Method: pushes object onto LinkedStack --*/     
           public void push(Object data) {
             Node newTop = new Node();
             newTop.data = data;
             newTop.previous = top;
             top = newTop;
          }     // end function push
       /*--- Pop Method: pop obejct off of LinkedStack ---*/
           public Object pop()      {
             Object data = top.data;
             top = top.previous;
             return data;
          }     // end function pop
       } // end class linked stackEdited by: drmsndrgns on Mar 12, 2008 8:10 AM
    Edited by: drmsndrgns on Mar 12, 2008 8:14 AM
    Edited by: drmsndrgns on Mar 12, 2008 8:26 AM

  • NullPointerException was thrown while extracting a value from an instance

    Dear all,
    We have got a null point exception during commit call. According to the stack trace shown below, it seems that it is a problem due to instance variable accessor. As we know toplink use reflection to access the instance variable value. I am curious whether the exception we got is related to any class-loader setting. Thanks a lot.
    =================
    Stack Trace:
    Exception [TOPLINK-69] (OracleAS TopLink - 10g (9.0.4.5) (Build 040930)): oracle
    .toplink.exceptions.DescriptorException
    Exception Description: A NullPointerException was thrown while extracting a valu
    e from the instance variable [versionID] in the object [com.oocl.csc.frm.pom.tes
    t.model.Company].
    Internal Exception: java.lang.NullPointerException
    Mapping: oracle.toplink.mappings.DirectToFieldMapping[versionID-->COMPANY.VERSIO
    NID]
    Descriptor: Descriptor(com.oocl.csc.frm.pom.test.model.Company --> [DatabaseTabl
    e(COMPANY)])
    at oracle.toplink.exceptions.DescriptorException.nullPointerWhileGetting
    ValueThruInstanceVariableAccessor(DescriptorException.java:1022)
    at oracle.toplink.internal.descriptors.InstanceVariableAttributeAccessor
    .getAttributeValueFromObject(InstanceVariableAttributeAccessor.java:68)
    at oracle.toplink.mappings.DatabaseMapping.getAttributeValueFromObject(D
    atabaseMapping.java:304)
    at oracle.toplink.mappings.DirectToFieldMapping.iterate(DirectToFieldMap
    ping.java:355)
    at oracle.toplink.internal.descriptors.ObjectBuilder.iterate(ObjectBuild
    er.java:1438)
    at oracle.toplink.internal.descriptors.DescriptorIterator.iterateReferen
    ceObjects(DescriptorIterator.java:258)
    at oracle.toplink.internal.descriptors.DescriptorIterator.startIteration
    On(DescriptorIterator.java:407)
    at oracle.toplink.publicinterface.UnitOfWork.discoverUnregisteredNewObje
    cts(UnitOfWork.java:1368)
    at oracle.toplink.publicinterface.UnitOfWork.discoverAllUnregisteredNewO
    bjects(UnitOfWork.java:1290)
    at oracle.toplink.publicinterface.UnitOfWork.assignSequenceNumbers(UnitO
    fWork.java:326)
    at oracle.toplink.publicinterface.UnitOfWork.collectAndPrepareObjectsFor
    Commit(UnitOfWork.java:664)
    at oracle.toplink.publicinterface.UnitOfWork.commitToDatabaseWithChangeS
    et(UnitOfWork.java:1130)
    at oracle.toplink.publicinterface.UnitOfWork.commitRootUnitOfWork(UnitOf
    Work.java:956)
    at oracle.toplink.publicinterface.UnitOfWork.commit(UnitOfWork.java:771)
    ====================
    ====================
    Mapping Description:
    <?xml version = '1.0' encoding = 'UTF-8'?>
    <project>
    <project-name>POM-TEST</project-name>
    <login>
    <database-login>
    <platform>oracle.toplink.oraclespecific.Oracle9Platform</platform>
    <driver-class>oracle.jdbc.driver.OracleDriver</driver-class>
    <connection-url>jdbc:oracle:thin:@sjcngdb2:1521:cdrfrmdv</connection-ur
    l>
    <user-name>pomowner</user-name>
    <password>BB742416276274A47F360CCDD2711570</password>
    <uses-native-sequencing>false</uses-native-sequencing>
    <sequence-preallocation-size>50</sequence-preallocation-size>
    <sequence-table>SEQUENCE</sequence-table>
    <sequence-name-field>SEQ_NAME</sequence-name-field>
    <sequence-counter-field>SEQ_COUNT</sequence-counter-field>
    <should-bind-all-parameters>false</should-bind-all-parameters>
    <should-cache-all-statements>false</should-cache-all-statements>
    <uses-byte-array-binding>true</uses-byte-array-binding>
    <uses-string-binding>false</uses-string-binding>
    <uses-streams-for-binding>false</uses-streams-for-binding>
    <should-force-field-names-to-upper-case>false</should-force-field-names
    -to-upper-case>
    <should-optimize-data-conversion>true</should-optimize-data-conversion>
    <should-trim-strings>true</should-trim-strings>
    <uses-batch-writing>false</uses-batch-writing>
    <uses-jdbc-batch-writing>true</uses-jdbc-batch-writing>
    <uses-external-connection-pooling>false</uses-external-connection-pooli
    ng>
    <uses-external-transaction-controller>false</uses-external-transaction-
    controller>
    <type>oracle.toplink.sessions.DatabaseLogin</type>
    </database-login>
    </login>
    <java-class>com.oocl.csc.frm.pom.test.model.Company</java-class>
    <tables>
    <table>COMPANY</table>
    </tables>
    <primary-key-fields>
    <field>COMPANY.COMPANY_KEY</field>
    </primary-key-fields>
    <descriptor-type-value>Normal</descriptor-type-value>
    <identity-map-class>oracle.toplink.internal.identitymaps.SoftCacheWeakI
    dentityMap</identity-map-class>
    <remote-identity-map-class>oracle.toplink.internal.identitymaps.SoftCac
    heWeakIdentityMap</remote-identity-map-class>
    <identity-map-size>100</identity-map-size>
    <remote-identity-map-size>100</remote-identity-map-size>
    <should-always-refresh-cache>false</should-always-refresh-cache>
    <should-always-refresh-cache-on-remote>false</should-always-refresh-cac
    he-on-remote>
    <should-only-refresh-cache-if-newer-version>false</should-only-refresh-
    cache-if-newer-version>
    <should-disable-cache-hits>false</should-disable-cache-hits>
    <should-disable-cache-hits-on-remote>false</should-disable-cache-hits-o
    n-remote>
    <alias>Company</alias>
    <copy-policy>
    <descriptor-copy-policy>
    <type>oracle.toplink.internal.descriptors.CopyPolicy</type>
    </descriptor-copy-policy>
    </copy-policy>
    <instantiation-policy>
    <descriptor-instantiation-policy>
    <type>oracle.toplink.internal.descriptors.InstantiationPolicy</ty
    pe>
    </descriptor-instantiation-policy>
    </instantiation-policy>
    <query-manager>
    <descriptor-query-manager>
    <existence-check>Check cache</existence-check>
    </descriptor-query-manager>
    </query-manager>
    <event-manager>
    <descriptor-event-manager empty-aggregate="true"/>
    </event-manager>
    <mappings>
    <database-mapping>
    <attribute-name>companyKey</attribute-name>
    <read-only>false</read-only>
    <field-name>COMPANY.COMPANY_KEY</field-name>
    <type>oracle.toplink.mappings.DirectToFieldMapping</type>
    </database-mapping>
    <database-mapping>
    <attribute-name>contact</attribute-name>
    <read-only>false</read-only>
    <reference-class>com.oocl.csc.frm.pom.test.model.Contact</referen
    ce-class>
    <is-private-owned>false</is-private-owned>
    <uses-batch-reading>false</uses-batch-reading>
    <indirection-policy>
    <mapping-indirection-policy>
    <type>oracle.toplink.internal.indirection.NoIndirectionPoli
    cy</type>
    </mapping-indirection-policy>
    </indirection-policy>
    <uses-joining>false</uses-joining>
    <foreign-key-fields>
    <field>COMPANY.CONTACT_OID</field>
    </foreign-key-fields>
    <source-to-target-key-field-associations>
    <association>
    <association-key>COMPANY.CONTACT_OID</association-key>
    <association-value>CONTACT.POID</association-value>
    </association>
    </source-to-target-key-field-associations>
    <type>oracle.toplink.mappings.OneToOneMapping</type>
    </database-mapping>
    <database-mapping>
    <attribute-name>createdBy</attribute-name>
    <read-only>false</read-only>
    <field-name>COMPANY.CREATED_BY</field-name>
    <type>oracle.toplink.mappings.DirectToFieldMapping</type>
    </database-mapping>
    <database-mapping>
    <attribute-name>creationClientID</attribute-name>
    <read-only>false</read-only>
    <field-name>COMPANY.CREATION_CLIENTID</field-name>
    <type>oracle.toplink.mappings.DirectToFieldMapping</type>
    </database-mapping>
    <database-mapping>
    <attribute-name>creationTime</attribute-name>
    <read-only>false</read-only>
    <field-name>COMPANY.CREATION_TIME</field-name>
    <type>oracle.toplink.mappings.DirectToFieldMapping</type>
    </database-mapping>
    <database-mapping>
    <attribute-name>employeeList</attribute-name>
    <read-only>false</read-only>
    <reference-class>com.oocl.csc.frm.pom.test.model.Person</referenc
    e-class>
    <is-private-owned>false</is-private-owned>
    <uses-batch-reading>false</uses-batch-reading>
    <indirection-policy>
    <mapping-indirection-policy>
    <type>oracle.toplink.internal.indirection.NoIndirectionPoli
    cy</type>
    </mapping-indirection-policy>
    </indirection-policy>
    <container-policy>
    <mapping-container-policy>
    <container-class>com.oocl.csc.frm.pom.impl.FWPersistentArra
    yList</container-class>
    <type>oracle.toplink.internal.queryframework.ListContainerP
    olicy</type>
    </mapping-container-policy>
    </container-policy>
    <relation-table>EMPLOYEMENT</relation-table>
    <source-key-fields>
    <field>COMPANY.COMPANY_KEY</field>
    </source-key-fields>
    <source-relation-key-fields>
    <field>EMPLOYEMENT.EMPLOYER_KEY</field>
    </source-relation-key-fields>
    <target-key-fields>
    <field>PERSON.POID</field>
    </target-key-fields>
    <target-relation-key-fields>
    <field>EMPLOYEMENT.EMPLOYEE_ID</field>
    </target-relation-key-fields>
    <type>oracle.toplink.mappings.ManyToManyMapping</type>
    </database-mapping>
    <database-mapping>
    <attribute-name>lastUpdateClientID</attribute-name>
    <read-only>false</read-only>
    <field-name>COMPANY.LAST_UPDATE_CLIENTID</field-name>
    <type>oracle.toplink.mappings.DirectToFieldMapping</type>
    </database-mapping>
    <database-mapping>
    <attribute-name>lastUpdatedBy</attribute-name>
    <read-only>false</read-only>
    <field-name>COMPANY.LAST_UPDATED_BY</field-name>
    <type>oracle.toplink.mappings.DirectToFieldMapping</type>
    </database-mapping>
    <database-mapping>
    <attribute-name>lastUpdateTime</attribute-name>
    <read-only>false</read-only>
    <field-name>COMPANY.LAST_UPDATE_TIME</field-name>
    <type>oracle.toplink.mappings.DirectToFieldMapping</type>
    </database-mapping>
    <database-mapping>
    <attribute-name>name</attribute-name>
    <read-only>false</read-only>
    <field-name>COMPANY.NAME</field-name>
    <type>oracle.toplink.mappings.DirectToFieldMapping</type>
    </database-mapping>
    <database-mapping>
    <attribute-name>partner</attribute-name>
    <read-only>false</read-only>
    <reference-class>com.oocl.csc.frm.pom.test.model.Company</referen
    ce-class>
    <is-private-owned>false</is-private-owned>
    <uses-batch-reading>false</uses-batch-reading>
    <indirection-policy>
    <mapping-indirection-policy>
    <type>oracle.toplink.internal.indirection.NoIndirectionPoli
    cy</type>
    </mapping-indirection-policy>
    </indirection-policy>
    <uses-joining>false</uses-joining>
    <foreign-key-fields>
    <field>COMPANY.PARTNER</field>
    </foreign-key-fields>
    <source-to-target-key-field-associations>
    <association>
    <association-key>COMPANY.PARTNER</association-key>
    <association-value>COMPANY.COMPANY_KEY</association-value>
    </association>
    </source-to-target-key-field-associations>
    <type>oracle.toplink.mappings.OneToOneMapping</type>
    </database-mapping>
    <database-mapping>
    <attribute-name>persistentCtxt</attribute-name>
    <read-only>false</read-only>
    <reference-class>com.oocl.csc.frm.pom.impl.FWPOMPersistentContext
    </reference-class>
    <is-null-allowed>false</is-null-allowed>
    <aggregate-to-source-field-name-associations>
    <association>
    <association-key>OWNERID</association-key>
    <association-value>COMPANY.OWNERID</association-value>
    </association>
    <association>
    <association-key>ROOTID</association-key>
    <association-value>COMPANY.ROOTID</association-value>
    </association>
    </aggregate-to-source-field-name-associations>
    <type>oracle.toplink.mappings.AggregateObjectMapping</type>
    </database-mapping>
    <database-mapping>
    <attribute-name>poid</attribute-name>
    <read-only>false</read-only>
    <field-name>COMPANY.POID</field-name>
    <type>oracle.toplink.mappings.DirectToFieldMapping</type>
    </database-mapping>
    <database-mapping>
    <attribute-name>version</attribute-name>
    <read-only>false</read-only>
    <field-name>COMPANY.VERSION</field-name>
    <type>oracle.toplink.mappings.DirectToFieldMapping</type>
    </database-mapping>
    <database-mapping>
    <attribute-name>versionID</attribute-name>
    <read-only>false</read-only>
    <field-name>COMPANY.VERSIONID</field-name>
    <type>oracle.toplink.mappings.DirectToFieldMapping</type>
    </database-mapping>
    </mappings>
    <type>oracle.toplink.publicinterface.Descriptor</type>
    </descriptor>
    </descriptors>
    </project>
    ====================
    ====================
    Session Creation Method:
    SessionBroker broker = (SessionBroker) manager.getSession(brokerName, Thread.currentThread().getContextClassLoader());
    broker.getLogin().getPlatform().getConversionManager().setLoader(Thread.currentThread().getContextClassLoader());
    ====================
    ===================
    Class Hierarchy:
    Object extends> ..xxx.. extends> FWObject extends> Company
    The problematic attribute -- versionID -- is defined at "FWObject" level.
    ===================
    ===================
    Environment Configuration:
    Application Server version: 10.1.2
    TopLink version : 9.0.4.5
    TopLink classpath: specified at container level
    FWObject classpath: specified at container level
    Company classpath: specified at application level
    ===================
    Thanks and regards,
    William

    Dear All,
    We have loaded the toplink.jar to container level instead of application level. Don't know whether it is a possible source of error. Moreover, what is the purpose of loading antlr.jar? What is this jar for?
    Thanks and regards,
    William

  • Error while saving state in 'client' , in ADF faces application

    Thank you for reading my post
    I have an ADF faces application and i get this error and my application does not function correctly , does any one has an idea ?
    thanks
    06/10/17 17:34:38.15 10.1.3.1.0 Started
    06/10/17 17:34:55.546 web2: 10.1.3.1.0 Started
    06/10/17 17:45:49.531 web2: Servlet error
    java.lang.NullPointerException
         at com.sun.faces.context.ExternalContextImpl.dispatch(ExternalContextImpl.java:322)
         at com.sun.faces.application.ViewHandlerImpl.renderView(ViewHandlerImpl.java:130)
         at oracle.adfinternal.view.faces.application.ViewHandlerImpl.renderView(ViewHandlerImpl.java:157)
         at com.sun.faces.lifecycle.RenderResponsePhase.execute(RenderResponsePhase.java:87)
         at com.sun.faces.lifecycle.LifecycleImpl.phase(LifecycleImpl.java:200)
         at com.sun.faces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:117)
         at javax.faces.webapp.FacesServlet.service(FacesServlet.java:198)
         at com.evermind[Oracle Containers for J2EE 10g (10.1.3.1.0) ].server.http.ResourceFilterChain.doFilter(ResourceFilterChain.java:64)
         at oracle.adfinternal.view.faces.webapp.AdfFacesFilterImpl._invokeDoFilter(AdfFacesFilterImpl.java:367)
         at oracle.adfinternal.view.faces.webapp.AdfFacesFilterImpl._doFilterImpl(AdfFacesFilterImpl.java:336)
         at oracle.adfinternal.view.faces.webapp.AdfFacesFilterImpl.doFilter(AdfFacesFilterImpl.java:196)
         at oracle.adf.view.faces.webapp.AdfFacesFilter.doFilter(AdfFacesFilter.java:87)
         at com.evermind[Oracle Containers for J2EE 10g (10.1.3.1.0) ].server.http.ServletRequestDispatcher.invoke(ServletRequestDispatcher.java:621)
         at com.evermind[Oracle Containers for J2EE 10g (10.1.3.1.0) ].server.http.ServletRequestDispatcher.forwardInternal(ServletRequestDispatcher.java:368)
         at com.evermind[Oracle Containers for J2EE 10g (10.1.3.1.0) ].server.http.HttpRequestHandler.doProcessRequest(HttpRequestHandler.java:866)
         at com.evermind[Oracle Containers for J2EE 10g (10.1.3.1.0) ].server.http.HttpRequestHandler.processRequest(HttpRequestHandler.java:448)
         at com.evermind[Oracle Containers for J2EE 10g (10.1.3.1.0) ].server.http.HttpRequestHandler.serveOneRequest(HttpRequestHandler.java:216)
         at com.evermind[Oracle Containers for J2EE 10g (10.1.3.1.0) ].server.http.HttpRequestHandler.run(HttpRequestHandler.java:117)
         at com.evermind[Oracle Containers for J2EE 10g (10.1.3.1.0) ].server.http.HttpRequestHandler.run(HttpRequestHandler.java:110)
         at oracle.oc4j.network.ServerSocketReadHandler$SafeRunnable.run(ServerSocketReadHandler.java:260)
         at com.evermind[Oracle Containers for J2EE 10g (10.1.3.1.0) ].util.ReleasableResourcePooledExecutor$MyWorker.run(ReleasableResourcePooledExecutor.java:303)
         at java.lang.Thread.run(Thread.java:619)
    06/10/17 17:46:02.703 web2: Servlet error
    javax.servlet.jsp.JspException: Error while saving state in 'client': 'An established connection was aborted by the software in your host machine'.
         at com.sun.faces.taglib.jsf_core.ViewTag.doAfterBody(ViewTag.java:206)
         at _index._jspService(_index.java:473)
         at com.orionserver[Oracle Containers for J2EE 10g (10.1.3.1.0) ].http.OrionHttpJspPage.service(OrionHttpJspPage.java:59)
         at oracle.jsp.runtimev2.JspPageTable.service(JspPageTable.java:453)
         at oracle.jsp.runtimev2.JspServlet.internalService(JspServlet.java:591)
         at oracle.jsp.runtimev2.JspServlet.service(JspServlet.java:515)
         at javax.servlet.http.HttpServlet.service(HttpServlet.java:856)
         at com.evermind[Oracle Containers for J2EE 10g (10.1.3.1.0) ].server.http.ServletRequestDispatcher.invoke(ServletRequestDispatcher.java:711)
         at com.evermind[Oracle Containers for J2EE 10g (10.1.3.1.0) ].server.http.ServletRequestDispatcher.forwardInternal(ServletRequestDispatcher.java:368)
         at com.evermind[Oracle Containers for J2EE 10g (10.1.3.1.0) ].server.http.ServletRequestDispatcher.unprivileged_forward(ServletRequestDispatcher.java:287)
         at com.evermind[Oracle Containers for J2EE 10g (10.1.3.1.0) ].server.http.ServletRequestDispatcher.access$100(ServletRequestDispatcher.java:50)
         at com.evermind[Oracle Containers for J2EE 10g (10.1.3.1.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.1.0) ].server.http.ServletRequestDispatcher.forward(ServletRequestDispatcher.java:198)
         at com.sun.faces.context.ExternalContextImpl.dispatch(ExternalContextImpl.java:322)
         at com.sun.faces.application.ViewHandlerImpl.renderView(ViewHandlerImpl.java:130)
         at oracle.adfinternal.view.faces.application.ViewHandlerImpl.renderView(ViewHandlerImpl.java:157)
         at com.sun.faces.lifecycle.RenderResponsePhase.execute(RenderResponsePhase.java:87)
         at com.sun.faces.lifecycle.LifecycleImpl.phase(LifecycleImpl.java:200)
         at com.sun.faces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:117)
         at javax.faces.webapp.FacesServlet.service(FacesServlet.java:198)
         at com.evermind[Oracle Containers for J2EE 10g (10.1.3.1.0) ].server.http.ResourceFilterChain.doFilter(ResourceFilterChain.java:64)
         at oracle.adfinternal.view.faces.webapp.AdfFacesFilterImpl._invokeDoFilter(AdfFacesFilterImpl.java:367)
         at oracle.adfinternal.view.faces.webapp.AdfFacesFilterImpl._doFilterImpl(AdfFacesFilterImpl.java:336)
         at oracle.adfinternal.view.faces.webapp.AdfFacesFilterImpl.doFilter(AdfFacesFilterImpl.java:196)
         at oracle.adf.view.faces.webapp.AdfFacesFilter.doFilter(AdfFacesFilter.java:87)
         at com.evermind[Oracle Containers for J2EE 10g (10.1.3.1.0) ].server.http.EvermindFilterChain.doFilter(EvermindFilterChain.java:15)
         at oracle.adf.model.servlet.ADFBindingFilter.doFilter(ADFBindingFilter.java:167)
         at com.evermind[Oracle Containers for J2EE 10g (10.1.3.1.0) ].server.http.ServletRequestDispatcher.invoke(ServletRequestDispatcher.java:619)
         at com.evermind[Oracle Containers for J2EE 10g (10.1.3.1.0) ].server.http.ServletRequestDispatcher.forwardInternal(ServletRequestDispatcher.java:368)
         at com.evermind[Oracle Containers for J2EE 10g (10.1.3.1.0) ].server.http.HttpRequestHandler.doProcessRequest(HttpRequestHandler.java:866)
         at com.evermind[Oracle Containers for J2EE 10g (10.1.3.1.0) ].server.http.HttpRequestHandler.processRequest(HttpRequestHandler.java:448)
         at com.evermind[Oracle Containers for J2EE 10g (10.1.3.1.0) ].server.http.HttpRequestHandler.serveOneRequest(HttpRequestHandler.java:216)
         at com.evermind[Oracle Containers for J2EE 10g (10.1.3.1.0) ].server.http.HttpRequestHandler.run(HttpRequestHandler.java:117)
         at com.evermind[Oracle Containers for J2EE 10g (10.1.3.1.0) ].server.http.HttpRequestHandler.run(HttpRequestHandler.java:110)
         at oracle.oc4j.network.ServerSocketReadHandler$SafeRunnable.run(ServerSocketReadHandler.java:260)
         at com.evermind[Oracle Containers for J2EE 10g (10.1.3.1.0) ].util.ReleasableResourcePooledExecutor$MyWorker.run(ReleasableResourcePooledExecutor.java:303)
         at java.lang.Thread.run(Thread.java:619)

    StateManagerImpl.saveSerializedView tries to let UIViewRoot be a session
    attribute and the error message says it should be serializable; certainly it' not.
    I think HttpSession.setAttribute does not claim the object should be serializable.
    I don't know why apache's StandardSession.setAttribute claims so.

  • Trying to write an if statement around the return value of a CANCEL_OPTION

    I am writing a program that takes an input String using JOptionPane. The String can be made of only letters of the A-Z alphabet and the space character. I have written an error-checking loop that will pop another input box up along with an error message if any invalid character is detected. The input box has an 'ok' button and a 'cancel' button. As it is, if you hit cancel, the program crashes and you get a NullPointerException. All I want to do is place an if statement inside of the error-checking loop, immediatly after the code to pop up the second input box, that simply does System.exit() and exits the program correctly(rather than crashing) if 'cancel' is clicked.
    My attempt at such an if statement is visible in the following code(letter is a boolean variable defined earlier, and message is the input String that has already been read in):
                   letter = isValidMessage(message);
              while(!letter)
                   message = JOptionPane.showInputDialog(null, "Message must contain only A-Z, a-z, or space character...");
                            if(JOptionPane.CANCEL_OPTION > 0  //or ==0 or ==1 or ==2, nothing works//)
                                JOptionPane.showMessageDialog(null, "No valid message entered - program will terminate...");
                                System.exit(JOptionPane.CANCEL_OPTION);
                   letter = isValidMessage(message);
                    }The if statement doesn't work correctly. If you click 'cancel' when the input box comes up, the program does terminate as it is supposed to. The problem is that if I type something in the box and click 'ok', it also causes the program to terminate rather than continuing. I've tried changing the > to ==. I've tried changing 0 to 1 to 2 to -1(I really am not sure which int return value of CANCEL_OPTION corresponds to which event). I think once I got to do the exact opposite...that is to say, it would continue on with the program whether I clicked 'cancel' or 'ok'. Which is equally bad. I don't know what I'm doing wrong.
    It's probably something simple that I'm just overlooking.

    Well, here's what CANCEL_OPTION is, according to the JOptionPane class:
    /** Return value from class method if CANCEL is chosen. */
        public static final int         CANCEL_OPTION = 2;However, I believe you're going about this in the wrong way.
    With JOptionPane, whenever you show a dialog, it usually returns whatever OPTION the user chose.
    For instance,
        int choice = JOptionPane.showConfirmDialog(parentComponent, "hello");That will bring up a dialog centered on parentComponent, with a message of "hello".
    It will have the default options (YES_NO_OPTION).
    What it returns is the option the user chose.
    There are 4 possible things it can return:
    YES_OPTION, when user clicks "Yes"
    NO_OPTION, when user clicks "No"
    ERROR_OPTION, when an unforseen error occurs and the dialog closes
    CANCEL_OPTION, when the user clicks "Cancel" (if that OPTION type were being used), or if they close the dialog
    So this is how you would check for CANCEL_OPTION:
        int choice = JOptionPane.showConfirmDialog(parentComponent, "hello");
        if (choice == JOptionPane.CANCEL_OPTION) {
            // User cancelled
        else if (choice == JOptionPane.YES_OPTION) {
            // User chose yes
        // EtcSo you see, going about it like this:
    if(JOptionPane.CANCEL_OPTION > 0  //or ==0 or ==1 or ==2, nothing works//)Is really the wrong way, because you're not checking what the user DID, but just what the constant variable "CANCEL_OPTION" is.
    However, it seems as if you're in a unique situation where you don't want the OPTION chosen by the user, but an input String.
    This is all well and good, but I think this limits how you can interact with the user, as the "showInputDialog" methods return the String the user input- not the OPTION they chose, and you need to use both.
    What I've done in the past is created a simple JPanel with its own JTextField.
    I pass the JPanel in as the "message" parameter of a showConfirmDialog call, and get both the user input and their chosen OPTION based off a getText call to the JTextField and the OPTION constant returned by showConfirmDialog.
    Basically,
    JPanel promptPanel = new JPanel(new BorderLayout());
    JTextField promptField = new JTextField();
    promptPanel.add(promptField, BorderLayout.CENTER);
    int choice = JOptionPane.showConfirmDialog(parentComponent, promptPanel, "Input", JOptionPane.OK_CANCEL_OPTION, JOptionPane.QUESTION_MESSAGE);
    if (choice == JOptionPane.OK_OPTION) {
       // User chose OK, see if invalid characters were entered
       String input = promptField.getText();
    else if (choice == JOptionPane.CANCEL_OPTION) {
       // User cancelled
    }Hope that helps.
    (note that I'm unsure if showConfirmDialog can accept OK_CANCEL_OPTION as its OPTION parameter, as it says only YES_NO_OPTION and YES_NO_CANCEL_OPTION can be used, but I seem to remember using it in the past. if OK_CANCEL_OPTION doesn't want to work, then use one of the other two and adjust your if statements accordingly)
    Cheers!
    Edited by: LukeFoss on Oct 9, 2007 10:39 PM

  • Fatal Error and NullPointerException in Oracle XML Transformer

    Hi,
    I'm building a dom tree in memory with oracle xml parser. Then I transform the dom document into a string to send xml to the client. But I get an fatal error on calling transform.
    I don't know what could be the problem, because apache and weblogic parser works, an when I create a dom document with org.w3c.dom elements and statements then the xml document can't be invalid,
    because the document implementation would throw an exception if wrong nodes or something like this should be inserted...
    I'm using oracle xml parser 9.2.0.4 for java, bea weblogic 7.0 and win2k.
    Thanks for help.
    XSL-1900: (Fatal Error) An internal error condition occurred.
    javax.xml.transform.TransformerException: XSL-1900: (Fatal Error) An internal error condition occurred.
    at oracle.xml.jaxp.JXTransformer.reportException(JXTransformer.java:681)
    at oracle.xml.jaxp.JXTransformer.transform(JXTransformer.java:309)
    java.lang.NullPointerException
    at oracle.xml.parser.v2.XSLSAXPrintDriver.printAttributes(XSLSAXPrintDriver.java:394)
    at oracle.xml.parser.v2.XSLSAXPrintDriver.startElement(XSLSAXPrintDriver.java:322)
    at oracle.xml.parser.v2.XMLElement.reportSAXEvents(XMLElement.java:993)
    at oracle.xml.parser.v2.XMLNode.reportChildSAXEvents(XMLNode.java:1014)
    at oracle.xml.parser.v2.XMLDocument.reportSAXEvents(XMLDocument.java:942)
    at oracle.xml.jaxp.JXTransformer.transform(JXTransformer.java:294)

    Hi,
    I'm having that problem to:
    I'm getting the following exception
    javax.xml.transform.TransformerException: XSL-1900: (Fatal Error) An internal error condition occurred.
         at oracle.xml.jaxp.JXTransformer.reportException(JXTransformer.java:723)
         at oracle.xml.jaxp.JXTransformer.transform(JXTransformer.java:340)
         at com.ac.mqif.control.Handler.handleLong(Handler.java:835)
         at com.ac.mqif.control.Handler.run(Handler.java:951)
    Caused by: java.lang.NullPointerException
         at oracle.xml.parser.v2.XPathStep.getSelectedNodes(XPathStep.java:380)
         at oracle.xml.parser.v2.PathExpr.getValue(XSLNodeSetExpr.java:483)
         at oracle.xml.parser.v2.XSLExprBase.getStringValue(XSLExprBase.java:363)
         at oracle.xml.parser.v2.XSLValueOf.processAction(XSLValueOf.java:99)
         at oracle.xml.parser.v2.XSLNode.processChildren(XSLNode.java:367)
         at oracle.xml.parser.v2.XSLTemplate.processAction(XSLTemplate.java:199)
         at oracle.xml.parser.v2.XSLApplyTemplates.processAction(XSLApplyTemplates.java:214)
         at oracle.xml.parser.v2.XSLApplyTemplates.processAction(XSLApplyTemplates.java:207)
         at oracle.xml.parser.v2.XSLApplyTemplates.processAction(XSLApplyTemplates.java:207)
         at oracle.xml.parser.v2.XSLApplyTemplates.processAction(XSLApplyTemplates.java:120)
         at oracle.xml.parser.v2.XSLNode.processChildren(XSLNode.java:367)
         at oracle.xml.parser.v2.XSLTemplate.processAction(XSLTemplate.java:199)
         at oracle.xml.parser.v2.XSLStylesheet.execute(XSLStylesheet.java:471)
         at oracle.xml.parser.v2.XSLStylesheet.execute(XSLStylesheet.java:448)
         at oracle.xml.parser.v2.XSLProcessor.processXSL(XSLProcessor.java:246)
         at oracle.xml.jaxp.JXTransformer.transform(JXTransformer.java:327)
         ... 2 more
    when using a stylesheet which has a template match condition of more than 1600 characters.
    The second thing is that the Oracle XML transformer is
    NOT threadsafe. I was using several threads using different templates to transform an incoming XML simultaneously but was ALWAYS getting internal XSL errors
    and Nullpointer Exceptions. I solved this by synchronizing the transformation, but I don't like it.
    I'm using the following versions on Windows XP:
    Oracle IDE: 9.0.3.10.35
    Business Components Version: 9.0.3.10.7
    SCM Support Version: 9.0.3.9.4
    Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.2-b28)
    Thanx,
    Ellcrys

  • Com.sap.engine.interfaces.messaging.api.exception.MessagingException: java.lang.NullPointerException in sap pi

    Hi all,
    I am working on SAP PI 7.3.1 SP09. Currently we have interfaces which uses 50200 port. I have created a http destination from nwa pointing to https://....url. So all of a sudden all the interfaces went to error state. After debugging i found that the port 50200 is replaced with 50201which is https port. After changing the port to initial value ie., 50200 all interfaces are working fine except the one which were pointing to https url and they are showing the following error description.
    <SAP:Error SOAP:mustUnderstand="1" xmlns:SAP="http://sap.com/xi/XI/Message/30" xmlns:SOAP="http://schemas.xmlsoap.org/soap/envelope/">
    <SAP:Category>XIAdapterFramework</SAP:Category>  
    <SAP:Code area="MESSAGE">GENERAL</SAP:Code>  
    <SAP:P1 />  
    <SAP:P2 />  
    <SAP:P3 />  
    <SAP:P4 />  
    <SAP:AdditionalText>com.sap.engine.interfaces.messaging.api.exception.MessagingException: java.lang.NullPointerException</SAP:AdditionalText>  
    <SAP:Stack />  
    <SAP:Retry>M</SAP:Retry>  
    </SAP:Error>
    The entire trace is as follows:
    <?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
    - <!--
    Inbound Message
    --> 
    - <SAP:Trace xmlns:SAP="http://sap.com/xi/XI/Message/30"> 
    <Trace level="1" type="T">Party normalization: sender</Trace>  
    <Trace level="3" type="T">Sender scheme external =</Trace>  
    <Trace level="3" type="T">Sender agency external =</Trace>  
    <Trace level="3" type="T">Sender party external =</Trace>  
    <Trace level="3" type="T">Sender party normalized =</Trace>  
    <Trace level="1" type="T">Determining the sender agreement</Trace>  
    <Trace level="3" type="T">##### DG: 3</Trace>  
    <Trace level="3" type="T">##### TO: 3</Trace>  
    <Trace level="1" type="T">XMB was called with URL /sap/xi/engine/?type=entry</Trace>  
    <Trace level="2" type="T">Request Line = POST /sap/xi/engine/?type=entry HTTP/1.0</Trace>  
    <Trace level="2" type="T">Host = 10.66.14.150:50200</Trace>  
    <Trace level="2" type="T">Server protocol = HTTP/1.0</Trace>  
    <Trace level="1" type="T">Remote address = 10.66.10.160</Trace>  
    <Trace level="1" type="T">User = SFUSER</Trace>  
    <Trace level="1" type="T">Process ID: 760</Trace>  
    <Trace level="1" type="T">Work Process ID: 10</Trace>  
    <Trace level="1" type="T">Message ID = 53BEFE7146893BD5E10000000A420AA0</Trace>  
    - <Trace level="1" type="B" name="CL_XMS_MAIN-ENTER_XMS"> 
    <Trace level="1" type="T">CL_XMS_MAIN->DETERMINE_EXT_PID: CENTRAL</Trace>  
    <Trace level="3" type="T">##### DG: 3</Trace>  
    <Trace level="3" type="T">##### TO: 3</Trace>  
    <Trace level="1" type="T">Hop engine name = is.02.devpipd1</Trace>  
    <Trace level="1" type="T">Hop engine type = IS</Trace>  
    <Trace level="1" type="T">Hop adapter name = XI</Trace>  
    <Trace level="1" type="T">Hop adapter namespace = http://sap.com/xi/XI/System</Trace>  
    - <Trace level="1" type="B" name="CL_XMS_TROUBLESHOOT-ENTER_PLSRV"> 
    <Trace level="3" type="T">No triggers found. OK.</Trace>  
    </Trace>
    <Trace level="3" type="T">system-ID = PD1</Trace>  
    <Trace level="3" type="T">client = 001</Trace>  
    <Trace level="3" type="T">language = E</Trace>  
    <Trace level="3" type="T">user = SFUSER</Trace>  
    <Trace level="1" type="Timestamp">2014-07-10T08:56:37Z INDIA</Trace>  
    <Trace level="1" type="T">ACL Check is performed</Trace>  
    <Trace level="1" type="T">XML validation is executed</Trace>  
    </Trace>
    <Trace level="1" type="B" name="CL_XMS_MAIN-CALL_UC_EXECUTE" />  
    - <!-- ************************************
    -->   
    <Trace level="1" type="T">PLNAME = CENTRAL</Trace>  
    <Trace level="1" type="T">QOS = BE</Trace>  
    <Trace level="1" type="B" name="CL_XMS_MAIN-CALL_PIPELINE_SYNC" />  
    - <!-- ************************************
    -->   
    <Trace level="1" type="T">>>>PID delete old pid determination coding</Trace>  
    <Trace level="3" type="T">Pipeline-Elements for pipeline SAP_CENTRAL</Trace>  
    <Trace level="3" type="T">0001 PLSRV_XML_VALIDATION_RQ_INB</Trace>  
    <Trace level="3" type="T">0002 PLSRV_RECEIVER_DETERMINATION</Trace>  
    <Trace level="3" type="T">0003 PLSRV_INTERFACE_DETERMINATION</Trace>  
    <Trace level="3" type="T">0004 PLSRV_RECEIVER_MESSAGE_SPLIT</Trace>  
    <Trace level="3" type="T">0005 PLSRV_MAPPING_REQUEST</Trace>  
    <Trace level="3" type="T">0006 PLSRV_OUTBOUND_BINDING</Trace>  
    <Trace level="3" type="T">0007 PLSRV_VIRUS_SCAN_RQ_OUT</Trace>  
    <Trace level="3" type="T">0008 PLSRV_XML_VALIDATION_RQ_OUT</Trace>  
    <Trace level="3" type="T">0009 PLSRV_CALL_ADAPTER</Trace>  
    <Trace level="3" type="T">0010 PLSRV_VIRUS_SCAN_RS_INB</Trace>  
    <Trace level="3" type="T">0011 PLSRV_XML_VALIDATION_RS_INB</Trace>  
    <Trace level="3" type="T">0012 PLSRV_MAPPING_RESPONSE</Trace>  
    <Trace level="3" type="T">0013 PLSRV_VIRUS_SCAN_RS_OUT</Trace>  
    <Trace level="3" type="T">0014 PLSRV_XML_VALIDATION_RS_OUT</Trace>  
    <Trace level="3" type="T">system-ID = PD1</Trace>  
    <Trace level="3" type="T">client = 001</Trace>  
    <Trace level="3" type="T">language = E</Trace>  
    <Trace level="3" type="T">user = SFUSER</Trace>  
    - <Trace level="1" type="B" name="CL_XMS_MESSAGE_PERS_MAN-WRITE_MESSAGE_LOG_TO_PERSIST"> 
    <Trace level="2" type="T">Persisting original message</Trace>  
    <Trace level="3" type="T">Message-Version = 000</Trace>  
    <Trace level="3" type="T">Pipeline CENTRAL</Trace>  
    </Trace>
    <Trace level="3" type="Timestamp">2014-07-10T08:56:37Z INDIA Begin of pipeline processing PLSRVID = CENTRAL</Trace>  
    - <Trace level="1" type="B" name="PLSRV_XML_VALIDATION_RQ_INB"> 
    <Trace level="3" type="Timestamp">2014-07-10T08:56:37Z INDIA Start of pipeline service processing PLSRVID= PLSRV_XML_VALIDATION_RQ_INB</Trace>  
    - <Trace level="1" type="B" name="CL_XMS_MAIN-CALL_PLSRV"> 
    <Trace level="3" type="T">Calling pipeline service: PLSRV_XML_VALIDATION_RQ_INB</Trace>  
    <Trace level="3" type="T">Reading Pipeline-Service specification...</Trace>  
    <Trace level="3" type="T">PLSRVTYPE =</Trace>  
    <Trace level="3" type="T">ADRESSMOD = LOCAL</Trace>  
    <Trace level="3" type="T">P_CLASS = CL_XMS_PLSRV_VALIDATION</Trace>  
    <Trace level="3" type="T">P_IFNAME = IF_XMS_PLSRV</Trace>  
    <Trace level="3" type="T">P_METHOD = ENTER_PLSRV</Trace>  
    <Trace level="3" type="T" />  
    - <Trace level="1" type="B" name="CL_XMS_MAIN-CALL_PLSRV_LOCAL"> 
    - <Trace level="1" type="B" name="CL_XMS_PLSRV_VALIDATION-ENTER_PLSRV"> 
    <Trace level="3" type="T">Pipeline Service = PLSRV_XML_VALIDATION_RQ_INB</Trace>  
    <Trace level="3" type="T">Skip Inbound Validation =</Trace>  
    <Trace level="3" type="T">Skip Outbound Validation =</Trace>  
    <Trace level="3" type="T">Area = XML_VALIDATION_INB</Trace>  
    <Trace level="1" type="T">Reading sender agreement</Trace>  
    <Trace level="1" type="T">Message does not contain a sender agreement</Trace>  
    <Trace level="1" type="T">Inbound validation by Integration Engine does not take place</Trace>  
    </Trace>
    </Trace>
    </Trace>
    <Trace level="3" type="Timestamp">2014-07-10T08:56:37Z INDIA End of pipeline service processing PLSRVID= PLSRV_XML_VALIDATION_RQ_INB</Trace>  
    </Trace>
    - <Trace level="1" type="B" name="CL_XMS_MESSAGE_PERS_MAN-WRITE_MESSAGE_LOG_TO_PERSIST"> 
    <Trace level="3" type="T">Persisting message after plsrv call</Trace>  
    <Trace level="3" type="T">Message-Version = 001</Trace>  
    <Trace level="3" type="T">Pipeline CENTRAL</Trace>  
    </Trace>
    - <Trace level="1" type="B" name="PLSRV_RECEIVER_DETERMINATION"> 
    <Trace level="3" type="Timestamp">2014-07-10T08:56:37Z INDIA Start of pipeline service processing PLSRVID= PLSRV_RECEIVER_DETERMINATION</Trace>  
    - <Trace level="1" type="B" name="CL_XMS_MAIN-CALL_PLSRV"> 
    <Trace level="3" type="T">Calling pipeline service: PLSRV_RECEIVER_DETERMINATION</Trace>  
    <Trace level="3" type="T

    HI,
    Thank you for your hint. Maybe I just forgot to mention one important fact. We have second SAP Netweaver PI 7.1 which is completely our system. The first one I mentioned in first message is the customer's one. The one we have extra is also connected to MAXIMO and GIS. Settings of this interface is completely same among one thing:
    Patch level of XIAF:
    1. customers SAP PI level is
    Adapter Common Library Version: 1.7.1007.20081105173106.0000, NW07_07_REL (2008-11-07T17:29:47+0000)
    Adapter Application Version: 1.7.1007.20081105173106.0000, NW07_07_REL (2008-11-07T17:30:00+0000)
    2. our SAP PI level is
    Adapter Common Library Version: 1.7.1008.20100215155230.0000, NW07_08_REL (2010-02-15T17:19:21+0000)
    Adapter Application Version: 1.7.1008.20100215155230.0000, NW07_08_REL (2010-02-15T17:19:31+0000)
    Both of them has Axis Version: Apache Axis version: 1.4 Built on Apr 22, 2006 (06:55:48 PDT)
    Also important to mention is fact that same problem happened in our SAP PI, but we implemented last patch of XIAF and it has suddenly started to work. I have suspicion it is somehow connected to this patch. Btw. this patch contains a lot of notes regarding  AXIS framework (i.e. 1435998, 1150375, 1048268), so obviously some bugs of the AXIS adapter has been resolved by this patch.
    What do you think ?
    Thanks

Maybe you are looking for

  • Creative Suite: Design Standard CS 6 will not sign in and activate

    Creative Suite: Design Standard  will not activate. I have registered the product and have an Adobe ID.  This is a reinstall since I have got a new compute and trashed my old one. It just says I have no internet connection which is untrue - any help?

  • Auto recovery?

    While completing my work on Excel, it quit. Of course i lost everything. Isn't there a way to retrieve my work? I thought my work would have been auto saved, but can not find out where to go or how to locate it. HELP!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

  • Setting canvas size at 300 ppi?

    Hi, I am trying to open a new document to make a design that will be printed. Since it will be printed, I set my resolution to 300 ppi. I need my canvas size to be 6.5" by 3.625", but the canvas size automatically sets itself to 6.5" by 3.627", and I

  • IVI Driver code in labview

    Hi,   I need to develop a code which will control  any DMM instrument using IVI driver. does any one know how to write the wrapper for this Regards Parthipan

  • Correction to javascript tutorial

    In http://download.oracle.com/docs/cd/E14373_01/appdev.32/e13363/javascript.htm#CHDDHAFA, it says to enter "confirmDelete('Would you like to perform this delete action?');" as the URL for the button. This should be "javascript:confirmDelete('Would yo