Is it safe to store reference?

I'm new to EJB, I've read about dynamic loading in EJB to improve performance. Is it safe to store a reference to object returned by InitialContext, because I assume that InitialContext returns an object representing the "class", not the "instance"?
For example:
public class SomeBean extends ...
    private Object objRef;
    public SomeDetail getDetail()
        try {
            Context jndiCtx = null;
            if (objRef == null)
                jndiCtx = new InitialContext();
                objRef = jndiCtx.lookup("Detail");
            Detail = (Detail)
                PortableRemoteObject.narrow(objRef, Detail.class);
        } catch (Exception NamingException) {
            NamingException.printStackTrace();
    }

No it isn't safe the way you have done it, and the lookup does not return you a "class" object, it returns a stub. You can, however, store references to Objects but these should be executed in the setSessionContext() or setEntityContext() methods - as these are always called before you can call the Remote methods on the bean (ie. when the bean is "resurrected" they will be called again - they will NOT be called every time a Remote method is called).

Similar Messages

  • Is it safe to store my macbook air on its end?

    I have limited space and was hoping it would be "safe"to store my MacBook Air on it's end (vs flat)?  If so, any end?  I'm thinking that you carry it around in a messenger bag or something and it is upright, so it probably is safe, but not sure for a prolonged time (like overnight). 
    Thanks for your feedback!

    It would be just fine.

  • Is it safe to store personal information on iphone 5

    I have an app called "for my eyes only" that is password protected, i was wondering if it was safe to store personal information in there on my iphone 5.

    In theory yes.
    However, as electronicsguy says, it is only as secure as your password and how private you keep your password.
    Note:  Assuming you backup your iPhone, that means the encrypted file is stored outside your iPhone, so use a long password, as if anyone gets access to a copy of the encrypted file, they could try a brute force password crack.  The longer you password, the less likely a brute force crack will be able to unlock the file.
    See the following site for more information about long passwords:
    Password Haystacks
    Gibson Research Corporation (GRC.com)
    <https://www.grc.com/haystack.htm>
    My suggestion for a long password, is one that is easy to enter on the iPhone keyboard, such as mostly alpha characters and spaces, as that is easier to enter on an iPhone keyboard, just make it long and you should be more than safe.

  • Best Way to store references to other objects

    Hi there,
    I want to design a class, that has several references to other instances. What is the best way to store such references within the class? As a vector? As a Hash-Table?
    What I need are:
    -get a certain element in this data-structure fast (let's say the fifth)
    -be able to list all elements referenced
    -delete a certain element (e.g. 5th one out of 10)
    What I do not necissarily need is:
    -to be able to search if a certain object is referenced by this one
    What do you propose?
    Any ideas?
    Thx
    Karlheinz Toni

    Any thoughts on hashtables etc?
    I used them in an application where i needed to get
    objects quickly. It allowed me to get the objects
    based on a criteria instead of by the object itself.
    It was really useful for me.Use HashMap instead of Hashtable. HashMap would also work but you can't get element 5 unless you use the element number as a key. If you do use the element number as the key, it's kind of like using a List except it won't renumber itself, which you may or may not want. For example, if you remove element 5 from a List element 6 (if it exists) becomes element 5. If you remove key 5 from the HashMap you just don't have an element 5 anymore i.e. the map will return null for get(new Integer(5));

  • Is it safe to extend Reference sub-classes?

    I'd like to extend SoftReference to include an instance field for the referent's ID. I'll use this to remove the referent's reference from a Map keyed by the ID. Is this acceptable?

    Yes, this can be a useful thing to do. That is why the Reference classes are not final.
    If you are putting your References into a ReferenceQueue, then extra state information stored in the References can be used to determine what actions to take when they are removed from the queue.

  • Is it safe to keep downloaded movies in the Macbook Pro or do I need to use an external hard disk for those ? Please suggest.

    Is it safe to store the downloaded movies from iTunes in my Macbook Pro or do I need to store those separately in an external hard disk ? Please advice.

    It will be no better or worse than any other video file and should not be responsible for any system instability.  As I alluded to earlier, video takes up a lot of space and you can quickly use up that 200 GB of space.  Download a few files to you MBP and see what impact it has.  I have a couple of external HDDs dedicated to video files (and backups of same) due to the large file sizes. 
    If you find that space is getting tight on your MBP, then get an external for the video files and another one to back them up.  I have a couple of external HDDs dedicated to video files (and backups of same) due to the large file sizes.
    Ciao.

  • Failure to Connect to Windows 8 Store using Domain Network

    Well, I am having a bit of trouble here. I am trying to connect to the Windows 8 Store to update my Lenovo ThinkPad to 8.1, but it seems that it will not connect 95% of the time. It is very rare for me to be able to get on to the store. Most of the time
    when I try to connect, I am at the local school which I am at 5 days a week. It keeps giving me the following message:
    Your PC isn't connected to the internet. To use the Store, connect to the internet and then try again.
    Let me say once more that I am at a school when this happens, I just want to know if there is anything I can do to fix it and what that might be.
    Thank you for taking the time to read this.

    Hi Ayers105,
    You may take a try to reset Windows Store cache, type WSReset.exe
    in the search box, then
    Select WSReset, wait for a moment and then try to update your apps again.
    Further, if the above won't help, try the following method:
    type or paste the following command:
    powershell -ExecutionPolicy Unrestricted Add-AppxPackage -DisableDevelopmentMode -Register $Env:SystemRoot\WinStore\AppxManifest.xml
    hit Enter.
    Now in that same Administrator Command Prompt type or paste: start "" "ms-windows-store:"
    Reference:
    Windows App Store doesn't load after 8.1 Upgrade v. 2 (Also Works for Windows 10!)
    Best regards
    Michael Shao
    TechNet Community Support

  • Problem with Persistent Object as Reference Attribute of Persistent Object

    Hello All,
    I have a problem with a persistent class that contains a reference attribute to another persistent class.  I can write the reference object attribute to the DB but when I read the reference attribute back from the DB the object is null.  Allow me to explain...
    I have two tables; one is a data table with one key field of type OS_GUID, the second is a mapping table with several business key fields and two further fields; an instance GUID and a class identifier GUID.  The data table is used to contain all the data for an object.  The mapping table is used to hold a relationship between the GUID assigned in the data table and the business key.  The mapping table has been structured in this way by following the help here:
    http://help.sap.com/saphelp_erp2005vp/helpdata/en/df/e785a9e87111d4b2eb0050dadfb92b/frameset.htm
    and the field mapping in persistent class for the mapping table has been mapped following the help here:
    http://help.sap.com/saphelp_erp2005vp/helpdata/en/06/f23c33638d11d4966d00a0c94260a5/frameset.htm
    The code I use to create entries in the data and mapping table is:
    <-snip->
      DATA:
        gv_blank_data_guid TYPE REF TO zcl_ps_data,
        gv_data_guid       TYPE        os_guid,
        go_data_ps         TYPE REF TO zcl_ps_data,
        go_data_agent      TYPE REF TO zca_ps_data,
        go_data_map_ps     TYPE REF TO zcl_ps_data_map,
        go_data_map_agent  TYPE REF TO zca_ps_data_map,
        go_exc             TYPE REF TO cx_root.
      go_data_agent = zca_ps_data=>agent.
      go_data_map_agent = zca_ps_data_map=>agent.
      TRY.
    Check if there's already data with the business key on the DB
          go_data_map_ps = go_data_map_agent->get_persistent(
                             i_data_ref     = iv_data_ref
                             i_action       = iv_action ).
    ... if there is then exit.
          EXIT.
        CATCH cx_root INTO go_exc.
      ENDTRY.
      TRY.
    Create the data...
          go_data_ps = go_data_agent->create_persistent(
                           i_root_guid = gv_blank_data_guid
                           i_req_date  = iv_req_date ).
          TRY.
    ... finally, write the new data to the data business key map table
              go_data_map_ps = go_data_map_agent->create_persistent(
                                 i_data_ref     = iv_data_ref
                                 i_action       = iv_action
                                 i_data_guid    = go_data_ps ).    "note1
            CATCH cx_root INTO go_exc.
          ENDTRY.
        CATCH cx_os_object_not_found.
      ENDTRY.
      COMMIT WORK.
    <-snip->
    The fact that it is possible to pass the object GO_DATA_PS in the call to GO_DATA_MAP_AGENT (the line that I've put the comment "note1" on) indicates to me that the reference to the data persistent object can be written to the DB by the mapping persistent object.  After executing the above code the mapping table object and class identifier fields are populated.  Also, if multiple entries are written to the tables then the class identifier field in the mapping table is always the same and the object ID is different as expected.
    However, the problem I have is if I read an object from the DB using the business key with the following code:
    <-snip->
      DATA:
        gv_req_date        type        datum,
        gv_data_guid       TYPE        os_guid,
        go_data_ps         TYPE REF TO zcl_ps_data,
        go_data_agent      TYPE REF TO zca_ps_data,
        go_data_map_ps     TYPE REF TO zcl_ps_data_map,
        go_data_map_agent  TYPE REF TO zca_ps_data_map,
        go_exc             TYPE REF TO cx_root.
      go_data_agent = zca_ps_data=>agent.
      go_data_map_agent = zca_ps_data_map=>agent.
      TRY.
    Read data mapping with the business key
          go_data_map_ps = go_data_map_agent->get_persistent(
                             i_data_ref     = iv_data_ref
                             i_action       = iv_action ).
    ... then read the data.
          TRY.
              CALL METHOD go_data_map_ps->get_data_guid
                RECEIVING
                  result = go_data_ps.
            CATCH cx_os_object_not_found.
          ENDTRY.
        CATCH cx_root INTO go_exc.
      ENDTRY.
    <-snip->
    At no point during this code are the attributes of the object of the persistent class for the data table populated with the contents of the fields of the data table referenced as the attribute of the mapping table.  To clarify, when viewing the object in the debugger all the attributes of the mapping object that are simple table fields are populated with the values of the fields of in the mapping table, however, the attributes of the object that represents the persistent class for the data table are not populated with the fields of the data table.  I had hoped that by reading the mapping table object the data object would automatically be populated.  Is there another step I need to perform to populate the data object?
    I'm sorry if the above is hard to follow.  Without being able to provide screenshots it's difficult to explain.
    If someone has managed to store references to persistent objects in a table and then read the references back could you list the steps you went through to create the persistent classes and include the code that reads the objects please?  The code I have almost works, I must be just missing some subtle point...
    Thanks in advance,
    Steve.

    Hi Andrea,
    The iObject being replicated at item level for Service Complaints is the SAP standard behaviour.
    Generally we raise complaint refering to some sales or service issues. In your scenario you are trying to create a complaint based on an iObject, then you have to mention the corresponding product details. I dont see any business requirement not to copy the iObject product at the item level.
    If you want it then I think only you have to write a Z program for it.
    Hope this helps!
    Regards,
    Chethan

  • Format of weblogic.store.Admin "dump -deep" XML output file?

    Does anyone know where I can find a detailed description of the format of the XML file created by using the "dump -deep" command within the Store Administration utility?
    I ran into a problem with stuck messages in a SAF persistent store on WebLogic 10.3.2. After trying everything I could think of to get the messages moving, I resorted to recovering them from the persistent store file into XML files on the filesystem, purging them from the SAF, and then re-injecting them onto the appropriate topics. The message recovery was very straightworward with a simple utility to extract the XML for the messages from the file generated by the "dump" command in the weblogic.store.Admin Store Administration utility. (NOTE: You must use the "-deep" dump option to get the message XML.)
    This process was hampered by the fact that the stuck messages were intended for more than one destination and I could not easily discern the intended destination for each. This information must be in the persistent store, but I do not know whether it is available in the "dump -deep" file.
    Any insight into the dump file format would be appreciated. I could not find anything in the docs.
    Thanks!
    - Harry

    There's no facility that I know of for interpreting the data in a store.Admin dump - which explains why there's no mention of such a thing in the docs. If you're using SAF agents, I think it may have been possible to boot the WL host server, and then use the WL JMS "message management" utilities to "export" the messages. If you still need help, I recommend opening a case with customer support - make sure to save the original backing store (.DAT files or tables with file stores).
    Tom

  • Are static nested classes thread-safe?

    There doesn't seem to be any definitive answer to this. Given the following code, is it thread-safe?
    public class SomeMultiThreadedWebController {
    public HttpServletResponse someMethodToExecuteViaWebRequest(HttpServletRequest request) {
        simpleQueryBuilder("SELECT...").addParameter("asdf","asdf").createQuery(EMF.getEntityManager()).executeUpdate();
    protected static class SimpleQueryBuilder {
             private String queryString;
             private Map<String, Object> params = new HashMap<String, Object>();
             public SimpleQueryBuilder(String queryString) {
                  this.queryString = queryString;
             public SimpleQueryBuilder addParameter(String name, Object value) {
                  params.put(name, value);
                  return this;
             public Query createQuery(EntityManager em) {
                  Query query = em.createQuery(queryString);
                  for (Entry<String, Object> entry : params.entrySet()) {
                       query.setParameter(entry.getKey(), entry.getValue());
                  return query;
        public static SimpleQueryBuilder simpleQueryBuilder(String queryString) {
             return new SimpleQueryBuilder(queryString);
    }Forget whether or not someone would do this, as this is just an example. I'm really trying to get at whether or not the instance variables inside the static nested class are thread-safe. Thanks for any responses.

    Hello,
    I believe you understand what you're talking about, but you state it in a way that is very confusing for others.
    Let me correct this (essentially, incorrect uses of the terminology):
    I agree that thread-safe or not is for an operation, for a member, it has some sort of contextual confusion.
    Member has a much broader meaning in the [Java Language Specification|http://java.sun.com/docs/books/jls/third_edition/html/names.html#6.4] . Even "class member" applies to both an attribute, a method, or an inner class or interface.
    I think you mean "member variable" of a class (aka "attribute" or "field"). By the way, static or not is irrelevant to the rest of the discussion.
    For an operation or a member, if there's only one thread could access it atomically in one moment, we could call it thread-safe.Mmm. I was tempted to say yes (I'm reluctant to commit myself). With an emphasis on "_The encapsulating class_ makes this member's usage thread-safe".
    Still, just synchronizing each operation on a member is not enough to make all usages "thread-safe":
    Consider a java.util.Vector: each add/get is synchronized, so it is atomic, fine.
    However if one thread adds several values, let's say 3, one by one, to a vector that initially contains 0 values, and another thread reads the vector's size() (another properly synchronized method), the reader thread may witness a size anywhere among 0, 1, 2, 3, which, depending on the business logic, may be a severely inconsistent state.
    The client code would have to make extra work (e.g. synchronizing on the vector's reference before the 3 adds) to guarantee that the usage is thread-safe.
    Thus any synchronized method(With the limit stated above)
    or immutable member (like primitive type) are thread-safe.
    Additionally for a member, if it's immutable, then it's thread-safe. You mean, immutable primitive type, or immutable object. As stated previously, an immutable reference to a mutable object isn't thread-safe.
    a static final HashMap still have thread-safe issue in practice because it's not a primitive.The underlined part is incorrect. A primitive may have thread-safety issues (unless it's immutable), and an object may not have such issues, depending on a number of factors.
    The put, get methods, which will be invoked probably, are not thread-safe although the reference to map is.Yes. And even if the put/get methods were synchronized, the client code could see consistency issues in a concurrent scenario, as demonstrated above.
    Additional considerations:
    1) read/write of primitive types are not necessarily atomic: section [ §17.7 of the JLS|http://java.sun.com/docs/books/jls/third_edition/html/memory.html#17.7] explicitly states that writing a long or double value (2 32-bits words) may not be atomic, and may be subject to consistency issues in a concurrent scenario.
    2) The Java Memory Model explicitly allows non-synchronized operations on non-volatile fields to be implemented in a "thread-unsafe" way by the JVM. Leading way to a lot of unintuitive problems such as the "Double-Checked Locking idiom is broken". Don't make clever guess on code execution path unless you properly synchronize access to variables across threads.
    Edited by: jduprez on Mar 4, 2010 9:53 AM

  • JMS SAF client paging directory definition ignored

    The paging directory definition in our ClientSAF.xml file is ignored:
              <weblogic-client-jms xmlns="http://www.bea.com/ns/weblogic/90" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
              <persistent-store>
                   <directory-path>C:\Work\newaupload\jms</directory-path>
                   <synchronous-write-policy>Disabled</synchronous-write-policy>
              </persistent-store>
              <saf-agent>
              <paging-directory>C:\Work\newaupload\jms-paging</paging-directory>
              </saf-agent>
              </weblogic-client-jms>
              Instead of the directory given in the configuration, the JMS SAF client creates a directory called "paging" in the current directory. In our case, the current directory is where all the binaries are and which is not writable, i.e. the JMS client fails.
              Is something wrong with the configuration? Or is this a bug?
              Peter
              Edited by peter05 at 05/30/2008 3:30 AM

    Hi Peter,
              For a server-side SAF with a file store, a paging directory would normally only be used internally for non-persistent messages - and I think client-side SAF would have the same behavior if it actually supports non-persistent messages in the first place.
              I don't know if the SAF client supports non-persistent - as I hadn't really thought about it -- there doesn't seem to be much purpose in it given that the purpose of SAF is store-and-forward and the "store" part implies persist messages.
              As a work-around, perhaps you can create the directory manually as read-only, then check to see if your app places any files in this directory. If it is, then your app could be creating non-persistent messages for store-and-forward, which likely isn't your intent -- non-persistent messages are not recovered on a restart, even if they are in a paging directory.
              If there must be an active paging directory for some reason, I advise (A) contacting customer support to find a way to configure it uniquely and (B), as a work-around, using an operating level linked directory or some-such to redirect the "paging" directory name out of your read-only binary directory to a better place.
              Hope this helps,
              Tom
              PS. In addition, it's a little strange to me that this directory name is hard-coded - what would happen if two SAF clients running in the same JVM attempted to use the same paging directory? Would they conflict with or even corrupt each-other?

  • Pet Store 2 example in netbeans

    Hello, ppl im trying to run the pet store 2 example given in this page:
    https://blueprints.dev.java.net/petstore/usingnetbeans.html
    using netbeans but i dont understand how to make it work, i;ve downloaded the jar file but if in netbeans i open a proyect but i cant open the jar as a project, can anybody help me? and later i would like to open it in Creator, is it possible?
    Tnks in advance!
    Belthazor

    Okay, the solution: don't let the text
    "2. Download and install the Java Pet Store Reference application. Click here (https://blueprints.dev.java.net/downloads.html) to download the JAR file. ..."
    mislead you like it did to me.
    There's no JAR file to download if you want to import Petstore in Netbeans. On page https://blueprints.dev.java.net/downloads.html don't choose "Web 2.0 Java Pet Store Application", click "Java BluePrints in Java EE SDK" instead. You have to download the full "Java BluePrints" example package (ZIP file) bundled with Java EE 5 SDK Update 2 OR just the package itself on the same page (http://java.sun.com/javaee/downloads/index.jsp) under section "Download the Components Independently".
    Have a nice day!

  • Download and store files directly to TimeCapsule?

    Hi,
    I'm wondering is there a way to save downloaded files direct to the TimeCapsule. Normaly after download files to my Mac, I have to copy and store them in TC. TC. Its time consuming process.
    Another is that safe when store files in Time Capsule?
    Thank for support!

    One should have an exclusive drive or partition for backup separate from one used just for storage. This assures a lower likelihood of damaging one or the other.
    If it were possible to partition a TC, then you could use one volume for backup and the other for storage, but even that would risk the loss of both were the drive to fail.

  • SAP Retail: Creating reference sales pricing

    Hi, I am looking for help in creating article reference sales prcing and store reference sales pricing.
    Article reference sales pricing:Price of Article# B should always be 10% less than article# A.
    Site reference pricing: Price of article# B in Store# S1 should always be 5% less than article# B in Store# S2.
    Please let me know if you any idea on this.

    That approach would effectively duplicate the implementation of BAPI_SALESDOCUMENT_COPY, wouldn't it?
    As there is a lot more data involved than just VBAK/VBAP (e.g texts, partners, conditions, schedules) this is not only a lot more effort it's also harder to get it right, especially since there might also be copy control customization which has to be take into account.
    Nevertheless I tried it and it isn't working in my case.
    I' have to create a debit memo request (BUS2096) out of a sales order (BUS2032), and BAPIs SALES_ORDER_CREATE* only handle BUS2032.

  • Closing a step reference

    Hello
    What is the proper method to use to close an open sequence step reference?  I can't seem to find one under any of the object classes methods.
    thanks

    If you are using Object Reference type Property Objects to store references, then there is no need to set those variables to nothing or null.  When the variable leaves scope (i.e. when the sequence or execution finishes), TestStand will automatically release the references.
    This is one advantage to using the TestStand API from a sequence, you don't have to worry about closing the references, because the Engine will do it for you.
    Josh W.
    Certified TestStand Architect
    Formerly blue

Maybe you are looking for

  • Is there a way to modify the delivery Quantity before Packing takes Place?

    Here is the story. ATP is currently allocating partial delivery unit qty's is the Sales order schedule lines. This is causing numerous problems from a business and logistical standpoint and I have yet after weeks of searching found a solution. The st

  • Ovi Suite Error code 12052

    Hello! I've been trying to resoft my Nokia N73 using the Ovi Suite. Everything works fine in the beginning, but then I get an error telling me that there was a problem with Nokia Suite and that I should reinstall the program and retry. Also, it gives

  • I try to connect to "itunes store" but when i connect i cant see any application that i can buy .  what should i do

    hi . just yesterday i update my itune to version 10.5 but when ever i coonect to itune store it is not showing any application there that i can purchae . what shall i do .

  • Create null message using BizTalk mapper XSLT

    Hi, I have a requirement to check if a message contains a certian value, and if so, throw away the message.  Does anyone know how this could be done using BizTalk mapper/ XSLT?  It's an ESB messaging only solution so don;t want to introduce orchestra

  • Icons in .jar files...

    Hi , I have configured successfully and see some icons on buttons. Next day , i took the .jar file , copied it in \java folder and i have configured appropriately the formsweb.cfg file - calling this .jar file among others- according to my system (wh