This is an automated email from the ASF dual-hosted git repository.

rzo1 pushed a commit to branch ee11
in repository https://gitbox.apache.org/repos/asf/tomee.git

commit a27ef8ac33eec5eaccf4339802c16d473a045d60
Author: Markus Jung <[email protected]>
AuthorDate: Wed Nov 5 18:00:08 2025 +0100

    proper exclusions to not leak old annotations api into classpath, remove 
ManagedBeans
---
 .../src/main/java/org/apache/openejb/Injector.java |  2 +-
 .../openejb/assembler/classic/JndiEncBuilder.java  |  5 --
 .../apache/openejb/config/AnnotationDeployer.java  | 44 --------------
 .../java/org/apache/openejb/config/AutoConfig.java | 30 ++--------
 .../openejb/config/rules/CheckAnnotationTest.java  | 13 -----
 .../apache/openejb/meta/ManagedBeanMetaTest.java   | 67 ----------------------
 .../org/apache/openejb/test/annotated/Red.java     | 32 -----------
 pom.xml                                            | 14 +++++
 8 files changed, 20 insertions(+), 187 deletions(-)

diff --git 
a/container/openejb-core/src/main/java/org/apache/openejb/Injector.java 
b/container/openejb-core/src/main/java/org/apache/openejb/Injector.java
index 96f6568517..c02f1c2ba8 100644
--- a/container/openejb-core/src/main/java/org/apache/openejb/Injector.java
+++ b/container/openejb-core/src/main/java/org/apache/openejb/Injector.java
@@ -132,7 +132,7 @@ public class Injector {
         }
 
         public NoInjectionMetaDataException(final String s, final Exception e) 
{
-            super(String.format("%s : Annotate the class with @%s so it can be 
discovered in the application scanning process", s, 
jakarta.annotation.ManagedBean.class.getName()), e);
+            super(String.format("%s : Annotate the class with @%s so it can be 
discovered in the application scanning process", s, 
LocalClient.class.getName()), e);
         }
     }
 
diff --git 
a/container/openejb-core/src/main/java/org/apache/openejb/assembler/classic/JndiEncBuilder.java
 
b/container/openejb-core/src/main/java/org/apache/openejb/assembler/classic/JndiEncBuilder.java
index 11f0bee598..e4879f7924 100644
--- 
a/container/openejb-core/src/main/java/org/apache/openejb/assembler/classic/JndiEncBuilder.java
+++ 
b/container/openejb-core/src/main/java/org/apache/openejb/assembler/classic/JndiEncBuilder.java
@@ -53,7 +53,6 @@ import org.apache.openejb.util.Logger;
 import org.apache.webbeans.config.WebBeansContext;
 import org.apache.webbeans.container.InjectableBeanManager;
 
-import jakarta.annotation.ManagedBean;
 import jakarta.ejb.EJBContext;
 import jakarta.ejb.TimerService;
 import jakarta.ejb.spi.HandleDelegate;
