-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 
Author Message
 Post subject: JNDI problem "Could not locate SessionFactory in JNDI&q
PostPosted: Tue Oct 17, 2006 11:36 am 
Regular
Regular

Joined: Mon Oct 02, 2006 12:03 pm
Posts: 62
Hello, I've used Hibernate Plugin of Hibernate Tools Package. I've generated all correctly, but in main process:

Main.java
Code:
package com.gmsoft;

import com.gmsoft.model.Role;
import com.gmsoft.model.RoleHome;

public class Main {

   public static void main(String[] args) {
      // TODO Auto-generated method stub
      com.gmsoft.model.Role rol = new Role(60,"Hibernate");
      com.gmsoft.model.RoleHome rolDAO = new RoleHome();
      rolDAO.persist(rol);
   }
}


Quote:
17-oct-2006 17:29:07 com.gmsoft.model.RoleHome getSessionFactory
GRAVE: Could not locate SessionFactory in JNDI
javax.naming.NoInitialContextException: Need to specify class name in environment or system property, or as an applet parameter, or in an application resource file: java.naming.factory.initial
at javax.naming.spi.NamingManager.getInitialContext(Unknown Source)
at javax.naming.InitialContext.getDefaultInitCtx(Unknown Source)
at javax.naming.InitialContext.getURLOrDefaultInitCtx(Unknown Source)
at javax.naming.InitialContext.lookup(Unknown Source)
at com.gmsoft.model.RoleHome.getSessionFactory(RoleHome.java:27)
at com.gmsoft.model.RoleHome.<init>(RoleHome.java:22)
at com.gmsoft.Main.main(Main.java:14)
Exception in thread "main" java.lang.IllegalStateException: Could not locate SessionFactory in JNDI
at com.gmsoft.model.RoleHome.getSessionFactory(RoleHome.java:30)
at com.gmsoft.model.RoleHome.<init>(RoleHome.java:22)
at com.gmsoft.Main.main(Main.java:14)


Can you help me, please?

Thanks in advance.


Top
 Profile  
 
 Post subject:
PostPosted: Tue Oct 17, 2006 2:11 pm 
Senior
Senior

Joined: Tue Mar 09, 2004 2:38 pm
Posts: 141
Location: Lowell, MA USA
You don't seem to using an App server which would prevent you using JNDI. Your best bet would be to bind your session factory to a static variable.

Ryan-

_________________
Ryan J. McDonough
http://damnhandy.com

Please remember to rate!


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.