[prev in list] [next in list] [prev in thread] [next in thread] 

List:       openejb-user
Subject:    Re: Test DataSource injection with EmbeddedTomEEContainer
From:       sgjava <sgjava () gmail ! com>
Date:       2015-12-08 16:14:48
Message-ID: 1449591288074-4677183.post () n4 ! nabble ! com
[Download RAW message or body]

This works:

    /**
     * Injected DataSource.
     */
    @Resource
    private DataSource testDs;

    /**
     * Set up. ${ehcache.listenerPort}
     *
     * @throws NamingException possible exception.
     */
    @Before
    public final void setUp() throws NamingException {
        log.info("setUp()");
        System.setProperty(Context.INITIAL_CONTEXT_FACTORY,
                "org.apache.openejb.core.LocalInitialContextFactory");
        System.setProperty("openejb.embedded.initialcontext.close ",
"DESTROY");
        System.setProperty("openejb.embedded.remotable", "true");
        System.setProperty("testDs", "new://Resource?type=DataSource");
        System.setProperty("testDs.JdbcDriver", "org.hsqldb.jdbcDriver");
        System.setProperty("testDs.JdbcUrl", "jdbc:hsqldb:mem:testdb");
        System.setProperty(EJBContainer.APP_NAME, "datasource-tomee");
        System.setProperty(EJBContainer.PROVIDER, "tomee-embedded");
        // Add WAR and MDB modules
        System.setProperty(EJBContainer.MODULES, new
File[]{Archive.archive().
            copyTo("WEB-INF/classes",
jarLocation(TestService.class)).asDir()}.
                toString());
        // Random port
       
System.setProperty(EmbeddedTomEEContainer.TOMEE_EJBCONTAINER_HTTP_PORT,
                "-1");
        container = EJBContainer.createEJBContainer();
        try {
            container.getContext().bind("inject", this);
        } catch (NamingException e) {
            log.severe(e.getMessage());
        }
    }





--
View this message in context: \
http://tomee-openejb.979440.n4.nabble.com/Test-DataSource-injection-with-EmbeddedTomEEContainer-tp4677167p4677183.html
 Sent from the TomEE Users mailing list archive at Nabble.com.


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic