Skip to content

Commit 89c78a8

Browse files
committed
[bugfix] Log a warning for Java Classes that cannot be loaded as part of an EXPath Package
See #4901
1 parent 45790db commit 89c78a8

File tree

1 file changed

+9
-4
lines changed

1 file changed

+9
-4
lines changed

exist-core/src/main/java/org/exist/repo/ClasspathHelper.java

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@
3939
import java.net.URI;
4040
import java.nio.file.Files;
4141
import java.nio.file.Path;
42+
import java.nio.file.Paths;
4243
import java.util.Collection;
4344
import java.util.Optional;
4445
import java.util.Set;
@@ -74,7 +75,7 @@ public static void updateClasspath(BrokerPool pool, org.expath.pkg.repo.Package
7475
final Path packageDir = resolver.resolveResourceAsFile(".");
7576
final Classpath cp = new Classpath();
7677
try {
77-
scanPackageDir(cp, packageDir);
78+
scanPackageDir(pkg, cp, packageDir);
7879
((EXistClassLoader)loader).addURLs(cp);
7980
} catch (final IOException e) {
8081
LOG.warn("An error occurred while updating classpath for package {}", pkg.getName(), e);
@@ -93,7 +94,7 @@ private static void scanPackages(BrokerPool pool, Classpath classpath) {
9394
try {
9495
final FileSystemStorage.FileSystemResolver resolver = (FileSystemStorage.FileSystemResolver) pkg.getResolver();
9596
final Path packageDir = resolver.resolveResourceAsFile(".");
96-
scanPackageDir(classpath, packageDir);
97+
scanPackageDir(pkg, classpath, packageDir);
9798
} catch (final IOException e) {
9899
LOG.warn("An error occurred while updating classpath for package {}", pkg.getName(), e);
99100
}
@@ -157,7 +158,7 @@ private static boolean isCompatible(final Package pkg) throws PackageException {
157158
}
158159
}
159160

160-
private static void scanPackageDir(Classpath classpath, Path module) throws IOException {
161+
private static void scanPackageDir(Package pkg, Classpath classpath, Path module) throws IOException {
161162
final Path dotExist = module.resolve(".exist");
162163
if (Files.exists(dotExist)) {
163164
if (!Files.isDirectory(dotExist)) {
@@ -169,7 +170,11 @@ private static void scanPackageDir(Classpath classpath, Path module) throws IOEx
169170
try (final BufferedReader reader = Files.newBufferedReader(cp)) {
170171
String line;
171172
while ((line = reader.readLine()) != null) {
172-
classpath.addComponent(line);
173+
if (!Files.exists(Paths.get(line))) {
174+
LOG.warn("Unable to add '" + line + "' to the classpath for EXPath package: " + pkg.getName() + ", as the file does not exist!");
175+
} else {
176+
classpath.addComponent(line);
177+
}
173178
}
174179
}
175180
}

0 commit comments

Comments
 (0)