Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJan Bartel2014-10-01 03:29:23 +0000
committerJan Bartel2014-10-01 03:29:23 +0000
commitbc265953a5c4eed7f14f8d90b374449a4119acbd (patch)
treedb29d882c11460d20bd2e38ac37364f1d76bcd33 /jetty-plus
parent149ee0104705200eaa3a2bfe240c8dabbe921788 (diff)
downloadorg.eclipse.jetty.project-bc265953a5c4eed7f14f8d90b374449a4119acbd.tar.gz
org.eclipse.jetty.project-bc265953a5c4eed7f14f8d90b374449a4119acbd.tar.xz
org.eclipse.jetty.project-bc265953a5c4eed7f14f8d90b374449a4119acbd.zip
445495 Improve Exception message when no jndi resource to bind for a name in web.xml
Diffstat (limited to 'jetty-plus')
-rw-r--r--jetty-plus/src/main/java/org/eclipse/jetty/plus/webapp/PlusDescriptorProcessor.java2
-rw-r--r--jetty-plus/src/test/java/org/eclipse/jetty/plus/webapp/PlusDescriptorProcessorTest.java31
-rw-r--r--jetty-plus/src/test/resources/web-fragment-4.xml16
3 files changed, 48 insertions, 1 deletions
diff --git a/jetty-plus/src/main/java/org/eclipse/jetty/plus/webapp/PlusDescriptorProcessor.java b/jetty-plus/src/main/java/org/eclipse/jetty/plus/webapp/PlusDescriptorProcessor.java
index 09bb4ccdbd..ca3f027bde 100644
--- a/jetty-plus/src/main/java/org/eclipse/jetty/plus/webapp/PlusDescriptorProcessor.java
+++ b/jetty-plus/src/main/java/org/eclipse/jetty/plus/webapp/PlusDescriptorProcessor.java
@@ -892,7 +892,7 @@ public class PlusDescriptorProcessor extends IterativeDescriptorProcessor
if (defaultNE!=null)
defaultNE.bindToENC(name);
else
- throw new IllegalStateException("Nothing to bind for name "+nameInEnvironment);
+ throw new IllegalStateException("Nothing to bind for name " + name);
}
diff --git a/jetty-plus/src/test/java/org/eclipse/jetty/plus/webapp/PlusDescriptorProcessorTest.java b/jetty-plus/src/test/java/org/eclipse/jetty/plus/webapp/PlusDescriptorProcessorTest.java
index c6ff2f7b3a..8199afd19d 100644
--- a/jetty-plus/src/test/java/org/eclipse/jetty/plus/webapp/PlusDescriptorProcessorTest.java
+++ b/jetty-plus/src/test/java/org/eclipse/jetty/plus/webapp/PlusDescriptorProcessorTest.java
@@ -19,6 +19,7 @@
package org.eclipse.jetty.plus.webapp;
+import java.lang.reflect.InvocationTargetException;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;
@@ -50,6 +51,7 @@ public class PlusDescriptorProcessorTest
protected FragmentDescriptor fragDescriptor1;
protected FragmentDescriptor fragDescriptor2;
protected FragmentDescriptor fragDescriptor3;
+ protected FragmentDescriptor fragDescriptor4;
protected WebAppContext context;
/**
* @throws java.lang.Exception
@@ -81,6 +83,9 @@ public class PlusDescriptorProcessorTest
URL frag3Xml = Thread.currentThread().getContextClassLoader().getResource("web-fragment-3.xml");
fragDescriptor3 = new FragmentDescriptor(org.eclipse.jetty.util.resource.Resource.newResource(frag3Xml));
fragDescriptor3.parse();
+ URL frag4Xml = Thread.currentThread().getContextClassLoader().getResource("web-fragment-4.xml");
+ fragDescriptor4 = new FragmentDescriptor(org.eclipse.jetty.util.resource.Resource.newResource(frag4Xml));
+ fragDescriptor4.parse();
}
@After
@@ -95,6 +100,32 @@ public class PlusDescriptorProcessorTest
}
@Test
+ public void testMissingResourceDeclaration()
+ throws Exception
+ {
+ ClassLoader oldLoader = Thread.currentThread().getContextClassLoader();
+ Thread.currentThread().setContextClassLoader(context.getClassLoader());
+
+ try
+ {
+ PlusDescriptorProcessor pdp = new PlusDescriptorProcessor();
+ pdp.process(context, fragDescriptor4);
+ fail("Expected missing resource declaration");
+ }
+ catch (InvocationTargetException ex)
+ {
+ Throwable cause = ex.getCause();
+ assertNotNull(cause);
+ assertNotNull(cause.getMessage());
+ assertTrue(cause.getMessage().contains("jdbc/mymissingdatasource"));
+ }
+ finally
+ {
+ Thread.currentThread().setContextClassLoader(oldLoader);
+ }
+ }
+
+ @Test
public void testWebXmlResourceDeclarations()
throws Exception
{
diff --git a/jetty-plus/src/test/resources/web-fragment-4.xml b/jetty-plus/src/test/resources/web-fragment-4.xml
new file mode 100644
index 0000000000..c2158ea156
--- /dev/null
+++ b/jetty-plus/src/test/resources/web-fragment-4.xml
@@ -0,0 +1,16 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<web-fragment
+ xmlns="http://java.sun.com/xml/ns/javaee"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-fragment_3_0.xsd"
+ version="3.0">
+
+ <name>Fragment 4</name>
+
+ <resource-ref>
+ <res-ref-name>jdbc/mymissingdatasource</res-ref-name>
+ <res-type>javax.sql.DataSource</res-type>
+ <res-auth>Container</res-auth>
+ </resource-ref>
+</web-fragment>

Back to the top