Skip to content

Instantly share code, notes, and snippets.

@mbogoevici
Forked from anonymous/Exception
Created June 24, 2011 01:14
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mbogoevici/1044027 to your computer and use it in GitHub Desktop.
Save mbogoevici/1044027 to your computer and use it in GitHub Desktop.
URL handling
java.lang.IllegalStateException: Illegal class loader binding
org.apache.naming.resources.DirContextURLStreamHandler.get(DirContextURLStreamHandler.java:223)
org.apache.naming.resources.DirContextURLStreamHandler.openConnection(DirContextURLStreamHandler.java:88)
java.net.URL.openConnection(URL.java:945)
test.TestServlet.doGet(TestServlet.java:19)
javax.servlet.http.HttpServlet.service(HttpServlet.java:734)
javax.servlet.http.HttpServlet.service(HttpServlet.java:847)
public class TestServlet extends HttpServlet {
@Override
protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
URL resourceUrl = req.getSession().getServletContext().getResource("/myresources/simple.resource");
URL copyUrl = new URL(resourceUrl.toExternalForm());
copyUrl.openConnection();
System.out.println("it worked");
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment