Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue 9905 websphere deploy war #9906

Merged
merged 4 commits into from
Sep 25, 2023
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion core/src/main/java/io/micronaut/core/io/IOUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ public class IOUtils {
private static final String SCHEME_FILE = "file";
private static final String SCHEME_JAR = "jar";
private static final String SCHEME_ZIP = "zip";
private static final String SCHEME_WSJAR = "wsjar";

private static final String COLON = ":";

Expand Down Expand Up @@ -125,7 +126,7 @@ static Path resolvePath(@NonNull URI uri,
IOExceptionBiFunction<List<Closeable>, String, Path> loadNestedJarUriFunction) throws IOException {
String scheme = uri.getScheme();
try {
if (SCHEME_JAR.equals(scheme) || SCHEME_ZIP.equals(scheme)) {
if (SCHEME_JAR.equals(scheme) || SCHEME_ZIP.equals(scheme) || SCHEME_WSJAR.equals(scheme)) {
// try to match FileSystems.newFileSystem(URI) semantics for zipfs here.
// Basically ignores anything after the !/ if it exists, and uses the part
// before as the jar path to extract.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -119,12 +119,28 @@ private Set<String> computeStandardServiceTypeNames(URL url) {
return typeNames;
}

private boolean isWebSphereClassLoader() {
return classLoader.getClass().getName().startsWith("com.ibm.ws.classloader");
}

private String buildResourceSearchPath() {
String path = "META-INF/micronaut/" + serviceName;

if (isWebSphereClassLoader()) {
// Special case WebSphere classloader
// https://github.com/micronaut-projects/micronaut-core/issues/....
mattmoss marked this conversation as resolved.
Show resolved Hide resolved
return path + "/";
}

return path;
}

private Enumeration<URL> findStandardServiceConfigs() throws IOException {
return classLoader.getResources(SoftServiceLoader.META_INF_SERVICES + '/' + serviceName);
}

private void findMicronautMetaServiceConfigs(BiConsumer<URI, String> consumer) throws IOException, URISyntaxException {
final String path = "META-INF/micronaut/" + serviceName;
String path = buildResourceSearchPath();
final Enumeration<URL> micronautResources = classLoader.getResources(path);
Set<URI> uniqueURIs = new LinkedHashSet<>();
while (micronautResources.hasMoreElements()) {
Expand Down
3 changes: 3 additions & 0 deletions core/src/test/groovy/io/micronaut/core/io/IOUtilsSpec.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,9 @@ class IOUtilsSpec extends Specification {
"META-INF/micronaut/io.micronaut.inject.BeanConfiguration" | "/META-INF/micronaut/io.micronaut.inject.BeanConfiguration" | "jar:file:/Users/sdelamo/.m2/repository/io/micronaut/micronaut-jackson-databind/3.5.7/micronaut-jackson-databind-3.5.7.jar!/META-INF/micronaut/io.micronaut.inject.BeanConfiguration"
"META-INF/micronaut/io.micronaut.inject.BeanConfiguration" | "/META-INF/micronaut/io.micronaut.inject.BeanConfiguration" | "zip:/u01/oracle/user_projects/domains/base_domain/servers/AdminServer/tmp/_WL_user/issue8386-0.1/y2p3pa/war/WEB-INF/lib/micronaut-jackson-databind-3.5.7.jar!/META-INF/micronaut/io.micronaut.inject.BeanConfiguration/"
"META-INF/micronaut/io.micronaut.inject.BeanConfiguration" | "/META-INF/micronaut/io.micronaut.inject.BeanConfiguration" | "zip:C:/oracle/user_projects/domains/base_domain/servers/AdminServer/tmp/_WL_user/issue8386-0.1/y2p3pa/war/WEB-INF/lib/micronaut-jackson-databind-3.5.7.jar!/META-INF/micronaut/io.micronaut.inject.BeanConfiguration/"
"META-INF/micronaut/io.micronaut.inject.BeanDefinitionReference" | "/META-INF/micronaut/io.micronaut.inject.BeanDefinitionReference" | "wsjar:file:/path/to/io/micronaut/micronaut-json-core/3.5.7/micronaut-json-core-3.5.7.jar!/META-INF/micronaut/io.micronaut.inject.BeanDefinitionReference"
"META-INF/micronaut/io.micronaut.inject.BeanConfiguration" | "/META-INF/micronaut/io.micronaut.inject.BeanConfiguration" | "wsjar:/path/to/io/micronaut/micronaut-jackson-databind/3.5.7/micronaut-jackson-databind-3.5.7.jar!/META-INF/micronaut/io.micronaut.inject.BeanConfiguration"
"META-INF/micronaut/io.micronaut.inject.BeanConfiguration" | "/META-INF/micronaut/io.micronaut.inject.BeanConfiguration" | "wsjar:C:/path/to/io/micronaut/micronaut-jackson-databind/3.5.7/micronaut-jackson-databind-3.5.7.jar!/META-INF/micronaut/io.micronaut.inject.BeanConfiguration"
}

void "resolvePath will fix jar uri on Windows/WebLogic"() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1751,6 +1751,7 @@ protected List<BeanDefinitionReference> resolveBeanDefinitionReferences() {
final SoftServiceLoader<BeanDefinitionReference> definitions = SoftServiceLoader.load(BeanDefinitionReference.class, classLoader);
beanDefinitionReferences = new ArrayList<>(300);
definitions.collectAll(beanDefinitionReferences, BeanDefinitionReference::isPresent);
beanDefinitionReferences.removeIf(Objects::isNull);
mattmoss marked this conversation as resolved.
Show resolved Hide resolved
}
return beanDefinitionReferences;
}
Expand Down
Loading