Created
June 29, 2017 22:35
-
-
Save BillBarnhill/2a67c22501e5ed4c8ad69a39c94769fc to your computer and use it in GitHub Desktop.
If you get AbstractMethodError when creating a JMS Session, then this might help (very rough code though)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // Call this, or put in a method and call, where exception is being thrown | |
| URL[] urls = ((URLClassLoader) (Thread.currentThread().getContextClassLoader())).getURLs(); | |
| StringBuilder sz = new StringBuilder("Classpath jars ["); | |
| sz.append(Integer.toString(urls.length)); | |
| sz.append("]...\n"); | |
| String searchFor = "jms/Session"; | |
| Map<File, String> matches = new HashMap<>(); | |
| for (URL url : urls) { | |
| File file = new File(url.getFile()); | |
| sz.append(" ").append(file.getAbsolutePath()); | |
| try { | |
| if (!file.isDirectory()) { | |
| JarFile jar = new JarFile(file); | |
| Enumeration<JarEntry> entries = jar.entries(); | |
| while (entries.hasMoreElements()) { | |
| JarEntry entry = entries.nextElement(); | |
| String name = entry.getName(); | |
| if (name.contains(searchFor)) { | |
| matches.put(file, name); | |
| } | |
| } | |
| jar.close(); | |
| } | |
| } catch (IOException e) { | |
| // TODO Auto-generated catch block | |
| e.printStackTrace(); | |
| } | |
| sz.append("\n"); | |
| } | |
| sz.append("\n"); | |
| sz.append("Found following matches for ").append(searchFor).append("...\n"); | |
| matches.forEach((k,v) -> { | |
| sz.append(" ").append(k.getName()).append(" contains ").append(v).append("\n"); | |
| }); | |
| sz.append("\n"); | |
| log.info(sz.toString()); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment