Global reference in J2EE

is it possible for inter-clients (for example, java bean, ejb or servlet in J2EE) to get a global reference to an object which is in momory?

Sure bind the object to global name using JNDI then use the name to look up the object from the various components.

Similar Messages

  • Making JNIEnv a global reference

    Hi All,
    I have a class A in which I have a method m1() and a static method m2(). From m1() I invoke a native method nm1() passing refernce to the JNIEnv and other parameters. When there is a call to nm1(), the control goes to nm2 another native method. From nm2, I need to make a call back method on class A to invoke m2(). Please note that I cannot pass JNIEnv reference to nm2(). Can I make the incoming JNIEnv inside nm1() a global reference and access it from nm2()? Also note that i will only make use of JNIEnv and not the jObject in the nm2(). I know it works but would like to know what would be the impact in the multi threaded scenario.
    Any inputs in this regard would be greatly apprciated.
    Thanks,
    Griish

    Hi,
    I think you should save the JavaVM* pointer then get back the JNIEnv* from it.
    See the callback part of JNative at http://jnative.cvs.sourceforge.net/jnative/JNativeCpp/CallBack.cpp?view=markup
    As you can see at line 11 the JNIEnv got from the vm pointer.
    I choose to save the JavaVM* pointer for potential threading issues.
    --Marc (http://jnative.sf.net)                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       

  • JHAT / JNI Global Reference

    I'm tracking down a memory leak using jmap and jhat. I have a number of objects (frames of a MDI) for which the only surviving strong reference is listed as a JNI Global Reference. I know basically what these are, but I know that I'm not calling NewGlobalRef in my JNI code (which consults the Windows registry and handles file dialogs).
    It may be coming from one of several 3rd party libraries that are included. Does anyone have advice on how to track these references in JNI land?
    The jhat output for rootset reference chains:
    Rootset references to com.example.Frame@0x7acc3a0 (excludes weak refs)
    References to com.example.Frame@0x7acc3a0 (773 bytes)
    JNI Global References
    JNI Global Reference :
    --> com.example.Frame@0x7acc3a0 (773 bytes)
    Thanks much,
    Michael

    You could mock the calls out for each dll.

  • Does DeleteGlobalRef(saved reference) delete all global references?

    Hello,
    I have a question regarding global references, if you assign two global references to the same object by....
    static jbobject savedReference, sameSavedReference Object,
    savedReference = env->newGlobalRef(obj);
    sameSavedReference = env->newGlobalRef(obj);
    then you call
    env->DeleteGlobalRef(savedReference);
    savedReference = null;
    sameSavedReference = null;
    When does the java object with the pointer sameSavedReference get garbage collected?
    Does the env->newGlobalReference hold a reference onto the same object, even if we called deleteGlobal with savedReference?
    Do you need to call also?
    env->DeleteGlobalRef(sameSavedReference);
    I know that if you try to access sameSavedReference after
    env->DeleteGlobalRef(savedReference);
    savedReference = null;
    sameSavedReference is no longer valid, however that could just mean that the global reference got deleted, and you need to resign sameSavedReference to another global reference.
    Whew this is confusing :) Any help would be appreciated!
    Tom

    I'm taking a guess :-) but I think if the references are different then they should be deleted. If the references are different, even if to the same object, I would think the deleteGlobalRef tells the JVM to remove that reference. I hope someone wiser will confirm :-)

  • How to set runtime references in J2EE library DC's

    Hi,
    I'm building an custom logon module. This is well described in
    http://help.sap.com/saphelp_nw04/helpdata/en/46/3ce9402f3f8031e10000000a1550b0/content.htm
    I created the following DC:
    1. simple java project DC that contains the login module class
    2. J2EE library DC that will act as the deployable component.
    The part "Make reference to the Security Provider service of the J2EE Engine." (2b) is where i get stumped:
    http://help.sap.com/saphelp_nw04/helpdata/en/bf/93d84072378031e10000000a1550b0/content.htm
    The example adds the reference direct to the provider.xml. I don't have that option when I develop the library as a DC.
    It seems that while EAR file DC's allow the adding of runtime library references via the application-j2ee.xml file, it seems that is not possible for J2EE library DCs.
    Specifically, I'm trying to get the follwing entry into the provider.xml:
    <references>
      <reference provider-name="sap.com" strength="weak" type="interface">security_api</reference>
    I saw one workaround in the SDN where they suggest to extract the provider.xml from the SDA and manually
    add the references but this isn't really an option in our case.
    Should I be deploying 'normal' EAR files in this case ? Have I overlooked something ?
    thanks
    Michael

    Hi,
    talk about overlooking the obvious . . . The appropriate public part is present in com.sap_SAP-JEE_1.
    Adding that worked.
    Michael

  • Global reference for columns

    Lets say I have three columns, A, B, and C. I want C to always be A-B. I can do this now but I always have to put in the row number, i.e. the formula for row 6 column C would be ( =a6-b6 ) and I have to put in the row number individually for each of the C column formulas. I would rather just put in a variable which would do it for each row automatically.

    If you enter
    =A2-B2 in cell C2
    you may fill the entire column without changing the row num by hand.
    Select the cell C2 then drag its bottom_right circular handle to the bottom of the column.
    The cells will be filled with an auto-adjusted row number.
    I used the short reference very often but since a few months I'm back to the complete reference for three reasons :=
    (1) if I export a spreadsheet to Numbers '08, the transcoder code will use the complete references. So I assumed that it may be a hidden reason.
    (2) As the User Guide never describe the short reference, I'm afraid that a new application version drop the short reference
    (3) I'm not sure that the short syntax is faster than the 'official' one.
    Yvan KOENIG (VALLAURIS, France) lundi 6 décembre 2010 19:15:22

  • Problem: J2EE Server Component Library's provider.xml error message

    Hello,
    I open the provider.xml fle. Then I click on the Jars tab and I get an error  message:
    The source page has errrors.  Other pages cannot be used until these errors are
    corrected.
    How can I correct the error(s) so that when I click on the Jars tab it will allow me add jar files?
    provider.xml content:
    ======================
    <?xml version="1.0" encoding="utf-8"?>
    <provider-descriptor>
      <display-name>Store jar files that need to be used at runtime</display-name>
      <component-name>global/lmco/runtime/j2ee/libs</component-name>
      <description/>
      <major-version>6</major-version>
      <minor-version>40</minor-version>
      <micro-version>0</micro-version>
      <provider-name>lmco.com</provider-name>
      <jars>
        <jar-name>
            commons-dbutils-1.0.jar
        </jar-name>
      </jars>
    </provider-descriptor>

    I have one provider.xml which has the dtd in it
    <?xml version='1.0' encoding='UTF-8'?>
    <!DOCTYPE provider-descriptor SYSTEM "library.provider.dtd">
    <provider-descriptor>
      <display-name>abclib</display-name>
      <component-name>abcLib</component-name>
      <description>
      </description>
      <major-version>6</major-version>
      <minor-version>1</minor-version>
      <micro-version>0</micro-version>
      <provider-name>com.company</provider-name>
      <group-name>
      </group-name>
      <references>
         <reference reference-type="hard">
         <reference-target provider-name="com.company" target-  type="library">xyzLib</reference-target>
    </reference>
    </references>
      <jars>
        <jar-name>aspectjrt.jar</jar-name>
        <jar-name>axiom-api-1.2.5.jar</jar-name>
        <jar-name>axiom-impl-1.2.5.jar</jar-name>
        <jar-name>nux.jar</jar-name>
        <jar-name>stax.jar</jar-name>
        <jar-name>xom.jar</jar-name>
      </jars>
    </provider-descriptor>
    check for the DOCTYPE declaration
    Regards
    Fariha

  • Problem with jni references

    i have to implement a few standard APIs. As a part of the implementation I have to provide references to an object I create. Now my underlying code is C++ with JNI used to throw the Java APIs. Problem is JNI now returns different references for the same object and hence my prupose id defeated. Could anyone suggest how this problem can be overcome.

    I'm not exactly sure what you're talking about, but it sounds like you may need to look into global references. Look at NewGlobalRef() and DeleteGlobalRef() and see if those help you out.
    God bless,
    -Toby Reyelts
    For all your JNI woes, check out Jace - http://jace.reyelts.com/jace

  • Is there a way to check which VI and it's subVI are using which item in a global variable.vi

    While i writing the program, the program is growing and i also use global variable for it, but sometime some variables is delete from the VI (due to modify of the VI)
    But usually I don't update the Global Variable.vi, there are is some indicator or control in the Global Variable.vi is not being select as a item in main VI.
    So how can i differentiate between the still using control/indicator(selected item in main VI) and extra control/indicator(not selected item in main VI)

    From your global definitions .vi, select one of the global variables, then right click. Select 'Find Global References'. This will give you a list of .vis using that global variable. You can also get the same info by right clicking a global variable reference on one of your .vis and selecting 'Find', then 'Global References'.
    Hope I understood your question!
    Matt

  • Communicate between SWF & Global static vars

    Sorry for my inglish...
    I’m having some problems on getting full communication between loaded SWFs. I'm totally stuck and my timing is running.
    Suppose the following scenario:
    Father-SWF has his own class and loads A-SWF and B-SWF. A and B SWF has his own class and package. To exchange values and run functions between SWF, I’m using a Global class with public static vars. Some of this vars are function, example:
    GLOBAL CLASS WITH STATIC VARS (com. with other class and package beetween SWF)
    package scripts
         public class GlobalAct
              public static var mainStage:Object;
              public static var myFuncGlobalA:Function;
              public static var myFuncGlobalB:Function;
    MAIN CLASS FATHER SWF
    package
         import flash.display.MovieClip;
         import scripts.GlobalAct;
         public class FatherClass extends
    MovieClip
              public function FatherClass():void
                   GlobalAct.mainStage
    = this;
                   GlobalAct.
    myFuncGlobal = myFunc;
              public function myFunc():void
                   //some wird stuff
    A_SWF CLASS
    package
    scripts
         import flash.display.MovieClip;
         import scripts.GlobalAct;
         public class Layout extends
    MovieClip
              private var someMc:MovieClip;
              public function Layout()
                    someMc
    = new MovieClip();
                    someMc. addEventListener(MouseEvent.CLICK,
    mouseFunc);
              public function mouseFunc (evt:MouseEvent):void
                   GlobalAct. myFuncGlobalA ();
    B_SWF CLASS
         Similar to A-SWF class but with other kind of functions…calling “GlobalAct.myFuncGlobalB();” for example.
    This works great, when I run Father-SWF, it load every SWF and functions run from SWF to SWF.
    The problem happens when I load Father-SWF in another SWF. There is a MAIN-SWF with his own set os class and a Global static vars Class.
    MAIN-SWF loads a SWF that will load Father-SWF into the MAIN-SWF.
    WORKING
    Father-SWF -> many SWF that could load other SWF
    NOT WORKING
    Main SWF -> SWF -> Father-SWF -> many SWF that could load other SWF
    When this happens none of the Global functions seems to work. The other Global vars seems OK, only function vars seems not to work.
    I only get the error: “TypeError: Error #1006: value is not a function. at scripts::Layout/ mouseFunc ()” when I try to click a button inside A-SWF.
    Does I lose my Global reference when loading the Father-SWF in another SWF?
    How can I make this bullet proof and generic for every situation?
    What’s the best oop practice to communicate between class and SWF on AS3?

    I figured it out.
    It's under the pop-up window. Select edit locations to select confirm.

  • Word 2007 Global Class

    Greetings,
    Using VS 2008 -VSTO - Word 2007 Add-In wizard.
    Is there a way to add your own global references to the system generated Globals internal class? For example, I'd like to keep track of the document opened during a session. if an event handler gets a reference to the document deep clones it and adds it to a hash structure, I'd like this "structure" to be stored under the Global internal class.
    On a different note, I do appreciate the ammount of work that went into build this framework. It makes it simple to build add-ins. The problem I have is that a lot of the power has been hidden by the framework, while that is very good for novices, it takes away control for an old guy like me.  Would it be possible to build just a assembly that gets loaded into an office application address space and shares the document model with it? Once again, the wizard is good, but I'd like a little more room to wiggle.
    Thanks,
    PP

    You can definately add your own properties to the generated Globals class.  Globals is a partial class defined in your add-in's designer file.  To extend it, simply add another partial implementation in another file.  Below is an example in C#:
    internal sealed partial class Globals
        internal static string MyCustomString { get; set; }
    public partial class ThisAddIn
        private void ThisAddIn_Startup(object sender, System.EventArgs e)
            Globals.MyCustomString = "Hello world!";
        private void ThisAddIn_Shutdown(object sender, System.EventArgs e)
    Here is another example in VB:
    Partial Friend NotInheritable Class Globals
        Private Shared _MyCustomString As String
        Friend Shared Property MyCustomString() As String
            Get
                Return _MyCustomString
            End Get
            Set(ByVal value As String)
                _MyCustomString = value
            End Set
        End Property
    End Class
    Public Class ThisAddIn
        Private Sub ThisAddIn_Startup(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Startup
            Globals.MyCustomString = "Hello world!"
        End Sub
        Private Sub ThisAddIn_Shutdown(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Shutdown
        End Sub
    End Class
    Regarding your second question, what control do you feel you have lost?  VSTO add-ins have access to the same Word object model used by non-VSTO add-ins.  Is there something in particular you would like to do in your add-in that you feel VSTO does not allow?
    -Phil

  • Get Globals ref in runtime

    Hi, I have the need of changing stattionGlobals variables value in runtime from LabView. This could not be a problem if I can pass the a reference object to the VI.
    The problem is that I have a Labview library and I can not change the connector panel of the VIs. Inside of severals VIs I should have the chance of changing some stationglobals variable value but without changing their connector panel. I guessed I could have store the Globals reference ( from engine-->globals) into a labview functional globals at the beginning of the sequence and then use it. But this reference change continually. And the Engine reference change continually too.
    Does anyone have some ideas?
    Thanks a lot.

    Hi,
    If you are passing the Engine reference to your VI's, then you can use Engine.Globals to get a reference to the StationGlobals then use the PropertyObject to Get or Set the value to your StationGlobals variable.
    If you are passing the SequenceContext to your VI's, then you can use SequenceContext.StationGlobals to get a reference to the StationGlobals then you can use the PropertyObject to Get or Set the value to your StationGlobals variable.
    In both cases the Lookup String would be just the name of the variable
    eg StationGlobals.MyString the lookup string would be "MyString"
    Regards
    Ray Farmer

  • A question about JNI references, persistence, and garbage collection

    I am writing a library to allow our Java developers to access C functions in our product. I want people on the Java side to be able to instantiate instances of a new object (on the C side), say "Map", and I want those objects to persist until they are destroyed on the Java side. I am thinking of creating a wrapper for the native methods, which stores an identifier for the instance of an object. When the C object is accessed, the identifier is passed to the C code which looks up the correct object in a table. I understand that if I use the NewGlobalReference call in JNI I can get objects to persist.
    When it is time for garbage collection I plan to override finalize() to call the C code and tell it to remove the Global Reference.
    Here's what I have in mind
    public class JMap() {
         private static int id;
         static {
              System.loadLibrary("libMap");
              /*Call C method which instantiates object and creates a GlobalReference
              which is stored in table. Returns ID for reference*/
              id = _init();
         public void setSize(int x, int y) {
              _setSize(id, x, y);
         public void finalize() {
              _finalize(id);
              super.finalize();
         private native int _init();
         /*calls DeleteGlobalReference for the reference matching this id*/
         private native void _finalize(int id);
         private native void _setSize(int id, int x, int y);
    }Is this the right thing to do? Have I understood the way JNI works with regard to GlobalReferences?
    Any comments, tips or pointers would be appreciated :)

    This probably should have been posted in the Native Methods sub-forum, I have reposted there:
    http://forum.java.sun.com/thread.jspa?threadID=657667
    Mods please delete this post :)

  • How to maintain reference across native calls?

    I'm using JNI to interface with an underlying C++ communications library. I am having trouble keeping my connection valid across native calls.
    For example, in one method I connect and save the connection in a global variable, then return. After I connect I would like to call a "send message" method, but when I do I doesn't recognize the saved connection.
    My question is do saved references persist across JNI calls when using the same object, or will all global vars be new ones? If not, does anyone know a way to get around this?
    Thanks for your help

    All JNI references that you create (through calls to NewObject, GetObjectArrayElement, GetObjectField, ...) or that are passed to your native code as parameters are local. That means that they are only valid for the duration of that native call and only on the thread from which that native call was invoked.
    You can create global references from local references using NewGlobalRef. A global reference is valid across all threads and does not have a limited lifetime. You must make sure to release your global references once you are done using them by calling DeleteGlobalRef.
    God bless,
    -Toby Reyelts
    Check out Jace, http://jace.reyelts.com/jace

  • J2EE host or port not specified; define them under "System Settings"

    HI
    Iu2019m facing the issue with  SOAMANAGER
    In transaction  SOAMANAGER we configure the endpoints(service and binding)  for the provider
    and  try test with  Open Web Service navigator for selected binding  under overview tab
    Its Showing the Error:
    J2EE host or port not specified; define them under "System Settings"
    please help me to resolve this issue.
    Thanks
    Vadde

    Issue resolve
    trtransaction SOAMANAGER --> System Global settings -->Access J2EE server --> here we need to specify the Java host name and Port number
    Thanks
    Vadde

Maybe you are looking for

  • Crystal report add on for 2007B PL17

    Dear Experts, I am using SAP B1 2007B PL17 and Crystl Report 10. To integrate the rpt files, I have instlled the CR add on . But the problem is with CRRuntime crruntime_12_0_mlb, Which version of it I need to download and where can i download it from

  • Cant run Java on my computer

    Hello, I'm running a XP pro (eng) with sp2 fully patched. I've tried with several several versions of JRE but no matter which one I try, I can never get Java to work on my PC. Even Java control panel window apears grey to me. [edit] Basically what ha

  • My Photo Stream filling up my work harddrive?

    In enabled My Photo Stream for my work computer to be able to pull off the occational work photo I take with my phone.  With two small kids, we take a lot of family photos.   Now seems to have 6 months of photo stream photos still on my work laptop. 

  • Solman trusted system not working

    Dear Experts, Few Months back we have completed the OS/DB Hardware migration. After that whenever any end user trying to post the message from production system, system is asking for password then posting the message. before that w/o asking the passw

  • Does closed captioning features work in the trial version?

    I'm trying to update the font and color in Captivate 5 using the trial version and my mouse arrow shows horizontal and then it locks up my computer.  Please help; any advice would be greatly appreciated.  Thanks