|
HI,
if u want to have a resource reference and use it in your
web
application, you should put hte resource reference in a file called
weblogic.xml (pls correct me if
i am
wrong, it worked with WLS 5.1).
If the
reference is used by an EJB, then it's fine to put it in ejb-xml.jar and
weblogic-ejb.jar, but
if u
are accessing that resource from a servlet etc, u should put it also in a
weblogic.xml file.
hope
this helps
br
marco
-----Original Message-----
From: ext kongtao [mailto:[EMAIL PROTECTED]] Sent: 26. August 2002 8:50 To: [EMAIL PROTECTED] Subject: I can't get the resource reference throught the <resource-ref> element! Hi All:
In my EJB ,I can't get a connection through the PoolConnection.Follwing is fragment of EntityBean/config.xml/ejb-jar.xml/weblogic-ejb-jar.xml.Pls help me! your help would be appreciated! In bean codes,The NullPointerException will be thrown when I invoke the getConnection method.Maybe I can find the JNDIName of DataSource .Why? -------java code--------
env.put(Context.PROVIDER_URL,"t3://localhost:80");
ctx=new InitialContext(env); ds=(DataSource)ctx.lookup("java:comp/env/jdbc/TXDataSource") --------config.xml-----
<JDBCConnectionPool
DriverName="com.microsoft.jdbc.sqlserver.SQLServerDriver" InitialCapacity="20" LoginDelaySeconds="1" MaxCapacity="50" naame="TestPool" URL="jdbc:microsoft:sqlserver://192.168.0.246:1433"/> -------web.xml-----
<resource-ref>
<description /> <res-ref-name>jdbc/TXDataSource</res-ref-name> <res-type>javax.sql.DataSource</res-type> <res-auth>Container</res-auth> </resource-ref> -------ejb-jar.xml-----
<entity>
<resource-ref> <description /> <res-ref-name>jdbc/TXDataSource</res-ref-name> <res-type>javax.sql.DataSource</res-type> <res-auth>Container</res-auth> </resource-ref> </entity> ------weblogic-ejb-jar.xml------------
<weblogic-enterprise-bean>
<ejb-name>StyleBean</ejb-name> <reference-descriptor> <resource-description> <res-ref-name>jdbc/TXDataSource</res-ref-name> <jndi-name>MyDataSource</jndi-name> </resource-description> </reference-descriptor> <jndi-name>StyleBean</jndi-name> </weblogic-enterprise-bean> ------------------------exception
fragment
java.lang.NullPointerException
at com.sabrina.ejb.StyleBean.getConnection(StyleBean.java:341) at com.sabrina.ejb.StyleBean.ejbCreate(StyleBean.java:55) at = com.sabrina.ejb.StyleBean_81hvkv_Impl.ejbCreate(StyleBean_81hvkv_Impl .............. |
