This is an automated email from the ASF dual-hosted git repository. rzo1 pushed a commit to branch TOMEE-4577 in repository https://gitbox.apache.org/repos/asf/tomee.git
commit 5d838a2c6cc3b5248f2f6b4404c3453274d23994 Author: Richard Zowalla <[email protected]> AuthorDate: Thu Feb 5 09:46:10 2026 +0100 TOMEE-4577 - Resources with explicit contructor-type set to "String" are broken --- .../openejb/assembler/classic/Assembler.java | 1 + .../openejb/resource/CustomURLAsResourceTest.java | 83 ++++++++++++++++++++++ 2 files changed, 84 insertions(+) diff --git a/container/openejb-core/src/main/java/org/apache/openejb/assembler/classic/Assembler.java b/container/openejb-core/src/main/java/org/apache/openejb/assembler/classic/Assembler.java index fb367569f2..00ee7daeee 100644 --- a/container/openejb-core/src/main/java/org/apache/openejb/assembler/classic/Assembler.java +++ b/container/openejb-core/src/main/java/org/apache/openejb/assembler/classic/Assembler.java @@ -3828,6 +3828,7 @@ public class Assembler extends AssemblerTool implements org.apache.openejb.spi.A case "long" -> long.class; case "float" -> float.class; case "double" -> double.class; + case "String" -> String.class; case "void" -> void.class; default -> Class.forName(typeName); // regular case }; diff --git a/container/openejb-core/src/test/java/org/apache/openejb/resource/CustomURLAsResourceTest.java b/container/openejb-core/src/test/java/org/apache/openejb/resource/CustomURLAsResourceTest.java new file mode 100644 index 0000000000..2cfae8b957 --- /dev/null +++ b/container/openejb-core/src/test/java/org/apache/openejb/resource/CustomURLAsResourceTest.java @@ -0,0 +1,83 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.openejb.resource; + +import jakarta.annotation.Resource; +import jakarta.ejb.EJB; +import jakarta.ejb.Singleton; +import org.apache.openejb.jee.EnterpriseBean; +import org.apache.openejb.jee.SingletonBean; +import org.apache.openejb.junit.ApplicationComposer; +import org.apache.openejb.testing.Configuration; +import org.apache.openejb.testing.Module; +import org.apache.openejb.testng.PropertiesBuilder; +import org.junit.Test; +import org.junit.runner.RunWith; + +import java.net.URL; +import java.util.Properties; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; + +@RunWith(ApplicationComposer.class) +public class CustomURLAsResourceTest { + @Configuration + public Properties config() { + return new PropertiesBuilder() + .p("url", "new://Resource?class-name=org.apache.openejb.resource.CustomURLAsResourceTest$CustomUrl&constructor=value&constructor-types=String") + .p("url.value", "http://tomee.apache.org") + .build(); + } + + @Module + public EnterpriseBean bean() { + return new SingletonBean(WithUrl.class).localBean(); + } + + @EJB + private WithUrl withUrl; + + @Test + public void url() { + final CustomUrl url = withUrl.getUrl(); + assertNotNull(url); + assertEquals("http://tomee.apache.org", url.getURL()); + } + + @Singleton + public static class WithUrl { + @Resource(name = "url") + private CustomUrl url; + + public CustomUrl getUrl() { + return url; + } + } + + public static class CustomUrl { + private final String value; + + public CustomUrl(String value) { + this.value = value; + } + + public String getURL() { + return value; + } + } +}
