Default Connection Object in EJB

When we use default connection to get a connection to the oracle database through a deployed EJB, it uses the internal driver or in short it returns the same connection object. Is this connection object synchronized and thread safe. I mean if multiple people access this EJB at once, will it be fine or will the connection crash or some exception is thrown.

Either pass them as parameters or make them into member variables.

Similar Messages

  • Passing connection object as EJB parameter

    I am working on a legacy website which uses stateless session EJB's and runs on
    WebLogic 6.1 using JDK 1.3 and Oracle 8.1.6, I am working on upgrading this
    application to WebLogic 9.2, JDK 1.5 and Oracle 10.2.
    I configured a datasource in WebLogic using the Oracle thin XA driver.
    When attempting to run the application I got an error message stating that an
    object which is not serializable is being passed as an EJB parameter. I found that
    several EJB methods are passing open database connections as parameters so to fix this
    issue we should change the code. However, I am reluctant to change the code since I
    believe that the reason for passing the connection objects is that the developers
    wished to preserve transactions and so any changes might result in many issues in
    the application. I have the following questions:
    - The code is doing something which is not allowed. So why was this okay in WebLogic
    6.1 using the older Oracle oci driver?
    - One way to get around this would be to convert the EJB's to POJOS. There are no
    container based properties and the only EJB's are stateless session EJB's. The
    high water mark for concurrant usage is 40. There is only a single server (no clustering)
    What kind of issues would such a
    conversion bring?
    - Would it be better to convert the EJB's to local interfaces? What kind of issues would
    this bring?
    Any other suggestions would be very much appreciated.

    Salma Saad wrote:
    Thanks Joe,
    Converting to POPJOS from EJB or to local EJB's is changing the code but it limits changes to the logic of the application which could result in unforseen issues.
    There is only 1 server and 1 jvm but I get a not serlializable exception which I did not get when running this code on WebLogic 6.2 or 8.1 using Oracle 8.1.6 and 9i .I am getting it now that I am using WL 9.2 and Oracle 10.2.
    I looked through all the parameters and everything is a string except for Connection which does not implement serializable. There is a Vector but all the contained objects are strings. Let me know if you have any ideas what I can do to get rid of this, and also why is it happenning in the newer version of WL when it didn't happen before?
    weblogic.utils.AssertionError: ***** ASSERTION FAILED *****
         at weblogic.rmi.internal.CBVWrapper.copy(CBVWrapper.java:57)
         at com.isr.applications.isrinteractive.ejb.sessionbean.user.UserBean_x07h56_EOImpl_CBV.validateLogin(Unknown Source)
         at jsp_servlet._admin.__validatelogin._jspService(__validatelogin.java:187)
         at weblogic.servlet.jsp.JspBase.service(JspBase.java:34)Hi. I looked at the code throwing this exception, and
    it's in a whole 'nother area of the server, nothing to
    do with JDBC or EJBs as such. It's odd too, because it
    seems to have already verified that whatever object
    it's dealing with is a serializable object...
    I recommend you're opening an official support case
    about this exception, and maybe they'll want help
    reproducing it...
    Joe
         at weblogic.servlet.internal.StubSecurityHelper$ServletServiceAction.run(StubSecurityHelper.java:225)
         at weblogic.servlet.internal.StubSecurityHelper.invokeServlet(StubSecurityHelper.java:127)
         at weblogic.servlet.internal.ServletStubImpl.execute(ServletStubImpl.java:283)
         at weblogic.servlet.internal.ServletStubImpl.onAddToMapException(ServletStubImpl.java:391)
         at weblogic.servlet.internal.ServletStubImpl.execute(ServletStubImpl.java:309)
         at weblogic.servlet.internal.TailFilter.doFilter(TailFilter.java:26)
         at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:42)
         at com.isr.applications.isrinteractive.servlets.reports.SessionFilter.doFilter(Unknown Source)
         at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:42)
         at weblogic.servlet.internal.WebAppServletContext$ServletInvocationAction.run(WebAppServletContext.java:3212)
         at weblogic.security.acl.internal.AuthenticatedSubject.doAs(AuthenticatedSubject.java:321)
         at weblogic.security.service.SecurityManager.runAs(SecurityManager.java:121)
         at weblogic.servlet.internal.WebAppServletContext.securedExecute(WebAppServletContext.java:1983)
         at weblogic.servlet.internal.WebAppServletContext.execute(WebAppServletContext.java:1890)
         at weblogic.servlet.internal.ServletRequestImpl.run(ServletRequestImpl.java:1344)
         at weblogic.work.ExecuteThread.execute(ExecuteThread.java:209)
         at weblogic.work.ExecuteThread.run(ExecuteThread.java:181)
    Caused by: java.io.NotSerializableException: java.lang.Object
         at java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1081)
         at java.io.ObjectOutputStream.defaultWriteFields(ObjectOutputStream.java:1375)
         at java.io.ObjectOutputStream.writeSerialData(ObjectOutputStream.java:1347)
         at java.io.ObjectOutputStream.writeOrdinaryObject(ObjectOutputStream.java:1290)
         at java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1079)
         at java.io.ObjectOutputStream.writeObject(ObjectOutputStream.java:302)
         at weblogic.rmi.extensions.server.CBVOutputStream.writeObject(CBVOutputStream.java:84)
         at weblogic.rmi.internal.CBVWrapper.copy(CBVWrapper.java:49)
         ... 20 more

  • Passivation of Connection Object in Stateful Session Bean

    Hi all,
    I am developing a Stateful session bean that has a Connection object as its instance variable. And this bean starts transaction that spans across multiple method calls and finally either commit or rollback.
    BeanClass
    UserTransaction utx;
    Connection conn;
    ejbCreate()
    allocateconnection();
    ejbRemove()
    closeconnection();
    ejbActivate()
    allocateconnection();
    ejbpassivate()
    closeconnection();
    StartTransaction()
    utx = getusertransaction();
    utx.begin();
    Method1()
    do something with database
    Method2()
    do something with database
    CommitTransaction()
    utx.commit();
    For example, the typical usage of this bean would be:
    bean.StartTransaction();
    bean.Method1();
    bean.Method2();
    bean.CommitTransaction();
    Here are my two questions:
    1. General Question: In order for a Connection object to join a Transaction, Do I have to create the connection after the transaction has started?
    2. If the answer to the above question is yes, then: I understand that when this bean get passivated, the UserTransaction instance object would be passivated. And since the connection object can't not be passivated, I have to recreate the connection object in ejbactivate() method, would newly created connection participate in the same Transaction that was being passivated and now activated?

    >
    Hi all,
    I am developing a Stateful session bean that has a
    Connection object as its instance variable. And this
    bean starts transaction that spans across multiple
    method calls and finally either commit or rollback.
    BeanClass
    UserTransaction utx;
    Connection conn;
    ejbCreate()
    allocateconnection();
    ejbRemove()
    closeconnection();
    ejbActivate()
    allocateconnection();
    ejbpassivate()
    closeconnection();
    StartTransaction()
    utx = getusertransaction();
    utx.begin();
    Method1()
    do something with database
    Method2()
    do something with database
    CommitTransaction()
    utx.commit();
    For example, the typical usage of this bean would be:
    bean.StartTransaction();
    bean.Method1();
    bean.Method2();
    bean.CommitTransaction();
    Here are my two questions:
    1. General Question: In order for a Connection object
    to join a Transaction, Do I have to create the
    connection after the transaction has started?Strictly NO. In fact, the connection is obtained first and then can a transaction begin.
    2. If the answer to the above question is yes, then: I
    understand that when this bean get passivated, the
    UserTransaction instance object would be passivated.
    And since the connection object can't not be
    passivated, I have to recreate the connection object
    in ejbactivate() method, would newly created
    connection participate in the same Transaction that
    was being passivated and now activated?
    The answer to first question being NO, your argument for question 2 does not hold true. According to the EJB specification, a stateful session bean can only be passivated between the transaction and not within a transaction. Your implementation for the stateful EJB is good to work.

  • Connection Object Class Overview

    Hello Experts,
    I created a class (cl02) and  the related characteristics (ct04) to be used for connection objects.  I wonder if there is a way to make the class field in the Assignments section pre-filled (or  pre-selected) when creating the connection object, so that the user won't have to select this class to enter the characteristics. I used the standard class indicator but I had no luck.
    Thanks in advance!

    Hi Eren,
    You can do this kind of default value assignments into screen fields by implementing user exits.
    Please have a look at exits EXIT_SAPLES55_001 to EXIT_SAPLES55_011 residing under component  XES55.
    Regards,
    Dilek

  • Functional location not reflected in connection object

    HI...
    I created a functional location in the plant maintanence module..however when i try to check this from the connection object SAP gives me an error sayin the Location does not belon to IS type C(connection Object).
    during FL creation i had specified the category as A (connection Object) and structure indicator as AO_GP (ISU defaults)...wat am i doing wrong..?

    HI MICK
    I  HOPE I  HAVE FOUND UR ANSWER
    JUST  GOI TO
    SPRO-SAP UTIL-MASTER DATACONNEC OBJECTBASIC SETTINGS-
    HERE IN THIS SCREEN  ENETR THE FOLLWONG  ENTRUIES
    IF U  HAVE ONE DELETE ANDMAKENEW AS HERE
    C     AO_GP   A
    C is connection object
    AO_GP  str
    A is fucnt  location  categ
    make it
    and u  will get ur issues solved
    kr
    raj

  • Error when connecting Applet to EJB

    Hi,
    I have an Applet that I try to connect to an EJB, but without success.
    To pinpoint the problem, I took the client-side code of the example ...examples\ejb\basic\BeanManaged
    and made an AWT Applet out of it.
    I seem to trap some error when I call the getInitialContext() when trying to find the Home interface.
    Nothing happens in my code (ie. the Applet) after I enter this part of the code. It is a it hard to say
    where it stops, since I do not get all output. It seems to die when I am trying to instantiate the
    Context-object or the AccountHome object. Maybe I just have a Classpath error.
    When running the BeanManaged as a Java Application, everything is working fine.
    Does anyone have any experience in these matters ?
    I am using WL 5.1.0 (no SP-s), JDK 1.2.2
    Regards, Erik

    Thanks for you answer Jos, but honestly I don't know what I should do then, since I can't get data from database through the applet.
    I have read some articles that we can get data from database through the applet (they use tomcat too). I have followed what the article said, but I still get the error.
    Do you have any idea Jos? Thank you very much for your nice attention
    Warmnest regards,
    Vijay

  • Updating to connection object in JDeveloper

    Dear all,
    For my BC4J project, I have a connection by name CorrosionConnection. This connection is set with username=cer2265, password=cer2265,sid=cer, hostname=196.15.40.23,port=1521.
    So for so good. Application is working fine and I can happily make any transaction.
    This is my default setting. Suppose I have placed a text file as follows.
    username: cer2265
    password: cer2265
    sid: cer
    hostname: 196.15.49.23
    port: 1521
    Let us name this file as connection.txt. When ever application starts application should read this file and should update CorrosionConnection object with this information.
    Now suppose If i need to change the ip address from 196.15.49.23 to 196.15.49.22 what I need to do is the following..
    username: cer2265
    password: cer2265
    sid: cer
    hostname: 196.15.49.22
    port: 1521
    Thus a type of dynamic connection object is now created, where I can even change the username, password , sid and port.
    I don't know how to do this. Reading the file can be done by any filestream object. Updating the connection object is the problem.
    Can any one help me in this regard,
    Thanks in advance.

    If you need your connection to be dynamic because of DHCP you could use "localhost" or "127.0.0.1" for your IP address if your database server is on same machine as application server.
    Otherwise I would recomend reading BLOG from Steve:
    http://radio.weblogs.com/0118231/2004/08/11.html
    and Oracle documentation:
    http://www.oracle.com/technology/products/jdev/howtos/10g/dynamicjdbchowto.html
    and Google :)

  • Parameterizing connection object

    I'd like to pass login info to the JDeveloper connection object (like you can do with the JDBC conn object).
    sessionInfo.setConnectionInfo(new LocalConnection("<<login info here??>>"));
    Is this possible?

    Dixon,
    It depends on what context you are talking about. All connection information used by a client at runtime is stored in a file named connections.properties. The connections are listed by name. Within the different client applications you can create, you only reference the name of the connection itself, allowing you to alter this text-file at runtime without having to edit your code in many places and re-compile it.
    We do allow for passing in a password at runtime. For the connection itself, make sure the checkbox for 'Include deployment password at runtime' is unchecked. It is (unchecked) by default, meaning the password for each connection is not written to the connection.properties file as text so the user must provide it.
    From a DAC client such as an application or an applet, you can create a login dialog where the user enters their username and password, and this information is used to perform the connection to the specified database. There is a login dialog control you can pick from the InfoSwing controls palette.
    From a JSP web application or servlet, you will need to do some work by hand. In the case of a JSP web app, the connection name is included in your BC4J.xcfg file, and the name of the config (and password) is listed in your appmodule.properties file. So it is a little more indirect.
    I believe the BC4J Auctions demo includes an example of a 'login dialog'. See the online help topic 'Business Components for Java Auctions Sample Web Application' under the Samples and Tutorials folder, then under Sample Applications.

  • Removing an IIOP User connection to an EJB on JServer

    I am writing an application using a servlet engine to connect to an EJB in JServer. I am not using connection pooling because each user will be logging in with their database username. When the session times out on the servlet, I would like to clean up the connection, and release the EBJ/IIOP connection. Is there a preferred method to do this, or should I let JServer time out?
    Thanks
    Ken

    The beans have session lifetime and will be removed/cleaned up when the session is deleted.
    The session is constructed when the first JNDI lookup (on InitialContext) to an object (EJB in your case) of a given database instance is made. The session is deleted when there are :
    a) no connections to the session
    -and-
    b) the EJB timeout has expired.
    The timeout only starts ticking when there are no connections to the session.

  • Passing JDBC Connection between differents EJB

    Hello,
    we are migrating diferents applications from WLS 4.5.2 to 6.1, some EJBs calls other
    EJBs with an java.sql.Connection as parameters. Is a problem known to use a connection
    which is obtained in other EJB?.
    we have foun a java.sql.SQLException when from the connection we call to preparedStatement
    method form Connection object.
    Thanks for all.

    Well, first you are only supposed to pass Serializable parameters. Second,
    it's better to just let the container manage your connections.
    Bob
    "Manuel Villalta" <[email protected]> wrote in message
    news:3cd920c4$[email protected]..
    >
    >
    >
    Hello,
    we are migrating diferents applications from WLS 4.5.2 to 6.1, some EJBscalls other
    EJBs with an java.sql.Connection as parameters. Is a problem known to usea connection
    which is obtained in other EJB?.
    we have foun a java.sql.SQLException when from the connection we call topreparedStatement
    method form Connection object.
    Thanks for all.

  • Updating to connection object

    Dear all,
    For my BC4J project, I have a connection by name CorrosionConnection. This connection is set with username=cer2265, password=cer2265,sid=cer, hostname=196.15.40.23,port=1521.
    So for so good. Application is working fine and I can happily make any transaction.
    This is my default setting. Suppose I have placed a text file as follows.
    username: cer2265
    password: cer2265
    sid: cer
    hostname: 196.15.49.23
    port: 1521
    Let us name this file as connection.txt. When ever application starts application should read this file and should update CorrosionConnection object with this information.
    Now suppose If i need to change the ip address from 196.15.49.23 to 196.15.49.22 what I need to do is the following..
    username: cer2265
    password: cer2265
    sid: cer
    hostname: 196.15.49.22
    port: 1521
    Thus a type of dynamic connection object is now created, where I can even change the username, password , sid and port.
    I don't know how to do this. Reading the file can be done by any filestream object. Updating the connection object is the problem.
    Can any one help me in this regard,
    Thanks in advance.

    If you need your connection to be dynamic because of DHCP you could use "localhost" or "127.0.0.1" for your IP address if your database server is on same machine as application server.
    Otherwise I would recomend reading BLOG from Steve:
    http://radio.weblogs.com/0118231/2004/08/11.html
    and Oracle documentation:
    http://www.oracle.com/technology/products/jdev/howtos/10g/dynamicjdbchowto.html
    and Google :)

  • How to store Connection object and call it from other programs.

    Hi,
    I am trying to connect to the database, store the connection object and use this connection object from other standalone java programs.
    Can any one tell me how to do this? I've tried in the following way:
    In the following program I am connecting to the database and saving the connection object in a variable.
    public class GetKT2Connection {
       public static void main(String[] args) {
          String url = "jdbc:odbc:SQLDsn;
          String dbUser = "sa";
          String dbPwd = "sa";
          Connection kt2conn = Connection connection = java.sql.DriverManager.getConnection(url, dbUser, dbPwd);
          if(kt2conn == null) {
             System.out.println("Database Connection Failure!");
          else {
             System.out.println("Connected to Database...");
         GetKTConnectionObj.storeKT2ConnectionObj(kt2conn);
    } Here is the program to save connection object in a variable.
    public class GetKTConnectionObj {
       static Connection kt2Connection = null;
       public static void storeKT2ConnectionObj(Connection conn) {
       kt2Connection = conn;
       public static Connection getKT2ConnectionObj() {
       try {
          return kt2Connection;
       catch(Exception e){
          System.out.println(e);
      return null;
    }Now from the following code I am trying to get the connection object that is stored. But this is throwing NullPointerException.
    public class Metrics_Migration {
      public static void main(String args[]) {
         try {
        java.sql.Connection connection_1 =   GetKTConnectionObj.getKT6ConnectionObj();
         catch(Exception e){
    }

    kt2Connection is null. You need to store it first, to make it not null. Otherwise it will stay null forever. And why on earth are you trying to do this THIS way?
    If you are running the two applications separately, it wont work either.

  • Windows RDS - configuring a default connection & desktop

    I'm looking at remote desktop options and used terminal services in the past.  I'm configuring remote desktop services on a Windows 2008 R2 server.  The goal is
    to allow users to go to a web page, pull up a remote desktop and access apps & server shares inside the network.
    I have it installed, and am able to get a connection using \\server\rdweb.  However, that takes me to the RDS default connection page. If I click on remote desktop it asks what computer I want to connect
    to.
    What I want to do is configure this or another web page to automatically connect to a default profile I've configured with various apps, or to create a new profile based on the user's login name like any PC
    does when you login with a new user ID.
    I'm sure it's in the documentation somewhere, I haven't run across it yet.

    Hi,
    Thanks for your posting in Windows Server Forum.
    As per your comment, I can say that you can try to change the login web page of RD web where you can place the default domain and user name for that user. 
    You can make changes on login.aspx file on “%windir%\Web\RDWeb\Pages\<The Language of Your Location>\”path as below:
    Change the original code section:
    <input id=”DomainUserName” name=”DomainUserName” type=”text” class=”textInputField” runat=”server” size=”25” autocomplete=”off” />
    to be:
    <input id=”DomainUserName” name=”DomainUserName” type=”text” class=”textInputField” runat=”server” size=”25” autocomplete=”off”
    value=”domainname\” />
    Please refer below thread for more information.
    How to set default logon domain RD Gateway and/or RD
    Web
    Hope it helps!
    Thanks,
    Dharmesh

  • Error in creating connection object

    Dear Experts
    When I am creating connection object using ES55 , I get Stop message saying : " Alternate ID not supported" and when i see Help it indicates : An alternative indicator is active in Customizing of the functional location. This functionality is not supported for connection objects and device locations
    what could be going wrong
    Plesae suggest me the solution
    Thanking you in advance
    warm regards
    narasimha

    Hi,
    Please check the following settings in SPRO:
    Plant Maintenance & Customer Service - -Master Data in Plant Maintenance & Customer Service --Technical Objects --Functional Locations --Alternate Labeling of Functional Locations - - Activate Alternative Labeling --
    In this setting pls inactive the setting for Alt.Label.Then go to ES55 and try.It will work.
    Thanks,
    Banasri Mitra

  • Duplicate check for Connection Objects in CRM

    Hi,
    I want to implement a duplicate check for connection objects in CRM. The duplicate check shall use the address of the connection object and perhaps additonal attributes. I have found a duplicate check for business partners using the basis address service and TREX as index pool. However, I couldn't find a similar functionality for connection objects. Does somebody know:
    1) How to implement a duplicate check for connection objects which is based on the address of the connection object?
    2) Is there a way to use the TREX-based duplicate check which is integrated into the basis address service for connection objects?
    Thanks in advance!
    Best regards,
    Frank

    I also have a requirement to check for duplicate address at connection object level and we are using SAP data servies to validate the address. Can anyone share their experience.

Maybe you are looking for

  • ITunes 11 deleted movie folder

    Not much else to do but continue argueing with Apple. Bit of history first, time machine asked to do a full system backup which I allowed, not thinking that it would do anything other than back up all the files and folders as usual. Monthly I use tim

  • Freezing a title roll?

    I've been getting some pretty good advice on the forum here. Here's another question: I would like to freeze the very last line of a title roll in the center of the screen for a few seconds before fading it out. I can get the roll done okay, and the

  • Facebook and Twitter importing contacts for Z10

    I just purchased the z10 yesterday and I love it! However when I imputed my Facebook and twitter information it synced my Facebook contacts and twitter ones with my personal contacts. Is there a way to turn that off? Or do I have to manually do it? T

  • Order By in Named Query

    Hello, is it possible to set ORDER BY in a Named Query Expression build through the Expression Builder? Or is it possible to trigger this while executing the Named Query in the UnitOfWork? Thanks, Thomas

  • Passing dynamic parameter to BEx Web from Visual Composer application

    Hi Experts, I have got a table with brand name with hierarchy node,  brand key and when the user selects a row on the table it should display detail data on the BEx Web. To do this, I have done the following; - Added a button to the Action Toolbar of