LDAP Context Initialization Problem in a Servlet's Init method

Hi
I have a servlet where I am using the InitialDirContext to Initialize context to a LDAP Server. I have created the context as a static variable. I am initializing the context in the init method and am using the same reference in the service method of the servlet. But if the context fails (due to naming exception and time out) in the init method all my requests in the service method will fail. Is there any way to validate the reference before using the same in the service method.
Also what is the best approach to initialize the context in a servlet. Whether to initialize in the service method or the init method.
I would appreciate if anyone can answer the above 2 queries.
Thanks in advace,
Ashish

If you want to use threadsafe objects in doPost/doGet there are two common ways to do this.
First, create the object in doPost/doGet. This may get expensive depending on the object, but it is 'easy' code and works.
The second option is to create a pool of objects in the servlet's init() method and to just have doPost/doGet get an object from the pool, use it and return it when done. This take a little more work to code, but the overhead of creating objects is almost eliminated. Look at jakarta/apache commons pool for a quick way to do this.
If you create on object in init() and use it in doPost/doGet, any time you get two request for the same servlet at the same time you will have synchronization issues that will usually cause problems. There is one instance of each Servlet, so all request for that servlet go through the single instance. Anything in doPost/doGet must be threadsafe.

Similar Messages

  • The servlet weblogic.servlet.AsyncInitServlet init method failed

    I installed WLS 9.2.2 recently with my app being on 8.1.5 for a long time.
    I chose to create a new domain instead of upgrading my existing one.
    I use the eclipse 3.2.2 with the WL plugin.
    When I start the server and login to the console not using eclipse it works fine.
    Trying to start the server and login to the console gives a internal server error.
    Any idea what could be wrong? I bolded the parts where I have looked into.
    Here is the console output:
    <Nov 19, 2008 3:13:02 PM CST> <Notice> <WebLogicServer> <BEA-000395> <Following extensions directory contents added to the end of the classpath:
    C:\bea92\weblogic92\platform\lib\p13n\p13n-schemas.jar;C:\bea92\weblogic92\platform\lib\p13n\p13n_common.jar;*C:\bea92\weblogic92\platform\lib\p13n\p13n_system.jar*;C:\bea92\weblogic92\platform\lib\wlp\netuix_common.jar;C:\bea92\weblogic92\platform\lib\wlp\netuix_schemas.jar;C:\bea92\weblogic92\platform\lib\wlp\netuix_system.jar;C:\bea92\weblogic92\platform\lib\wlp\wsrp-common.jar>
    <Nov 19, 2008 3:13:03 PM CST> <Info> <WebLogicServer> <BEA-000377> <Starting WebLogic Server with Java HotSpot(TM) Client VM Version 1.5.0_10-b03 from Sun Microsystems Inc.>
    <Nov 19, 2008 3:13:05 PM CST> <Info> <Management> <BEA-141107> <Version: WebLogic Server 9.2 MP2 Mon Jun 25 01:32:01 EDT 2007 952826 >
    <Nov 19, 2008 3:13:10 PM CST> <Info> <WebLogicServer> <BEA-000215> <Loaded License : C:\bea92\license.bea>
    <Nov 19, 2008 3:13:10 PM CST> <Notice> <WebLogicServer> <BEA-000365> <Server state changed to STARTING>
    <Nov 19, 2008 3:13:10 PM CST> <Info> <WorkManager> <BEA-002900> <Initializing self-tuning thread pool>
    <Nov 19, 2008 3:13:11 PM CST> <Notice> <Log Management> <BEA-170019> <The server log file C:\bea92\user_projects\domains\domain\servers\AdminServer\logs\AdminServer.log is opened. All server side log events will be written to this file.>
    <Nov 19, 2008 3:13:15 PM CST> <Notice> <Security> <BEA-090082> <Security initializing using security realm myrealm.>
    <Nov 19, 2008 3:13:22 PM CST> <Notice> <WebLogicServer> <BEA-000365> <Server state changed to STANDBY>
    <Nov 19, 2008 3:13:22 PM CST> <Notice> <WebLogicServer> <BEA-000365> <Server state changed to STARTING>
    <Nov 19, 2008 3:13:30 PM CST> <Error> <HTTP> <BEA-101359> <The servlet weblogic.servlet.AsyncInitServlet init method failed while it was run in the background. The exception was: java.lang.NoClassDefFoundError: com/bea/p13n/management/ApplicationFilePoller$Handler.
    java.lang.NoClassDefFoundError: com/bea/p13n/management/ApplicationFilePoller$Handler
         at java.lang.ClassLoader.defineClass1(Native Method)
         at java.lang.ClassLoader.defineClass(ClassLoader.java:620)
         at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:124)
         at java.net.URLClassLoader.defineClass(URLClassLoader.java:260)
         at java.net.URLClassLoader.access$100(URLClassLoader.java:56)
         Truncated. see log file for complete stacktrace
    >
    <Nov 19, 2008 3:13:37 PM CST> <Notice> <Log Management> <BEA-170027> <The server initialized the domain log broadcaster successfully. Log messages will now be broadcasted to the domain log.>
    <Nov 19, 2008 3:13:37 PM CST> <Notice> <WebLogicServer> <BEA-000365> <Server state changed to ADMIN>
    <Nov 19, 2008 3:13:37 PM CST> <Notice> <WebLogicServer> <BEA-000365> <Server state changed to RESUMING>
    <Nov 19, 2008 3:13:39 PM CST> <Notice> <Server> <BEA-002613> <Channel "Default" is now listening on 127.0.0.1:7005 for protocols iiop, t3, ldap, http.>
    <Nov 19, 2008 3:13:39 PM CST> <Notice> <WebLogicServer> <BEA-000331> <Started WebLogic Admin Server "AdminServer" for domain "domain" running in Development Mode>
    <Nov 19, 2008 3:13:40 PM CST> <Notice> <WebLogicServer> <BEA-000365> <Server state changed to RUNNING>
    <Nov 19, 2008 3:13:40 PM CST> <Notice> <WebLogicServer> <BEA-000360> <Server started in RUNNING mode>
    <Nov 19, 2008 3:22:04 PM CST> <Error> <HTTP> <BEA-101020> <[weblogic.servlet.internal.WebAppServletContext@d6c6a0 - appName: 'consoleapp', name: 'console', context-path: '/console'] Servlet failed with Exception
    java.lang.NullPointerException
         at weblogic.servlet.AsyncInitServlet.service(AsyncInitServlet.java:124)
         at weblogic.servlet.internal.StubSecurityHelper$ServletServiceAction.run(StubSecurityHelper.java:227)
         at weblogic.servlet.internal.StubSecurityHelper.invokeServlet(StubSecurityHelper.java:125)
         at weblogic.servlet.internal.ServletStubImpl.execute(ServletStubImpl.java:283)
         at weblogic.servlet.internal.TailFilter.doFilter(TailFilter.java:26)
         Truncated. see log file for complete stacktrace
    Edited by: user5384782 on Nov 19, 2008 1:42 PM
    Edited by: user5384782 on Nov 19, 2008 3:59 PM

    Thanks for your replies adrian and david.
    The only thing I see different is that eclipse has different arguments when calling the jvm at the top.
    startWebLogic.cmd:
    C:\bea92\JDK150~1\bin\java -client -Xms256m -Xmx512m -XX:CompileThreshold=8000
    -XX:PermSize=48m -XX:MaxPermSize=128m -Xverify:none -da -Dplatform.home=C:\b
    ea92\WEBLOG~1 -Dwls.home=C:\bea92\WEBLOG~1\server -Dwli.home=C:\bea92\WEBLOG~1\i
    ntegration -Dweblogic.management.discover=true -Dwlw.iterativeDev= -Dwlw.testC
    onsole= -Dwlw.logErrorsToConsole= -Dweblogic.ext.dirs=C:\bea92\patch_weblogic922
    \profiles\default\sysext_manifest_classpath -Dweblogic.Name=AdminServer -Djava.s
    ecurity.policy=C:\bea92\WEBLOG~1\server\lib\weblogic.policy weblogic.Server
    eclipse:
    -hotspot -Xms32m -Xmx200m -Dweblogic.ProductionModeEnabled=
    Eclipse may be calling the cmd I dont know.
    I will try upgrading my eclipse like adrian said, but in the meantime I appreciate any further advice/tips.

  • How servlet's init method is overridden ?

    Here is a sample code to override servlet's init method.
    public class BookDBServlet ... {
            private BookstoreDB books;
            public void init(ServletConfig config) throws ServletException {
                // Store the ServletConfig object and log the initialization
                super.init(config);
                // Load the database to prepare for requests
                books = new BookstoreDB();
        }I dont get why super.init(config); is called.
    Comment says +// Store the ServletConfig object and log the initialization+
    what does "Store" mean here ? Where it is stored ?
    how it is logged ( log4j / commons -logging ? ) and where (which file) it is logged ?
    Can we remove this line without any damage ?

    There are several calls you can make to the servlet object which are simply delegated to the ServletConfig object, most notably getServletContext(). The default action of the init(SerletConfig config) method is to store the config in a field which is defined in GenericServlet, so that these calls can work. If you don't do this then calling getServletContext() at some later time will give you a NullPointerException.
    I think the reference to logging is that, if you use the built in servlet logging system, rather than log4j or java.util.loging then this depends on a valid servlet context, which in turn, depends on a valid servlet config reference.

  • Why Servlet has init method?

    Hello,
    i am new bie to servlet. Can you tell me why servlet has init method to initialize?
    Why do not we use constructor instead of init method to initialize? Does servlet allow constructor?
    Why init method has SevletConfig as argument?
    Please help me to get knowledge regarding this. Any URL for this(sun or anything), please send.
    Thanks,
    balachandar

    http://www.unix.org.ua/orelly/java-ent/servlet/ch03_03.htm

  • Urgent....How can i redirect to my jsp page from servlet in init() method..

    How can i redirect to my jsp page from servlet in init() method..Becoz that servlet is calling while server startsup..so im writing some piece of code in init() method..after that i want to redirect to some jsp page ...is it possible?
    using RequestDispatcher..its not possible..becoz
    RequestDispatcher rd = sc.getRequestDispatcher("goto.jsp");
    rd.foward(req,res);
    Here the request and response are null objects..
    So mi question can frame as how can i get request/response in servlet's init method()..

    Hi guys
    did any one get a solution for this issue. calling a jsp in the startup of the servlet, i mean in the startup servlet. I do have a same req like i need to call a JSP which does some data reterival and calculations and i am putting the results in the cache. so in the jsp there in no output of HTML. when i use the URLConnection i am getting a error as below.
    java.net.SocketException: Unexpected end of file from server
    at sun.net.www.http.HttpClient.parseHTTPHeader(HttpClient.java:707)
    at sun.net.www.http.HttpClient.parseHTTP(HttpClient.java:612)
    at sun.net.www.http.HttpClient.parseHTTPHeader(HttpClient.java:705)
    at sun.net.www.http.HttpClient.parseHTTP(HttpClient.java:612)
    at sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLCon
    nection.java:519)
    at com.toysrus.fns.alphablox.Startup.callJSP(Unknown Source)
    at com.toysrus.fns.alphablox.Startup.init(Unknown Source)
    at org.apache.tomcat.core.ServletWrapper.doInit(ServletWrapper.java:317)
    so plz do let me know how to call a jsp in the start up of a servlet.
    Thanks
    Vidya

  • Why servlet has init() method insteadof constructor

    Why servlet has init() method insteadof constructor

    Depends completely on the servlet. If the servlet implements SingleThreadedModel, then multiple instances of the servlet will be created.
    Reason: Most servlets work quite well with multiple threads, the bulk of the variables are declared locally within the service method. Sometimes, however, the servlet needs to be able to handle multiple threads even though it is not thread safe. In such as case the SingleThreadedModel is implemented to tell the container to use a new (or one from a pool) servlet. In this case the init method will be called each time.
    [As an aside: there is of course one (not obscure, but not normal) scenario where you would call the constructor of a servlet directly - this would be where you are writing a container.  'Ah!' you say, 'I will leave that kind of madness to the boys and girls at Jakarta' - however, you may wish to write a container as a test frame for you servlet, which you should be doing.]

  • Printing in servlet's init() method

    i am trying to print out some information in init() method, but i can not create a 'response' object of ServletResponse to print with out.prinln() method for displaying these information in browser. please help me for working it out. i have given code below.
    public void init(ServletConfig config) throws ServletException {
            //response.setContentType("text/html;charset=UTF-8");
            //PrintWriter out = res.getWriter();
            Enumeration parameters = config.getInitParameterNames();
            while(parameters.hasMoreElements()) {
                String parameter = (String)parameters.nextElement();
                System.out.println("Parameter name: " + parameter);
                System.out.println("Parameter value: " + config.getInitParameter(parameter));
        }

    You don't 'create' a response object, the container does it and passes it to your code.
    You don't service requests in the init method, it's for initialization. You only setup stuff that you want to use later there.
    And in any case, do you even see 'response' declared anywhere?
    Move your code to a doGet() or doPost() method.
    People on the forum help others voluntarily, it's not their job.
    Help them help you.
    Learn how to ask questions first: http://www.catb.org/~esr/faqs/smart-questions.html
    ----------------------------------------------------------------

  • Cairngorm 3 Module and Parsley Context initialization problem.

    Hi,
       I am using parsley 2.2, cairngorm 3 module library. When the module is loaded the parsley context is not getting initialized at that time and returing null for the objects managed by the parsley container.
    <fx:Script>
    <![CDATA[
    import mx.events.FlexEvent;
    import org.spicefactory.parsley.flex.modules.FlexModuleSupport;
    import org.spicefactory.parsley.flex.tag.builder.ContextBuilderTag;
    [Bindable][Inject]public var faultMgtContainerPM:NMSFaultMgtContainerPM;
    public function get contextBuilder() : ContextBuilderTag
    return contextBuilderTag;
    ]]>
    </fx:Script>
    <fx:Declarations>
    <spicefactory:ContextBuilder id="contextBuilderTag" config="{ NMSFaultMgtModuleContext }" />
    <spicefactory:Configure />
    <s:Consumer id="notification" destination="sessionlog-notification-bus"
    fault="faultMgtContainerPM.notification_faultHandler(event)"
    message="faultMgtContainerPM.notification_messageHandler(event)"/>
    </fx:Declarations>
    In the above code the Inject of NMSFaultMgtContainerPM class doesn't work and returing null when accessed in the creationComplete event of the app.
    By the way the context file contains the NMSFaultMgtContainerPM class entry.
    Please let me know if I am missing any thing.
    Regards,
    Purushotham

    Hi,
    Please have a look at the [Init] metadata from the Parsley configuration : http://www.spicefactory.org/parsley/docs/2.1/manual/lifecycle.php#methods
    If you want the Parsley Container to invoke methods on your object when it is created or when it is destroyed,
    you can add the [Init] or [Destroy] metadata tags to the corresponding methods:
    [Init]
    public function init () : void
    [Destroy]
    public function dispose () : void
    The methods marked with [Init] get invoked after the object has been instantiated and
    all injections have been processed.
    The methods marked with [Destroy] get invoked after the Context instance they belong to has been
    destroyed with Context.destroy() or when the object was removed from the Context.
    See 6.3 Object Lifecycle Methods for details.
    For Flex Components declared in regular MXML files and wired to the Context as described in 7 Dynamic View Wiring
    the lifecycle is different: For those objects the methods get invoked whenever the object is added to or removed from the
    stage respectively. Of course the [Destroy] method additionally gets invoked if the Context the object
    was wired to was destroyed.
    Let me know if this works for you

  • Significance of context param in web.xml to initialize any variable?servlet

    I am writing a standalone web appplication for rss (xml) creation where i am having jsp servlets class etc.
    Now to write rss.xml and read it back in application i have temporarily used c:\\rss.xml but to make it capable working in web application which can be uploaded in website i need to make it configurable i need to kep it in context param of web.xml and in init() method of servlet of my application what exactly i should do there.what i have tried is this :
    public class Startup extends HttpServlet {
    private static String rssFeed;
    private ServletContext ctx;
    Logger log = Logger.getLogger(Startup.class);
    public void init(){
    log.debug("Initializing APPLICATION CONTEXT Variables");
    ctx = getServletContext();
    rssFeed = (String)ctx.getInitParameter("RssFeed");
    log.debug("Rss : " + rssFeed);
    String rssFile = this.getServletContext().getRealPath("") + File.separator + "WEB-INF" + File.separator + "rss.properties";
    Properties property = new Properties();
    try{
    InputStream propertiesFile = new FileInputStream(rssFile);
    property.load(propertiesFile);
    catch (IOException e) {
    log.error("IOException during domainValuesList file Reading");
    e.printStackTrace();
    log.error("Exception while loading AllowedDomainValues file");
    log.debug("Domain Values Lists Updated");
    /** Get Host Name (Server Name) where application is hosted on
    public static String getRssFeed(){
    return rssFeed;
    after that i called this startup servlet class in other servlet taken this getRssFeed()
    stored it as string passed as parametr to other class where i need to call it but there i am getting null pointer exception which says not initialized.
    even what i have written in web.xml is here:
    <context-param>
    <param-name>RssFeed</param-name>
    <param-value>c:\\rsshandler.xml</param-value>
    </context-param>
    <servlet>
    <servlet-name>Startup</servlet-name>
    <servlet-class>src.Startup</servlet-class>
    <init-param>
    <param-name>RssFeedConfig</param-name>
    <param-value>/WEB-INF/rss-config.xml</param-value>
    </init-param>
    </servlet>
    <servlet-mapping>
    <servlet-name>Startup</servlet-name>
    <url-pattern>/Startup</url-pattern>
    <load-on-startup>1</load-on-startup>
    </servlet-mapping>
    i tried what i know or understood but its not working.
    one more thing i have doneis:created rss.properties files in web-inf
    lines added are
    rssfeed=c:\\rsshandler.xml
    but even i am not getting this why
    or what sholud i do here.
    this thing needs to be configurablewhich we can change later easily.
    any suggestions.
    thanks
    vijendra

    Ben -
    There can be init params for the servlet or for the servlet context. For the servlet, this looks like:
    <servlet>
    <servlet-name>InitServlet</servlet-name>
    <servlet-class>package1.InitServlet</servlet-class>
    <init-param>
    <param-name>message</param-name>
    <param-value>Hello From Initialization Parameter</param-value>
    </init-param>
    </servlet>
    in the web.xml file, and is accessed using:
    public void init(ServletConfig config) throws ServletException
    super.init(config);
    message = config.getInitParameter("message");
    For a servlet context init param, you define it as you did using the web.xml settings editor:
    <context-param>
    <param-name>hello</param-name>
    <param-value>hi</param-value>
    </context-param>
    This is accessed using:
    public void init(ServletConfig config) throws ServletException
    super.init(config);
    message1 = config.getServletContext().getInitParameter("hello");
    Hope this helps,
    Lynn
    Java Tools Team

  • Unavailable or Initialization problem when viewing the servlets from admin console

    Hi
    I am on Weblogic 5.1.0. I connect to myServer which comes configured by
    default. When i see the
    registered servlets inside HTTP, on the console i see Unavailable or
    Initialization problem on every
    servlet that i select. Also when i try to load the servlet, it gives me the
    following error :--
    Property Change error for property "Load". Unable to load servlet.
    This is happening for all the servlets which are inside the General
    application inside HTTP tab.
    But when i executing the servlet examples that comes along with Weblogic,
    those examples are
    working fine.
    Also, i started my console and started the "myServer" instance and attached
    it to the console. But due to
    some reason my console hung. So i closed down the console window by pressing
    the browser close button.
    The weblogic server instance of "myServer" was still running. Then i started
    the console again and attached the
    running weblogic server instance of "myServer" to the console and went to
    servlets. This time all the servlets
    show "Previous Class Load Problem".
    Why all this is happening. Has this any where documented how to use the
    Weblogic console and Weblogic server
    instances. I have gone thru the Installation documentation of Weblogic but
    nothing like this has been mentioned over
    there.
    Thanks for ur help
    Niranjan

    Hi,
    Try to find which object causing high cpu usage following Oracle Doc ID 779349.1.
    by looking into the files then we can find what would be exact cause of this issue.
    Regards,
    Kalyan

  • If there is a problem starting a servlet....

    I'm currently writting an exception handler for my servlet's init() method.
    My question is, if there is a problem initialising the servlet (i.e. config files won't load etc) what's the best way to put the servlet out of action?
    I'm thinking maybe call the destroy() method within the catch block of init(). Would this be right?
    If so what happens if the servlet is shutdown and then there is another request? Will the container (Tomcat) attempt to start the servlet again?
    Thanks,

    When you say "And the container will always attempt to
    start the servlet after startup." Do you mean after
    shutdown?That's a strange way to say it, but I suppose you might look at it that way. The container shuts down at some point in time. It doesn't attempt to init the servlet then, but after it starts up it does attempt to init the servlet. Either immediately or upon its first use.
    It seems a bit strange for the container to keep
    restarting a servlet that will always fail on init().How should the container know that? It cannot make any assumptions about what init() might do the next time. Perhaps it failed because the system manager put a configuration file in the wrong place; it might be there now. Basically it's the manager's problem if the servlet init() fails every time, not the container's.
    Oh and I don't suppose there is a class constuctor
    exception is there, for when a constructor fails?Constructors can throw exceptions if they are designed to do so.

  • 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 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.

  • Why Servlets having Init() even though its having constructors

    Hi friends , i ve one doubt,
    in servlets all initilization part can be handled by Iinit() method,
    my qn is each servlet is singleton oriented i.e, each has only one instance, it means only one time constructor will called, and init() also called only once, so instead of init() we can use constructor, in this case why sun people provide us init() method,
    please give me soln.

    -nevermind-
    I've found something interesting in Google:
    http://www.unix.org.ua/orelly/java-ent/servlet/ch03_03.htm
    The init() method is typically used to perform servlet initialization--creating or loading objects that are used by the servlet in the handling of its requests. Why not use a constructor instead? Well, in JDK 1.0 (for which servlets were originally written), constructors for dynamically loaded Java classes (such as servlets) couldn't accept arguments. So, in order to provide a new servlet any information about itself and its environment, a server had to call a servlet's init() method and pass along an object that implements the ServletConfig interface. Also, Java doesn't allow interfaces to declare constructors. This means that the javax.servlet.Servlet interface cannot declare a constructor that accepts a ServletConfig parameter. It has to declare another method, like init(). It's still possible, of course, for you to define constructors for your servlets, but in the constructor you don't have access to the ServletConfig object or the ability to throw a ServletException.

  • Problem with Sessions, Servlets, Netscape and Solaris

    We are experiencing a problem that is confounding and frustrating us (I have
              a felling that it is something exremely minor that we are overlooking).
              Here goes:
              Context:
              The problem only occurs when using a netscape browser against weblogic
              4.51running on our Solaris 7 box (Everything works fine through IE, and
              through both browsers against our development machines which are on NT)
              Problem:
              We have a bunch of JSP pages and servlets that are used togehter throughout
              our site. They both manage session information for the user. What is
              happening is that there is no problem maintaining session information among
              all the JSP pages, but when we hit a servlet that we use to stream graphs
              back to the browser, it gets the session but it has no contents all of a
              sudden. What seems to be even more strange is that the session is not
              tagged as new (by checking isNew()), it is just empty of the contents that
              were placed it by the JSP pages. Again, this is only occurring from
              Netscape browsers against our Solaris server.
              If anyone can provide any help it would be greatly appreciated. I can
              provide more details if need be.
              Jeremy
              

    There is a property in the weblogic.properties file that lets you set
              the cookie name. If this isn't set, the port will be appended as part of
              the name. I've had a similar problem switching between http and https
              and losing sessions.
              Carles
              Jeremy wrote:
              >
              > in the link tothe servlet the URL had a :80 in it. This was because the url
              > was generated by a JSP page so that when it was moved from server to server
              > and port to port the code wouldn't have to be changed. Unfortuneately,
              > Netscape sucks and takes this to mean that x.x.x.x and x.x.x.x:80 are
              > different and won't acknowledge the cookie from the JSP pages (x.x.x.x) to
              > the servlet (x.x.x.x:80). Thanks fpr your help.
              >
              > Jeremy <[email protected]> wrote in message
              > news:[email protected]...
              > > my mistake, it appears to always happen on port 80 regardless of the
              > server
              > > it is on.
              > >
              > > Jeff Martin <[email protected]> wrote in message
              > > news:[email protected]...
              > > > It really sounds like your servlet is making a new session, even though
              > > > isNew() doesn't say so. What you might try to do is use session.getId()
              > > > to print out the session ID from your jsp pages as well as your servlets
              > > > to determine if it really is a new session.
              > > >
              > > > Do your servlets and JSPs both use the same scheme (http or https) or
              > > > cookie.setSecure()? Do your cookies use domains or paths in either
              > > > servlets or jsps (cookies can be restricted to certain subdirectories
              > > > which might be different between jsps and servlets)? Are you testing
              > > > through a proxy or firewall, or does either browser have different proxy
              > > > settings than the others?
              > > >
              > > > Jeff
              > > >
              > > > Jeremy wrote:
              > > > >
              > > > > We are experiencing a problem that is confounding and frustrating us
              > (I
              > > have
              > > > > a felling that it is something exremely minor that we are
              > overlooking).
              > > > > Here goes:
              > > > >
              > > > > Context:
              > > > > The problem only occurs when using a netscape browser against weblogic
              > > > > 4.51running on our Solaris 7 box (Everything works fine through IE,
              > and
              > > > > through both browsers against our development machines which are on
              > NT)
              > > > >
              > > > > Problem:
              > > > > We have a bunch of JSP pages and servlets that are used togehter
              > > throughout
              > > > > our site. They both manage session information for the user. What is
              > > > > happening is that there is no problem maintaining session information
              > > among
              > > > > all the JSP pages, but when we hit a servlet that we use to stream
              > > graphs
              > > > > back to the browser, it gets the session but it has no contents all of
              > a
              > > > > sudden. What seems to be even more strange is that the session is not
              > > > > tagged as new (by checking isNew()), it is just empty of the contents
              > > that
              > > > > were placed it by the JSP pages. Again, this is only occurring from
              > > > > Netscape browsers against our Solaris server.
              > > > >
              > > > > If anyone can provide any help it would be greatly appreciated. I can
              > > > > provide more details if need be.
              > > > >
              > > > > Jeremy
              > >
              > >
              

Maybe you are looking for

  • Running a winbatch processing using webutil_host.host

    In 6i form, this is not a problem of clicking a button which run 2 procedures -creating a temp .txt file and bringing up a word document by executing a winbatch .exe file. After converting this 6i form to 10g form. Somehow, the winbatch .exe file is

  • Complex PO - Prepayment A/c

    How does the pre-payment account default for the advance line in Complex Work Purchase Order?

  • Setting the sql statement

    http://www.egbolig.dk/drift_bo_syd.rpt (HERE IS THE REPORT) We are using SAP Crystal Report .NET Runtime files (http://scn.sap.com/docs/DOC-7824 newest version 13.0.9.1312) in our web asp.net application. Everything have been working fine, but we hav

  • WebDynpro ABAP : Table with DropDownByKey does not have neat focus

    Hi Experts, I have a table, with one column of type dropdownbyKey, i need this so that i can display the DESCRIPTION rather than key. Issue is when i select a ROW in this table i see a special YELLOW BG COLOR on all columns except the column that has

  • OS 10.5.8 to OS 10.6.3 problems

    I have an Imac which I just updated from OS 10.5.8  to OS 10.6.3 (snow leopard).  I could not start up my photoshop CS unless I installed rosseta  from the new OS disk.  Once I did this photoshop was glitchy and I could not scan from my canon MP470 p