[Geoserver-users] Setting up a JNDI DB resource in Jetty for Geoserver?

Hello All,

Can anyone point me to an example of how to setup a JNDI DB resource in Jetty, so that it is available from within GeoServer?
Which jetty config xml file (or the geoserver web.xml?) should the JNDI resource be added to?
Are there any examples for PostGIS, Oracle and/or SQL Server JNDI connections that you could also point me to?

I’ve scanned the docs and looked online for examples… and most are either not Jetty specific, or don’t really explain where (which file) the content should be put into…

thanks in advance,
John

Hi John,
have you already checked out this page in the GeoServer manual?
http://docs.geoserver.org/latest/en/developer/eclipse-guide/#configuring-jndi-resources-in-jetty

It’s about running Jetty under Eclipse, but probably similar steps apply to standalone Jetty (I have not tried though).

Hope this helps.

···

On Thu, May 12, 2016 at 8:08 PM, John McCarty <johmcc1138@anonymised.com> wrote:

Hello All,

Can anyone point me to an example of how to setup a JNDI DB resource in Jetty, so that it is available from within GeoServer?
Which jetty config xml file (or the geoserver web.xml?) should the JNDI resource be added to?
Are there any examples for PostGIS, Oracle and/or SQL Server JNDI connections that you could also point me to?

I’ve scanned the docs and looked online for examples… and most are either not Jetty specific, or don’t really explain where (which file) the content should be put into…

thanks in advance,
John

Mobile security can be enabling, not merely restricting. Employees who
bring their own devices (BYOD) to work are irked by the imposition of MDM
restrictions. Mobile Device Manager Plus allows you to control only the
apps on BYO-devices by containerizing them, leaving personal data untouched!
https://ad.doubleclick.net/ddm/clk/304595813;131938128;j


Geoserver-users mailing list
Geoserver-users@anonymised.comsts.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/geoserver-users

Best regards,
Stefano Costa

