Return-Path: X-Original-To: archive-asf-public-internal@cust-asf2.ponee.io Delivered-To: archive-asf-public-internal@cust-asf2.ponee.io Received: from cust-asf.ponee.io (cust-asf.ponee.io [163.172.22.183]) by cust-asf2.ponee.io (Postfix) with ESMTP id EABAB200D33 for ; Wed, 8 Nov 2017 07:53:32 +0100 (CET) Received: by cust-asf.ponee.io (Postfix) id E91E7160BE0; Wed, 8 Nov 2017 06:53:32 +0000 (UTC) Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by cust-asf.ponee.io (Postfix) with SMTP id DF485160BDA for ; Wed, 8 Nov 2017 07:53:31 +0100 (CET) Received: (qmail 43702 invoked by uid 500); 8 Nov 2017 06:53:30 -0000 Mailing-List: contact users-help@tomcat.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: "Tomcat Users List" Delivered-To: mailing list users@tomcat.apache.org Received: (qmail 43690 invoked by uid 99); 8 Nov 2017 06:53:30 -0000 Received: from pnap-us-west-generic-nat.apache.org (HELO spamd3-us-west.apache.org) (209.188.14.142) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 08 Nov 2017 06:53:30 +0000 Received: from localhost (localhost [127.0.0.1]) by spamd3-us-west.apache.org (ASF Mail Server at spamd3-us-west.apache.org) with ESMTP id 4906B180740 for ; Wed, 8 Nov 2017 06:53:29 +0000 (UTC) X-Virus-Scanned: Debian amavisd-new at spamd3-us-west.apache.org X-Spam-Flag: NO X-Spam-Score: -0.151 X-Spam-Level: X-Spam-Status: No, score=-0.151 tagged_above=-999 required=6.31 tests=[DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, FREEMAIL_ENVFROM_END_DIGIT=0.25, HTML_MESSAGE=2, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-2.8, RCVD_IN_SORBS_SPAM=0.5, SPF_PASS=-0.001] autolearn=disabled Authentication-Results: spamd3-us-west.apache.org (amavisd-new); dkim=pass (2048-bit key) header.d=gmail.com Received: from mx1-lw-us.apache.org ([10.40.0.8]) by localhost (spamd3-us-west.apache.org [10.40.0.10]) (amavisd-new, port 10024) with ESMTP id hvwvQ5w_SYDq for ; Wed, 8 Nov 2017 06:53:25 +0000 (UTC) Received: from mail-io0-f182.google.com (mail-io0-f182.google.com [209.85.223.182]) by mx1-lw-us.apache.org (ASF Mail Server at mx1-lw-us.apache.org) with ESMTPS id 585AB5F30B for ; Wed, 8 Nov 2017 06:53:25 +0000 (UTC) Received: by mail-io0-f182.google.com with SMTP id m81so4850545ioi.13 for ; Tue, 07 Nov 2017 22:53:25 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:in-reply-to:references:from:date:message-id:subject:to; bh=/5xaN4WiYOt9kLtbecYQhKCx45q24ige2ZNDffQotRE=; b=Y7x8JhsAAsEg7WBJo7YClg9cCdBgl7NSk6smVxde/FHsvb/mgQDVoja8qea8O2NuYq /mgDWDei1toen02B1DSWr6Z8RMAgJ7gF7N9BxXPqwrUXcO7vIiaJ9EzlNfnTndDzURmH o/3DRbBBOcDBXosG/Vq4/kWNO45eZBjEL0zZA4bOI2M6kglR5dD4BARfYOgaNfhqxc6W PfunPqiPR2GNpVnPlosqSfUg9kb05LqJmwLsA+/UNpPS4MwYMDhdl20bO8EHsAB+xHQt 0REfbuGVDzwTLku+IguRzhXwU6w7jKlnfr3Is2hAL4Jy01y9ZAxdmaWKIGesDy5Wv0xa Ghrg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to; bh=/5xaN4WiYOt9kLtbecYQhKCx45q24ige2ZNDffQotRE=; b=liB/0O2gfxPl0KK19KM3snpeklK3/JmQtC1LHpLlLQ2wDEZF1A5fJU4RrkzH/o+I3T kXAN3H4IlzXECgGYW9kwoXAtJBmnqr2gDKVc+Vww1VDyyJlIMzri6kCCZ8oA6gHzzTd8 qjrPoM78KbkPUEDl8l3tO5e2AmzgIkcYajSKuzg4aR884lekiqoHW/aAZRIv/dSN9/oQ GpV96RUOYBqNdGbChz82ssT5H04m3IU5ou5j8O1q0ZYqVibWwQDEc2TUeBKheMlONpgM dDDS3iBcqxk1SEpyVXO9GMErz9bt2VLg0T+REH6/IemOCZMKwwjX2ppto3sbrceQ/dhY S0+g== X-Gm-Message-State: AJaThX68Qku9LoVObSxq91WMcpGGCT2332H74aDAARCdw/rRR0BDr46D lUpEH0At7qQWOKO+t7XAe0uQrNi5e8NThEZ7jfLGRA== X-Google-Smtp-Source: ABhQp+QAM+6vt2YHj6qkik90BRtWCD8XTl2pRE0+fs45POiNHcxFGTiPOz0zRDM5yaDQzK0WGnUOyFJgWsasAx+TfgM= X-Received: by 10.107.46.32 with SMTP id i32mr1594470ioo.8.1510123999009; Tue, 07 Nov 2017 22:53:19 -0800 (PST) MIME-Version: 1.0 Received: by 10.2.183.147 with HTTP; Tue, 7 Nov 2017 22:53:18 -0800 (PST) In-Reply-To: References: <70fa6fae-f7a9-9084-d105-a04a8a259430@apache.org> From: Maxim Solodovnik Date: Wed, 8 Nov 2017 13:53:18 +0700 Message-ID: Subject: Re: Start embedded Tomcat 9.0.1 server from java code To: Tomcat Users List Content-Type: multipart/alternative; boundary="001a1136f3d6871f71055d732438" archived-at: Wed, 08 Nov 2017 06:53:33 -0000 --001a1136f3d6871f71055d732438 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Thanks for the clarifications! I'll update my code On Wed, Nov 8, 2017 at 1:49 PM, R=C3=A9my Maucherat wrote= : > On Wed, Nov 8, 2017 at 5:30 AM, Maxim Solodovnik > wrote: > > > OK :) > > I finally found the difference :))) > > > > Tomcat.java 8.5.23: > > public void start() throws LifecycleException { > > getServer(); > > getConnector(); > > server.start(); > > } > > > > Tomcat.java 9.0.1: > > public void start() throws LifecycleException { > > getServer(); > > server.start(); > > } > > > > This is why Tomcat 9.0.2 has no connectors .... > > Is it bug or feature? > > > > The automatic connector creation, among other tings, was conflicting with > other more sophisticated uses so it was refactored. It was not possible t= o > start Tomcat without a connector so that capability was added in Tomcat 9= . > If you want to get a default connector, you have to call getConnector > yourself. > BZ60297, BZ60368, then a Tomcat 9 specific change. > > R=C3=A9my > > > > > > > On Wed, Nov 8, 2017 at 12:07 AM, Tobias Soloschenko < > > tobiassoloschenko@googlemail.com> wrote: > > > > > Hi Maxim, > > > > > > same for me I just created a simple setup like this: > > > > > > String baseDir =3D"."; > > > String webappDirLocation =3D "src/main/webapp/"; > > > String webxmlDirLocation =3D "src/main/webapp/WEB-INF/web.xml= "; > > > Tomcat tomcat =3D new Tomcat(); > > > tomcat.setPort(8080); > > > tomcat.setBaseDir(baseDir); > > > tomcat.getHost().setAppBase(baseDir); > > > tomcat.getHost().setDeployOnStartup(true); > > > tomcat.getHost().setAutoDeploy(true); > > > tomcat.enableNaming(); > > > StandardContext ctx =3D (StandardContext) > > > tomcat.addWebapp("/project", new File(webappDirLocation). > > > getAbsolutePath()); > > > File additionWebInfClasses =3D new File("target/classes"); > > > WebResourceRoot resources =3D new StandardRoot(ctx); > > > resources.addPreResources(new DirResourceSet(resources, > > > "/WEB-INF/classes", > > > additionWebInfClasses.getAbsolutePath(), "/")); > > > ctx.setResources(resources); > > > ctx.setDefaultWebXml(new File(webxmlDirLocation). > > > getAbsolutePath()); > > > tomcat.start(); > > > tomcat.getServer().await(); > > > > > > I just placed in a Servlet into my classpath and applied the mapping = in > > > the web.xml - with the dependencies of tomcat-embed-core and > > > tomcat-embed-jasper of version 9.0.1 it is not working and with 8.5.2= 3 > it > > > does. > > > > > > Here is the log of both. > > > > > > 8.5.23 > > > > > > Nov. 07, 2017 6:02:44 NACHM. org.apache.coyote.AbstractProtocol init > > > INFORMATION: Initializing ProtocolHandler ["http-nio-8080"] > > > Nov. 07, 2017 6:02:44 NACHM. org.apache.tomcat.util.net. > NioSelectorPool > > > getSharedSelector > > > INFORMATION: Using a shared selector for servlet write/read > > > Nov. 07, 2017 6:02:44 NACHM. org.apache.catalina.core.StandardService > > > startInternal > > > INFORMATION: Starting service [Tomcat] > > > Nov. 07, 2017 6:02:44 NACHM. org.apache.catalina.core.StandardEngine > > > startInternal > > > INFORMATION: Starting Servlet Engine: Apache Tomcat/8.5.23 > > > Nov. 07, 2017 6:02:44 NACHM. org.apache.catalina.startup.ContextConfi= g > > > getDefaultWebXmlFragment > > > INFORMATION: No global web.xml found > > > Nov. 07, 2017 6:02:45 NACHM. org.apache.coyote.AbstractProtocol start > > > INFORMATION: Starting ProtocolHandler ["http-nio-8080=E2=80=9C] > > > > > > 9.0.1 > > > > > > Nov. 07, 2017 6:06:56 NACHM. org.apache.catalina.core.StandardService > > > startInternal > > > INFORMATION: Starting service [Tomcat] > > > Nov. 07, 2017 6:06:56 NACHM. org.apache.catalina.core.StandardEngine > > > startInternal > > > INFORMATION: Starting Servlet Engine: Apache Tomcat/9.0.1 > > > Nov. 07, 2017 6:06:56 NACHM. org.apache.catalina.startup.ContextConfi= g > > > getDefaultWebXmlFragment > > > INFORMATION: No global web.xml found > > > > > > kind regards > > > > > > Tobias > > > > > > > Am 07.11.2017 um 15:56 schrieb Maxim Solodovnik < > solomax666@gmail.com > > >: > > > > > > > > Thanks for the hints :) > > > > > > > > I have created sample project: https://github.com/solomax/ > > > tomcat-from-java > > > > > > > > I have compared detailed logs. > > > > > > > > Following lines appears in logs while Tomcat8 is used > > > > Nov 07, 2017 9:1 PM org.apache.catalina.util.LifecycleBase > > > > setStateInternal > > > > FINE: Setting state for [Connector[HTTP/1.1-8080]] to > > > > [INITIALIZING] > > > > Nov 07, 2017 9:1 PM org.apache.tomcat.util.modeler.Registry > > > > registerComponent > > > > FINE: Managed=3D Tomcat:type=3DConnector,port=3D8080 > > > > > > > > These lines are missing while Tomcat9 is used > > > > > > > > Maybe you can tell me why? > > > > > > > > On Mon, Nov 6, 2017 at 7:55 PM, Mark Thomas > wrote: > > > > > > > >> On 04/11/17 15:25, Maxim Solodovnik wrote: > > > >>> Maybe I can set breakpoint somewhere? and check what is wrong? > > > >>> Could you point me to the correct class? > > > >> > > > >> No idea where to look at this point. I'd probably start with the > > start() > > > >> method and go from there. > > > >> > > > >> Maybe try turning on debug logging? > > > >> > > > >> Mark > > > >> > > > >> > > > >>> > > > >>> On Fri, Nov 3, 2017 at 5:26 PM, Maxim Solodovnik < > > solomax666@gmail.com > > > > > > > >>> wrote: > > > >>> > > > >>>> I'm OK to add missing code to my tests, > > > >>>> but I'm not sure what need to be added :( > > > >>>> > > > >>>> On Fri, Nov 3, 2017 at 3:24 PM, Maxim Solodovnik < > > > solomax666@gmail.com> > > > >>>> wrote: > > > >>>> > > > >>>>> I see no errors, > > > >>>>> Using debugger I can see tomcat.server.state =3D=3D STARTED > > > >>>>> > > > >>>>> Everything works as expected if I'm switching back to 8.5.23 > > without > > > >> any > > > >>>>> other changes > > > >>>>> > > > >>>>> nestat reports: > > > >>>>> *netstat -an |grep 8080* > > > >>>>> tcp6 0 0 :::8080 :::* > > > >>>>> LISTEN > > > >>>>> > > > >>>>> for 8.5.23 > > > >>>>> > > > >>>>> > > > >>>>> On Fri, Nov 3, 2017 at 3:08 PM, Mark Thomas > > > wrote: > > > >>>>> > > > >>>>>> On 03/11/17 04:51, Maxim Solodovnik wrote: > > > >>>>>>> Hello, > > > >>>>>>> > > > >>>>>>> I recently migrated from Tomcat 8.5.23 to Tomcat 9.0.1 > > > >>>>>>> Everything works as expected except tests :( > > > >>>>>>> > > > >>>>>>> I'm using following code to start embedded Tomcat and test CX= F > > web > > > >>>>>> services [1]. > > > >>>>>>> With Tomcat 9.0.1 tests failed, netstat -an displays port 808= 0 > is > > > not > > > >>>>>>> being listened > > > >>>>>>> What need to be changed? > > > >>>>>> > > > >>>>>> If Tomcat isn't listening then there should be an exception or > > error > > > >>>>>> message reported at some point. Do you see anything in the log= s? > > > >>>>>> > > > >>>>>> Mark > > > >>>>>> > > > >>>>>> > > > >>>>>>> > > > >>>>>>> > > > >>>>>>> [1] https://github.com/apache/openmeetings/blob/master/ > openmeeti > > > >>>>>> ngs-web/src/test/java/org/apache/openmeetings/webservice/ > > > >>>>>> AbstractWebServiceTest.java#L98 > > > >>>>>>> > > > >>>>>> > > > >>>>>> > > > >>>>>> ------------------------------------------------------------ > > > --------- > > > >>>>>> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org > > > >>>>>> For additional commands, e-mail: users-help@tomcat.apache.org > > > >>>>>> > > > >>>>>> > > > >>>>> > > > >>>>> > > > >>>>> -- > > > >>>>> WBR > > > >>>>> Maxim aka solomax > > > >>>>> > > > >>>> > > > >>>> > > > >>>> > > > >>>> -- > > > >>>> WBR > > > >>>> Maxim aka solomax > > > >>>> > > > >>> > > > >>> > > > >>> > > > >> > > > >> > > > >> ------------------------------------------------------------ > --------- > > > >> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org > > > >> For additional commands, e-mail: users-help@tomcat.apache.org > > > >> > > > >> > > > > > > > > > > > > -- > > > > WBR > > > > Maxim aka solomax > > > > > > > > > --------------------------------------------------------------------- > > > To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org > > > For additional commands, e-mail: users-help@tomcat.apache.org > > > > > > > > > > > > -- > > WBR > > Maxim aka solomax > > > --=20 WBR Maxim aka solomax --001a1136f3d6871f71055d732438--