Tomee maven 安装目标发送:无法初始化 class org.apache.openejb.util.JuliLogStreamFactory
Tomee maven install goal sends: Could not initialize class org.apache.openejb.util.JuliLogStreamFactory
我有以下 class 有一个集成测试:
@LocalClient
public class AdminDummyTest extends TestCase {
private static final String propFileName = "\config\testconfig.properties";
private Config config;
private Properties p;
private Context context;
@EJB
IBasicConfigDao basicDaoConfig;
@Override
protected void setUp() throws IOException, NamingException {
config = new Config();
p = config.getPropertiesFromFile(propFileName);
p.put(Context.INITIAL_CONTEXT_FACTORY, "org.apache.openejb.client.LocalInitialContextFactory");
context = new InitialContext(p);
context.bind("inject", this);
}
public void testGetDataFromDatabase() throws NamingException {
BasicConfig bs = basicDaoConfig.getFirst();
assertEquals("BIZ", bs.getType());
assertEquals("Description", bs.getValue());
}
}
当我 运行 通过右键单击测试 class 并选择 运行 作为 eclipse 中的 junit 测试时,测试工作正常但是当我 运行 maven安装目标(运行 也是测试)我得到以下堆栈跟踪:
testGetDataFromDatabase(com.mycomp.base.admin.AdminDummyTest) Time elapsed: 0.094 sec <<< ERROR!
java.lang.NoClassDefFoundError: Could not initialize class org.apache.openejb.util.JuliLogStreamFactory
at org.apache.openejb.util.Logger.configure(Logger.java:96)
at org.apache.openejb.util.Logger.<clinit>(Logger.java:39)
at org.apache.openejb.util.OptionsLog.<init>(OptionsLog.java:31)
at org.apache.openejb.util.OptionsLog.install(OptionsLog.java:39)
at org.apache.openejb.core.LocalInitialContextFactory.init(LocalInitialContextFactory.java:96)
at org.apache.openejb.core.LocalInitialContextFactory.init(LocalInitialContextFactory.java:62)
at org.apache.openejb.core.LocalInitialContextFactory.getInitialContext(LocalInitialContextFactory.java:46)
at javax.naming.spi.NamingManager.getInitialContext(NamingManager.java:684)
at javax.naming.InitialContext.getDefaultInitCtx(InitialContext.java:307)
at javax.naming.InitialContext.init(InitialContext.java:242)
at javax.naming.InitialContext.<init>(InitialContext.java:216)
at com.mycomp.base.admin.AdminDummyTest.setUp(AdminDummyTest.java:41)
at junit.framework.TestCase.runBare(TestCase.java:139)
at junit.framework.TestResult.protect(TestResult.java:122)
at junit.framework.TestResult.runProtected(TestResult.java:142)
at junit.framework.TestResult.run(TestResult.java:125)
at junit.framework.TestCase.run(TestCase.java:129)
at junit.framework.TestSuite.runTest(TestSuite.java:255)
at junit.framework.TestSuite.run(TestSuite.java:250)
at org.junit.internal.runners.JUnit38ClassRunner.run(JUnit38ClassRunner.java:84)
at org.apache.maven.surefire.junit4.JUnit4Provider.execute(JUnit4Provider.java:252)
at org.apache.maven.surefire.junit4.JUnit4Provider.executeTestSet(JUnit4Provider.java:141)
at org.apache.maven.surefire.junit4.JUnit4Provider.invoke(JUnit4Provider.java:112)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:601)
at org.apache.maven.surefire.util.ReflectionUtils.invokeMethodWithArray(ReflectionUtils.java:189)
at org.apache.maven.surefire.booter.ProviderFactory$ProviderProxy.invoke(ProviderFactory.java:165)
at org.apache.maven.surefire.booter.ProviderFactory.invokeProvider(ProviderFactory.java:85)
at org.apache.maven.surefire.booter.ForkedBooter.runSuitesInProcess(ForkedBooter.java:115)
at org.apache.maven.surefire.booter.ForkedBooter.main(ForkedBooter.java:75)
我在网上搜索了这个错误,但无法解决问题。我使用 Tomee 1.7.0 plus 作为 EJB 容器。我会在项目的 pom 下方注明:
<project
xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.mycomp.base.admin</groupId>
<artifactId>Base_Admin</artifactId>
<packaging>jar</packaging>
<name>${project.artifactId}</name>
<parent>
<groupId>com.mycomp.base</groupId>
<artifactId>Base_Parent</artifactId>
<version>0.0.1-SNAPSHOT</version>
<relativePath>../Base_Parent/pom.xml</relativePath>
</parent>
<dependencies>
<dependency>
<groupId>com.mycomp.base.commons</groupId>
<artifactId>Base_Commons</artifactId>
<version>0.0.1-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>5.1.6</version>
</dependency>
<dependency>
<groupId>com.mycomp.base.config</groupId>
<artifactId>Base_Config</artifactId>
<version>0.0.1-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>org.apache.openejb</groupId>
<artifactId>tomee-embedded</artifactId>
<version>1.6.0</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.apache.openejb</groupId>
<artifactId>javaee-api</artifactId>
<version>6.0-6-tomcat</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.apache.openejb</groupId>
<artifactId>openejb-loader</artifactId>
<version>4.7.0</version>
</dependency>
<dependency>
<groupId>org.apache.openejb</groupId>
<artifactId>openejb-core</artifactId>
<version>4.7.0</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.apache.openejb</groupId>
<artifactId>openejb-client</artifactId>
<version>4.7.0</version>
</dependency>
<dependency>
<groupId>org.apache.openejb</groupId>
<artifactId>openejb-jee</artifactId>
<version>4.7.0</version>
</dependency>
<dependency>
<groupId>org.apache.openejb</groupId>
<artifactId>openejb-api</artifactId>
<version>4.7.0</version>
</dependency>
<dependency>
<groupId>org.apache.openjpa</groupId>
<artifactId>openjpa</artifactId>
<version>2.4.0</version>
</dependency>
</dependencies>
我知道 JuliLogStreamFactory 在 openejb-core 包中,我已经添加了具有 'test' 范围的包(参见 pom.xml 文件),但由于某种原因,这不起作用。如果需要其他信息,请告诉我。
我不确定它是否有帮助,但我更改了测试(在线搜索其他测试方法)但遇到了同样的问题(测试 运行 用 'run as junit test' 没问题但在调用 maven install 时失败):
@PropertyFile("\config\testconfig.properties")
@RunWith(EJBContainerRunner.class)
public class AdminDummyTest extends TestCase {
@TestResource
private Context context;
@EJB
IBasicConfigDao basicDaoConfig;
@Override
protected void setUp() throws NamingException, IOException {
basicDaoConfig = (IBasicConfigDao) context.lookup("java:global/Base_Admin/BasicConfigDao");
}
@Test
public void testGetDataFromDatabase() throws NamingException {
BasicConfig bs = basicDaoConfig.getFirst();
assertEquals("BIZ", bs.getType());
assertEquals("Description", bs.getValue());
}
}
我猜你的类路径搞砸了(tomee 1.6 应该使用 openejb 4.6 或 tomee 1.7 和 openejb 1.7)。确保 tomee/openejb 如前所述对齐,您应该解决此问题。
我有以下 class 有一个集成测试:
@LocalClient
public class AdminDummyTest extends TestCase {
private static final String propFileName = "\config\testconfig.properties";
private Config config;
private Properties p;
private Context context;
@EJB
IBasicConfigDao basicDaoConfig;
@Override
protected void setUp() throws IOException, NamingException {
config = new Config();
p = config.getPropertiesFromFile(propFileName);
p.put(Context.INITIAL_CONTEXT_FACTORY, "org.apache.openejb.client.LocalInitialContextFactory");
context = new InitialContext(p);
context.bind("inject", this);
}
public void testGetDataFromDatabase() throws NamingException {
BasicConfig bs = basicDaoConfig.getFirst();
assertEquals("BIZ", bs.getType());
assertEquals("Description", bs.getValue());
}
}
当我 运行 通过右键单击测试 class 并选择 运行 作为 eclipse 中的 junit 测试时,测试工作正常但是当我 运行 maven安装目标(运行 也是测试)我得到以下堆栈跟踪:
testGetDataFromDatabase(com.mycomp.base.admin.AdminDummyTest) Time elapsed: 0.094 sec <<< ERROR!
java.lang.NoClassDefFoundError: Could not initialize class org.apache.openejb.util.JuliLogStreamFactory
at org.apache.openejb.util.Logger.configure(Logger.java:96)
at org.apache.openejb.util.Logger.<clinit>(Logger.java:39)
at org.apache.openejb.util.OptionsLog.<init>(OptionsLog.java:31)
at org.apache.openejb.util.OptionsLog.install(OptionsLog.java:39)
at org.apache.openejb.core.LocalInitialContextFactory.init(LocalInitialContextFactory.java:96)
at org.apache.openejb.core.LocalInitialContextFactory.init(LocalInitialContextFactory.java:62)
at org.apache.openejb.core.LocalInitialContextFactory.getInitialContext(LocalInitialContextFactory.java:46)
at javax.naming.spi.NamingManager.getInitialContext(NamingManager.java:684)
at javax.naming.InitialContext.getDefaultInitCtx(InitialContext.java:307)
at javax.naming.InitialContext.init(InitialContext.java:242)
at javax.naming.InitialContext.<init>(InitialContext.java:216)
at com.mycomp.base.admin.AdminDummyTest.setUp(AdminDummyTest.java:41)
at junit.framework.TestCase.runBare(TestCase.java:139)
at junit.framework.TestResult.protect(TestResult.java:122)
at junit.framework.TestResult.runProtected(TestResult.java:142)
at junit.framework.TestResult.run(TestResult.java:125)
at junit.framework.TestCase.run(TestCase.java:129)
at junit.framework.TestSuite.runTest(TestSuite.java:255)
at junit.framework.TestSuite.run(TestSuite.java:250)
at org.junit.internal.runners.JUnit38ClassRunner.run(JUnit38ClassRunner.java:84)
at org.apache.maven.surefire.junit4.JUnit4Provider.execute(JUnit4Provider.java:252)
at org.apache.maven.surefire.junit4.JUnit4Provider.executeTestSet(JUnit4Provider.java:141)
at org.apache.maven.surefire.junit4.JUnit4Provider.invoke(JUnit4Provider.java:112)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:601)
at org.apache.maven.surefire.util.ReflectionUtils.invokeMethodWithArray(ReflectionUtils.java:189)
at org.apache.maven.surefire.booter.ProviderFactory$ProviderProxy.invoke(ProviderFactory.java:165)
at org.apache.maven.surefire.booter.ProviderFactory.invokeProvider(ProviderFactory.java:85)
at org.apache.maven.surefire.booter.ForkedBooter.runSuitesInProcess(ForkedBooter.java:115)
at org.apache.maven.surefire.booter.ForkedBooter.main(ForkedBooter.java:75)
我在网上搜索了这个错误,但无法解决问题。我使用 Tomee 1.7.0 plus 作为 EJB 容器。我会在项目的 pom 下方注明:
<project
xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.mycomp.base.admin</groupId>
<artifactId>Base_Admin</artifactId>
<packaging>jar</packaging>
<name>${project.artifactId}</name>
<parent>
<groupId>com.mycomp.base</groupId>
<artifactId>Base_Parent</artifactId>
<version>0.0.1-SNAPSHOT</version>
<relativePath>../Base_Parent/pom.xml</relativePath>
</parent>
<dependencies>
<dependency>
<groupId>com.mycomp.base.commons</groupId>
<artifactId>Base_Commons</artifactId>
<version>0.0.1-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>5.1.6</version>
</dependency>
<dependency>
<groupId>com.mycomp.base.config</groupId>
<artifactId>Base_Config</artifactId>
<version>0.0.1-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>org.apache.openejb</groupId>
<artifactId>tomee-embedded</artifactId>
<version>1.6.0</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.apache.openejb</groupId>
<artifactId>javaee-api</artifactId>
<version>6.0-6-tomcat</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.apache.openejb</groupId>
<artifactId>openejb-loader</artifactId>
<version>4.7.0</version>
</dependency>
<dependency>
<groupId>org.apache.openejb</groupId>
<artifactId>openejb-core</artifactId>
<version>4.7.0</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.apache.openejb</groupId>
<artifactId>openejb-client</artifactId>
<version>4.7.0</version>
</dependency>
<dependency>
<groupId>org.apache.openejb</groupId>
<artifactId>openejb-jee</artifactId>
<version>4.7.0</version>
</dependency>
<dependency>
<groupId>org.apache.openejb</groupId>
<artifactId>openejb-api</artifactId>
<version>4.7.0</version>
</dependency>
<dependency>
<groupId>org.apache.openjpa</groupId>
<artifactId>openjpa</artifactId>
<version>2.4.0</version>
</dependency>
</dependencies>
我知道 JuliLogStreamFactory 在 openejb-core 包中,我已经添加了具有 'test' 范围的包(参见 pom.xml 文件),但由于某种原因,这不起作用。如果需要其他信息,请告诉我。
我不确定它是否有帮助,但我更改了测试(在线搜索其他测试方法)但遇到了同样的问题(测试 运行 用 'run as junit test' 没问题但在调用 maven install 时失败):
@PropertyFile("\config\testconfig.properties")
@RunWith(EJBContainerRunner.class)
public class AdminDummyTest extends TestCase {
@TestResource
private Context context;
@EJB
IBasicConfigDao basicDaoConfig;
@Override
protected void setUp() throws NamingException, IOException {
basicDaoConfig = (IBasicConfigDao) context.lookup("java:global/Base_Admin/BasicConfigDao");
}
@Test
public void testGetDataFromDatabase() throws NamingException {
BasicConfig bs = basicDaoConfig.getFirst();
assertEquals("BIZ", bs.getType());
assertEquals("Description", bs.getValue());
}
}
我猜你的类路径搞砸了(tomee 1.6 应该使用 openejb 4.6 或 tomee 1.7 和 openejb 1.7)。确保 tomee/openejb 如前所述对齐,您应该解决此问题。