Clarification needed on servlet class reloading

          I have a question about servlet reloading in WLS6.0
          Let's assume i have version 1.0 of a SomeServlet.class loaded in WLS.
          Client are accessing it currently.
          Now let's say i create version 1.1 of SomeServlet.class and i want to deploy it in WLS.
          I have the "servlet reloading" turned ON.
          So that means that version 1.1 will be immediately loaded by WLS right?
          Question: Will WLS first unload version1.0? If so, what happens to the clients who are using version 1.0?
          Will they get a ClassCastException? Or will they be abruptly switched from 1.0 to 1.1? Will they see any any error at all?
          Thanks.
          PS: If i had deployed the servlet in a WAR file, will the same rules apply? In other words, if i replace the WAR file will a newer version, what will happen to the classes from the previous WAR file that are being used by clients.
          Is there a document explaining "how WLS reloads/hot-deploys servlets/ejb"? I understand that WLS6.0 uses a new "classloader architecture" that is different from WLS5.1.0. Some document to explain the differences would be helpful. Thanks.
          

The new version will be loaded immediately into a new classloader.
          The old version will remain (in its old classloader) until there are no
          longer any references to it (which will happen when clients that were
          using the old version have completed their operations).
          mark
          Jeff Mathers wrote:
          > Did you ever get clarification on this point?
          >
          > I am trying to figure out how to force WLS 6 to reload servlets following a
          > re-compile. Your message hinted at a way to do this. Can you fill me in?
          >
          > Jeff Mathers
          > IT R&D
          > RWJPRI - Johnson & Johnson
          >
          > "R" <[email protected]> wrote in message
          > news:[email protected]...
          > >
          > > I have a question about servlet reloading in WLS6.0
          > >
          > > Let's assume i have version 1.0 of a SomeServlet.class loaded in WLS.
          > > Client are accessing it currently.
          > > Now let's say i create version 1.1 of SomeServlet.class and i want to
          > deploy it in WLS.
          > > I have the "servlet reloading" turned ON.
          > > So that means that version 1.1 will be immediately loaded by WLS right?
          > >
          > > Question: Will WLS first unload version1.0? If so, what happens to the
          > clients who are using version 1.0?
          > > Will they get a ClassCastException? Or will they be abruptly switched from
          > 1.0 to 1.1? Will they see any any error at all?
          > >
          > > Thanks.
          > >
          > > PS: If i had deployed the servlet in a WAR file, will the same rules
          > apply? In other words, if i replace the WAR file will a newer version, what
          > will happen to the classes from the previous WAR file that are being used by
          > clients.
          > >
          > > Is there a document explaining "how WLS reloads/hot-deploys servlets/ejb"?
          > I understand that WLS6.0 uses a new "classloader architecture" that is
          > different from WLS5.1.0. Some document to explain the differences would be
          > helpful. Thanks.
          

