Avoid assigning to servlet static fields without using a shared lock??

Hi
i received the following warning on my code, does anyone give me a help on this? Thanks
"Avoid assigning to servlet static fields from javax.servlet.Service.service () without using a shared lock."
And my code are as follow:
public class MyDataSource {
    private static DataSource ds = null;
    public static DataSource getDataSource() throws NamingException, Exception
        if (ds==null){
               InitialContext ctx = new InitialContext();
            try{
                synchronized(getDataSource()){
                if(ds==null){
                    ds = (DataSource) ctx.lookup(SysProperties.ds);
            } catch (Exception ex) {
                throw new Exception("DBConnection Exception: " +ex.toString());
            }finally{
                    if(ctx !=null){
                        ctx.close();
        return ds;       
}

The service method of a servlet is multi-threaded to handle multiple requests. Hence,any static or public fields accessed by the service method should be restricted to a single thread access (for example using synchronized keyword) to make it thread-safe. That is why you are getting the warning message.

Similar Messages

  • How do i lock all fields without using the signature function with adobe lifecycle designer 9

    How do i lock all fields without using the signature function with adobe lifecycle designer 9 ...
    I want it to have the same affect as when a signature is used but not use that function. I want a button that says lock all fields. And then you can click it again to unlock all fields...
    Thanks

    Here you go!
    LOCK the form once its SAVEd?

  • How do I share my iTunes library to an iPad without using "Home Sharing"?

    I have set up my iTunes library to be shared with others over our home network.  This is the "Share your library" option, and NOT "Home Sharing" since my wife has her own Apple ID and I, unfortunatly, have 2.  She was wanting to listen to our music on her iPad but could not figure out how to access the shared library.  The "Music" app (click more, select library) only seems to work for Home Shared libraries.  (In fact, I had tried Home Sharing first and when I turned it off, all of the buttons at the bottom of the Music app's screen disappeared - note:  she has no music stored on the iPad.)
    So, how can an iPad access a shared iTunes music library without using Home Sharing?
    (iPad 2, iOS 6; Mac 10.8, iTunes 10 because 11 totally inhibits my ability to use my iPod the way I want.)

    -> Home Sharing is different than logging into the iTunes store.
    You enable Home Sharing using one AppleID. Doesn't matter which you use but all devices must use the same AppleID for Home Sharing.

  • How to move vertically the fields without using the Cross tab layout

    Hi all,
    I'm using Oracle Business Intelligence Discoverer Plus 10g (10.1.2.48.18).
    With Administrator I created a custom folder and I have the following list of fields:
    Ticket id
    Creation date
    Actual Situation
    Gravity
    Owner
    Category
    Group
    Inside my report I have as parameter the Ticket id, and then my intention is to create a page item for the ticket id, in order to change it directly from the report.
    Now my question is very simple. Instead to show the data as usual:
    !http://www.freeimagehosting.net/uploads/3da37e6a71.jpg!
    I'd like to know if there's a way to show these fields exactly in this way:
    !http://www.freeimagehosting.net/uploads/e578a40bb4.jpg!
    I tried to create a Cross tab layout, starting from the Table layout, but it doesn't work because I don't have data points to show, and above all I don't need a Cross tab logic.
    I need only to move vertically all the fields in order to show, for each ticket, all the ticket's details as shown above.
    Is it possible to have this layout ?
    Thanks in advance
    Alex

    Hi Rod, I'm sorry if I answered you only now.
    My expression "in order to change it directly from the report" was just related to the Ticket Id, but right now the customer's requirements changed and I don't need to change it inside the report ; I just insert the Ticket Id at the beginning as parameter and then I see all its details.
    So, I tried your second solution (row generators) following the article on the blog...and It worked perfectly.
    Summarizing I created:
    1. a folder called "Row Generator - 20 rows"
    2. a complex folder called "Fields names"
    and then I created a join between the Tickets folder and the Fields names folder with the Dummy field
    I also create a LOV (on the Administrator) based on a calculated field inside the Fields names folder (I followed the LOV example shown inside the Row Generators Blog Article).
    Now, created the first piece:
    !http://www.freeimagehosting.net/uploads/e578a40bb4.jpg!
    I'm trying to create others details blocks, always in "vertical style" (Customer’s Data, Further Information, etc) as below:
    !http://www.freeimagehosting.net/uploads/8e006eb3cf.jpg!
    Do you know if this layout is feasible ?

  • Sum a field without using field in group by statement- sql server 2008 SSRS

    I am trying to write a query as follows;
    select todate, sum(entries) as A, sum(entries) as B  *(where dept=HR)
    from table 1
    where dept in(IT,HR)
    group by todate
    here A is summation of all the entries for dept IT and HR
    and want to get B as summation of entries having dept HR only
    Kindly note this sql would be used in ssrs 2008 dataset query.
    Please help.
    Thanks

    Hi, you can write it like this:
    select todate, sum(entries) as A, SUM(CASE WHEN Dept = 'HR' THEN entries ELSE 0 END) as B
    from table 1
    where dept in('IT','HR')
    group by todate
    Martina White

  • Can I use two different iTunes accounts on one computer without using Family sharing

    So my wife made the mistake of logging into her iTunes account on my computer to purchase some music and she also (without knowing what she was doing) turned on family sharing at some point.
    This is irritating for multiple reasons:
    Now I have hundreds of artists added to my iTunes match, all of who I care nothing about and don't want the clutter in my artist list, but I can't figure out how to permanently delete them off of my account. Also, now if I login to my account on iTunes I can't play any of my music for 90 days.
    Is there ANY way for me to re-organize my music, delete her junk, and get myself back to where I can play my purchased music on my iTunes account? Any time I try to organize or delete her music it shows back up next time I open it.
    I almost feel like I need to download all of my music off of the cloud, delete my iTunes account, and then open another one AFTER organizing my music while offline and then enable match again. Everything is so cluttered and frustrating. Looking for some advice.

    1. Give her a separate user account on your computer. If you have a backup copy of the library, you can restore it.
    2. If you encounter a 90-day waiting period, click here and ask the iTunes Store staff if they'll remove it.
    (125941)

  • Sort Rowset field values without using rowset.sort or sortscroll

    Hi dudes,
    any one tell me the different ways to sort a rowset values ie, single field or more than one field without using Rowset.sort or Sortscroll() method. i tried some ways but not get the optimum solution.

    My first question to you would be why you want alternatives for Rowset.sort or Sortscroll.
    Your question doesn't describe your true issue or motive to search for alternatives for delivered PeopleTools Apis & Buildin Functions.

  • F4 help on ALV without using OO

    Hi,
    How can I get F4 help on an ALV field without using OO concept?
    That particular field does not have a value table assigned to it. So i have manually created a matchcode.
    regards
    Nishant.
    Message was edited by: Nishant Gupta

    hi,
    check these links
    http://sap.ittoolbox.com/groups/technical-functional/sap-r3-dev/f4-help-in-alv-grid-812677
    http://sap.ittoolbox.com/groups/technical-functional/sap-r3-dev/f4-help-in-alv-grid-812668
    ALV grid f4 help
    ALV F4 Help Error
    Re: Help in ALV grid

  • Assign Type conflict with field symbols

    I have two tables tab1 & tab2, want to assign field values from tab1 to tab2 suing field symbols. Deatils are :
    TYPES: BEGIN OF ty_tab1,
        item1   TYPE char20,
        item2   TYPE char20,
        val1 type i,
        val2 type i,
    END OF ty_tab1,
    BEGIN OF ty_tab2,
        item1 TYPE char20,
        item2 TYPE char20,
    END OF ty_tab2.
    DATA: it_tab1 TYPE TABLE OF ty_tab1,
                it_tab2 TYPE TABLE OF ty_tab2.
      FIELD-SYMBOLS <fs_tab1> TYPE ty_tab1.
                     <fs_tab2t> type ty_tab2.
      LOOP AT it_tab1 assigning <fs_tab1>.
        READ TABLE it_tab2  assigning <fs_tab2> WITH KEY item1 = <fs_tab1>-item1
                                                                                    item2 = <fs_tab1>-item2.
        IF sy-subrc EQ 0.
          ASSIGN COMPONENT 'ITEM1' OF STRUCTURE <fs_tab1> TO <fs_tab2>.
         ASSIGN COMPONENT 'ITEM2' OF STRUCTURE <fs_tab1> TO <fs_tab2>.
        endif.
    endloop.
    Getting error msg
    You attempted to assign a field to a typed field symbol, but the field does not have the required type.         
    whats the reason of error.
    Edited by: Matt on May 27, 2011 8:59 AM - added  tags

    Taken from example dump
    A new value is to be assigned to the field "...", although this field is
    entirely or partly protected against changes.
    The following are protected against changes:
    - Character literals or numeric literals
    - Constants (CONSTANTS)
    - Parameters of the category IMPORTING REFERENCE for functions and
    methods
    - Untyped field symbols not yet assigned a field using ASSIGN
    - TABLES parameters if the actual parameter is protected against changes
    - USING reference parameters and CHANGING parameters for FORMs, if the
    actual parameter is protected against changes and
    - Accesses using field symbols if the field assigned using ASSIGN is
    protected (or partially protected, e.g. key components of an internal
    table with the type SORTED or HASHED TABLE) against changes
    - Accesses using references, if the field bound to the reference is
    protected (or partially protected) against changes
    - External write accesses to READ-ONLY attributes,
    - Content of a shared object area instance accessed using a shared lock
    (ATTACH_FOR_READ).
    You likely fall in one of these cases. Check each and if still unsure please share your code so we can reproduce the error.
    Regards
    Marcin

  • Data fetch from table without Refresh and without using tab key.

    hi Friends,
    I have a problem i want to extract data from table without Refresh into text field without using Tab key. when i'll enter any value in a text field then corressponding value should come in to corressponding textfield without using Tab Key.
    eg. when i enter emp_id 101 in a text field then the first_name and last_name ,adress should come in to corressponding text fields without refresh and without using Tab key.
    How Can I do this.
    Thanks
    Manoj

    Hi Manoj,
    I assume that this is similar to: Data fetch without Refresh rather than Re: Value of one textfield should come into another textfield Without Using TAB ?
    If so, the only change you need to make on the first one is to use "onkeyup" instead of "onchange" in the item's "HTML Form Element Attributes" setting.
    Note, however, that the user must move away from the item at some point (for example, to click a button), so the onchange will be triggered anyway.
    Andy

  • Static field changes for both instances

    Whenever I construct a new object with a static field or use a set method on any of the instances of that object, the static field will change to the last modification made. In the case of my program, whenever the static String color field is changed to the last modification made. This only happens with the static fields, the other fields work just fine.
    Why does this problem occur?

    Sorry, I can't understand the question. If you have lots of different objects, all of the same class, they all share one copy of the static field, so if you invoke a method that changes the static field on one instance, all the other instances will see that change.
    if you don't want this behaviour, don't make the field static; then each instance will have its own copy of the field.

  • Capture context change without using UDF

    Hi,
    I need to find context change of a field without using UDF.
    I know we can do it in an UDF by comparing with ResultList.CC.
    But do we have any graphical constant that notifies a context change?
    regards,
    Piyush

    Hi,
        There is no graphical constant by which you can identify a context change without using UDF. However, if you leave the context of the field at the level of the immediate parent and map accordingly, you can handle the contexts directly in your GUI mapping. This however would also depend on your mapping requirements.
    Regards,
    Shiladitya

  • How to display the fields in ALV Output without using Field catalog?

    How to display the fields in ALV Output without using Field catalog?
    Could you pls tell me the coding?
    Akshitha.

    Hi,
    u mean without building field catalog. is it? I that case, we can use the FM REUSE_ALV_FIELDCATALOG_MERGE.
    data: itab type table of mara.
    CALL FUNCTION 'REUSE_ALV_FIELDCATALOG_MERGE'
    EXPORTING
    i_program_name = sy-repid
    i_structure_name = itab
    CHANGING
    ct_fieldcat = lt_fieldcat[]
    EXCEPTIONS
    inconsistent_interface = 1
    program_error = 2
    OTHERS = 3.
    *Pass that field catalog into the fillowing FM
    call function 'REUSE_ALV_GRID_DISPLAY'
           exporting
                i_callback_program      = gd_repid
                i_grid_title            = 'REPORTING'
                is_layout              = gt_layout
                it_fieldcat             = lt_fieldcat[]
           tables
                t_outtab                = itab.

  • How to set item values without using fields in branch's ACTION block?

    Okay, I will try to say this in a easy way so it is not weird.
    I have created a button, SAVE, that has a Branch of branch type: Branch To Function Returning A Page. This is my code for the branch:
    if :P2008_NAP_SUPPORTING_MATERIALS = 'Yes' then
    return '2092';
    else
    return '2040';
    end if;
    The code for this type of branch is stored in the ACTION block of the Branch page. The ACTION block for a Branch of branch type: Branch To Function Returning A Page is different than the ACTION block for a Branch of branch type: Branch To Page Or URL.
    I need to set some item values with some specific values, which I can do with a branch type: Branch To Page Or URL. This is not possible with the branch type: Branch To Function Returning A Page. The ACTION block is totally different.
    How can I set some values on say Page 2040 from Page 2008 without using fields in the branch's ACTION block?
    Thank you in advance,
    Maggie

    Andy and Scott,
    I love seeing different perspectives in solving problems, it opens my eyes to new ways of looking at/using the tools (reserved words and 'Function returning a Page', etc.).
    One of my pet peeves has been that on branches I was limited to only 10 variables to be passed (I know, who would want more - but there was an instance where I had to pass more), and an even more frustrating time when using report Column Linking, which limits me to 3 variables.
    At least with the Branch linking I can use your suggestion Andy and add the variable setting statements into the function. I am assuming of course (and I should be able to) that I will be able to set more that 10 variables in a IF condition prior to the RETURN statement. This method will be much more understandable, for me, when looking through the branch at a later time to see what is happening, than an URL link where all the variable are strung out 'in a line' so to speak.
    I will still need to use URL Target branching on Links contained within a Column Attribute when I need to pass more than 3 variables, of which I have several places where I do this.
    Thomas

  • Assigning External content type field column value using Client Object Model

    I have a problem assinging External column value to ListItem object with client object model-based application I'm developing. To be precise, I am able to retrieve data related to external content type by reading external list created from this content type
    but I don't know how to properly use it to assign value to this field. By doing some research on my own I concluded that BDC ID column from external list is the way to go since it uniquely defines selected row from external list but that doesn't
    tell me much since I don't know what to do with it. Currently I ended up with partial solution - to assign plain string value of picker column but that makes this value visible only in "View Properties" option on Sharepoint and not in "Edit Properties"
    which pritty much makes sence since it isn't properly related to rest of the data in specific row. Does someone have a better solution for this?
    Igor S.

    I think I understand your problem.
    In my example I have an external data column "Beneficiary Name", using a Beneficiary external content type (accessing a table of beneficiaries in a SQL table).
    I want to set the "Beneficiary Name" property using the client object model. I know the name of the beneficiary but not the ID value.
    It is a fairly simple solution. You just need to identify the name of the property SharePoint assigns to the ID field, in my case it is called "Beneficiary_ID". Then set the two properties as follows:
    thisItem["Beneficiary_Name"] = "Charitable Trust";
    thisItem["Beneficiary_ID"] = -1;
    thisItem.Update();
    Setting the ID property to -1 causes the server to do an automatic lookup for the ID from the value assigned to the item.

Maybe you are looking for

  • Dunning Letter Report for Portugal

    Hi All For Dunning Letter Portugal language rdf file made some changes in layout like removing break for credit and debit transactions and moving address field to right side But fields from Dunning letter setup in applications (first line) is getting

  • CS4 Prod Premium-can't update or uninstall

    My basic issue is that updates to the suite won/t work. Nothing will update and there is no error message as to why.Now I discover can't uninstall CS4. Yes, I've been in contact with support and they told me to run the windows cleanup utility and rem

  • Email for multiple locations (phone and pc's)

    It seems that if i pull emails onto my phone and then delete them before I pull them onto my pc, they can't be downloaded onto my pc anymore.  I know there is a setting in Outlook to "Leave a copy of messages on server".  Is there a way to set this s

  • BO with BI Queries

    Hi BO Experts, Currently i am working on Business Intelligence 7.0.I just want to know what is the role of BO with BI. In BI, we have different areas. 1. Extraction. 2. Modeling. 3. Reporting. Is BO is used only in the reporting side (using Crystal R

  • About LSMW and Idoc

    Hi Guys I am new to LSMW and IDoc or BAPI method. Can anyone email me some step by step docs. Pls dont send me other methods, I knew it already! Thx in advance! Kun Bao