Skip to content

Commit

Permalink
[DROOLS-7484] ClassNotFoundException occurs when launching business-a… (
Browse files Browse the repository at this point in the history
#5347) (#5367)

* [DROOLS-7484] ClassNotFoundException occurs when launching business-application by mvn spring-boot:run

* - add null check
  • Loading branch information
tkobayas committed Jul 6, 2023
1 parent a6982e5 commit 630de7e
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,11 @@ private Class<?> getClass(String name) throws ClassNotFoundException {

private byte[] loadClassData(String name) throws IOException {
for (URL url : urls) {
URL tryUrl = new URL(url.toString() + "!/" + name);
if (url == null) {
continue;
}
String prefix = "file".equals(url.getProtocol()) ? "jar:" : "";
URL tryUrl = new URL(prefix + url.toString() + "!/" + name);
try (InputStream stream = tryUrl.openStream()) {
if (stream == null) {
continue;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -375,4 +375,11 @@ public void testKieMavenPluginEmptyProject() {
}
}

@Test
public void loadClassInJarKieModuleMetaData() {
ReleaseId releaseId = KieServices.Factory.get().newReleaseId("org.drools", "knowledge-api", "5.5.0.Final");
KieModuleMetaData kieModuleMetaData = KieModuleMetaData.Factory.newInJarKieModuleMetaData(releaseId, DependencyFilter.COMPILE_FILTER);
Class<?> sessionClockClass = kieModuleMetaData.getClass("org.drools.time", "SessionClock");
assertThat(sessionClockClass).isNotNull();
}
}

0 comments on commit 630de7e

Please sign in to comment.