Similar Messages

  • NON-SERVLET, NON-EJB DYNAMIC CLASS RELOAD

    hi,
              In weblogic 5.1, is there a way to reload a class from the clientclasses directory without restarting the server? it's just a class in the clientclasses used by the JSPs. a kind of hotdeploy for NON-EJB, NON-SERVLET CLASS. SPECIFIC guidance will be immensely appreciated..
              Thanks in advance
              Vijay
              

    please show us the full error message.
    it sounds like a classpath problem...

  • Why need to restart server while modifying the servlet class

    Hi,
    i have some doubt, i hope any one can clear my doubt about servlet
    why we need to restart the web container while every time we modify the servlet class code
    Thanks & Regards
    vijay

    When you deploy a web application to a web container, you are deploying the
    .class files of your servlet not your source code. There is no servlet source code on the container (shouldn't be).
    So if you change your source code, the container knows nothing about it until you compile the code
    to create new .class files and then replace the container's class files with the new ones.
    You can configure most servers for hot deployment and/or start them in debug mode to ease the cycle during development.

  • Tomcat servlet class not refreshing

    I just started to work with Tomcat.
    My problem is that once I have compiled and put a servlet in myApps\WEB-INF\Classes directory even after I recompile it the browser displays old version. Only stopping and starting Tomcat shows the new version
    My browser is IE v 6.
    I have done everything as instructed in the book Java for the Web with Servlets... by Kurniawan.
    My web.xml looks like so
    <?xml version="1.0" encoding="ISO-8859-1"?>
    <!DOCTYPE web-app
    PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"
    "http://java.sun.com/dtd/web-app_2_3.dtd">
    <web-app>
    <servlet-mapping>
    <servlet-name>invoker</servlet-name>
    <url-pattern>/servlet/*</url-pattern>
    </servlet-mapping>
    <servlet>
              <servlet-name>Testing</servlet-name>
              <servlet-class>TestingServlet</servlet-class>
    </servlet>
    </web-app>      
    My CLASSPATH variable looks like so
    c:\j2sdk1.4.2_01\lib;.;c:\1ourfolder\Java Stuff;c:\jakarta-tomcat-4.1.27\common\lib\servlet.jar;C:\IBM\SQLLIB\java\db2java.zip;C:\IBM\SQLLIB\java\db2jcc.jar;C:\IBM\SQLLIB\java\sqlj.zip;C:\IBM\SQLLIB\bin;C:\IBM\SQLLIB\java\common.jar
    Is there something I need to add in the web.xml file? On the comp.lang.java.help forum there was reference to the WEB-INF\classes directory being in classpath and removing that made it work but I don't have that situation AFAIK.
    Thanks

    This must have been answered many times but with the software evolving as it does there must be different ways of doing this. This is what I did
    On your browser go to the manager page.
    http://localhost:8080/manager/html
    You may be prompted for a userid and password
    If you haven't done so already edit the conf\tomcat-users.xml file in the tomcat directory and add a line to set you up as a manager. This is going to be something like this
    <user username="manager" password="tomcat" roles="manager"/>
    Login as manager/tomcat.
    On the resultant webpage you should see a list of applications, myApps will be in that list. Stop it and start it (follow the grid to the right)
    Now your servlet class will be refreshed.
    I looked at other responses in this forum and found this answer
    http://forum.java.sun.com/thread.jsp?forum=33&thread=404559
    "...If it is tomcat 4.1 then you can use its adminitrator jsp page to make your context(webapp) reloadable. This in turn will make chages to your your server file and will add the context back to tomcat without stopping it..."
    At this time I haven't figured out how to do this ;-)
    Oh, and could you use code tags the next time?

  • How can i make a servlet (class) temporarily unavailable, except for ADMIN

    Hello All!
    I am rather new to the programming field and have already completed a web-project in Java only with Servlets. (no jsp). I have a login procedure, means I have a user management for users and admins. If an admin is logged in, he/she should be able to deactivate the servlet with a mouse-click as long he activates it again with the same. if the servlet is deactivated, other users/admins trying to access the servlet should get a "servlet is currently unavailable" message. but the admin, who is logged in, still should be able to work with the servlet! how can i realise that?
    in other words, by clicking that particular button, the servlet should be made "non-multi-thread" and other way round by activating it.
    any ideas??? how can the standard "servlet currently unavailable" page be displayed? I have tomcat 4 on a linux machine! i'd be really grateful if someone oculd help me.
    another question i have is, how to define a "pseudo" link address to the servlet. now, the servlet can only be accessed by typing like this: http://servername.xy.com:8080/ProjectName/servlet/ServletName (because I have activated the servlet mapping in the server.xml/web.xml with /servlet/*)
    but I want a link like this: http://servername.xy.com:8080/shortname
    How can I do this in an easy way?? I have treid to create a web.xml in der WEB-INF folder of the servlet with following content, but it is not working:
    <?xml version="1.0" encoding="ISO-8859-1"?>
    <!DOCTYPE web-app PUBLIC
    "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"
    "http://java.sun.com/dtd/web-app_2_3.dtd">
    <web-app>
    <servlet>
    <servlet-name>
    shortname
    </servlet-name>
    <servlet-class>
    ClassName
    </servlet-class>
    </servlet>
    </web-app>
    Thanks a lot in advance for your kind help,
    lisa

    Ok,
    You'll need to find a tutorial on servlet filters. Its not that hard a concept.
    http://java.sun.com/j2ee/1.4/docs/tutorial/doc/Servlets8.html#wp64572
    Filters need to be configured in the web.xml.
    Basically they are a buffer between a request and your servlet.
    Any requests for the servlet, go through the filter first. It lets you do some processing before/after the servlet gets called. Its a good way of putting in some generic code that need to be run for many servlets - security checks are often implemented in this fashion.
    This should give you an idea of the sort of thing you need. I haven't really written one before, so I copied this out of the tutorial and did some basic framework for it....
    public final class TestFilter implements Filter {
       private FilterConfig filterConfig = null;
       public void init(FilterConfig filterConfig) throws ServletException {
          this.filterConfig = filterConfig;
       public void destroy() {
          this.filterConfig = null;
       public void doFilter(ServletRequest request,  ServletResponse response, FilterChain chain) throws IOException, ServletException {
            // if you want to get the session will need to cast request to an HttpServletRequest
            Session session = request.getSession();
            String requestURL = request.getRequestURL();
            // check if this URL is for a servlet that is disabled for this user
           // somehow you have to keep track of this ... maybe in the servletContext ?
        User user = (User) session.getAttribute("user")     
          boolean disabled = checkDisabled(requestURL, user);
          // if its not disabled, go ahead
          if (!disabled)
            chain.doFilter(request, response);
        else{
            // send the servlet off somewhere else - requestDispatcher maybe?
    }

  • How to publish a servlet class to web server?

    background:
    web server: tomcat apache 4
    context path: webapp\test\
    servlet path: webapp\test\WEB-INF
    servlet name: HelloWorld.class
    i tried to placed the servlet class file to above servlet path,
    but i can't invoke the servlet by http://localhost:8080/test/HelloWorld
    what should i do in order to invoke the servlet at browser?
    Is a web.xml necessary a must to provided a mapping between request name and actual class name?

    First of all you need a *.war structure which look like this
    /app-name
    /app-name/WEB-INF/
    /app-name/WEB-INF/lib
    /app-name/WEB-INF/classes
    When you have created this structure you add your servlet (HelloWorld.class) in the classes directory (Create the package structure first).
    When this is done you need to map the servlet to a given uri which is done in the web.xml. An example is found below:
    <servlet>
    <servlet-name>hello</servlet-name>
    <servlet-class>package.HelloWorld</servlet-class>
    </servlet>
    <servlet-mapping>
    <servlet-name>hello</servlet-name>
    <url-pattern>/hello/*</url-pattern>
    </servlet-mapping>
    Hopefully this will help :-)
    best regards
    Stig

  • Dynamic class reloading in modular web application

    Hi.
    My web application has these requirements:
    A. Functional modularization (like plug-ins). Modules will be simple jars containing application logic classes: dto beans, business logic services, dao (jpa), framework stuff (Struts2), etc...
    B. At runtime and without restarting the application "class loading" must be aware of classes inside new, changed and removed modules.
    C. Some of these jars will be outside the web application folder (WEB-INF/lib), possibly outside the container itself too.
    My question:
    1. Can I achieve all or some of my requirements with a Java web application?
    2. How should I manage the modules?
    3. Do I need some special web container feature (maybe osgi)?
    4. Can I use a custom class loader in my application?
    The architecture objectives are:
    I. Provide scalability.
    II. Efficient development process (independent deployment and no application restart required).
    III. Better production support (no application restart required for changes).
    More on the architecture:
    a). Functional scalability, meaning this that my application may functionally grow up to an indeterminate number of small functional modules.
    b). Modules will be developed, deployed and maintained independently so the application discovers and loads classes on demand.
    c). Avoid a big .war file containing all the small modules because a small change in one module would involves deploying all the other modules (possibly hundreds o even thousands of them) and restarting the application.
    d). Above point involves dynamic class reloading.
    I guess this is addressed by OSGI (looks like heavy to deal with), Jigsaw (still under development) and maybe others. I think the key point is the class loader. I will develop a custom class loader but maybe you have some advice for me before starting to develop.
    Thanks and regards.

    Classes maintained by the container should not be loaded by an application. You want the container to read those classes and react accordingly. Most of those classes are read when the container starts up a container restart will be required. Trying to leverage another container within a container does not sound like it will be worth (if you can get it to work).
    Perhaps you should state the problem that you are trying to solve with these modules so that others may suggest more feasible solutions to achieve your target goals.

  • How can I find the servlet class name from inside a ServletFilter?

    Ive implemented a servlet filter, but need to discover the class name of any servlet class that gets executed.
    Ive dug through the spec and cant seem to find any path to do this.
    Seems the methods needed to do this have been deprecated. (for security reasons?)
    Is there any way to write a ServletFilter to grab this info?
    If not, is there any other way to capture every servlet execution in the container, time its execution, and log the class name along with the execution time?
    (***WITHOUT*** requiring a classpath over ride of any container provider classes)
    Any help is much appreciated. Been banging my head against this for some time now :(

    request.getServletPath() returns the part of the URL which refers to the servlet. It isn't the classname of the servlet but it should be a reasonable surrogate. If you log that, then you could write some code which reads your web.xml and uses the servlet-mapping elements to convert it to servlet class names later.

  • Tomcat session expires after compiling servlet/ class

    Hi,
    Does anybody know why tomcat(4.1) session expires if you modify a serlvet or class and compile it.
    After compiling I refresh the page and I get session invalidated page. And every time I compile I have to relogin.
    Any ideas ? Is there a work around ?

    In serverl.xml, if you have set the reloadable="true" attribute in your <Context/> tag for your web application then each time one of the servlet classes is modified, tomcat will reload the web application. Set reloadable="false" and this will stop.
    tobes

  • Retrieve ServletContext from non-servlet class

    A servlet calls a method which is located in another class which is not a servlet. Within this method of the non-servlet class, i need to access the ServletContext of the servlet that has called the method. What i am currently doing is simply passing the ServletContext as a parameter to the method.
    I would like to avoid passing the ServletContext all the time, so i'm wondering if it's possible, from the non-servlet class, to retrieve the ServletContext of the servlet which has called the method of the non-servlet class.

    Thanks J-Fine, that's a smart suggestion. BTW in the meantime i figured out that passing the ServletContext is not that bad idea, after all it reflects the structure of the app. However if i'll change my mind again i'll do like you suggested.

  • Add non-servlet class to Tomcat

    Hi,
    does anyone know, what I have to do, to be able
    to use a simple non-servlet class file in my
    jsp-pages.
    e.g.
    MyClass.class
    In my jsp page:
    <%
    MyClass m = new MyClass( );
    %>
    I was told that I simply have to put it in the
    web-inf/classes directory, but that doesn't seem
    to work ...
    Any help would be appreciated! Thanx. chris

    You need to use the "import" statement or else use the full class name. Also, some servers don't handle the default package well so you may want to try placing the class in a package.
    e.g. if class is mypackage.MyClass, it is placed in web-inf/classes/mypackage/MyClass.class
    In the JSP, code:
    <%@ page import="mypackage.MyClass" %>
    <%
    MyClass m = new MyClass();
    %>or you could use "useBean" to avoid scriptlets.

  • Dynamic Class Reloading

    As I know that setting has to be made to the application server to enable the class reloading features, so that the changes to the components (such as enterprise beans, servlets, and JSP files) to a running server can be deployed without having to stop the application server process and start it again.
    I'm just wondering, for those Web Hosting Company that offer JSP-compatible Web Servers services, are they forced to have the Class Reloading Feature enabled for their Web Server?? else how they can provided 7 x 24 service, as no downtime are allowed, please advise?

    "... else how they can provided 7 x 24 service, as no downtime are allowed, please advise?"
    Most large organisations wishing to redeploy an application but maintain service would not use class reloading (which would be a path to chaos!) but would use their load balancers or clustering software to disable connections to some (half?) of their servers. They'd then load the updated software onto the out-of-service servers, swich the live traffic onto them and then update the remaining servers before bringing them back into service.
    This kind of redeployment can also be achieved by running more than one instance of the app server on each box, with only one instance 'live' at any one time. Updates are made to the off-line instances and then connections redirected to them. This has the advantage that the old code is still in place so fall-back is easy if there's a problem with the redeployed code.

  • Servlet Class dependency is not found at weblogic startup.

    I have the following ear file which includes:
    web-inf\lib (contains all the needed utilities jar)
    *ejb.jar
    *webapp.war (The WEB-INF\lib dir inside war file contains all the needed utilities
    jars.
    I get the following BEA-101250 error saying that a servlet could not be loaded
    because a class that it depends on is not in the classpath. But I think I place
    all the needed jars in the startWebLogic.cmd file as well as in the WEB-INF\lib
    of the ear and war files. However, if a classs that a servlet depends on is not
    found, why doesn't weblogic simply tells us what that class is (instead of guessing
    to death)? How can I find which class that the servlet depends on is not found?
    Thanks.
    BEA-101250
    Error: [context]: Servlet class className for servlet svltName could not be loaded
    because a class on which it depends was not found in the classpath classPath.\nt.
    Description
    [context]: Servlet class className for servlet svltName could not be loaded because
    a class on which it depends was not found in the classpath classPath.\nt.
    Cause
    One of the classes the servlet class uses was not recognized by the Web application
    classloader.
    Action
    Make sure the class is available either in WEB-INF/classes or WEB-INF/lib or
    system classpath.

    Hmm, do you perhaps have the prefer web-inf-classes set in weblogic.xml?
    -- Rob
    rock wrote:
    I place all the utilties class in the top level APP-INF/lib. Same error. I installed
    this application on JBoss and everything runs fine. I really don't know what
    classes or jar that weblogic says that a servlet depends on.
    There are only a finite number of places where you can put all the needed jars
    in which that servlet depends:
    1. myapp.ear/APP-INF/lib
    2. myapp.ear/WEB-INF/lib
    3. or put it to a directory in the ear and refer to each jars in the CLASS-PATH
    line of the MANIFEST.MF file.
    4. myweb.war/WEB-INF/lib
    5. EJBs are in myapp.ear top directory
    6. Refer to all the jars in startWebLogic.cmd script as it starts.
    I still don't know what jars I am missing.
    Thanks.
    Rob Woollen <[email protected]> wrote:
    rock wrote:
    Rob,
    I remove all the classpath, but when I deploy the ejb complains thatit missed
    all the needed utilities class. Ok, stop there. If the utilities classes need to be seen by both the
    EJBs and webapp, then placing them in WEB-INF/lib is not enough. That
    makes them available only to the webapp.
    If you're using 8.1, then the solution is pretty simple. Move your
    utility classes into a top-level directory named APP-INF/lib
    ie
    ear/APP-INF/lib/utils.jar
    ear/fooejb.jar
    ear/fooweb.war
    If you're using < 8.1, then you can still move the jars to APP-INF/lib,
    but you'll need to add manifest class-path entries to the EJB and webapp.
    -- Rob
    I again place it on - the ear deploys fine (ejbs
    and war). But the starting servlet could not loaded because it cannotfinds a
    class that it depends on. I think I reference all the classes or jarsthat it
    needs - so I need it to tell me which one. I don't know why weblogicmakes it
    so difficult. It took me a month already and all I need to do is findthe class
    that it complains about.
    Rob Woollen <[email protected]> wrote:
    Yes, it would be nicer if that exception had more information.
    You told the web container the servlet-class in your web.xml. THe
    web
    container tried to load it and got a NoClassDefFoundError.
    Unfortuantely that exception doesn't include much information.
    NoClassDefFoundErrors are caused by something in a parent loader
    depending on something in a child classloader.
    Step #1 is for you to remove everything you've added to the $CLASSPATH.
    If that doesn't solve your problem, post again.
    -- Rob
    rock wrote:
    I have the following ear file which includes:
    web-inf\lib (contains all the needed utilities jar)
    *ejb.jar
    *webapp.war (The WEB-INF\lib dir inside war file contains all the
    needed
    utilities
    jars.
    I get the following BEA-101250 error saying that a servlet could notbe loaded
    because a class that it depends on is not in the classpath. But Ithink I place
    all the needed jars in the startWebLogic.cmd file as well as in theWEB-INF\lib
    of the ear and war files. However, if a classs that a servlet dependson is not
    found, why doesn't weblogic simply tells us what that class is (insteadof guessing
    to death)? How can I find which class that the servlet depends onis not found?
    Thanks.
    BEA-101250
    Error: [context]: Servlet class className for servlet svltName couldnot be loaded
    because a class on which it depends was not found in the classpathclassPath.\nt.
    Description
    [context]: Servlet class className for servlet svltName could notbe loaded because
    a class on which it depends was not found in the classpath classPath.\nt.
    Cause
    One of the classes the servlet class uses was not recognized by theWeb application
    classloader.
    Action
    Make sure the class is available either in WEB-INF/classes or WEB-INF/libor
    system classpath.

  • Servlet class

    ok the servlet class is suppose to be in the j2sdk1.4.0right well every time i try to compile a servlet it tells me the package does not exist like when i use import java.servlet.*;. What im i doing wrong and how can i fix this . thanks

    did you recently download the j2sdk1.4? Did you used to have 1.3.1? If so...you may need to change which javac you are using...If you use a IDE make sure the settings point to the new j2sdk1.4 instead of 1.3.1

  • Quiestion about servlet class

    hi,
    Is any know what happen broswer run a servlet class? it keep in cache some where?
    I run tomcat-4.1.27 on Linux box, I just find out. After I modified the java code and recomplier (no error), re-run on broswer. It still show my old java class result.
    Did I miss something?
    Thanks

    the browser itself has absolutely nothing to do with the html generation inside a servlet. servlets are serverside-only "applications".
    after changing your servlet code make sure todo the following:
    - compile the source file(s)
    - make sure the servlet engine (in your case tomcat) is reloading your webapp
    (if the webapp admin is available you might restart your webapp by using this admin tool)
    if after all the browser is still showing the old servlet result code you should also check the browser caching settings and maybe clear the cache.

Maybe you are looking for

  • Email notification - Ok/Cancel text in the email

    Hello , I am using oracle BPM 11g , have configured Human Task to send email notification to owner of the task . Email gets sent correctly but in the body of email i am getting text as "OK/Cancel" (at the bottom of email ) Not sure how to remove this

  • Update values on an Adobe Interactive Form

    My question refers to the thread posted back in 2004 which remains unanswered... Thread: http'How to update values in Adobe form? With ECC 6.00 (SP10) , assuming that the Webdynpro and Adobe Interactive Forms has been correctly setup, can values on a

  • 10.5.7 Has killed my machine

    I ran the updater from the software update pane, restarted. After several minutes a message popped up saying that it could not be installed and to contact the maker of the software (which is obviously Apple). I clicked the only button available, whic

  • Upgrade to Mountain Lion on 2GB MBA?

    I've used Apple computers since 2005 so while I can navigate and use it far better than my parents who are Windows users through and through I don't know a whole lot about them. I want to upgrade to Lion. Messages (though I've heard there are issues)

  • How can connect java with 3D Max

    i want to make 3d maze by reading from text file for example when i read 0, then i draw wall when i read 1 i draw path ..and so on and i want to move the object in the maze by using AI techniques my questions are: - can I read from file and draw by u