cancel
Showing results for 
Search instead for 
Did you mean: 

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

Former Member
0 Kudos

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)

Accepted Solutions (0)

Answers (1)

Answers (1)

Former Member
0 Kudos

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