==
GeoServer Professional Services from the experts! Visit
[http://goo.gl/it488V](http://goo.gl/it488V) for more information.
==
Dott. Stefano Costa
Senior Software Engineer

GeoSolutions S.A.S.
Via di Montramito 3/A
55054  Massarosa (LU)
Italy
phone: +39 0584 962313
fax:     +39 0584 1660272

[http://www.geo-solutions.it](http://www.geo-solutions.it)
[http://twitter.com/geosolutions_it](http://twitter.com/geosolutions_it)

-------------------------------------------------------
AVVERTENZE AI SENSI DEL D.Lgs. 196/2003
Le informazioni contenute in questo messaggio di posta elettronica e/o
nel/i file/s allegato/i sono da considerarsi strettamente riservate.
Il loro utilizzo è consentito esclusivamente al destinatario del
messaggio, per le finalità indicate nel messaggio stesso. Qualora
riceviate questo messaggio senza esserne il destinatario, Vi preghiamo
cortesemente di darcene notizia via e-mail e di procedere alla
distruzione del messaggio stesso, cancellandolo dal Vostro sistema.
Conservare il messaggio stesso, divulgarlo anche in parte,
distribuirlo ad altri soggetti, copiarlo, od utilizzarlo per finalità
diverse, costituisce comportamento contrario ai principi dettati dal
D.Lgs. 196/2003.

The information in this message and/or attachments, is intended solely
for the attention and use of the named addressee(s) and may be
confidential or proprietary in nature or covered by the provisions of
privacy act (Legislative Decree June, 30 2003, no.196 - Italy's New
Data Protection Code).Any use not in accord with its purpose, any
disclosure, reproduction, copying, distribution, or either
dissemination, either whole or partial, is strictly forbidden except
previous formal approval of the named addressee(s). If you are not the
intended recipient, please contact immediately the sender by
telephone, fax or e-mail and delete the information in this message
that has been received in error. The sender does not give any warranty
or accept liability as the content, accuracy or completeness of sent
messages and accepts no responsibility  for changes made after they
were sent or for other risks which arise as a result of e-mail
transmission, viruses, etc.

John,

I wrote that section of the guide. It needs to be updated for Jetty 9 as some of the Jetty class names have changed (on my to-do list). I have attached an updated jetty.xml for Jetty 9 and postgres. The Oracle content should still work once the Jetty classes are changed.

I have not tried using JNDI from standalone Jetty, only from Eclipse. I think you should be able to insert the New element from the attached jetty.xml inside the Configure element of your existing etc/jetty.xml (for example from your geoserver-*-bin.zip).

In Eclipse I also set some Java properties. If you need these, add them to your bin/startup.sh or similar. But standalone Jetty might set these itself? Try without them first.

-Djava.naming.factory.url.pkgs=org.eclipse.jetty.jndi
-Djava.naming.factory.initial=org.eclipse.jetty.jndi.InitialContextFactory

You will likely also need to copy/move (not sure) the postgresql jar from webapps/geoserver/WEB-INF/lib to the top-level lib so Jetty can find the driver at startup time. You may also need the commons dbcp jar for the configured connection pool; I do not know for standalone Jetty.

If I recall correctly, Jetty is more permissive than Tomcat and does not require you to declare your JNDI resource in the GeoServer web.xml. It just works.

If you get it working, please report back so we can add JNDI for standalone Jetty to the manual.

Kind regards,
Ben.

On 13/05/16 07:51, Stefano Costa wrote:

Hi John,
have you already checked out this page in the GeoServer manual?
http://docs.geoserver.org/latest/en/developer/eclipse-guide/#configuring-jndi-resources-in-jetty

It's about running Jetty under Eclipse, but probably similar steps apply to
standalone Jetty (I have not tried though).

Hope this helps.

On Thu, May 12, 2016 at 8:08 PM, John McCarty <johmcc1138@anonymised.com> wrote:

Hello All,

Can anyone point me to an example of how to setup a JNDI DB resource in
Jetty, so that it is available from within GeoServer?
Which jetty config xml file (or the geoserver web.xml?) should the JNDI
resource be added to?
Are there any examples for PostGIS, Oracle and/or SQL Server JNDI
connections that you could also point me to?

I’ve scanned the docs and looked online for examples… and most are either
not Jetty specific, or don’t really explain where (which file) the content
should be put into…

thanks in advance,
John

------------------------------------------------------------------------------
Mobile security can be enabling, not merely restricting. Employees who
bring their own devices (BYOD) to work are irked by the imposition of MDM
restrictions. Mobile Device Manager Plus allows you to control only the
apps on BYO-devices by containerizing them, leaving personal data
untouched!
https://ad.doubleclick.net/ddm/clk/304595813;131938128;j
_______________________________________________
Geoserver-users mailing list
Geoserver-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/geoserver-users

------------------------------------------------------------------------------
Mobile security can be enabling, not merely restricting. Employees who
bring their own devices (BYOD) to work are irked by the imposition of MDM
restrictions. Mobile Device Manager Plus allows you to control only the
apps on BYO-devices by containerizing them, leaving personal data untouched!
https://ad.doubleclick.net/ddm/clk/304595813;131938128;j

_______________________________________________
Geoserver-users mailing list
Geoserver-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/geoserver-users

--
Ben Caradoc-Davies <ben@anonymised.com>
Director
Transient Software Limited <http://transient.nz/&gt;
New Zealand

jetty.xml (1.29 KB)

John, please keep discussions on list.

Yes, you are correct: 2.8.x is bundled with Jetty 6. 2.9.x and master use Jetty 9. To use Jetty 6, the same instructions apply, just use the old names from the guide. The Jetty renaming occurred in Jetty 7:
https://wiki.eclipse.org/Jetty/Starting/Porting_to_Jetty_7#Renaming_of_Packages_and_Classes

Jetty 9:

<Configure class="org.eclipse.jetty.server.Server">
     <New class="org.eclipse.jetty.plus.jndi.Resource">

Jetty 6:

<Configure class="org.mortbay.jetty.Server">
     <New class="org.mortbay.jetty.plus.naming.Resource">

Tomcat is widely used. Jetty is lightweight and has quick startup. Whichever you prefer.

I do not know about SQL server. Perhaps a new thread to draw attention?

Kind regards,
Ben.

On 13/05/16 10:05, John McCarty wrote:

Thanks Ben!

It looks like this is using Jetty6 tho… I’m using Geoserver 2.8.2, from the Windows installer.
Can you confirm if that is Jetty6 or 9? Or how would/could I swap out v6 for v9?

Maybe I should just install Tomcat7 and run it all thru that? Maybe it would be easier to setup the JNDI there too?

Also, the main thing I’m trying for here is to see if I can get a connection to a SQL Server 2012 DB…. which I’m not sure is possible yet anyway… the Goeserver extension for SQL Server says it only supports up to 2008.

thanks,
John

On May 12, 2016, at 3:38 PM, Ben Caradoc-Davies <ben@anonymised.com> wrote:

John,

I wrote that section of the guide. It needs to be updated for Jetty 9 as some of the Jetty class names have changed (on my to-do list). I have attached an updated jetty.xml for Jetty 9 and postgres. The Oracle content should still work once the Jetty classes are changed.

I have not tried using JNDI from standalone Jetty, only from Eclipse. I think you should be able to insert the New element from the attached jetty.xml inside the Configure element of your existing etc/jetty.xml (for example from your geoserver-*-bin.zip).

In Eclipse I also set some Java properties. If you need these, add them to your bin/startup.sh or similar. But standalone Jetty might set these itself? Try without them first.

-Djava.naming.factory.url.pkgs=org.eclipse.jetty.jndi
-Djava.naming.factory.initial=org.eclipse.jetty.jndi.InitialContextFactory

You will likely also need to copy/move (not sure) the postgresql jar from webapps/geoserver/WEB-INF/lib to the top-level lib so Jetty can find the driver at startup time. You may also need the commons dbcp jar for the configured connection pool; I do not know for standalone Jetty.

If I recall correctly, Jetty is more permissive than Tomcat and does not require you to declare your JNDI resource in the GeoServer web.xml. It just works.

If you get it working, please report back so we can add JNDI for standalone Jetty to the manual.

Kind regards,
Ben.

On 13/05/16 07:51, Stefano Costa wrote:

Hi John,
have you already checked out this page in the GeoServer manual?
http://docs.geoserver.org/latest/en/developer/eclipse-guide/#configuring-jndi-resources-in-jetty

It's about running Jetty under Eclipse, but probably similar steps apply to
standalone Jetty (I have not tried though).

Hope this helps.

On Thu, May 12, 2016 at 8:08 PM, John McCarty <johmcc1138@anonymised.com> wrote:

Hello All,

Can anyone point me to an example of how to setup a JNDI DB resource in
Jetty, so that it is available from within GeoServer?
Which jetty config xml file (or the geoserver web.xml?) should the JNDI
resource be added to?
Are there any examples for PostGIS, Oracle and/or SQL Server JNDI
connections that you could also point me to?

I’ve scanned the docs and looked online for examples… and most are either
not Jetty specific, or don’t really explain where (which file) the content
should be put into…

thanks in advance,
John

------------------------------------------------------------------------------
Mobile security can be enabling, not merely restricting. Employees who
bring their own devices (BYOD) to work are irked by the imposition of MDM
restrictions. Mobile Device Manager Plus allows you to control only the
apps on BYO-devices by containerizing them, leaving personal data
untouched!
https://ad.doubleclick.net/ddm/clk/304595813;131938128;j
_______________________________________________
Geoserver-users mailing list
Geoserver-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/geoserver-users

------------------------------------------------------------------------------
Mobile security can be enabling, not merely restricting. Employees who
bring their own devices (BYOD) to work are irked by the imposition of MDM
restrictions. Mobile Device Manager Plus allows you to control only the
apps on BYO-devices by containerizing them, leaving personal data untouched!
https://ad.doubleclick.net/ddm/clk/304595813;131938128;j

_______________________________________________
Geoserver-users mailing list
Geoserver-users@lists.sourceforge.net <mailto:Geoserver-users@lists.sourceforge.net>
https://lists.sourceforge.net/lists/listinfo/geoserver-users

--
Ben Caradoc-Davies <ben@anonymised.com <mailto:ben@anonymised.com>>
Director
Transient Software Limited <http://transient.nz/&gt;
New Zealand
<jetty.xml>

--
Ben Caradoc-Davies <ben@anonymised.com>
Director
Transient Software Limited <http://transient.nz/&gt;
New Zealand