With out using Weblogic libraries to maintain the same functionality

Hi,
Please tell the solution of my problem.Here application developed in Weblogic,now we are migrating that applicationin jboss.Here one java servlet program is there which is using Weblogic libraries to get the connection pool .
How can change the code without using Weblogic libraries to maintain the same funtionality. Is there any alternate method to get the connection pools in Jboss.
Here I am attaching the code ,please go througth the code and provide me the correct solution.
package gsk.servlets;
import java.io.*;
import java.sql.Connection;
import java.sql.Statement;
import java.sql.ResultSet;
import javax.naming.Context;
import javax.naming.NamingException;
import javax.management.*;
import javax.management.InstanceNotFoundException;
import javax.management.InvalidAttributeValueException;
import javax.management.Notification;
import javax.servlet.*;
import javax.servlet.http.*;
//Below lines are commnented by Anupama on 29-09-05 to avoid using Weblogic libraries.
//import weblogic.jndi.Environment;
//import weblogic.management.MBeanHome;
//import weblogic.management.MBeanCreationException;
//import weblogic.management.*;
//import weblogic.management.runtime.*;
//import weblogic.management.configuration.*;
//import weblogic.management.RemoteNotificationListener;
//import weblogic.management.logging.WebLogicLogNotification;
//import javax.management.Notification.*;
//below lines are added by Anupama T on 29-09-05 to run the same functionality without using Weblogic libraries
import org.jboss.management.*;
import org.jboss.jdbc.*;
import org.jboss.naming.*;
import org.jboss.management.j2ee.MBean;
import javax.management.AttributeChangeNotification;
import javax.management.JMException;
import javax.management.MalformedObjectNameException;
import javax.management.MBeanServer;
import javax.management.NotificationListener;
import javax.management.ObjectName;
import org.jboss.logging.Logger;
import org.jboss.system.ServiceMBean;
import gsk.adip.portal.GKMProperties;
import gsk.adip.dbconnectionservice.DatabaseConnector;
* @author jjc18400
* The ConnectionsManager class acts as a Servlet that listens and
* responds to events that are thrown by WebLogic MBeans. In particular,
* it listens for failures in WebLogic connection pools, and attempts to
* restore these pools.
public class ConnectionsManager extends HttpServlet implements NotificationListener {
     private static Context ctx;
     private static MBean managedHome;
     private static MBean adminHome;
     private static String SERVER_NAME;
     private static String DOMAIN_NAME;
     private static MBeanServer myServer;
     private JDBCConnectionPoolRuntimeMBean connectionPoolMBean;
     private JDBCConnectionPoolMBean jdbcConnPoolMBean;
     private JDBCConnectionPoolMBean myPool;
     private static ResultSet rset = null;
     public void init(ServletConfig config) throws ServletException {
          super.init(config);
          System.out.println("Initializing the ConnectionsManager servlet.");
          SERVER_NAME = GKMProperties.getProperty("GKM_SERVER_NAME");
          DOMAIN_NAME = GKMProperties.getProperty("DOMAIN_NAME");
          findMBeans();
          testConnectionPool("GENNETConnectionPool");
          try {
               //findConnPool("GENNETConnectionPool").addNotificationListener(this, null, null);
               RemoteMBeanServer rmbs = adminHome.getMBeanServer();
               WebLogicObjectName oname =
                    new WebLogicObjectName("TheLogBroadcaster", "LogBroadcasterRuntime", DOMAIN_NAME, SERVER_NAME);
               rmbs.addNotificationListener(oname, this, null, null);
          catch (IllegalArgumentException e) {}
          catch (MalformedObjectNameException e) {}
          catch (InstanceNotFoundException e) {}          
     public void handleNotification(Notification notification, Object obj) {
          WebLogicLogNotification wln = (WebLogicLogNotification)notification;
          System.out.println("\nWebLogicLogNotification");
          System.out.println(" type = " + wln.getType());
          System.out.println(" message id = " + wln.getMessageId());
          System.out.println(" server name = " + wln.getServername());
          System.out.println(" timestamp = " + wln.getTimeStamp());
          System.out.println(" message = " + wln.getMessage() + "\n");
     private void testConnectionPool(String poolName) {
          JDBCConnectionPoolMBean aPool = findConnPool(poolName);
          JDBCConnectionPoolRuntimeMBean aRuntimeMBean = findRuntimeMBean(poolName);
          /*while(aRuntimeMBean.getPoolState()) {
               try {
                    Thread.sleep(6000);
                    System.out.println("Thread is sleeping.");
               catch (InterruptedException ie) {
          retargetConnPool(aPool);
     private JDBCConnectionPoolRuntimeMBean findRuntimeMBean(String aPoolName) {
          JDBCConnectionPoolRuntimeMBean aRuntimeMBean = null;
          if (managedHome != null) {
               try {
                    aRuntimeMBean = (JDBCConnectionPoolRuntimeMBean)managedHome.
                              getRuntimeMBean(aPoolName, "JDBCConnectionPoolRuntime");
               catch (InstanceNotFoundException e) {
                    System.out.println("Unable to find the JDBCConnectionPoolRuntimeMBean: " + e);
                    aRuntimeMBean = null;
          return aRuntimeMBean;
     private JDBCConnectionPoolMBean findConnPool(String poolName) {
          if (adminHome != null) {
               try {
                    myPool = (JDBCConnectionPoolMBean)adminHome.getMBean(poolName, JDBCConnectionPoolMBean.class);
               catch (InstanceNotFoundException e) {
                    System.out.println("Unable to find the JDBCConnectionPoolMBean: " + e);
                    myPool = null;
          return myPool;
     private void retargetConnPool(JDBCConnectionPoolMBean aPool) {
          //System.out.println("The connection pool: " + aPool.toString() + " is not responding.\nAttempting to retarget the pool...");
          try {
               System.out.println("Attempting to remove " + myServer.toString() + " from the connection pool target list.");
               aPool.removeTarget(myServer);
               System.out.println("Removal successful: " + aPool.getTargets().toString());
               aPool.addTarget(myServer);
               System.out.println("Addition successful: " + aPool.getTargets().toString());
          catch (InvalidAttributeValueException e) {
               System.out.println(e.toString());
          catch (DistributedManagementException e) {
               System.out.println(e.toString());
     public void doPost(HttpServletRequest req, HttpServletResponse resp)
               throws ServletException, IOException {
          String poolName = (String)req.getParameter("poolName");
          String dataSource = (String)req.getParameter("dataSource");
          //System.out.println("req.getAttribute(poolName) is: " + poolName);
          //System.out.println("req.getAttribute(dataSource) is: " + dataSource);
          String message = runTestQuery(dataSource);
          getConnectionPoolMBean(poolName);
          resp.setContentType("text/html");
          PrintWriter out = resp.getWriter();
          out.println("<html>");
          out.println(" <head><title>The ConnectionsManager Responds:</title></head>");
          out.println(" <body>");
          out.println(" <h1>" + message + "</h1>");
          out.println(" </body>");
          out.println("</html>");
     public void destroy() {
          System.out.println("Destroying the ConnectionsManager servlet.");
     public String getServletInfo() {
          return "This servlet monitors and corrects errors in WebLogic connection pools.";
     /**private void runTests() {
          while (false) {
               rset = testConnection();
               if (rset == null) {
                    resetConnectionPool();                    
               try {
                    wait();
               catch (InterruptedException e) {}
     private String runTestQuery(String dataSource) {
          String statusMessage = "";
          Connection conn = null;
          Statement stmt = null;
          ResultSet rset = null;
          //String aPoolName = "GENNETConnectionPool";
          String aSql = "select * from dual where 1 = 1";
          try {
               conn = DatabaseConnector.getDatabaseConnection(dataSource);
               System.out.println("Established database connection.");
               if (conn != null) {
                    conn.setAutoCommit(false);
                    stmt = conn.createStatement();
                    rset = stmt.executeQuery(aSql);
                    statusMessage = "The connection \'" + dataSource + "\' is OK.";
          catch (Exception e) {
               try {
                    conn.rollback();
               catch (Exception e1) {}
               e.printStackTrace();
               statusMessage = "The connection \'" + dataSource + "\' has failed.\n" + e.toString();
          finally {
               try {
                    if (stmt != null) stmt.close();
                    if (conn != null) conn.close();
               catch (Exception e) {
                    e.printStackTrace();
               return statusMessage;
     public void resetConnectionPool() {
     private void findConnPoolRuntimeMBean(String poolName) {
          try {
               connectionPoolMBean = (JDBCConnectionPoolRuntimeMBean)managedHome.getRuntimeMBean(poolName, "JDBCConnectionPoolRuntime");
          catch (InstanceNotFoundException e) {
               System.out.println("Unable to find the JDBCConnectionPoolRuntimeMBean: " + e);
     private void findMBeans() {
          Environment env = new Environment();
          try {
               ctx = env.getInitialContext();
               managedHome = (MBeanHome)ctx.lookup(MBeanHome.JNDI_NAME + "." + SERVER_NAME);
               System.out.println(MBeanHome.JNDI_NAME + "." + SERVER_NAME + " -- managedHome found successfully.");
               adminHome = (MBeanHome)ctx.lookup(MBeanHome.ADMIN_JNDI_NAME);
               System.out.println(MBeanHome.ADMIN_JNDI_NAME + " -- adminHome found successfully.");
               myServer = (ServerMBean)adminHome.getMBean(SERVER_NAME, ServerMBean.class );
               System.out.println(MBeanHome.ADMIN_JNDI_NAME + " -- " + SERVER_NAME + " instance found successfully.");
               ctx.close();
          catch (NamingException e) {
               System.out.println("Naming Exception: " + e);
               managedHome = null;
               adminHome = null;
          catch (InstanceNotFoundException e) {
               System.out.println("Unable to find the JDBCConnectionPoolMBean: " + e);
     public String displayHomeName() {
          getConnectionPoolMBean("GENNETConnectionPool");
          if (managedHome != null) {
               return new String("MBeanHome found successfully.");
          else return new String("MBeanHome not found.\nSee WL Console for error.");
     private void getConnectionPoolMBean(String poolName) {
          String thisPoolName = poolName;
          connectionPoolMBean = null;
          if (managedHome != null) {
               try {
                    connectionPoolMBean =
                         (JDBCConnectionPoolRuntimeMBean)managedHome.getRuntimeMBean(thisPoolName, "JDBCConnectionPoolRuntime");
                    if (connectionPoolMBean != null) {
                         System.out.println("JDBCConnectionPoolRuntime found successfully.");
                         System.out.println("connectionPoolMBean.toString() is: " + connectionPoolMBean.toString());
                         System.out.println("connectionPoolMBean.getFailuresToReconnectCount() is: " + connectionPoolMBean.getFailuresToReconnectCount());
                         System.out.println("connectionPoolMBean.getPoolState() is: " + connectionPoolMBean.getPoolState());
               catch (InstanceNotFoundException e) {
                    System.out.println("Unable to find the JDBCConnectionPoolRuntimeMBean: " + e);
                    connectionPoolMBean = null;
          // Obtain MBeanHome for the administration server.
          /*JDBCConnectionPoolMBean mbean = (JDBCConnectionPoolMBean)home.
                    getConfigurationMBean(poolName, "JDBCConnectionPoolConfig");
          mbean.setConnLeakProfilingEnabled(true);
          mbean.setSqlStmtParamLoggingEnabled(true);
          mbean.setSqlStmtMaxParamLength(maxLen);*/
          /*try {
               mypool = (JDBCConnectionPoolMBean)mbh.getMBean( "mypool",
               JDBCConnectionPoolMBean.class );
          catch( javax.management.InstanceNotFoundException e ) {
               mypool = (JDBCConnectionPoolMBean) mbh.createAdminMBean( "mypool",
                    "JDBCConnectionPool", "mydomain" );
               mypool.addTarget( myserver );
               mypool.setDriverName( "org.gjt.mm.mysql.Driver" );*/
          if (adminHome != null) {
               try {
                    myPool = (JDBCConnectionPoolMBean)adminHome.getMBean(poolName, JDBCConnectionPoolMBean.class);
               catch (InstanceNotFoundException e) {
                    System.out.println("Unable to find the JDBCConnectionPoolMBean: " + e);
          if (myPool != null) {
               //System.out.println("myPool.getMaxCapacity() is: " + myPool.getMaxCapacity());
               try {
                    myPool.setMaxCapacity(10);
                    System.out.println("Before: myPool.getMaxCapacity() is: " + myPool.getMaxCapacity());
                    myPool.setMaxCapacity(100);
                    System.out.println("After: myPool.getMaxCapacity() is: " + myPool.getMaxCapacity());
               catch (InvalidAttributeValueException e) {
                    System.out.println("Max Capacity is an invalid value.");
               //System.out.println("myPool.getMaxCapacity() is: " + myPool.getMaxCapacity());
}

Hy, i've got the same problem as you. Did you find out a solution.
If so, please contact me. Thanks a lot.
Lorenzo

Similar Messages

  • I would like to know how i can create a bell graph with out using sub VIs, the data that i created consists in 500 readings with values of 0 to 100, i calculated the mean value and standard diviation. I hope some one can help me

    I would like to know how i can create a bell graph with out using sub VIs, the data that i created consists in 500 readings with values of 0 to 100, i calculated the mean value and standard diviation. I hope some one can help me

    Here's a quick example I threw together that generates a sort-of-bell-curve shaped data distribution, then performs the binning and plotting.
    -Kevin P.
    Message Edited by Kevin Price on 12-01-2006 02:42 PM
    Attachments:
    Binning example.vi ‏51 KB
    Binning example.png ‏12 KB

  • How to get the line in the template (smartform) with out using under score

    Hi,
         How to get the line in the template (smartform) with out using under score,
         and how to print the box (line the check box - small squre box (which is used ot mark the tick by the user in front of the item).
         Please provide the valueble answer as early as possible.
    Thanks,
    Ravi

    Hi Ravi,
    Line -
    Use a SMATSTYLE for this purpose.in the smartstyle create a paragraph or character with underline atribute.Then call the smartstyle in the text.
    Search SDN with Key <b>UNDERSCORE</b>.. will get few more posts on the same.
    For Checkbox - refer link
    Re: Quick Question on Smartforms
    Re: putting tick mark into check box in smartform
    Reward points if this Helps.
    Manish
    Message was edited by:
            Manish Kumar

  • HT1539 can i add my digital copy to itunes with out using the disk? my netbook does not have a disk drive and i want to add my movie to my ipod can i do it with out the use of the disk and just the code?

    Can I add my digital copy movie to my iTunes with out using the disk, my gateway laptop/netbook does not have a disk drive I have the unused code and everything, I just can't stuck the movie into the computer itself and my desktop computer has no internet on it. Is there a way to add my movie to my iPod touch 2nd generation tuning 4.2.1

    Hiya!
    It depends on what kind of digital copy you have.  This article goes ino details regarding the two types, and depending on the type you have, you may or may not need the DVD to redeem the code.
    Transferring video from DVDs with iTunes digital content
    http://support.apple.com/kb/HT1539
    I hope this helps!  Best wishes and good luck!

  • How to know the size of the string with out using the length() method

    i want to find the lenght of the
    String s="Sudha";
    with out using the lenght() method.

    Not true (I mean the part about "The only String
    call"). But if it had been true, I might haveagreed
    with this:
    Assuming one uses the 'exception' approach thenwhat
    method other than charAt() is needed?I probably misunderstood your post, I thought you
    meant that the only alternative to length() would be
    charAt() and catching the exception.There are many ways and if the teacher had said find 5 ways of finding the length of a String then I would have fealt happier because it would have meant the student would have to read and study the whole of the String API.
    I like
    int length = (s+"sabre").lastIndexOf("sabre");

  • Deletion of duplicates in the table with out using rowid

    How can I delete duplicates in the table with out using ROWID .

    hi
    sleect count(coulmnname),columnname from table
    group by columnname
    having count(columnname) > 1;
    find the primary key of the table
    apply the below query
    delete from table
    where (primary key,repeated column name )
    not in
    ( select min(primary key), repeated column
    from employee group by repeated column );
    use this in the primary key column use empid ,,,the repated column is ename
    empid ename
    1 sankar
    2 sankar
    try this one

  • How to display the alv report blocks wise with out using the blocked alv

    Hi
    How to display the alv report with out using the blocked alv function module.
    Thanks
    Chinnu

    see this Standard Program
    RPR_ABAP_SOURCE_SCAN

  • )How can we schedule the info package daily run at 6 AM, with out useing in

    Hi
       Can any one explain 1) what is information broadcasting &how can we use this.
    2)What are the settings we have to do when we use the charts in WAD's
    3)How can we schedule the info package daily run at 6 AM, with out useing in process chains
    Thanks
    Bharath

    Hi,
      Information broadcaster :
          you can precalculate and distribute(thru mail) the query, workbook and webtemplate through online link or html file to the receipents (users).
    have a look at the below link.
         http://help.sap.com/saphelp_nw04/helpdata/en/3a/0e044017355c0ce10000000a1550b0/frameset.htm
    Infopackage scheduling:
         you can schedule the infopackage daily at your desired time .In the schedule tab ,select the start later in background and in the scheduling option give the date and time and give the period values as daily.
    Regards,
    Siva.

  • Plz help me about my Iphone  5s battary life is so bad without using in the night keep on after 6 hours  morning when i open battary  % lose 60 percentage  with out using

    Plz help me about my Iphone  5s battary life is so bad without using in the night keep on after 6 hours  morning when i open battary  % lose 60 percentage  with out using plz help me..

    Maximize iPhone Battery (iOS7):
    1) Turn off Airdrop: Control Center >AirDrop > Off
    2) Limit background app refresh. Turn it off for applications such as Google/Facebook.Settings > General > Background App Refresh
    3) Turn off automatic updates: Settings > iTunes & App Store >  Updates and Apps (off)
    4) Unneccessary Location Services: Settings > Privacy > Location Services > System Services > Off (uncheck as needed)
    5) Turn off Paralax: Settings > General > Accessibility > Reduce Motion
    6) Siri, and her 'raise to speak.' Turn it off: Settings > General > Siri > Raise to Speak
    7) Exclude items from Spotlight search as needed: Settings > General > Spotlight Search
    8) Remove unneccessary notifications: Settings > Notification Center > None (per app basis)
    9) Make sure auto-brightness is on, or reduce the brightness to 25% or less if desired.Settings > Wallpapers & Brightness
    10) Use Still backgrounds only: Settings > Wallpapers & Brightness> Choose Wallpaper
    11) Fetch email instead of "Push":  Settings > Mail, Contacts, Calendar > Fetch New Data >Push(off) & Fetch every 15 minutes
    12) Disable LTE if needed: Settings > Cellular > Enable 4G/LTE (OFF)
    13) Reduce Autolock: Settings > General > Auto-Lock > 1 Minute
    14) Disable Vibrations with Ring: Settings > Sounds > Vibrate on Ring (off)
    15) Close Applications regularly: Double Tap Home Button > Swipe up on App to close

  • How to get the inserted row primary key with out  using select statement

    how to return the primary key of inserted row ,with out using select statement
    Edited by: 849614 on Apr 4, 2011 6:13 AM

    yes thanks to all ,who helped me .its working fine
    getGeneratedKeys
    String hh = "INSERT INTO DIPOFFERTE (DIPOFFERTEID,AUDITUSERIDMODIFIED)VALUES(DIPOFFERTE_SEQ.nextval,?)";
              String generatedColumns[] = {"DIPOFFERTEID"};
              PreparedStatement preparedStatement = null;
              try {
                   //String gen[] = {"DIPOFFERTEID"};
                   PreparedStatement pstmt = conn.prepareStatement(hh, generatedColumns);
                   pstmt.setLong(1, 1);
                   pstmt.executeUpdate();
                   ResultSet rs = pstmt.getGeneratedKeys();
                   rs.next();
    //               The generated order id
                   long orderId = rs.getLong(1);

  • With out inbound Idoc can we post the data using we19

    Hi,
            with out inbound idoc can we post the data using we 19.........
    for testing any idoc type particular to inbound FM is posting application data..in TABLES.....
    Regards,
    Raghunadh.

    HI Raghunadh Babu 
    The main purpose of given WE19 Transaction by SAP... To generate test IDoc and check whether the data is posting according to business requirement....
    Answer for your question.....Yes U can generate IDoc...
    Enjoy playing with we19...
    RR

  • How to find the year ago measure with out using time series functions

    hi all
    is there any way to find year ago sales with out using time series functions like ago
    Thanks
    Sreedhar

    Hello Madan,
    Thanks for the reply.
    It still doesn't consider the product into account.
    My columns are as below
    Prod Week End DATE Current Sales Prior Sales % Change
    A 12/4/2010 100 0
    A 12/11/2010 200 100
    A 12/18/2010 300 200
    B 12/4/2010 400 300(this value is not for prod B, i want this to b 0 aswell. But we get product A's last sale amount)
    Is there any way this can be done. I have tried evaluate,MSUM.
    I cannot build a time dimension as all I have is a view.
    Thanks,
    Deep

  • How To Split File In to Multiple Files With out using B.P.M

    Hi Guys,
    How To Split File In to Multiple Files With out using B.P.M.
    Thanks in advance
    Regards's
    KIran.B

    Hello
    below r the links were u will find message spilitting by graphicaaly i.e without using BPM.
    /people/claus.wallacher/blog/2006/06/29/message-splitting-using-the-graphical-mapping-tool
    Sender File Adapter with file conversion  Multimapping --file content conversion with split messg mapping
    https://www.sdn.sap.com/irj/sdn/weblogs?blog=/pub/wlg/2748---- [original link is broken] [original link is broken] [original link is broken]
    multimappig
    /people/narendra.jain/blog/2005/12/30/various-multi-mappings-and-optimizing-their-implementation-in-integration-processes-bpm-in-xi
    hope this resolve your problem
    thank's
    Chetan

  • Async-Sync scenario with out using BPM

    Hi All,
    With SP19 we can implement File-RFC-File scenario with out using BPM.
    But can any one suggest how can I implement the following File-RFC-File scenario without using BPM.
    My input file has five elements. A1,A2,A3,A4,A5
    The RFC (BAPI) needs A2 and A3 as input and it produces the output R6.
    Now in the destination I need to populate D1,D2,D3,D4,D5,D6.
    D1 has to be mapped from A1 and so on till fifth element. D6 will be mapped from R6. In order to achieve this we need to store the value of source interface before calling the RFC so that when we get the response back we can populate the entire destination structure.
    Can anyone advise how to go about it. I don't want to use a BPM here.
    Thanks
    Abinash

    Hi
    the following thread may help you
    Weblog to send Response from RFC to File in Asyn Mode Using Proxy [original link is broken]
    File - RFC - File without a BPM - Possible from SP 19.
    Thanks,
    Ram

  • Accessing BAPI's using JAVA with out using webdynpro URGENT

    hi Experts,
    What is the procedure for calling RFC/BAPI's using JAVA with out using the webdynpro. Please let me know what are the possibilities with step by step implementation.
    Regards
    Vijay

    Hi Boris Rubarth,
    Thaks for relavant information.
    I have kind of the requirement. The clinet is asking for connecting the SAP RFC using java application. The build Jar or .war or .Ear for which are going to develop should be compatible for running on any of the Applications server like they have Tom cat, weblogic, websphere server.
    so the .jar for or .ear file which we are going to develop should be able to run accessing the RFC/ BAPIs from any of these servers other than SAP WAS that is what their target.
    Please give me your suggestion, which is better approach. currently their SAP system is 4.6c . So presently it is not possible the webservice approach. But they have plans to go for upgrade to ECC6.0
    In that case only JCO option is possible. If use this option . Is it possible to access application which is deployed irrespective of the WAS by doing the required configuration.
    Basically i am aware of the ABAP webservice work bech steps and also the JAVA coding also.
    Please suggest me what is the better way to achieve this.
    Regards

Maybe you are looking for