@@ -297,10 +296,6 @@ public class JndiEncBuilder {
                 final Object reference;
                 if (URL.class.equals(type)) {
                     reference = new URLReference(referenceInfo.resourceID);
-                } else if (type.isAnnotationPresent(ManagedBean.class)) {
-                    final ManagedBean managed = 
type.getAnnotation(ManagedBean.class);
-                    final String name = managed.value().length() == 0 ? 
type.getSimpleName() : managed.value();
-                    reference = new LinkRef("module/" + name);
                 } else if (referenceInfo.resourceID != null) {
                     final String jndiName = "openejb/Resource/" + 
referenceInfo.resourceID;
                     reference = new IntraVmJndiReference(jndiName);
diff --git 
a/container/openejb-core/src/main/java/org/apache/openejb/config/AnnotationDeployer.java
 
b/container/openejb-core/src/main/java/org/apache/openejb/config/AnnotationDeployer.java
index 6844682c77..17aed84e78 100644
--- 
a/container/openejb-core/src/main/java/org/apache/openejb/config/AnnotationDeployer.java
+++ 
b/container/openejb-core/src/main/java/org/apache/openejb/config/AnnotationDeployer.java
@@ -147,7 +147,6 @@ import org.apache.xbean.finder.MetaAnnotatedClass;
 import org.apache.xbean.finder.archive.Archive;
 import org.apache.xbean.finder.archive.ClassesArchive;
 
-import jakarta.annotation.ManagedBean;
 import jakarta.annotation.PostConstruct;
 import jakarta.annotation.PreDestroy;
 import jakarta.annotation.Resource;
@@ -1438,36 +1437,6 @@ public class AnnotationDeployer implements 
DynamicDeployer {
                 LegacyProcessor.process(beanClass.get(), enterpriseBean);
             }
 
-            for (final Annotated<Class<?>> beanClass : 
finder.findMetaAnnotatedClasses(ManagedBean.class)) {
-                final ManagedBean managed = 
beanClass.getAnnotation(ManagedBean.class);
-                final String ejbName = getEjbName(managed, beanClass.get());
-
-                // TODO: this is actually against the spec, but the 
requirement is rather silly
-                // (allowing @Stateful and @ManagedBean on the same class)
-                // If the TCK doesn't complain we should discourage it
-                if (!isValidEjbAnnotationUsage(ManagedBean.class, beanClass, 
ejbName, ejbModule)) {
-                    continue;
-                }
-
-                EnterpriseBean enterpriseBean = 
ejbJar.getEnterpriseBean(ejbName);
-                if (enterpriseBean == null) {
-                    enterpriseBean = new 
org.apache.openejb.jee.ManagedBean(ejbName, beanClass.get());
-                    ejbJar.addEnterpriseBean(enterpriseBean);
-                }
-                if (enterpriseBean.getEjbClass() == null) {
-                    enterpriseBean.setEjbClass(beanClass.get());
-                }
-                if (enterpriseBean instanceof SessionBean) {
-                    final SessionBean sessionBean = (SessionBean) 
enterpriseBean;
-                    sessionBean.setSessionType(SessionType.MANAGED);
-
-                    final TransactionType transactionType = 
sessionBean.getTransactionType();
-                    if (transactionType == null) {
-                        sessionBean.setTransactionType(TransactionType.BEAN);
-                    }
-                }
-            }
-
             for (final Annotated<Class<?>> beanClass : 
finder.findMetaAnnotatedClasses(MessageDriven.class)) {
                 final MessageDriven mdb = 
beanClass.getAnnotation(MessageDriven.class);
                 final String ejbName = getEjbName(mdb, beanClass.get());
@@ -1600,9 +1569,6 @@ public class AnnotationDeployer implements 
DynamicDeployer {
             if (clazz.isAnnotationPresent(Singleton.class)) {
                 return SessionType.SINGLETON;
             }
-            if (clazz.isAnnotationPresent(ManagedBean.class)) {
-                return SessionType.MANAGED;
-            }
             return null;
         }
 
@@ -1866,10 +1832,6 @@ public class AnnotationDeployer implements 
DynamicDeployer {
             return singleton.name().isEmpty() ? beanClass.getSimpleName() : 
singleton.name();
         }
 
-        private String getEjbName(final ManagedBean managed, final Class<?> 
beanClass) {
-            return managed.value().isEmpty() ? beanClass.getSimpleName() : 
managed.value();
-        }
-
         private boolean isValidEjbAnnotationUsage(final Class annotationClass, 
final Annotated<Class<?>> beanClass, final String ejbName, final EjbModule 
ejbModule) {
             final List<Class<? extends Annotation>> annotations = new 
ArrayList(Arrays.asList(Singleton.class, Stateless.class, Stateful.class, 
MessageDriven.class));
             annotations.remove(annotationClass);
@@ -3443,11 +3405,6 @@ public class AnnotationDeployer implements 
DynamicDeployer {
                     && all.remote.isEmpty()) {
                     all.remote.add(webServiceItf);
                 }
-
-                //alway set Local View for ManagedBean
-                if (beanClass.isAnnotationPresent(ManagedBean.class)) {
-                    sessionBean.setLocalBean(new Empty());
-                }
             }
 
             // Finally, add all the business interfaces we found
@@ -5913,7 +5870,6 @@ public class AnnotationDeployer implements 
DynamicDeployer {
     private static boolean isEJB(final Class<?> clazz) {
         return clazz.isAnnotationPresent(Stateless.class)
             || clazz.isAnnotationPresent(Singleton.class)
-            || clazz.isAnnotationPresent(ManagedBean.class)  // what a weird 
idea!
             || clazz.isAnnotationPresent(Stateful.class); // what another 
weird idea!
     }
 
diff --git 
a/container/openejb-core/src/main/java/org/apache/openejb/config/AutoConfig.java
 
b/container/openejb-core/src/main/java/org/apache/openejb/config/AutoConfig.java
index c247580bb6..0946a58231 100644
--- 
a/container/openejb-core/src/main/java/org/apache/openejb/config/AutoConfig.java
+++ 
b/container/openejb-core/src/main/java/org/apache/openejb/config/AutoConfig.java
@@ -66,7 +66,6 @@ import org.apache.openejb.util.SuperProperties;
 import org.apache.openejb.util.URISupport;
 import org.apache.openejb.util.URLs;
 
-import jakarta.annotation.ManagedBean;
 import jakarta.ejb.TimerService;
 import jakarta.enterprise.inject.spi.BeanManager;
 import jakarta.jms.Queue;
@@ -778,7 +777,7 @@ public class AutoConfig implements DynamicDeployer, 
JndiConstants {
             final String refType = getType(ref, classLoader);
 
             // skip references such as URLs which are automatically handled by 
the server
-            if (isIgnoredReferenceType(refType, classLoader)) {
+            if (isIgnoredReferenceType(refType)) {
                 continue;
             }
 
@@ -811,7 +810,7 @@ public class AutoConfig implements DynamicDeployer, 
JndiConstants {
             final String refType = getType(ref, classLoader);
 
             // skip references such as URLs which are automatically handled by 
the server
-            if (isIgnoredReferenceType(refType, classLoader)) {
+            if (isIgnoredReferenceType(refType)) {
                 continue;
             }
 
@@ -839,18 +838,8 @@ public class AutoConfig implements DynamicDeployer, 
JndiConstants {
         }
     }
 
-    private boolean isIgnoredReferenceType(final String typeName, final 
ClassLoader loader) {
-        if (ignoredReferenceTypes.contains(typeName)) {
-            return true;
-        } else if (loader != null) {
-            try {
-                final Class<?> type = loader.loadClass(typeName);
-                return type.isAnnotationPresent(ManagedBean.class);
-            } catch (final ClassNotFoundException e) {
-                // ignore
-            }
-        }
-        return false;
+    private boolean isIgnoredReferenceType(final String typeName) {
+        return ignoredReferenceTypes.contains(typeName);
     }
 
     private void deploy(final EjbModule ejbModule, final AppResources 
appResources) throws OpenEJBException {
@@ -1206,15 +1195,6 @@ public class AutoConfig implements DynamicDeployer, 
JndiConstants {
             return;
         }
 
-        try {
-            final Class<?> clazz = 
ejbModule.getClassLoader().loadClass(refType);
-            if (clazz.isAnnotationPresent(ManagedBean.class)) {
-                return;
-            }
-        } catch (final Throwable t) {
-            // no-op
-        }
-
         try {
             ResourceLink link = ejbDeployment.getResourceLink(refName);
             if (link == null) {
@@ -1279,7 +1259,7 @@ public class AutoConfig implements DynamicDeployer, 
JndiConstants {
         final String refType = getType(ref, classLoader);
 
         // skip references such as SessionContext which are automatically 
handled by the server
-        if (isIgnoredReferenceType(refType, classLoader)) {
+        if (isIgnoredReferenceType(refType)) {
             return;
         }
 
diff --git 
a/container/openejb-core/src/test/java/org/apache/openejb/config/rules/CheckAnnotationTest.java
 
b/container/openejb-core/src/test/java/org/apache/openejb/config/rules/CheckAnnotationTest.java
index 2b83afed4b..36eb195bb8 100644
--- 
a/container/openejb-core/src/test/java/org/apache/openejb/config/rules/CheckAnnotationTest.java
+++ 
b/container/openejb-core/src/test/java/org/apache/openejb/config/rules/CheckAnnotationTest.java
@@ -19,12 +19,10 @@ package org.apache.openejb.config.rules;
 import org.apache.openejb.config.AppModule;
 import org.apache.openejb.config.EjbModule;
 import org.apache.openejb.jee.EjbJar;
-import org.apache.openejb.jee.ManagedBean;
 import org.apache.openejb.jee.MessageDrivenBean;
 import org.apache.openejb.jee.StatefulBean;
 import org.apache.openejb.jee.StatelessBean;
 import org.apache.openejb.test.annotated.Green;
-import org.apache.openejb.test.annotated.Red;
 import org.apache.openejb.test.annotated.Yellow;
 import org.apache.xbean.finder.AnnotationFinder;
 import org.apache.xbean.finder.archive.ClassesArchive;
@@ -59,17 +57,6 @@ public class CheckAnnotationTest {
     }
 
 
-    @Keys({@Key(value = "annotation.invalid.managedbean.webservice", type = 
KeyType.WARNING)})
-    public AppModule testWebServiceWithManagedBean() {
-        final EjbJar ejbJar = new EjbJar();
-        ejbJar.addEnterpriseBean(new ManagedBean(Red.class));
-        final EjbModule ejbModule = new EjbModule(ejbJar);
-        ejbModule.setFinder(new AnnotationFinder(new 
ClassesArchive(Red.class)).link());
-
-        final AppModule appModule = new AppModule(ejbModule);
-        return appModule;
-    }
-
     @Keys({@Key(value = "ann.local.forLocalBean", type = KeyType.WARNING)})
     public EjbModule shouldWarnForLocalAnnotationOnBeanWithNoInterface() {
         final EjbJar ejbJar = new EjbJar();
diff --git 
a/container/openejb-core/src/test/java/org/apache/openejb/meta/ManagedBeanMetaTest.java
 
b/container/openejb-core/src/test/java/org/apache/openejb/meta/ManagedBeanMetaTest.java
deleted file mode 100644
index c9d8fce3d8..0000000000
--- 
a/container/openejb-core/src/test/java/org/apache/openejb/meta/ManagedBeanMetaTest.java
+++ /dev/null
@@ -1,67 +0,0 @@
-/*
- * 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.meta;
-
-import org.junit.runner.RunWith;
-
-import jakarta.annotation.ManagedBean;
-import jakarta.ejb.LocalBean;
-import java.lang.annotation.ElementType;
-import java.lang.annotation.Retention;
-import java.lang.annotation.RetentionPolicy;
-import java.lang.annotation.Target;
-
-/**
- * @version $Rev$ $Date$
- */
-
-@RunWith(MetaRunner.class)
-public class ManagedBeanMetaTest {
-
-    @MetaTest(expected = ExpectedBean.class, actual = ActualBean.class)
-    public void test() {
-    }
-
-
-    @ManagedBean
-    @Metatype
-    @Target({ElementType.TYPE})
-    @Retention(RetentionPolicy.RUNTIME)
-    public static @interface ContainerControlled {
-    }
-
-    /**
-     * Standard bean
-     */
-    @ManagedBean
-    @LocalBean
-    public static class ExpectedBean implements Bean {
-    }
-
-    /**
-     * Meta bean
-     */
-    @ContainerControlled
-    @LocalBean
-    public static class ActualBean implements Bean {
-    }
-
-
-    public static interface Bean {
-    }
-
-}
\ No newline at end of file
diff --git 
a/container/openejb-core/src/test/java/org/apache/openejb/test/annotated/Red.java
 
b/container/openejb-core/src/test/java/org/apache/openejb/test/annotated/Red.java
deleted file mode 100644
index a62b3dc6d2..0000000000
--- 
a/container/openejb-core/src/test/java/org/apache/openejb/test/annotated/Red.java
+++ /dev/null
@@ -1,32 +0,0 @@
-/*
- * 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.test.annotated;
-
-import jakarta.annotation.ManagedBean;
-import jakarta.interceptor.AroundInvoke;
-import jakarta.jws.WebService;
-
-@ManagedBean
-@WebService
-public class Red {
-
-    // need to add this @AroundInvoke to cause validation to fail. Validation 
does not
-    // fail on warnings, which causes this framework to not work properly
-    @AroundInvoke
-    public void sayCheese() {
-    }
-}
diff --git a/pom.xml b/pom.xml
index f9a247d9d0..c760b01cf2 100644
--- a/pom.xml
+++ b/pom.xml
@@ -1321,6 +1321,13 @@
         <groupId>org.apache.activemq</groupId>
         <artifactId>activemq-ra</artifactId>
         <version>${version.activemq}</version>
+
+        <exclusions>
+          <exclusion>
+            <groupId>jakarta.resource</groupId>
+            <artifactId>jakarta.resource-api</artifactId>
+          </exclusion>
+        </exclusions>
       </dependency>
       <dependency>
         <groupId>org.apache.activemq</groupId>
@@ -1331,6 +1338,13 @@
         <groupId>org.apache.activemq</groupId>
         <artifactId>activemq-broker</artifactId>
         <version>${version.activemq}</version>
+
+        <exclusions>
+          <exclusion>
+            <groupId>jakarta.annotation</groupId>
+            <artifactId>jakarta.annotation-api</artifactId>
+          </exclusion>
+        </exclusions>
       </dependency>
       <dependency>
         <groupId>org.apache.activemq</groupId>

Reply via email to