Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

RWT 4 issue with 'contextDirectory' using Jetty embedded #248

Open
brotenet opened this issue Nov 14, 2024 · 0 comments
Open

RWT 4 issue with 'contextDirectory' using Jetty embedded #248

brotenet opened this issue Nov 14, 2024 · 0 comments

Comments

@brotenet
Copy link

Hello :)

I am trying to get an RWT 4.0 (rap-4.0.0-R-20240904-0717) application up and running using the Jetty (12.0.12) dependencies that are included in the RWT 4.0 Release archive in embedded mode and I keep getting the following error in 'server.start()':

java.lang.NullPointerException: The parameter 'contextDirectory' must not be null.

..which is raised by the ParamCheck.java class.

This is the server initiation code:

private static void testBasicServer() throws Exception {
		Server server = new Server(8080);
        ServletContextHandler context = new ServletContextHandler(ServletContextHandler.SESSIONS);
        context.setTempDirectory(new File("/tmp/" + UUID.randomUUID().toString())); //Create a unique temp directory
        context.newResource(new URI(context.getTempDirectory().getCanonicalPath())); //Set the temp directory as the resource path 
        context.setContextPath("/");
        context.setInitParameter("org.eclipse.rap.applicationConfiguration", "tests.HelloWorldConfiguration");
        context.addEventListener(new RWTServletContextListener());
        ServletHolder rwtServletHolder = new ServletHolder(new RWTServlet());
        context.addServlet(rwtServletHolder, "/hello");
        server.setHandler(context);
        server.start(); //This is where the code breaks
        server.join();
	}

This is the full exception trace:

java.lang.NullPointerException: The parameter 'contextDirectory' must not be null.
	at org.eclipse.rap.rwt.internal.util.ParamCheck.notNull(ParamCheck.java:29)
	at org.eclipse.rap.rwt.internal.resources.ResourceDirectory.configure(ResourceDirectory.java:27)
	at org.eclipse.rap.rwt.internal.application.ApplicationContextImpl.doActivate(ApplicationContextImpl.java:372)
	at org.eclipse.rap.rwt.internal.application.ApplicationContextImpl.activate(ApplicationContextImpl.java:244)
	at org.eclipse.rap.rwt.application.ApplicationRunner.start(ApplicationRunner.java:80)
	at org.eclipse.rap.rwt.engine.RWTServletContextListener.contextInitialized(RWTServletContextListener.java:51)
	at org.eclipse.jetty.ee10.servlet.ServletContextHandler.callContextInitialized(ServletContextHandler.java:1591)
	at org.eclipse.jetty.ee10.servlet.ServletContextHandler.contextInitialized(ServletContextHandler.java:497)
	at org.eclipse.jetty.ee10.servlet.ServletHandler.initialize(ServletHandler.java:670)
	at org.eclipse.jetty.ee10.servlet.ServletContextHandler.startContext(ServletContextHandler.java:1325)
	at org.eclipse.jetty.ee10.servlet.ServletContextHandler.lambda$doStart$0(ServletContextHandler.java:1047)
	at org.eclipse.jetty.server.handler.ContextHandler$ScopedContext.call(ContextHandler.java:1446)
	at org.eclipse.jetty.ee10.servlet.ServletContextHandler.doStart(ServletContextHandler.java:1044)
	at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:93)
	at org.eclipse.jetty.util.component.ContainerLifeCycle.start(ContainerLifeCycle.java:169)
	at org.eclipse.jetty.server.Server.start(Server.java:624)
	at org.eclipse.jetty.util.component.ContainerLifeCycle.doStart(ContainerLifeCycle.java:120)
	at org.eclipse.jetty.server.Handler$Abstract.doStart(Handler.java:491)
	at org.eclipse.jetty.server.Server.doStart(Server.java:565)
	at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:93)
	at tests.Testing.testBasicServer(Testing.java:39)
	at tests.Testing.main(Testing.java:20)

Please note that the aforementioned code used to work perfectly with older versions of RWT (e.g. 3.4 and older)

I am most probably missing something here... but I really cannot find what it is.
Any suggestion on how to fix this would be greatly appreciated.

ksnip_20241114-064943

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant