Repository: tomee
Updated Branches:
  refs/heads/master df25e829d -> 9b3604fc5


avoid to fail if we cant find classes


Project: http://git-wip-us.apache.org/repos/asf/tomee/repo
Commit: http://git-wip-us.apache.org/repos/asf/tomee/commit/9b3604fc
Tree: http://git-wip-us.apache.org/repos/asf/tomee/tree/9b3604fc
Diff: http://git-wip-us.apache.org/repos/asf/tomee/diff/9b3604fc

Branch: refs/heads/master
Commit: 9b3604fc5be753f395fadc36ab63f0d9096fa65b
Parents: df25e82
Author: Romain manni-Bucau <rmannibu...@gmail.com>
Authored: Sat Aug 13 18:59:19 2016 +0200
Committer: Romain manni-Bucau <rmannibu...@gmail.com>
Committed: Sat Aug 13 18:59:19 2016 +0200

----------------------------------------------------------------------
 .../openejb/config/AnnotationDeployer.java      | 53 ++++++++++++--------
 1 file changed, 31 insertions(+), 22 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/tomee/blob/9b3604fc/container/openejb-core/src/main/java/org/apache/openejb/config/AnnotationDeployer.java
----------------------------------------------------------------------
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 528fb33..35521c3 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
@@ -247,7 +247,6 @@ import java.lang.reflect.Method;
 import java.lang.reflect.Modifier;
 import java.net.MalformedURLException;
 import java.net.URI;
-import java.net.URISyntaxException;
 import java.net.URL;
 import java.net.URLClassLoader;
 import java.util.ArrayList;
@@ -1502,6 +1501,8 @@ public class AnnotationDeployer implements 
DynamicDeployer {
             { // after having found EJB for auto CDI activation
                 final Map<URL, List<String>> managedClasses;
                 Beans beans = ejbModule.getBeans();
+
+                final boolean deployComp;
                 if (beans == null && 
!ejbModule.getEjbJar().getEnterpriseBeansByEjbName().isEmpty()
                         && 
Boolean.parseBoolean(ejbModule.getProperties().getProperty("openejb.cdi.activated",
 "true"))
                         && 
Boolean.parseBoolean(SystemInstance.get().getProperty("openejb.cdi.activated-on-ejb",
 "true"))) {
@@ -1519,32 +1520,37 @@ public class AnnotationDeployer implements 
DynamicDeployer {
                         beans.setUri(URI.create("jar:file://!/" + 
ejbModule.getModuleUri().toASCIIString() + 
"/META-INF/beans.xml").toASCIIString());
                     }
                     ejbModule.setBeans(beans);
+                    deployComp = false; // no need normally since mainly only 
EJB will be injectable
+                } else {
+                    deployComp = true;
                 }
 
                 if (beans != null) {
                     managedClasses = beans.getManagedClasses();
                     getBeanClasses(beans.getUri(), finder, managedClasses, 
beans.getNotManagedClasses(), ejbModule.getAltDDs());
 
-                    // passing jar location to be able to manage maven 
classes/test-classes which have the same moduleId
-                    String id = ejbModule.getModuleId();
-                    if (ejbModule.getJarLocation() != null &&
-                            
(ejbModule.getJarLocation().contains(ejbModule.getModuleId() + 
"/target/test-classes".replace("/", File.separator)) ||
-                                    
ejbModule.getJarLocation().contains(ejbModule.getModuleId() + 
"/build/classes/test".replace("/", File.separator)))) {
-                        // with maven/gradle if both src/main/java and 
src/test/java are deployed
-                        // moduleId.Comp exists twice so it fails
-                        // here we simply modify the test comp bean name to 
avoid it
-                        id += "_test";
-                    }
-                    final String name = BeanContext.Comp.openejbCompName(id);
-                    final org.apache.openejb.jee.ManagedBean managedBean = new 
CompManagedBean(name, BeanContext.Comp.class);
-                    managedBean.setTransactionType(TransactionType.BEAN);
-                    ejbModule.getEjbJar().addEnterpriseBean(managedBean);
-
-                    if 
("true".equals(SystemInstance.get().getProperty("openejb.cdi.support.@Startup", 
"true"))) {
-                        final List<Annotated<Class<?>>> forceStart = 
finder.findMetaAnnotatedClasses(Startup.class);
-                        final List<String> startupBeans = 
beans.getStartupBeans();
-                        for (final Annotated<Class<?>> clazz : forceStart) {
-                            startupBeans.add(clazz.get().getName());
+                    if (deployComp) {
+                        // passing jar location to be able to manage maven 
classes/test-classes which have the same moduleId
+                        String id = ejbModule.getModuleId();
+                        if (ejbModule.getJarLocation() != null &&
+                                
(ejbModule.getJarLocation().contains(ejbModule.getModuleId() + 
"/target/test-classes".replace("/", File.separator)) ||
+                                        
ejbModule.getJarLocation().contains(ejbModule.getModuleId() + 
"/build/classes/test".replace("/", File.separator)))) {
+                            // with maven/gradle if both src/main/java and 
src/test/java are deployed
+                            // moduleId.Comp exists twice so it fails
+                            // here we simply modify the test comp bean name 
to avoid it
+                            id += "_test";
+                        }
+                        final String name = 
BeanContext.Comp.openejbCompName(id);
+                        final org.apache.openejb.jee.ManagedBean managedBean = 
new CompManagedBean(name, BeanContext.Comp.class);
+                        managedBean.setTransactionType(TransactionType.BEAN);
+                        ejbModule.getEjbJar().addEnterpriseBean(managedBean);
+
+                        if 
("true".equals(SystemInstance.get().getProperty("openejb.cdi.support.@Startup", 
"true"))) {
+                            final List<Annotated<Class<?>>> forceStart = 
finder.findMetaAnnotatedClasses(Startup.class);
+                            final List<String> startupBeans = 
beans.getStartupBeans();
+                            for (final Annotated<Class<?>> clazz : forceStart) 
{
+                                startupBeans.add(clazz.get().getName());
+                            }
                         }
                     }
                 }
@@ -1634,8 +1640,11 @@ public class AnnotationDeployer implements 
DynamicDeployer {
             // force cast otherwise we would be broken
             final IAnnotationFinder delegate = 
FinderFactory.ModuleLimitedFinder.class.isInstance(finder) ?
                     
FinderFactory.ModuleLimitedFinder.class.cast(finder).getDelegate() : finder;
-            final AnnotationFinder annotationFinder = 
AnnotationFinder.class.cast(delegate);
+            if (!AnnotationFinder.class.isInstance(delegate)) {
+                return; // only few tests
+            }
 
+            final AnnotationFinder annotationFinder = 
AnnotationFinder.class.cast(delegate);
             final Archive archive = annotationFinder.getArchive();
 
             if (!WebappAggregatedArchive.class.isInstance(archive)) {

Reply via email to