You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tomee.apache.org by jl...@apache.org on 2009/09/14 10:59:04 UTC
svn commit: r814528 - in /openejb/trunk/openejb3/container/openejb-core/src:
main/java/org/apache/openejb/config/AnnotationDeployer.java
test/java/org/apache/openejb/config/AnnotationDeployerTest.java
Author: jlmonteiro
Date: Mon Sep 14 08:59:04 2009
New Revision: 814528
URL: http://svn.apache.org/viewvc?rev=814528&view=rev
Log:
OPENEJB-1063: Main-Class containing "/" instead of "." fails java.lang.NoClassDefFoundError: IllegalName
Modified:
openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/config/AnnotationDeployer.java
openejb/trunk/openejb3/container/openejb-core/src/test/java/org/apache/openejb/config/AnnotationDeployerTest.java
Modified: openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/config/AnnotationDeployer.java
URL: http://svn.apache.org/viewvc/openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/config/AnnotationDeployer.java?rev=814528&r1=814527&r2=814528&view=diff
==============================================================================
--- openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/config/AnnotationDeployer.java (original)
+++ openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/config/AnnotationDeployer.java Mon Sep 14 08:59:04 2009
@@ -681,6 +681,15 @@
if (clientModule.getMainClass() != null){
String className = clientModule.getMainClass();
+
+ // OPENEJB-1063: a Main-Class should use "." instead of "/"
+ // it wasn't check before jdk 1.5 so we can get old module with
+ // bad format http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=4986512
+ // replace all "/" by "."
+ if (className.indexOf("/") != -1) { // className can't be null here
+ className = className.replaceAll("/", ".");
+ clientModule.setMainClass(className);
+ }
Class clazz;
try {
Modified: openejb/trunk/openejb3/container/openejb-core/src/test/java/org/apache/openejb/config/AnnotationDeployerTest.java
URL: http://svn.apache.org/viewvc/openejb/trunk/openejb3/container/openejb-core/src/test/java/org/apache/openejb/config/AnnotationDeployerTest.java?rev=814528&r1=814527&r2=814528&view=diff
==============================================================================
--- openejb/trunk/openejb3/container/openejb-core/src/test/java/org/apache/openejb/config/AnnotationDeployerTest.java (original)
+++ openejb/trunk/openejb3/container/openejb-core/src/test/java/org/apache/openejb/config/AnnotationDeployerTest.java Mon Sep 14 08:59:04 2009
@@ -1,62 +1,102 @@
-/**
- * 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.config;
-
-import org.apache.openejb.jee.AssemblyDescriptor;
-import org.apache.openejb.jee.EjbJar;
-import static org.hamcrest.CoreMatchers.*;
-import static org.junit.Assert.assertThat;
-import org.junit.Test;
-
-import javax.ejb.ApplicationException;
-
-/**
+/**
+ * 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.config;
+
+import org.apache.openejb.assembler.classic.AppInfo;
+import org.apache.openejb.assembler.classic.Assembler;
+import org.apache.openejb.assembler.classic.ClientInfo;
+import org.apache.openejb.jee.AssemblyDescriptor;
+import org.apache.openejb.jee.EjbJar;
+
+import static org.hamcrest.CoreMatchers.*;
+import static org.junit.Assert.assertThat;
+
+import org.junit.Assert;
+import org.junit.Test;
+
+import javax.ejb.ApplicationException;
+
+/**
* @version $Rev$ $Date$
- */
-public class AnnotationDeployerTest {
-
- @Test
- /**
- * For http://issues.apache.org/jira/browse/OPENEJB-980
- */
- public void applicationExceptionInheritanceTest() throws Exception {
- EjbJar ejbJar = new EjbJar("test-classes");
- EjbModule ejbModule = new EjbModule(ejbJar);
- AnnotationDeployer.DiscoverAnnotatedBeans discvrAnnBeans = new AnnotationDeployer.DiscoverAnnotatedBeans();
- ejbModule = discvrAnnBeans.deploy(ejbModule);
-
- AssemblyDescriptor assemblyDescriptor = ejbModule.getEjbJar().getAssemblyDescriptor();
- org.apache.openejb.jee.ApplicationException appEx =
- assemblyDescriptor.getApplicationException(BusinessException.class);
- assertThat(appEx, notNullValue());
- assertThat(appEx.getExceptionClass(), is(BusinessException.class.getName()));
- assertThat(appEx.getRollback(), is(true));
-
- appEx = assemblyDescriptor.getApplicationException(ValueRequiredException.class);
- assertThat(appEx, notNullValue());
- assertThat(appEx.getExceptionClass(), is(ValueRequiredException.class.getName()));
- assertThat(appEx.getRollback(), is(true));
- }
-
- @ApplicationException(rollback = true)
- public abstract class BusinessException extends Exception {
- }
-
- public class ValueRequiredException extends BusinessException {
- }
-
-}
+ */
+public class AnnotationDeployerTest {
+
+ @Test
+ /**
+ * For http://issues.apache.org/jira/browse/OPENEJB-980
+ */
+ public void applicationExceptionInheritanceTest() throws Exception {
+ EjbJar ejbJar = new EjbJar("test-classes");
+ EjbModule ejbModule = new EjbModule(ejbJar);
+ ejbModule.setJarLocation(null); // TODO check why it's necessary now
+ AnnotationDeployer.DiscoverAnnotatedBeans discvrAnnBeans = new AnnotationDeployer.DiscoverAnnotatedBeans();
+ ejbModule = discvrAnnBeans.deploy(ejbModule);
+
+ AssemblyDescriptor assemblyDescriptor = ejbModule.getEjbJar().getAssemblyDescriptor();
+ org.apache.openejb.jee.ApplicationException appEx =
+ assemblyDescriptor.getApplicationException(BusinessException.class);
+ assertThat(appEx, notNullValue());
+ assertThat(appEx.getExceptionClass(), is(BusinessException.class.getName()));
+ assertThat(appEx.getRollback(), is(true));
+
+ appEx = assemblyDescriptor.getApplicationException(ValueRequiredException.class);
+ assertThat(appEx, notNullValue());
+ assertThat(appEx.getExceptionClass(), is(ValueRequiredException.class.getName()));
+ assertThat(appEx.getRollback(), is(true));
+ }
+
+ @Test
+ /**
+ * For https://issues.apache.org/jira/browse/OPENEJB-1063
+ */
+ public void badMainClassFormatTest() throws Exception {
+ ConfigurationFactory config = new ConfigurationFactory();
+ Assembler assembler = new Assembler();
+
+ AppModule app = new AppModule(this.getClass().getClassLoader(), "test-app");
+
+ ClientModule clientModule = new ClientModule(null, app.getClassLoader(), app.getJarLocation(), null, null);
+
+ // change "." --> "/" to check that main class is changed by the AnnotationDeployer
+ String mainClass = MyMainClass.class.getName().replaceAll("\\.", "/");
+ clientModule.setMainClass(mainClass);
+
+ app.getClientModules().add(clientModule);
+
+ AppInfo appInfo = config.configureApplication(app);
+
+ assembler.createApplication(appInfo);
+
+ ClientInfo clientInfo = appInfo.clients.get(0);
+ Assert.assertNotNull(clientInfo);
+ Assert.assertEquals(MyMainClass.class.getName(), clientInfo.mainClass);
+ }
+
+ @ApplicationException(rollback = true)
+ public abstract class BusinessException extends Exception {
+ }
+
+ public class ValueRequiredException extends BusinessException {
+ }
+
+ public static final class MyMainClass {
+ public static void main(String[] args) {
+
+ }
+ }
+
+}