[jboss-user] [JBoss Seam] - Testing without EJB
jcruise
do-not-reply at jboss.com
Fri May 25 20:08:00 EDT 2007
Hi
Does anybody know how to bootstrap the microcontainer in a test class or console app? I am using pojo/hibernate/tomcat so I don't want to use the embedded ejb-3. I tried simply extending SeamTest, using code a bit like this:
| public class Administration extends SeamTest {
|
| EntityManager em() {
| EntityManagerFactory emf = Persistence
| .createEntityManagerFactory("myDatabase");
| EntityManager em = emf.createEntityManager();
| return em;
| }
|
| public static void main(String[] args) throws Exception {
| Administration app = new Administration();
| app.execute();
| }
|
| private void execute() throws Exception {
|
| EntityManager em = em();
|
| em.getTransaction().begin();
|
| Log log = (Log) getInstance("log");
| log.info("Starting Administration Console");
|
|
| ... stuff with my components ...
|
|
| em.getTransaction().commit();
| }
|
but I get the following error:
| 15:55:15,967 ERROR [NamingHelper] Could not obtain initial context
| javax.naming.NamingException: Local server is not initialized
| at org.jnp.interfaces.LocalOnlyContextFactory.getInitialContext(LocalOnlyContextFactory.java:30)
| at javax.naming.spi.NamingManager.getInitialContext(Unknown Source)
| at javax.naming.InitialContext.getDefaultInitCtx(Unknown Source)
| at javax.naming.InitialContext.init(Unknown Source)
| at javax.naming.InitialContext.<init>(Unknown Source)
| at org.hibernate.util.NamingHelper.getInitialContext(NamingHelper.java:28)
|
Any ideas?
Cheers
J
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4048807#4048807
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4048807
More information about the jboss-user
mailing list