Hi, I don't normally set up JNDI for Jetty, and haven't used Eclipse in years, but... last time I did something similar, I modified Start.java to add a JNDI data source programmatically:
private static void setupJNDI(WebAppContext wah) throws Exception { BasicDataSource bds = new BasicDataSource(); bds.setDriverClassName("org.postgresql.Driver"); bds.setUrl("jdbc:postgresql://localhost:5433/test"); bds.setUsername("test"); bds.setPassword("test"); bds.setDefaultAutoCommit(false); bds.setMaxActive(20); bds.setMaxIdle(10); bds.setMinIdle(10); bds.setMaxWait(60000); new Resource("java:comp/env/jdbc/test", bds); } And you have your WebAppContext in the main method of the Start class. Alternatively, I just setup Tomcat with JNDI, deploy, start in debug mode (catalina.sh jpda run) and then attach from the IDE. Hope this helps Cheers Andrea On Tue, Nov 14, 2023 at 7:35 PM Peter Smythe <g...@smythe.co.za> wrote: > Hi Devs > > Has anyone managed to get GeoServer 2.25.x and Eclipse working with Jetty > JNDI recently? I am following > https://docs.geoserver.org/latest/en/developer/eclipse-guide/index.html#configuring-jndi-resources-in-jetty > <https://fdfdfha.r.af.d.sendibt2.com/tr/cl/tT75zApsyU58KU0o6Szko5ilN6QHTegRDUi6CGielatiH0SCQ3koaHNVv14h0L88VVIP5ccukzOWNDN8HaLOUC4RG_6MGEjCXh292Gpuqcm5IMWyHbdUuWf5ScyDNfY13IIrBa9M-2_rZTKLtmU1oUjgu72mLPMgG991BpfR4sPjM138qnS0DvJCy1vVTZsv9syUJ1pn2oFuFsq6l6lvZxOD9AnYoYj4IbsPjXm-JHKgt51fXHa774WnDAkzFrErqKvSn8OmAmwz6dQ3MsbEAATUaT2dNwBqdmn99MyMDR7L3ws6V2pHsfPwg5AXbQnx1twlfh1LWYQT6A55QTHo9brDQQmMtEeV5qzU7mnYlC_Hng92djkAqeusrpl5jgGC1NTSLF0iLQWGZZcCx3_guytPIu8> > > and my jetty.xml file is set correctly with -Djetty.config.file: > > <?xml version="1.0" encoding="UTF-8"?> >> <!DOCTYPE Configure PUBLIC "-//Jetty//Configure//EN" " >> http://www.eclipse.org/jetty/configure_9_3.dtd >> <https://fdfdfha.r.af.d.sendibt2.com/tr/cl/Glm3u3AtdqRCQw34s77Z8dfCgIzwdv7JU7zfXo_98zWPtk4nha1jqrhXU9Uf6Bu39FLCBWU_NqRkxs45hFUw1PnSXOTKkntcjzqsGRZAsTP0RnTuVjYd4xVF0yDdhGTNUBHFfTY4Gq0F41TOedxwMTX4UGNRWn23nlaVB9Vo-1BygtSLK8rWMdS3N4wKbSkn9lAqqGjU4DIyBRe2m_feJvBqFtf_kLqNke850Iu4fPKOF6FrQu3FhHCZBT_gGFmbZo7jA2zXQgMJsttkQhwotlJ-536BPJTIZS7Ah5b3E4_4JWqT0ZRq3Tn6_W8B19A> >> "> >> <Configure> >> <New id="jndiref" class="org.eclipse.jetty.plus.jndi.Resource"> >> <Arg><Ref refid="Server"/></Arg> >> <Arg>jdbc/jndiref</Arg> >> <Arg> >> <New class="org.postgresql.ds.PGSimpleDataSource"> >> <Set name="User">user</Set> >> <Set name="Password">password</Set> >> <Set name="DatabaseName">database</Set> >> <Set name="ServerName">server</Set> >> <Set name="PortNumber">5432</Set> >> </New> >> </Arg> >> </New> >> </Configure> >> > > Note that I am using org.postgresql.ds.PGSimpleDataSource > > When I debug the Start.java "Loading Jetty config from file" I see that > the 2 deprecated methods setServerName (singular) and setPortNumber > (singular) do not actually set their respective properties, and the object > has properties serverNames (plural) and portNumbers which remain unset (and > thus JNDI does not work). > > It seems like these methods have been replaced by the plural versions > (e.g. setPortNumbers) ref: > > https://jdbc.postgresql.org/documentation/publicapi/org/postgresql/ds/common/BaseDataSource.html#setPortNumber-int- > <https://fdfdfha.r.af.d.sendibt2.com/tr/cl/P3YHSrnjdBLKcmqEbmMVOjgAxchkpE3zPdJ3lw6zQmltIFborgCen8UfU00Z2usnIiwCdlzn0qJ4myBY6hlx39x9lod6U31vUkv1Ff47kzRlmBRjj7lsjfAM1LQxl7w1zY7dklgp3OIp3mTsNx9dK3CCsroIIF0XsVGL3vrXdqt_5QCtTPFysqXorIAyVjmTq5_Xf4fEsIyj7rq92tSQyqxj7Ce1_paJwTMD3HhAOmx-pIEbxwRdPWzTs-tm4GrpSaGYN7JMn3dI2wEIdE_TkqK35bC93U2zqDqtFpSI306I3WNwx9_nMyYcDxJSaaSIyMHPE7fm7YdqaOqNeTTXYDqhW-mqQfodbTgySTy8FdrCZ1Vj4A7IToug4BG8hGdbYbBeHom1eOZBQptN833onsXZlqtP6CsZlNBfmxzVL2s> > > But that (plural) method does not exist and throws a NoSuchMethodException > in org.eclipse.jetty.xml.XmlConfiguration L 629 if I attempt to use > > <Set name="ServerName*s*">server</Set> > <Set name="PortNumber*s*">5432</Set> > (note plurals) instead. > > Can anyone send me updated instructions, please? > > Secondly, the documentation says: > > > Jetty does not mandate a reference-ref in GeoServer WEB-INF/web.xml, so > there is no need to modify that file. > > however, I found that running jetty from maven did require me to add to > the web.xml: > > <resource-ref> >> <res-ref-name>jdbc/jndiref</res-ref-name> >> <res-type>javax.sql.DataSource</res-type> >> <res-auth>Container</res-auth> >> </resource-ref> > > > Can anyone confirm if this is necessary for Eclipse, and which file > exactly must be modified (i.e.where is web.xml)? > > Thanks > > Peter > > Logs: > > Nov 14, 2023 3:31:59 PM org.geoserver.web.Start main > INFO: Loading Jetty config from file: > ../../../../../GEOSERVER_DATA_DIR/jetty.xml > 15:31:59 WARN [xml.XmlConfiguration] - Deprecated method public void > org.postgresql.ds.common.BaseDataSource.setServerName(java.lang.String) in > UNKNOWN-LOCATION > 15:31:59 WARN [xml.XmlConfiguration] - Deprecated method public void > org.postgresql.ds.common.BaseDataSource.setPortNumber(int) in > UNKNOWN-LOCATION > 15:31:59 WARN [xml.XmlConfiguration] - Deprecated method public void > org.postgresql.ds.common.BaseDataSource.setServerName(java.lang.String) in > UNKNOWN-LOCATION > 15:31:59 WARN [xml.XmlConfiguration] - Deprecated method public void > org.postgresql.ds.common.BaseDataSource.setPortNumber(int) in > UNKNOWN-LOCATION > Nov 14, 2023 3:31:59 PM org.geoserver.web.Start main > SEVERE: GeoServer starting > ... > _______________________________________________ > Geoserver-devel mailing list > Geoserver-devel@lists.sourceforge.net > https://lists.sourceforge.net/lists/listinfo/geoserver-devel > -- Regards, Andrea Aime == GeoServer Professional Services from the experts! Visit http://bit.ly/gs-services-us for more information. == Ing. Andrea Aime @geowolf Technical Lead GeoSolutions Group phone: +39 0584 962313 fax: +39 0584 1660272 mob: +39 339 8844549 https://www.geosolutionsgroup.com/ http://twitter.com/geosolutions_it ------------------------------------------------------- Con riferimento alla normativa sul trattamento dei dati personali (Reg. UE 2016/679 - Regolamento generale sulla protezione dei dati “GDPR”), si precisa che ogni circostanza inerente alla presente email (il suo contenuto, gli eventuali allegati, etc.) è un dato la cui conoscenza è riservata al/i solo/i destinatario/i indicati dallo scrivente. Se il messaggio Le è giunto per errore, è tenuta/o a cancellarlo, ogni altra operazione è illecita. Le sarei comunque grato se potesse darmene notizia. This email is intended only for the person or entity to which it is addressed and may contain information that is privileged, confidential or otherwise protected from disclosure. We remind that - as provided by European Regulation 2016/679 “GDPR” - copying, dissemination or use of this e-mail or the information herein by anyone other than the intended recipient is prohibited. If you have received this email by mistake, please notify us immediately by telephone or e-mail
_______________________________________________ Geoserver-devel mailing list Geoserver-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/geoserver-devel