Yes to get to the comp environment you need to be using the Context supplied
by calling new InitialContext() within the bean. There was another post
concerning this a while back. If you are creating a Context in some other
fashion then this is probably the problem.
-----Original Message-----
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED]]On Behalf Of Jonathan
Ackerman
Sent: Tuesday, March 20, 2001 11:13 PM
To: '[EMAIL PROTECTED]'
Subject: RE: [JBoss-user] Datasource woes
Very strange...
The error message means that it cannot find the "comp" level in the JNDI
path you specified. Since this should always exist it makes me suspect the
look up code.
In the code I'm working with I just use the default context supplied by the
container for doing JNDI lookups with. Something like:
......
try
{
dataSource = (DataSource) new
InitialContext().lookup("java:comp/env/jdbc/PatDS");
}
catch(NamingException e)
{
throw new EJBException("Datasource not found !");
}
.....
Try that and see what happens....
Jonathan
-----Original Message-----
From: Jeff Markham [mailto:[EMAIL PROTECTED]]
Sent: Wednesday, 21 March 2001 3:26 p.m.
To: [EMAIL PROTECTED]
Subject: RE: [JBoss-user] Datasource woes
I dunno. I changed my jboss.xml to:
<jboss>
<resource-managers>
<resource-manager res-class="org.jboss.ejb.deployment.JDBCResource">
<res-name>jdbc/pfiProduction</res-name>
<res-jndi-name>java:/jdbc/pfiProduction</res-jndi-name>
</resource-manager>
</resource-managers>
<enterprise-beans>
<entity>
<ejb-name>SystemCodeTypeManager</ejb-name>
<jndi-name>SystemCodeTypeManager</jndi-name>
<resource-ref>
<res-ref-name>jdbc/pfiProduction</res-ref-name>
<resource-name>jdbc/pfiProduction</resource-name>
</resource-ref>
</entity>
</enterprise-beans>
</jboss>
and I'm gettin' the identical exception even after restarting jBoss.
-----Original Message-----
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED]]On Behalf Of Jonathan
Ackerman
Sent: Tuesday, March 20, 2001 7:51 PM
To: '[EMAIL PROTECTED]'
Subject: RE: [JBoss-user] Datasource woes
You are missing the bit in your jboss.xml file that maps your bean's
resource ref to your resource manager.
This should look a bit like this:
<entity>
.....
<resource-ref>
<res-ref-name>jdbc/pfiProduction</res-ref-name>
<resource-name>jdbc/pfiProduction</resource-name>
</resource-ref>
......
</entity>
Also your <res-jndi-name> should map to the JNDI name for your Datasource.
You will see this info displayed when you start up JBoss and it initialises
the pool. In your case I think it should be "java:/jdbc/pfiProduction".
The trick is:
1) EJB declares a resource ref to a Datasource in ejb-jar.xml. The name for
this normally starts with "jdbc/" i.e. "jdbc/pfiProduction". Your bean can
then do a lookup for "java:comp/env/jdbc/pfiProduction" in its code to get
the Datasource
2) In jboss.xml you flesh out the EJB's resource ref, by tying the reference
declared in ejb-jar.xml to a JBoss resource manager's name
3) Also in jboss.xml you declare a resource manager that is tied to the JNDI
name for your Datasource. The name of the resource manager is the one that
you used in step two.
Hope this helps
Jonathan
-----Original Message-----
From: Jeff Markham [mailto:[EMAIL PROTECTED]]
Sent: Wednesday, 21 March 2001 12:05 p.m.
To: [EMAIL PROTECTED]
Subject: [JBoss-user] Datasource woes
I don't think I know the black magic necessary to get a simple datasource.
(Judging by the list, I don't think I'm alone). Can somebody tell me what
the incantation is please? Here's my stuff:
jBoss 2.1 (CVS 3/13/01)
PostgreSQL 7.0.3
My jboss.jcml:
. . .
<mbean code="org.jboss.jdbc.JdbcProvider"
name="DefaultDomain:service=JdbcProvider">
<attribute name="Drivers">org.postgresql.Driver</attribute>
</mbean>
<mbean code="org.jboss.jdbc.XADataSourceLoader"
name="DefaultDomain:service=XADataSource,name=jdbc/pfiProduction">
<attribute name="PoolName">jdbc/pfiProduction</attribute>
<attribute
name="DataSourceClass">org.opentools.minerva.jdbc.xa.wrapper.XADataSourceImp
l</attribute>
<attribute name="Properties"></attribute>
<!--attribute
name="URL">jdbc:interbase://localhost/C:/appserver/database/pfi.gdb</attribu
te-->
<attribute name="URL">jdbc:postgresql://localhost/pfi</attribute>
<attribute name="JDBCUser">pfinet</attribute>
<attribute name="Password">pfinet</attribute>
</mbean>
My ejb-jar.xml
. . .
<entity>
<description></description>
<ejb-name>SystemCodeTypeManager</ejb-name>
<home>com.pfi.sys.SystemCodeTypeManagerHome</home>
<remote>com.pfi.sys.SystemCodeTypeManager</remote>
<ejb-class>com.pfi.sys.SystemCodeTypeManagerEJB</ejb-class>
<persistence-type>Bean</persistence-type>
<prim-key-class>com.pfi.sys.SystemCodeTypePK</prim-key-class>
<reentrant>False</reentrant>
<resource-ref>
<res-ref-name>jdbc/pfiProduction</res-ref-name>
<res-type>javax.sql.DataSource</res-type>
<res-auth>Container</res-auth>
</resource-ref>
</entity>
My jboss.xml:
<jboss>
<resource-managers>
<resource-manager>
<res-name>jdbc/pfiProduction</res-name>
<res-jndi-name>jdbc/pfiProduction</res-jndi-name>
</resource-manager>
</resource-managers>
</jboss>
My BMP code:
. . .
Properties p = new Properties();
p.setProperty("java.naming.factory.initial","org.jnp.interfaces.NamingContex
tFactory");
p.setProperty("java.naming.provider.url","localhost");
p.setProperty("java.naming.factory.url.pkgs","org.jboss.naming;");
InitialContext initial = new InitialContext(p);
DataSource ds =
(DataSource)initial.lookup("java:comp/env/jdbc/pfiProduction");
return ds.getConnection();
. . .
my error:
[SystemCodeTypeManager] javax.naming.NameNotFoundException: comp not bound
_______________________________________________
JBoss-user mailing list
[EMAIL PROTECTED]
http://lists.sourceforge.net/lists/listinfo/jboss-user
_______________________________________________
JBoss-user mailing list
[EMAIL PROTECTED]
http://lists.sourceforge.net/lists/listinfo/jboss-user
_______________________________________________
JBoss-user mailing list
[EMAIL PROTECTED]
http://lists.sourceforge.net/lists/listinfo/jboss-user
_______________________________________________
JBoss-user mailing list
[EMAIL PROTECTED]
http://lists.sourceforge.net/lists/listinfo/jboss-user
_______________________________________________
JBoss-user mailing list
[EMAIL PROTECTED]
http://lists.sourceforge.net/lists/listinfo/jboss-user