Why does SunOne 6.1 call servlet init() method twice on startup

Hi,
SunOne6.1 sp 5 is running my servlet's init() method twice when I put load-on-startup in the web-xml file. Is this a known problem and is there a work around as no amount of synchronising seems to work.
I'm running 2.3.dtd for the default_web.xml file and my entries look like this :-
<servlet>
<servlet-name>RelatisLogin</servlet-name>
<servlet-class>com.MyServlet</servlet-class>
<load-on-startup>7</load-on-startup>
</servlet>
This init method only contains a basic check at the moment :-
public void init()
System.out.println("init.....");
If I take <load-on-startup> away and run the server then call the servlet via the url it only runs init once.
I've tried synchronizing the block but this doesn't work.
The synchonization code I used looks like this:-
public void init(ServletConfig config) throws ServletException
synchronized( AnotherClass.staticString )
if ( AnotherClass.staticString.length() > 0 ) return;
System.out.println( AnotherClass.staticString.length() );
AnotherClass.staticString = "init has been called";
try
int i = 0;
i = i/i;
} catch(Exception e)
e.printStackTrace();
The declaration of "AnotherClass.staticString" is :-
public static String staticString = "";
The output of "System.out.println( AnotherClass.staticString.length() );" is 0 and displayed twice.
I deliberately cause a divide by zero error to get a stack trace so that i can determine what called init(), the stack trace is printed twice and is always :-
java.lang.ArithmeticException: / by zero
at com.MyServlet.init(MyServlet.java:47)
at org.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper.java:921)
at org.apache.catalina.core.StandardWrapper.load(StandardWrapper.java:813)
at org.apache.catalina.core.StandardContext.loadOnStartup(StandardContext.java:3478)
at org.apache.catalina.core.StandardContext.start(StandardContext.java:3760)
at com.iplanet.ias.web.WebModule.start(WebModule.java:251)
at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1133)
at org.apache.catalina.core.StandardHost.start(StandardHost.java:652)
at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1133)
at org.apache.catalina.core.StandardEngine.start(StandardEngine.java:355)
at org.apache.catalina.startup.Embedded.start(Embedded.java:995)
at com.iplanet.ias.web.WebContainer.start(WebContainer.java:431)
at com.iplanet.ias.web.WebContainer.startInstance(WebContainer.java:500)
at com.iplanet.ias.server.J2EERunner.confPostInit(J2EERunner.java:161)
It looks like SunOne starts then calls init() and then restarts and calls init() again.
The same code and same web.xml entries work fine in Tomcat 5, init() only every gets called once.
Any ideas? Can I post this as a bug?
Thanks in advance for any help.
Chris.

