Skip to Content
avatar image
Former Member

DAO pattern & Lookup datasource with NamingException in the same J2EE APP

Hello Experts:

I'm developing an J2EE application with EJB's for transactional operations (that works fine!) and I'm implementing the J2EE DAO Pattern using a DAO ConnectionFactory with OpenSQL/JDBC standard for Querying the DB, but here my problems begins:

The DAOConnectionFactory Singleton Class is placed in a java package inside the same application that holds my Entitys & Sessions (remember this ejb's works fine!) and I'm trying to get the "localy-configured-in-the-j2ee-application" alias-datasource for my DAO Querys, but "lookup" doesn't find this resource!!!.

I'm thinking, there's not remote access to this resouce because the DAO-CF is in the same context and JVM, but this appreciation is correct? or what I miss?

Another remark: I've been used the Telnet Administrator and the same lookup string is founded correctly!.

Here is the Codec:


public class ConexionFactory implements Serializable {
	private static ConexionFactory singleton = null;

	private DataSource ds;

	protected ConexionFactory() {
		String source = "jdbc/BURO_COMM";
		try {

			Context ctx = new InitialContext();
			ds = (DataSource) ctx.lookup(source);
			if (null == ds) {
				throw new RuntimeException("Couldn't get the datasource");
			}
		} catch (NameNotFoundException e) {
			throw new RuntimeException(e.getMessage());
		} catch (NamingException e) {
			throw new RuntimeException(e.getMessage());
		}

	}

	public static ConexionFactory getInstance() {

		if (null == singleton) {
			singleton = new ConexionFactory();
		}

		return singleton;
	}
.... (some other methods)

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

1 Answer

  • avatar image
    Former Member
    May 17, 2007 at 04:21 PM

    Hello all again:

    I've been making some tests (and investigation reading other posts) and I found that everything is related with the Resource Sharing Scope of my Session Object that commands the process. And it works fine.

    By now, for my conceptual test is Ok and finally i must work in this app arquitecure path:

    ->Web Service (with a POJO in a web module)

    -


    >ProcessRender Class (a POJO with the main control logic)

    -


    >BussinesDelegate's -->ServiceLocator

    -


    >SessionFacades --->Entity's

    -


    >DAO Connection Factory---->OpenSQL/JDBC Querys

    Add comment
    10|10000 characters needed characters exceeded