Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [jetty-users] Keep the sessions after a redeploy

After much digging I finally managed to solve the problem. For those interested, here's the solution:

<Set name="lazyLoad">true</Set>

Apparently, version 6 does not require this parameter

On Wed, Dec 15, 2010 at 4:53 PM, Filipe Sousa <natros@xxxxxxxxx> wrote:
Hi,

I'm using embedded jetty 7.2.2 in a project and I need to redeploy without losing sessions. 
I'm using the following contents on file WEB-INF/jetty-web.xml. I am also using a realm for application security.

<Set name="sessionHandler">
<New class="org.eclipse.jetty.server.session.SessionHandler">
<Arg>
<New class="org.eclipse.jetty.server.session.HashSessionManager">
<Set name="storeDirectory">/tmp/jetty</Set>
</New>
</Arg>
</New>
</Set>

The redeploy is triggered when I touch a xml file in /contexts folder:
<?xml version="1.0"?>
<!DOCTYPE Configure PUBLIC "-//Jetty//Configure//EN" "http://www.eclipse.org/jetty/configure.dtd">
<Configure class="org.eclipse.jetty.webapp.WebAppContext">
<Set name="contextPath">/guia-ects</Set>
<Set name="resourceBase"><SystemProperty name="jetty.home" default="." />/WebContent</Set>
</Configure>

After doing a redeploy, I got a NullPointerException when accessing a protected URL. After tracing the error, I detected that the parameter user is null

MappedLoginService.class:
 public boolean validate(UserIdentity user)
    {
        if (_users.containsKey(user.getUserPrincipal().getName()))
            return true;
        
        if (loadUser(user.getUserPrincipal().getName())!=null)
            return true;
                
        return false;
    }

This is the code for running jetty7:

public class JettyServer {
private final String PATH = System.getProperty("user.dir");
private Server server;
private final ContextHandlerCollection handlers = new ContextHandlerCollection();
private DeploymentManager deploymentManager;

public JettyServer() {
System.setProperty("jetty.home", PATH);
System.setProperty("javax.net.ssl.trustStore", PATH + "/etc/keystore.jks");
System.setProperty("javax.net.ssl.trustStorePassword", "password");

createServer();
createDeploymentManager();
createContextProvider();
}

private void createContextProvider() {
ContextProvider provider = new ContextProvider();
provider.setMonitoredDirName(PATH + "/contexts");
provider.setScanInterval(1);
deploymentManager.addAppProvider(provider);
}

private void createDeploymentManager() {
deploymentManager = new DeploymentManager();
deploymentManager.setContexts(handlers);
server.addBean(deploymentManager);
}

private void createServer() {
server = new Server(8080);
server.setStopAtShutdown(true);
server.setHandler(handlers);
}

private void run() throws Exception {
server.start();
server.join();
}

public static void main(String[] args) throws Exception {
JettyServer server = new JettyServer();
server.run();
   }
}

I don't have this problem with Jetty 6.1.26. Is this a bug?

Thanks.
--
Filipe Sousa



--
Filipe Sousa

Back to the top