Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [jetty-dev] Jetty Server Migration from 5.1.1 to Jetty 9

Hi Greg,

I have changed the following code in Jetty6 to Jetty9 migration. I'm facing an issue that Illegal StateException :'No contexts found"   
   
        Existing code in Jetty6:
        this.jettyWebServer = new Server(); //org.mortbay.jetty.Server

        ThreadPool threadPool = new ThreadPool(threadPoolSize);

        jettyWebServer.setThreadPool(threadPool);

        Connector connector = new SelectChannelConnector();

        connector.setPort(port);

        this.jettyWebServer.setConnectors(new Connector[]{connector});
 
        WebAppDeployer webAppDeployer = new WebAppDeployer();

        webAppDeployer.setContexts(this.jettyWebServer); /// setContexts method is not available in        Jetty9

        webAppDeployer.setWebAppDir(warpath);

        webAppDeployer.setExtract(true);

        webAppDeployer.setParentLoaderPriority(true);

        webAppDeployer.start();

        this.jettyWebServer.setStopAtShutdown(true);

        this.jettyWebServer.setSendServerVersion(false);
            

        this.jettyWebServer.start();
        this.jettyWebServer.join();
       
        I have modified the above code for Jetty9 as follows::

         Jetty9 code:

DeploymentManager deploymentManager = new DeploymentManager(); // added DeploymentManager in Jetty9
        QueuedThreadPool threadPool = new QueuedThreadPool(threadPoolSize);// Thread pool
        threadPool.setMaxThreads(500);
      
        this.jettyWebServer = new Server(threadPool);// org.eclipse.jetty.Server
        
        ContextHandlerCollection contexts = new ContextHandlerCollection();
    
        contexts.setHandlers(new Handler[] { context});

        this.jettyWebServer.setHandler(contexts);
    
        ServerConnector connector = new ServerConnector(jettyWebServer);
       
        connector.setPort(port);
      
        this.jettyWebServer.setConnectors(new Connector[]{connector});
          
        WebAppProvider webAppDeployer = new WebAppProvider();// WebAppProvider replaced webAppDeployer in Jetty6
      
        webAppDeployer.setExtractWars(true);

        webAppDeployer.setParentLoaderPriority(true);

        webAppDeployer.setMonitoredDirName(warpath);
            
        deploymentManager.addAppProvider(webAppDeployer);
        this.jettyWebServer.addBean(deploymentManager);
        this.jettyWebServer.setStopAtShutdown(true);
        this.jettyWebServer.start();
        this.jettyWebServer.join();

In Jetty 9 code I have deploymentmanager and webAppProvider classes. Since there is no setContexts method in Jetty9 How can we set the context?. Also the jetty9 code is correct ?. Could you please help me ?.

Do I need to use webAppContext instead of Deploymentmanager?. I'm using embedded jetty and deploying .aar file.


Thanks,
Arun



On Wed, Aug 19, 2015 at 4:31 AM, Greg Wilkins <gregw@xxxxxxxxxxx> wrote:

Arun,

use ServerConnector for SelectChannelConnector

Have a look at the embedded jetty examples for examples of minimal starts to jetty: https://www.eclipse.org/jetty/documentation/current/embedded-examples.html#embedded-one-webapp

On 18 August 2015 at 02:09, Arun Kumar <arunkumarstay@xxxxxxxxx> wrote:
Hi Greg,

The class  'selectchannelconnector' in Jetty6  is not available in Jetty9. Could you please tell which is the alternative for 'selectchannelconnector'  in Jetty 9 ?.

Thanks

On Tue, Aug 4, 2015 at 2:28 AM, Greg Wilkins <gregw@xxxxxxxxxxx> wrote:
HttpServer -> org/eclipse/jetty/server/Server
HttpContext -> org/eclipse/jetty/server/handler/ContextHandler
SocketListener -> org/eclipse/jetty/server/ServerConnector

cheers


On 4 August 2015 at 01:33, Arun Kumar <arunkumarstay@xxxxxxxxx> wrote:
Hi Greg,

Thanks for the reply. I'm referring the link you shared. But the main issue I'm facing is unable to replace the package "org.mortbay.html ". The existing code using classes from html package.
Could you please help to find out these html classes in Jetty 9. Any alternative on this.

Also some classes in like HttpContext, HttpServer, SocketListener are not found in "org.eclipse.jetty.http" package. Please help me on this .

Thanks,
Arun

On Mon, Aug 3, 2015 at 7:49 AM, Greg Wilkins <gregw@xxxxxxxxxxx> wrote:

Arun,

have a look at the doco for porting from jetty 6 to jetty 7, as that has the big name changes in it:

 https://wiki.eclipse.org/Jetty/Starting/Porting_to_Jetty_7

So while a port from 5 to 9 will be different, the bulk of the changes needed will be described in the 6 to 7 transformation.

cheers



On 3 August 2015 at 03:12, Arun Kumar <arunkumarstay@xxxxxxxxx> wrote:
Hi Friends,

I'm migrating a Java application from Jetty Server 5.1.1 to Jetty 9. In the existing project I can see only one jar file related to
Jetty 5(org.mortbay.Jetty 5.1.1) .

I have downloaded Jetty-all -9.0 jar and build the project. But some of the packages in existing code shows compile error since the packages in org.mortbay.Jetty in 5.1 changed to org.eclipse,jetty in version 9.

My code is using some imports like org.mortbay.http.HttpServer, org.mortbay.http.HttpContext. I'm unable to see the similar packages in Jetty-all-9.0.jar.

Also package  'org.mortbay.html'  needs to replace with similar classes in Jetty 9.

Could someone help me to fix these compile errors ?. Which are the new classes and packages in Jetty9?.

Is the procedure I'm following is correct for Jetty 9 ?.


Thanks,
Arun

_______________________________________________
jetty-dev mailing list
jetty-dev@xxxxxxxxxxx
To change your delivery options, retrieve your password, or unsubscribe from this list, visit
https://dev.eclipse.org/mailman/listinfo/jetty-dev


_______________________________________________
jetty-dev mailing list
jetty-dev@xxxxxxxxxxx
To change your delivery options, retrieve your password, or unsubscribe from this list, visit
https://dev.eclipse.org/mailman/listinfo/jetty-dev


_______________________________________________
jetty-dev mailing list
jetty-dev@xxxxxxxxxxx
To change your delivery options, retrieve your password, or unsubscribe from this list, visit
https://dev.eclipse.org/mailman/listinfo/jetty-dev


_______________________________________________
jetty-dev mailing list
jetty-dev@xxxxxxxxxxx
To change your delivery options, retrieve your password, or unsubscribe from this list, visit
https://dev.eclipse.org/mailman/listinfo/jetty-dev


_______________________________________________
jetty-dev mailing list
jetty-dev@xxxxxxxxxxx
To change your delivery options, retrieve your password, or unsubscribe from this list, visit
https://dev.eclipse.org/mailman/listinfo/jetty-dev



--

_______________________________________________
jetty-dev mailing list
jetty-dev@xxxxxxxxxxx
To change your delivery options, retrieve your password, or unsubscribe from this list, visit
https://dev.eclipse.org/mailman/listinfo/jetty-dev


Back to the top