adds lookup-name to web.xml resource reference and removes custom JNDI context parameter

Sat, 16 May 2020 11:37:57 +0200

author
Mike Becker <universe@uap-core.de>
date
Sat, 16 May 2020 11:37:57 +0200
changeset 50
2a90d105edec
parent 49
d9c24f0ab8f7
child 51
dd0a45ae25d7

adds lookup-name to web.xml resource reference and removes custom JNDI context parameter

also removes jstl-impl from compile time dependencies - tomcat users must provide the library manually

pom.xml file | annotate | diff | comparison | revisions
src/main/java/de/uapcore/lightpit/Constants.java file | annotate | diff | comparison | revisions
src/main/java/de/uapcore/lightpit/DatabaseFacade.java file | annotate | diff | comparison | revisions
src/main/webapp/WEB-INF/web.xml file | annotate | diff | comparison | revisions
--- a/pom.xml	Sat May 16 09:28:57 2020 +0200
+++ b/pom.xml	Sat May 16 11:37:57 2020 +0200
@@ -33,13 +33,14 @@
         </dependency>
         <dependency>
             <groupId>javax.servlet</groupId>
-            <artifactId>jstl</artifactId>
-            <version>1.2</version>
+            <artifactId>javax.servlet-api</artifactId>
+            <version>3.1.0</version>
+            <scope>provided</scope>
         </dependency>
         <dependency>
             <groupId>javax.servlet</groupId>
-            <artifactId>javax.servlet-api</artifactId>
-            <version>3.1.0</version>
+            <artifactId>jstl</artifactId>
+            <version>1.2</version>
             <scope>provided</scope>
         </dependency>
     </dependencies>
--- a/src/main/java/de/uapcore/lightpit/Constants.java	Sat May 16 09:28:57 2020 +0200
+++ b/src/main/java/de/uapcore/lightpit/Constants.java	Sat May 16 11:37:57 2020 +0200
@@ -48,11 +48,6 @@
     public static final String CTX_ATTR_LANGUAGES = "available-languages";
 
     /**
-     * Name for the context parameter optionally specifying the JNDI context;
-     */
-    public static final String CTX_ATTR_JNDI_CONTEXT = "jndi-context";
-
-    /**
      * Name for the context parameter optionally specifying a database schema.
      */
     public static final String CTX_ATTR_DB_SCHEMA = "db-schema";
--- a/src/main/java/de/uapcore/lightpit/DatabaseFacade.java	Sat May 16 09:28:57 2020 +0200
+++ b/src/main/java/de/uapcore/lightpit/DatabaseFacade.java	Sat May 16 11:37:57 2020 +0200
@@ -139,9 +139,6 @@
 
         dataSource = null;
 
-        final String contextName = Optional
-                .ofNullable(sc.getInitParameter(Constants.CTX_ATTR_JNDI_CONTEXT))
-                .orElse("java:comp/env");
         final String dbSchema = Optional
                 .ofNullable(sc.getInitParameter(Constants.CTX_ATTR_DB_SCHEMA))
                 .orElse(DB_DEFAULT_SCHEMA);
@@ -155,9 +152,9 @@
         }
 
         try {
-            LOG.debug("Trying to access JNDI context {}...", contextName);
+            LOG.debug("Trying to access JNDI context ...");
             Context initialCtx = new InitialContext();
-            Context ctx = (Context) initialCtx.lookup(contextName);
+            Context ctx = (Context) initialCtx.lookup("java:comp/env");
 
             dataSource = retrieveDataSource(ctx);
 
--- a/src/main/webapp/WEB-INF/web.xml	Sat May 16 09:28:57 2020 +0200
+++ b/src/main/webapp/WEB-INF/web.xml	Sat May 16 11:37:57 2020 +0200
@@ -14,6 +14,7 @@
         <res-ref-name>jdbc/lightpit/app</res-ref-name>
         <res-type>javax.sql.DataSource</res-type>
         <res-auth>Container</res-auth>
+        <lookup-name>java:/jdbc/lightpit/app</lookup-name>
     </resource-ref>
     <error-page>
         <error-code>404</error-code>

mercurial