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 09bb4ccdbd0..ca3f027bdeb 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 c6ff2f7b3ac..8199afd19d3 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 @@ -94,6 +99,32 @@ public class PlusDescriptorProcessorTest Thread.currentThread().setContextClassLoader(oldLoader); } + @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 00000000000..c2158ea156a --- /dev/null +++ b/jetty-plus/src/test/resources/web-fragment-4.xml @@ -0,0 +1,16 @@ + + + + + Fragment 4 + + + jdbc/mymissingdatasource + javax.sql.DataSource + Container + +