Sorry to have not replied to this thread earlier.....forgot all about it.
The reason init was being called twice by IPanet (Sun One) is IPanet comes with a default context called "Search" already in server.xml file.
This context was loading all the classes on my class path and this causing "init" to run. Then my context entry also loaded all the files in the class path.
Quite why Sun include this "Search" context is beyond me......annoying. If you take it out the the problem goes away.
Basically if you leave this in then your running to web servers (JVM's) your one and Sun's stupid "Search" one. As they are separate JVM's no amount of synchronisation would ever fix it.

Similar Messages

  • Why does skype forward my calls

    Why does skype forward my calls to my skype number when I am online?

    Hi sydneysmith1234,
    I can see in your account that you have an active calling subscription. Please note that subscriptions renew automatically, as stated in our Terms of Use. You will be charged for it's renewal depending on the period you selected. Please refer to the private message I sent to you for further details.
    To check your private message, just go to Skype Community home page (community.skype.com), scroll at the bottom of the page. You will see "Private Message" just above "Users Online."
    Due to the time it can take for some transactions to be processed, we charge you three days in advance to ensure prompt delivery of your subscription. You do not lose these three days: your subscription is still valid for the full period that you sign up for.
    Your subscription will renew even if you are not using it. Skype subscription is the same with other subscriptions like cables, telephones, etc., wherein you are automatically charged for their renewal.
    For more information on how subscriptions work, you may refer to this link: https://support.skype.com/en/faq/FA10414/
    If answer was helpful please mark it with Kudos and if issue is resolved mark it with solution. This will help other users find this answer more easily. Thanks in advance!

  • Why does Adobe promise return calls and then not do so?

    Why does Adobe promise return calls and then not do so?   To avoid talking with customers?

    Thanks for your reply - unfortunately I have talked with an Adobe
    representative in India and their action is to put one on hold
    indefinitely.  I am annoyed  because I paid an additional $60 to them 
    for no reason.  Appreciate your comment.
    des

  • Iplanet kjs servlet init() method

    In iplanet is the servlet init method called in each KJS engine.
    I have a continous thread running in a servet.This is invoked by a webased hyperlink.Some times ther happens to be 2 threads running and results in false operations.Conflict b/w threads.
    Suspect one thread in each KJS is running.

    This is the incorrect forum for this question. Sun ONE Application Server 7 is a completely new appserver and does not have KJS related technologies or APIs. Please check AppServer 6 forum.
    HTH.
    Paul

  • Why Do We Have To Call super.init(config); in init() method of servlet?

    Hi, everyone..
    I wonder why we call super.init(config) in init method of servlet... If i dont call it ; when i try to get servletcontext in service method it throws java.lang.NullPointerException...when we call super.init() , what is happening behind the scene? If anybody has a technical explanation for my question , i will be very pleased...
    THX FOR YOUR FUTURE REPLIES IN ADVANCE....

    I am sorry about the uppercases and i dont want to seem smart on java forums... Anyway, m8 this is the thing that i know... i meant; for instance when we override doGet or doPost method ; we dont need to override init method; but the server loads the servlet and we can get the context of the servlet in these methods easily by calling getServletContext() method; however when we want to call service method implicitly by jndi, servlet needs to be loaded and init method must call its parent...(i also write down in web.xml <load-on-startup>.... for that servlet).
    thx for your replies in advance....

  • Servlet init() method called multiple times

    We have a Servlet-based application which does lengthy initialization.
    We've noticed that when multiple requests arrive,
    but the Servlet's init() method has not returned yet
    for the first request, the application server calls init() multiple times.
    You can even see this with the Fortune sample
    Servlet. Starting the app server and sending 20 or 30
    simultaneous requests causes multiple Fortune Servlet init messages to appear in the kjs log.
    Why is this? We do not implement SingleThreadModel.
    Doesn't the J2EE 1.2 spec say init will be called
    only once?
    How do we prevent it?
    A Startup class which inits our
    Servlet?
    Or a synchronized block within our init method, with some checks of static member variables
    so that the initialization work only happens once?
    Or is there some kregedit magic or deployment descriptor change I could make?
    Again, it's not a SingleThreadModel issue, so don't
    point me there.
    This is iAS 6.0 SP4, on Solaris, by the way.

    Hi
    Yes,you are right. In iAS6.0 SP4 When multiple requests arrive,and the Servlet's init() method has not returned yet for the first request, the application server calls init()multiple times. This problem is resolved in iAS 6.5.
    There is no kregedit magic that will solve this problem.
    Right now the workaround is any of the solution you proposed. Or use iAS6.5. I have tested it with fortune.
    Please download it and check with your application.
    you can find free download at http://developer.iplanet.com/appserver/testdrive/testdrive_65.html
    Thanks

  • Why does my iphone disconnect calls

    why does my iphone disconnect my calls

    Know of any ways to excercise those signals to make them stronger??
    EDIT: I live in a major Metro Area and there are antennas within 2 blocks of my home!!
    Crancked

  • Invoking servlets init method

    Let's just say I want to write a startup class that initilizes a servlet,
              (just like ServletStartup class). How would I do this without using the
              URLConnection class?
              Thanks
              

    c00ler wrote:
    Hey guys,
    Studying JDBC & Java by O'Reilly. Old book, very old. You'd be better off with the Sun JDBC tutorial. Google for it.
    init() method is not really explained in the book and i'm kind of stuck. As far as i understand it's used to initialise servlet before its execution right? O'Reilly uses it to connect to the database (i'm find with connection part), problem is i don't understand why i can't connect through proccessRequest() method and I can't actually find the init() method within servlet...unless of course i write my own one. There is code offered by O'Reilly:
    Terrible form. More evidence of just how out of date this book is. No one would write a servlet to do this now.
    Book was published quite a few years ago...is there different implementation to this?
    Also for some reason Class.forName().newInstance() throws unidentified error if i use SQLException (even though java.sql.* is there), but works fine with Exception...any ideas???Not unidentified if you look at the javadocs for Class - it throws ClassNotFoundException, among others.
    You don't have to call newInstance() - Class.forName() is sufficient for registering the driver class.
    %

  • Need clarification - Rreg Servlets init method and construction

    Hi,
    My friends asks me 'Is init method of servlet is necessary? Can't we do whatever we want to do in Init method, in the constructor of the servlet? Why is init method is necessary?'
    Thanks in advance,
    Guhan

    byte[] tripleDesKeyData = key.getBytes();
    Instead of getting Bytes directly from that Hex string now i am getting in the following way......
    byte[] tripleDesKeyData = Encryption.tempHexStringToByteArray(key);
    public static byte[] tempHexStringToByteArray(String hexString){
         byte[] bytes = new byte[hexString.length() / 2];
         for (int i = 0; i < bytes.length; i++) {
              bytes[i] = (byte) Integer.parseInt(hexString.substring(2*i, 2*i+2), 16);
         return bytes;
    And using that key to decrypt....as of now its working fine now
    Why i am posting this is for others to use further....

  • Why does Windows 7 not show up in System Preference's "Startup Disk"

    Why does Windows 7, installed via Boot Camp, show up when you hold down the option key when booting but the drive does not show up in System Preferences under the Startup Disk icon.
    As an aside Windows 7 runs perfectly on my MacBook.
    - Mike

    Now I found I'm not alone. My situation is similar but not exactly the same.
    I recently switched from the white MacBook to latest mac mini, tried installing XP Pro not successful for some reasons then tried Win7 (build 7000). On my old macbook this worked perfectly.
    Got win7 updated and picked win7 as startup disk in windows, used that for few days without going back to leopard. On just one occasion I booted with 'alt' key pressed (using a PC keyboard) I have choices of drives so I thought everything was fine. As soon as I booted into leopard I found no win7 partition in system>preference>startup disk, OMG I couldn't boot back to win7 since then. From that point onwards the 'alt' key didn't work for me. Every time only leopard can be booted.
    What can I do now?
    Why it was OK in macbook but didn't work on mini? Is it worth investing on a mac external keyboard just to get the 'option' key?

  • Why does my macbook show  emails as being sent twice

    why does my MacBook Pro  show  emails as being sent twice

    You don't need to delete them form iTunes on your computer. Notice the dotted circles next to the songs. That indicates that the songs are essentially in limbo. They may not be on your iPad or they might appear in the Music app but will not play.
    Sometimes unsyncing those songs will totally remove those ghost traces of the music nd sometimes, you have to restore the iPad to get rid of those traces of the songs.
    If you Google "grey dotted circles next to songs in iTunes" you will find a plethora of articles that talk about this.

  • Why does each episode in my Season Pass download twice?

    I have recently started using iTunes to buy my TV series.  I have subsribed to House Season 8 and Game of Thrones Season 2.  With both, when I download the latest episode, it appears twice on the downloads list.  The files are always the same size, so I don't think it is a SD version and a HD version (plus we don't seem to get HD versions here in Australia).  If I allow both to complete there are duplicate entries in iTunes and both seem to be identical.  Generally I just delete one, as soon as it starts, to save bandwidth.  I have double checked, and have not accidentally purchased either season twice.  This does not seem to happen for other seasons, that I have bought after all episodes are released.  Any insights would be appreciated, I did a few searches and couldn't find any solutions.

    I am having this problem too, for 2 days now. I'd love an answer on how to fix this..I have contacted support and reported the problem yesterday morning, but my passes still aren't showing up.

  • Why does my ipod download selections from my library twice?

    When downloading selections from my ipod some of the selections were downloaded twice.  When I look in my devices menu it is only there once.  I have even deleted the selections from my devices menu but it still remains on my ipod twice.

    Maybe your Internet Service Provider shuts down some server at 9pm every day.

  • Why does a folder with a question mark momentarily appear at startup?

    Hi everyone.
    Is that normal or is that indicative of potential problems to come?
    Thanks,
    Al

    Hi, Hank. What model is the old Powerbook?
    Hi eww,
    According to http://docs.info.apple.com/article.html?artnum=24604, it is the PowerBook (FireWire) computer (M7572). As I understand it, this is a G3.
    If it's a Powerbook G4 (any model), that CD can't
    boot it, and in order to perform an installation on
    the Powerbook, you would have had to start the PB
    from its hard drive, insert the CD into the external
    FireWire drive, and then perform the Clean Install
    that way. I'm surprised if that was possible; the
    installer should have refused to run.
    Well, IIRC, this is indeed what I did...
    Even if it did
    run successfully, both the installed OS 9.0.4 and the
    OS 9.0.4 on the CD itself would be unable to boot the
    PB afterward, possibly resulting in exactly the
    symptoms you see now.
    ...and I think you have nailed it.
    If this is an accurate
    description of what you did and how things went, the
    solution is to obtain an appropriate OS 9 installer
    disc for the Powerbook model in question — that what
    disc that is will depend on which PB G4 model you have.
    If it's the last of the Powerbook G3's (the first PB
    that had a built-in FireWire port), it was originally
    shipped with OS 9.0.2, and a retail (not
    model-specific) OS 9.0.4 CD should boot it OK. If
    your CD is a valid one for that model, you should be
    able to boot the Powerbook to the CD now, even if the
    installation was unsucessful — unless your
    FireWire optical drive isn't bootable itself: some
    aren't. Have you ever booted the Powerbook or any
    other Mac to a CD in that drive before?
    It sounds like you are describing the situation perfectly. The OS 9.0.4 CD is what we have. I did indeed boot to a Norton SystemWorks 2.0 CD yesterday via the FireWire external drive, but I was unable to change the startup disk (so as to be able to restart the PowerBook from the HD).
    You mentioned that I probably can't boot to an OS CD via the FireWire drive, and it is true that I have not been able to do this. Before I decide on another (stupid) course of action, I'll wait until you comment.
    My next idea is (1) to start up the two Macs -- connected via FireWire -- with the PowerBook in target disk mode, (2) insert the OS 9.0.4 disk into the iMac, and (3) choose to install system software on the PowerBook ("choose volume"). Could this work?
    Thanks again,
    Hank

  • Request for help related to t:dataList calling my bean method twice

    Hello,
    I'm trying to use <t:dataList> from myFaces library: I'm getting the data that i wanted on the UI. However, my method on the bean is getting called twice when i use t:dataList.
    If i use, <UI:repeat> instead of <t:dataList>, everything is fine (meaning my method gets called only once which is the expected behavior).
    Did anybody come across this issue with <t:dataList>?
    Thank you in advance,
    Here is my code:
    <t:dataList value="#{logBean.interactionsList}" var="e" rowIndexVar="index">
    <tr class="#{index mod(2) !=0?'evenRow':''}">
    <td>#{index+1}</td>
    <td>#{e.name}</td>
    <td>#{e.notes}</td>
    </tr>
    </t:dataList>

    Which method do you mean? I'm assuming the getter for the value binding? If that is the case, you may need to learn to live with it. This seems to be the typical behavior of JSF components (i.e., do not cache the value of EL expressions, instead re-evaluate). In some cases this is the behavior you want.
    Now that you know the components will be doing this, the trick is to move the caching (if applicable) to your bean. In other words, if the value of getter is the result of a long running process, save it in an instance variable for the next invocation.

Maybe you are looking for