tomee-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Andreas Karalus <>
Subject Re: "Local server is not initialized"
Date Wed, 10 Sep 2008 09:01:21 GMT

Here is a simple example to show that the lookup is failing. 
The class is the testclass from openejb jpa-hibernate example. I added a new
test2 method to simulate behaviour. 

package org.superbiz.injection.h3jpa;

import junit.framework.TestCase;

import javax.naming.Context;
import javax.naming.InitialContext;
import java.util.Properties;
import java.util.List;

import org.superbiz.injection.h3jpa.Movie;
import org.superbiz.injection.h3jpa.Movies;

 * @version $Revision: 607077 $ $Date: 2007-12-27 06:55:23 -0800 (Thu, 27
Dec 2007) $
public class MoviesTest extends TestCase {

    public void test() throws Exception {
        Properties p = new Properties();
        p.put("movieDatabase", "new://Resource?type=DataSource");
        p.put("movieDatabase.JdbcDriver", "org.hsqldb.jdbcDriver");
        p.put("movieDatabase.JdbcUrl", "jdbc:hsqldb:mem:moviedb");

        p.put("movieDatabaseUnmanaged", "new://Resource?type=DataSource");
        p.put("movieDatabaseUnmanaged.JdbcDriver", "org.hsqldb.jdbcDriver");
        p.put("movieDatabaseUnmanaged.JdbcUrl", "jdbc:hsqldb:mem:moviedb");
        p.put("movieDatabaseUnmanaged.JtaManaged", "false");

        Context context = new InitialContext(p);

        Movies movies = (Movies) context.lookup("MoviesLocal");

        movies.addMovie(new Movie("Quentin Tarantino", "Reservoir Dogs",
        movies.addMovie(new Movie("Joel Coen", "Fargo", 1996));
        movies.addMovie(new Movie("Joel Coen", "The Big Lebowski", 1998));

        List<Movie> list = movies.getMovies();
        assertEquals("List.size()", 3, list.size());

        for (Movie movie : list) {

        assertEquals("Movies.getMovies()", 0, movies.getMovies().size());
     * this method simulates a call in production code, 
     * with a bean lookup from a normal "POJO" class 
     * @throws Exception
    public void test2() throws Exception{
    	// this call unfortunately fails.
    	// question is how can we instantiate another initalContext while
openejb is running, whithout touching production code? 
    	InitialContext context = new InitialContext();
    	Movies movies = (Movies) context.lookup("MoviesLocal");
View this message in context:
Sent from the OpenEJB User mailing list archive at

View raw message