4 Replies Latest reply on Nov 6, 2013 4:57 PM by Wolf-Dieter Fink

    Unnatural behaviour of JBOSS EAP6

    Mohd Riyaz Newbie

      Hi,

      I need a help regarding the scenario which im providing below


      In my EJB 2.0 applcation that is running in JBOSS EAP 6,i have a jsp page in which i had 4 buttons,upon clicking on any of the  buttons,will display a popup window with some customer information(only informational window),the above described functionality will work fine if server is up for 2/3 hours,after that the popup windows does not fetch any information because it cud nt get connection object,apart from that functionality remaining things will work absolutely fine(all the remaining transactions ),i:e i can able to get the connection object for remaining stuff, the above issue gets resolved after doing a server bounce but it stays for only few hours,only the popup window functioanlity is behaving unnaturally,


      My guess for the above issue is may be because of usage of single database but  different schema tables to display the popup window information.


      Any help will would be great..

        • 1. Re: Unnatural behaviour of JBOSS EAP6
          Wolf-Dieter Fink Master

          Could you share the relevant code and the exact error messages?

          • 2. Re: Unnatural behaviour of JBOSS EAP6
            Sheeraz Junejo Newbie

            I think code would really help on how you are loading this pop-up but as you have mentioned that getConnection() is failing, are you properly closing the connection once it is used by other requests? Could you please verify that .close() is getting executed once you are done with it? Might be this popup is opening a connection to fetch data and not closing it?

            • 3. Re: Unnatural behaviour of JBOSS EAP6
              Mohd Riyaz Newbie

              Below is the code through which my popup window gets displayed:

              The connection which i mentioned in the post is a database connection,im getting the connection from the datasource whenever i need to display the popup window

              JSP code is pasted below:

              if (btnname == "viewral")
              {
              window.open('','viewral','scrollbars=yes,toolbar=no,menubar=yes,width=800,height=550,top=75,left=300');
              document.reviewFrn.target="viewral";
              document.reviewFrn.formtype.value="RAL";
              document.reviewFrn.frn_action.value="viewforms";
              document.reviewFrn.action="/usf/FundingRequestServlet";
              document.reviewFrn.submit();
              }

              Portion of code from Servlet where the popup window is getting called:

              String sJSPAction = (String) request.getParameter("frn_action");

              if ( sJSPAction.equals("viewforms") )
              {
              Vector forms_vector = new Vector();
              // Read the Form type for which view screen is needed.
              if( request.getParameter("formtype").equals("RAL"))
              {
              // Obtaining the Value of the FRN from the JSP editfrn.jsp
              frnNo = request.getParameter("formfrn");
              USFEnv.getLog().writeDebug( "FRN #"+frnNo, this,null );
              // Create db connection for EJB
              frnInfoEJBean.connect();
              // Get the FRN data
              forms_vector = frnInfoEJBean.getRalDataByFrn(frnNo);
              // Release db connection for EJB
              frnInfoEJBean.release();
              // Set the data that has been retreived.
              request.setAttribute( "forms_vector",forms_vector);
              request.setAttribute( "countForm","false");
              // Include the JSP
              includeJSP( request, response, FRN_JSP_PATH, "viewral" );
              }

              From the above code connect() and release() methods are pasted below:

              public void connect() throws ConnectException,RemoteException
              {
              USFEnv.getLog().writeDebug( "creating db connection()" , this , null );
              ejbConn = null;
              ejbConn = dbconn.open();

              if ( ejbConn == null )
              {
              throw new ConnectException( "Database connection failure" );
              }
              }
              public void release() throws ConnectException,RemoteException
              {

              try
              {
              USFEnv.getLog().writeDebug( " release db connection()", this, null );
              if ( ejbConn != null )
              ejbConn.close();
              ejbConn = null;
              }
              catch( Exception ex )
              {
              throw new ConnectException( "Database connection not released" );
              }
              }

               

              The below method is getting called from servlet:

              public Vector getRalDataByFrn( String frnNo )
              {
              StringBuffer query = new StringBuffer( "" );
              Vector rals_vector = new Vector();
              PreparedStatement pstmt = null;
              ResultSet rs = null;

              query.append( "select * from stage_ral_form where frn = ? order by email_date" );
              USFEnv.getLog().writeDebug( " Get ral form by FRN Query: " + query.toString() , this, null );

              try
              {
              USFEnv.getLog().writeDebug( " Get ral form by FRN Query conn obj: " +conn , this, null );
              pstmt = conn.prepareStatement( query.toString() );

              pstmt.setString(1,frnNo);

              rs = pstmt.executeQuery();

              while( rs.next() )
              {……
              }

              Database Connection:


              private static DataSource ds = null;
              private static java.sql.Connection conn=null;

              static {
              // Load the type 2 driver
              try {

              ds = (DataSource)USFEnv.ic.lookup("java:/jboss/datasources/usfdev");

              } catch (Exception e) {
              USFEnv.getDefaultLog().writeWarn("DataSource could not be found using JNDI ",null,null);
              }

              • 4. Re: Unnatural behaviour of JBOSS EAP6
                Wolf-Dieter Fink Master

                I don't understand the code right now.

                But if you lookup a Datasource you can call getConnection(), after you finish the work you have to close the ResutSet, Statement and the connection itselfe.

                Otherwise you might run into problems b/c of opend cursors or connection leaking