Problems with static member variables WAS: Why is the static initializer instantiating my class?!

Hi,
I have been hunting down a NullPointerException for half a day to come to
the following conclusion.
My constructor calls a method which uses static variables. Since an intance
of my class is created in the static block when the class is loaded, those
statics are probably not fully initialized yet and the constructor called
from the static block has those null pointer problems.
I've considered moving the initialization of the static variables from the
declaration to the static block. But your code is inserted BEFORE any other
code. Therefore not solving my problem.
Two questions:
1) what would be a solution to my problem? How can I make sure my static
variables are initialized before the enhancer generated code in the static
block calls my constructor? Short of decompiling, changing the code and
recompiling.
2) Why is the enhancing code inserted at the beginning of the static block
and not at the end? The enhancements would be more transparent that way if
the static variables are initialized in the static block.
Thanks,
Eric

Hi Eric,
JDO calls the no-args constructor. Your application should regard this constructor as belonging
primarily to JDO. For example, you would not want to initialize persistent fields to nondefault
values since that effort is wasted by JDO's later initilization to persistent values. Typically all
you want to initialize in the no-args constructor are the transactional and unmanaged fields. This
rule means that you need initialization after construction if your application uses the no-args
constructor and wants persistent fields initialized. On the other hand, if your application really
uses constructors with arguments, and you're initializing persistent fields in the no-args
constructor either unintentionally through field initializers or intentionally as a matter of
consistency, you will find treating the no-args constructor differently helpful.
On the other hand, if Kodo puts its static initializer code first as you report, then it is a bug.
Spec Section 20.16: "The generated static initialization code is placed after any user-defined
static initialization code."
David Ezzio
Eric Borremans wrote:
>
Hi,
I have been hunting down a NullPointerException for half a day to come to
the following conclusion.
My constructor calls a method which uses static variables. Since an intance
of my class is created in the static block when the class is loaded, those
statics are probably not fully initialized yet and the constructor called
from the static block has those null pointer problems.
I've considered moving the initialization of the static variables from the
declaration to the static block. But your code is inserted BEFORE any other
code. Therefore not solving my problem.
Two questions:
1) what would be a solution to my problem? How can I make sure my static
variables are initialized before the enhancer generated code in the static
block calls my constructor? Short of decompiling, changing the code and
recompiling.
2) Why is the enhancing code inserted at the beginning of the static block
and not at the end? The enhancements would be more transparent that way if
the static variables are initialized in the static block.
Thanks,
Eric

