Ungureanu Adrian
Ungureanu Adrian

Reputation: 155

Tomee maven install goal sends: Could not initialize class org.apache.openejb.util.JuliLogStreamFactory

I have the following class that has one integration test:

@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());
}

}

When I run this test by right clicking the test class and selecting run as junit test in eclipse the test works fine but when I run the maven install goal (which runs the test also ) I get the following stacktrace:

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$1.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)

I searched this error online but couldn't solve the problem. I'm using Tomee 1.7.0 plus as EJB container. I'll note below the pom of the project:

<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>

I know that JuliLogStreamFactory is in the openejb-core package and I have added that package with 'test' scope (see pom.xml file) but for some reason this does not work. If other information is needed please tell me.


I'm not sure if it will help but I changed the test (searched online for other methods to test) but have reached the same problem (the test runs fine with 'run as junit test' but fails when calling 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());
    }
}

Upvotes: 0

Views: 1241

Answers (1)

Romain Manni-Bucau
Romain Manni-Bucau

Reputation: 3422

I guess your classpath is messed up (tomee 1.6 should use openejb 4.6 or tomee 1.7 with openejb 1.7). Ensure tomee/openejb are aligned as explained previously and you should get rid of this issue.

Upvotes: 1

Related Questions