Similar Messages

  • A problem with RDP when WAEs was connected to the network

    The customer has a problem with RDP sessions on one Microsoft cluster server. The problem started when the WAEs (management and acceleration WAEs) are connected to a network (where a cluster is connected). Did anybody have the similar problem? The sessions are connected, but after some different times these sessions are frozen. This problem is only with this Microsoft cluster, the RDP on other servers are good. The WAAS is 4.0.17b14.

    Hi,
    I have the same problem as I write. RDP seems to get slower when I connect the WAEs and the login timesout before the user can type the username and password.
    I have ensured that "EPM Classification" is disbled.
    Check and see if Term-services are well configured on the TS server side. Maybe some config is conflicting with WAAS TS optimization.
    What happens when you set TS to passthrough?
    Also try this for your case;
    " HOW-TO: Configuring RDP and Terminal Services for Full WAAS Optimization
    Microsoft RDP and Terminal Services are, by default, compressed and encrypted. As such, the default Cisco WAAS policy for these applications is to apply TCP optimizations only. RDP and Terminal Services can be configured to allow Cisco WAAS to provide full optimization (DRE, LZ, TFO) which is a 2X-10X improvement over native WAN and 2X-3X improvement over the compression provided by Microsoft.
    Configuring Microsoft RDP and Terminal Services to support Cisco WAAS full optimization requires a change to the client and a change to the server.
    On the client, disable compression by editing the .RDP file for the connection using Notepad or a similar text editor. Identify a line in the file that shows "compression:i:1". Modify this line to say "compression:i:0". This disables compression for the RDP/TS connection.
    On the server, open the Terminal Services Configuration found under Start > Programs > Administrative Tools. From here, expand Terminal Services Configuration to Connections. Double-click the "RDP-Tcp" entry found in the workspace. Change the encryption level to "Low", which specifies that only login will be encrypted. Then, click "Ok" and close Terminal Services Configuration.
    Then, modify the Cisco WAAS policy on the configured device group (or explicitly on each of the WAEs) called "MS-Terminal-Services". Set this policy to "Optimize Full". "
    Anyone out there with a clue why RDP gets disconnected?

  • HI,had a problem with my iphone4,phone was reset@ Apple store now it will not sync with my itunes.Anyone know what i need to do please

    Hi,had a problem with my iphone4, phone was reset at the Apple store BUT now it is not being recognised by my computer. Itunes is up to date & i have tried my usb with my ipod & everything is ok.Any idea what to do next please??

    iOS: Device not recognized in iTunes for Windows

  • Static member variable conundrum

    I'm using an abstract base class so that subclasses can share common functionality.
    Each subclass needs a static member variable (a String) that needs to be accessed from the abstract base class in some of it's methods.
    This is where the problem is; I would like to declare an abstract variable in the base class so that the base class methods can use the variable, but you can't make an abstract variable static.
    Is there a way around this or am I approaching this problem from the wrong direction?

    I can't remember if you can override static methodsTested this and determined that you can't. The superclass static gets called. Makes sense.
    I also tested my suggested code, and made a few improvements ... maybe it isn't quite so ugly after all (can you tell that I'm slogging through some boring stuff?):
    public class Tester1
        protected static HashMap _stringTable = new HashMap();
        static
            _stringTable.put(Tester1.class, "Tester 1");
        protected String getString()
            return (String)_stringTable.get(this.getClass());
        public static void main(String[] argv)
            Tester1 t1 = new Tester1();
            Tester2 t2 = new Tester2();
            Tester1 t3 = new Tester2();
            System.out.println("t1.getString() = " + t1.getString());
            System.out.println("t2.getString() = " + t2.getString());
            System.out.println("t3.getString() = " + t3.getString());
    public class Tester2 extends Tester1
        static
            _stringTable.put(Tester2.class, "Tester 2");

  • My IPad cannot download live Tv from skygo. I have no problem with my lap top so I assume the broad band is okay. Can anybody suggest why the live streaming will not work on my iPad one.

    My IPad cannot download live Tv from skygo. I have no problem with my lap top so I assume the broad band is okay. Can anybody suggest why the live streaming will not work on my iPad .

    Are you using the Sky Go app to try and watch it ? If so are you logged in with your Sky account ?
    If you are using the app then you could try closing the app completely and see if it works when you re-open it : from the home screen (i.e. not with Sky Go 'open' on-screen) double-click the home button to bring up the taskbar, then press and hold any of the apps on the taskbar for a couple of seconds or so until they start shaking, then press the '-' in the top left of the Sky Go app to close it, and touch any part of the screen above the taskbar so as to stop the shaking and close the taskbar.
    If that doesn't work then you could try a reset : press and hold both the sleep and home buttons for about 10 to 15 seconds (ignore the red slider), after which the Apple logo should appear - you won't lose any content, it's the iPad equivalent of a reboot.

  • I downloaded IOS6 earlier today and my 4S has died twice, it has gone from 45 to 32% in the last 5 minutes and i have icloud, internet, all apps closed with nothing running at all!! There is a serious problem with ios6, my phone was hot at charging time.

    I downloaded IOS6 earlier today and my 4S has died twice, it has gone from 45 to 32% in the last 5 minutes and i have icloud, internet, all apps closed with nothing running at all!! There is a serious problem with ios6, my phone was working hot at chargering time. Apple need to address this asap!!!!

    Hi Suzy Q,
    I can send and receive calls.
    I get "messaging stopped" when doing a lot of texts.
    Texts come up "ghosted" meaning they have the text on the bottom and a transparent one overlaid  on top. they then become one. But I get the ghosting most of the time when I go into a message from a contact to send a text.
    When I go to call logs or text logs, the numbers come up first, and then then the names pop up randomly, meaning not in order down the page, until they are all shown. lots of lag time.
    It runs slow.
    I have 5 apps on here. I should be able to have a  lot of apps on here, and play music, and have files, and...and....and.
    I can get online but doing a Google search, when the page with the choices comes up, it is blurred and I have to tap on the screen for it to become clear and readable.
    When online and scrolling, it hitches sometimes/lags/gets stuck then unstuck
    I get VZWAVS has stopped. (not sure if those are the right letters)
    The status bar that is supposed to be gray with the new update, goes back and forth between green--the old os--to gray. And I have found no continuity with when I get green or when I get gray.
    I get a black screen on occasion.
    sometimes the proximity sensor doesn't work.
    sometimes when I have my bluetooth on and have "hands free mode" on, I get the a text message read through the headset and also through the handset.
    I soft reboot often--turn it off wait a bit and

  • Hello. I have problem here can someone plz help. I have usb of 32 gb but i have problem with it while i was trying to partition of it and it fails and my usb disappear from finder and desktop i have tried every possible thing but nothing  works .

    Hello. I have problem here can someone plz help. I have usb of 32 gb but i have problem with it while i was trying to partition of it and it fails and my usb disappear from finder and desktop i have tried every possible thing but nothing  works .

    Yea i tried in disk utility and its got faiiled and the partitation has deleted and when i tried  to replug the  usb  msg show up by saying  usb not compaitnle. With this mac  and  take me to disk utility  and thanks for replying

  • Why is the static method in the superclass more specific?

    Why is the static method in the superclass more specific than the static method in the subclass? After all, int is a subtype of long, but Base is not a subtype of Sub.
    class Base {
        static void m(int i){ System.out.println("Base"); }
    class Sub extends Base {
        static void m(long l){ System.out.println("Sub"); }
    class Test {
        public static void main(String[] args) {
            int i = 10;
            Sub sub = new Sub();
            sub.m(i);
    }The first example compiles without error.
    Output: Base
    class Base {
        void m(int i){ System.out.println("Base"); }
    class Sub extends Base {
        void m(long l){ System.out.println("Sub"); }
    class Test {
        public static void main(String[] args) {
            int i = 10;
            Sub sub = new Sub();
            sub.m(i);
    }In the second example, both instance methods are applicable and accessible (JLS 15.12.2.1), but neither is more specific (JLS 12.2.2), so we get a compiler error as expected.
    : reference to m is ambiguous,
    both method m(int) in Base and method m(long) in Sub match
    sub.m(i);
    ^
    1 error
    Why don�t we get a compiler error for the static methods?

    Thank you for your ideas.
    ====
    OUNOS:
    I don't get Sylvia's response. This is about static methods, what are instances are needed for??Yes, the question is about static methods. I included the example with non-static methods for a comparison. According to JLS 15.12.2, both examples should cause a compiler error.
    And why you create a Sub object to call the method, and dont just call "Sub.m(..)"Yes, it would make more sense to call Sub.m(i). Let�s change it. Now, I ask the same question. Why is there no compiler error?
    ====
    DANPERKINS:
    The error in your logic stems from calling static methods on instances, as ounos pointed out. Solution: don't. You won't see any more ambiguities.A static member of a class may also be accessed via a reference to an object of that class. It is not an error. (The value of the reference can even be null.)
    Originally I was looking only at the case with non-static methods. Therefore, I used sub.m(i). Once I understood that case, I added the static modifiers. When posting my question, I wish I had also changed sub.m to Sub.m. Either way, according to JLS 15.12.2, a compiler error should occur due to ambiguous method invocation.
    ====
    SILVIAE:
    The question was not about finding an alternative approach that doesn't throw up an ambiguity. The question related to why, in the particular situations described, the ambiguity arises in only one of them.
    Yes.
    Proposing an alternative approach doesn't address the question.
    Yes.
    ====
    If anyone is really interested, here is some background to the question. Some people studying for a Sun Java certificate were investigating some subtleties of method invocations:
    http://saloon.javaranch.com/cgi-bin/ubb/ultimatebb.cgi?ubb=get_topic&f=24&t=019182
    I remember seeing the non-static case discussed in this forum once before in a more practical context. jschell probably knows the link.

  • Has anyone in this Forum had problems with installing and running Adobe apps on the new MacPro?

    Has anyone in this Forum had problems with installing and running Adobe apps on the new MacPro?
    I have been trying to install Photoshop CS6 & CC and Acrobat Pro XI on my Mac Pro (late 2013). I keep getting a 'configuration' error message and wondered if the problem was wide spread.
    TIA,
    Jerry

    Thanks, Martin.
    Good to hear someone has had success. The lack of it here is frustrating and depressing.
    Thanks again,
    Jerry

  • I'm having problem with text boxes.  Whenever i hit the enter button to start a new line or paragraph, the cursor doesn't drop down to the next line.  Instead i get this little red + sign in the box.

    I'm having problem with text boxes.  Whenever i hit the enter button to start a new line or paragraph, the cursor doesn't drop down to the next line.  Instead i get this little red + sign in the box.

    You are absolutely right.  Thought Enter meant Enter.  I was wrong.  Thank you for the help.
    Rod Rogers, Broker
    Accredited Land Consultant (ALC)
    Metcalf Land Company, Inc.
    Office: 864-585-0444
    Mobile: 864-316-0297
    Fax: 864-583-6000
    <http://www.metcalfland.com> www.metcalfland.com

  • I have a problem with session manager session files because of the invalid json storage data submited by firefox

    Hi, i have problem with session manager's session files. The problem is: the submitted storage data from firefox which is put between "storage":{ and its matching closing brace } But in some of my session files there is non equal { and } under storage's braces. I need to get storage data but in my case it is very hard to do. My question is there any char put before or after { and } like /{ or \{ to avoid confusion? If there is not such thing, i think there could be different solution but i am not sure: i look couple of my session files; after "storage":{...} there is ,_"formDataSaved" so i can get storage data in this example ... by looking between "storage":{ and ,"_formDataSaved" easily. Is there every time ,"_formDataSaved" after "storage":{ ?  Thank you.

    Well, it seems waiting is not my strong suit..! I renamed a javascript file called recovery to sessionstore. This file was in the folder sessionstore-backups I had copied from mozilla 3 days ago, when my tabs were still in place. I replaced the sessionstore in mozilla's default folder with the renamed file and then started mozilla. And the tabs reappeared as they were 3 days ago!
    So there goes the tab problem. But again when I started mozilla the window saying "a script has stopped responding" appeared, this time the script being: chrome//browser/contenttabbrowser.xml2542
    If someone knows how to fix this and make firefox launch normally, please reply! Thank you

  • I have tried to install iTunes 5 but when Windows it starts to install it  says there`s a problem with my Windows installer Paket and cancel the Program

    i have tried to install iTunes 5 but when Windows it starts to install it  says there`s a problem with my Windows installer Paket and cancel the Program. I`ve searched for answears in the web and they said ischould waste my old Itunes version and try it again. But it happend the same again! Now i havent any iTunes version and iAlso can`t Load a new one!!!! Pllease help me !!!

    I solved it myself, after the "note" which came back from FF/Mozilla just as I finished my message, commenting on what it was that my system had , I wnnt back to check my plug-ins etc. I downloaded the latest Java, BOTH 32bit AND 64 bit versions and latest Firefox.
    Now all is working.
    Thanks,
    B.

  • I am having problems with creating my apple id. On the phone it is advising me that the ID is not created and then when i do it online it says that it has been created. Can you advise me on what to do please?

    I am having problems with creating my apple id. On the phone it is advising me that the ID is not created and then when i do it online it says that it has been created. Can you advise me on what to do please?

    Apple ID FAQ   http://support.apple.com/kb/HE37

  • Hello, I have a problem with my mac book pro after running the battery dead on a game.  The display has shrunk leaving two black margins on either side. What to do ?

    Hello, I have a problem with my mac book pro after running the battery dead on a game.  The display has shrunk leaving two black margins on either side. What to do ?

    Go to System Preferences>Displays and set the resolution to "Best for this computer" (or something to that effect).
    Clinton

  • I have a problem with running an EXE file on win2000, the Lab View is 5.1 and I do not know if it is 16 bit...

    I have a problem with running an EXE file on win2000, the Lab View is 5.1 and I do not know if it is 16 bit...what should I do?

    Hi Arika,
    The drivers that you need to install to make your executable work depends on what your executable is doing. To get started, you need to have the LabVIEW Run-Time Engine installed on your target machine (the Win2000 machine you are planning to use) in order to run your executable. Next, you need to determine what drivers your executable uses, if any. For example, if you are using GPIB instrument control, you will need to install the NI-488 drivers on your target machine. If you are performing data acquisition, you will need to install NI-DAQ drivers. If you are doing image acquistion, you will need to install NI-IMAQ drivers.
    All these drivers are available for downloading on ni.com. To get the drivers, go to ht
    tp://www.ni.com/support , click on the link that takes you to Drivers and Updates (under Option 3), and click on the links to get to the driver(s) you need. For example, if you need the LabVIEW 5.1.1 Run-Time engine, click on the All Drivers and Updates by Application link on the main page (http://www.ni.com/softlib.nsf/). Then click on the LabVIEW link, Windows 2000, Run Time Engine, and then you will see the link to get to the page to download the LabVIEW 5.1.1 Run-Time Engine.
    I hope this information helps.
    Best Regards,
    Wilbur Shen
    National Instruments

Maybe you are looking for

  • Email sturen with JSF

    Hi, I am developping a site with JSF.. If the user fills insome information, tan automatic email should be sent to hem.. Can someone help me to do that? Thanks

  • ActiveX-Control in C++ LoadFile does not work

    I tried to use the ActiveX Control in my C++ Application. But when i try to call "LoadFile", it does not work. Everytime i call it i get a "false" as response, but i don't know why it is not possible to open that file. I tried everything i could imag

  • Hierarchical reporting w/ duplicate children -- fail?

    I have a hierarchical report in CR XI displaying a directory structure that is mostly working fine.  However, there are some duplicate folder names in various spots in the tree, and they are being grouped together under one of the parent folders inst

  • Cost Factor in Shortest Path

    Hi, I need a little help. I am performing routing on geodatic data (i.e., locations with Lat/Long). I think the AStar shortest path algorithms are finding the shortest path on the basis of distance betwwen two nodes. I am not quite sure whether they

  • Anyone used VisionNet system "designed to provide real-time streaming video feeds over the Internet"?

    I'm a Mac user and we only have Macs at home. My son just started preschool, which offers a VisionNet system--"a state-of-the-art system of cameras, servers, and software designed to provide real-time streaming video feeds over the Internet." However