File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes BEA/Weblogic and the fly likes Data Source and JNDI problem Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Products » BEA/Weblogic
Bookmark "Data Source and JNDI problem" Watch "Data Source and JNDI problem" New topic
Author

Data Source and JNDI problem

Gurpreet Saini
Ranch Hand

Joined: Jun 09, 2002
Posts: 295
Hi reader,
I am getting following error:
Unable to deploy EJB: CabinBean from cabin.jar:
The DataSource with the JNDI name: C:\\Program Files\Common Files\ODBC\Data Sour
ces\cabin.dsn could not be located. Please ensure that the DataSource has been deployed successfully and that the JNDI name in your EJB Deployment descriptor is correct.
I want to use CMP services and for that I had created a data source whose name is cabin.dsn and is located in the above said path but still after that I am getting the above said error. My JNDI path is fully qualified my CabinHome.class file is in cabin directory. I had written in the following way in my DD : <jndi-name>cabin-CabinHome</jndi-name>
Please tell me where I am wrong ?.
Waiting for your response.
thank you,
Chris Mathews
Ranch Hand

Joined: Jul 18, 2001
Posts: 2712
You need a JDBC Datasource in WebLogic, which can be created using the WebLogic Console. The CMP bean is expecting the JNDI name of this Datasource.
See this link on Datasources: Overview of Datasources.
Gurpreet Saini
Ranch Hand

Joined: Jun 09, 2002
Posts: 295
Hi chris,
According to your instructions I had created DataSource as well as Connection pool in administrative console. But I am getting the error:Unable to deploy EJB: CabinBean from cabin.jar:
The DataSource with the JNDI name: cabinPool could not be located. Please ensure
that the DataSource has been deployed successfully and that the JNDI name in yo
ur EJB Deployment descriptor is correct.
I am using MsAccess 2000 and the name of table is cabin the odbc driver name is also cabin but the name of database is db1.
I copy paste the connection pool data which I had created:
Name: cabinPool
URL: jdbc dbc:cabin
Driver Classname: sun.jdbc.odbc.JdbcOdbcDriver
Properties
(key=value): user=none
password=none
ACLName:
Password: change...
Open String Password: change...
Here , I copy paste Data Source elements:
Name: TxSource
JNDI Name: togetherPool
Pool Name: cabinPool
Enable Two-Phase Commit
Row Prefetch Enabled
Row Prefetch Size: 48
Stream Chunk Size: 256 bytes
Now I copy paste my weblogic-cmp-rdbms-jar xml file:
<!DOCTYPE weblogic-rdbms-jar PUBLIC
'-//BEA Systems, Inc.//DTD WebLogic 6.0.0 EJB RDBMS Persistence//EN'
'C://Sun/weblogic/ejb20/cmp/rdbms/weblogic-rdbms20-persistence-600.dtd'>
<weblogic-rdbms-jar>
<weblogic-rdbms-bean>
<ejb-name>CabinBean</ejb-name>
<data-source-name>cabinPool</data-source-name>
<table-name>Cabin</table-name>
<field-map>
<cmp-field>id</cmp-field>
<dbms-column>ID</dbms-column>
</field-map>
<field-map>
<cmp-field>ship</cmp-field>
<dbms-column>SHIP_ID</dbms-column>
</field-map>
<field-map>
<cmp-field>bedCount</cmp-field>
<dbms-column>BED_COUNT</dbms-column>
</field-map>
<field-map>
<cmp-field>name</cmp-field>
<dbms-column>NAME</dbms-column>
</field-map>
<field-map>
<cmp-field>deckLevel</cmp-field>
<dbms-column>DECK_LEVEL</dbms-column>
</field-map>
</weblogic-rdbms-bean>
<create-default-dbms-tables>True</create-default-dbms-tables>
</weblogic-rdbms-jar>

Here, Is the copy paste of weblogic-ejb-jar.xml:
<!DOCTYPE weblogic-ejb-jar PUBLIC "-//BEA Systems, Inc.//DTD WebLogic 6.0.0 EJB//EN" "C://Sun/weblogic/ejb20/dd/xml/weblogic600-ejb-jar.dtd">
<weblogic-ejb-jar>
<weblogic-enterprise-bean>
<ejb-name>CabinBean</ejb-name>
<entity-descriptor>
<persistence>
<persistence-type>
<type-identifier>WebLogic_CMP_RDBMS</type-identifier>
<type-version>6.0</type-version>
<type-storage>META-INF/weblogic-cmp-rdbms-jar.xml</type-storage>
</persistence-type>
<persistence-use>
<type-identifier>WebLogic_CMP_RDBMS</type-Identifier>
<type-version>6.0</type-version>
</persistence-use>
</persistence>
</entity-descriptor>

<jndi-name>cabin.CabinHome</jndi-name>
</weblogic-enterprise-bean>

</weblogic-ejb-jar>
Please, tell me where is the actual problem. Also tell me that in my DD is my jndi-name and data-source-name elements are ok or not ?.
thank you
Chris Mathews
Ranch Hand

Joined: Jul 18, 2001
Posts: 2712
You need to give your CMP the JNDI Name of the Datasource, which in your case is togetherPool not cabinPool.
Gurpreet Saini
Ranch Hand

Joined: Jun 09, 2002
Posts: 295
Hi chris,
Though I had successfuly deployed the bean but when I run the client program then it gives me the following exception at run time:

javax.naming.NameNotFoundException: Unable to resolve 'CabinHome' Resolved: '' U
nresolved:'CabinHome' ; remaining name 'CabinHome'
at weblogic.rmi.internal.BasicOutboundRequest.sendReceive(BasicOutboundR
equest.java:85)
at weblogic.rmi.cluster.ReplicaAwareRemoteRef.invoke(ReplicaAwareRemoteR
ef.java:263)
at weblogic.rmi.cluster.ReplicaAwareRemoteRef.invoke(ReplicaAwareRemoteR
ef.java:230)
at weblogic.rmi.internal.ProxyStub.invoke(ProxyStub.java:35)
at $Proxy0.lookup(Unknown Source)
at weblogic.jndi.internal.WLContextImpl.lookup(WLContextImpl.java:342)
at javax.naming.InitialContext.lookup(InitialContext.java:350)
at Client.main(Client.java:19)
What could be the possible problem with JNDI ?. From specifications I read that this exception occurs when component is not bounded.
Tell me how can I rectify this problem.
Chris Mathews
Ranch Hand

Joined: Jul 18, 2001
Posts: 2712
In the descriptor the JNDI Name of your ejb is cabin.CabinHome. Either change the client to use cabin.CabinHome or switch the JNDI name in the descriptor to just CabinHome.
Rama Raghavan
Ranch Hand

Joined: Aug 22, 2001
Posts: 116
Do you see the object bound to the JNDI tree..?
Check if you are using the same name that you see when you view JNDI tree.
Gurpreet Saini
Ranch Hand

Joined: Jun 09, 2002
Posts: 295
Hi chris
I did exactly what you said to do. I got the desired output on my dos console. It was very enjoying. But when I restarted the weblogic server again it give me the following error plus the I again had to deploy the bean:
Unable to deploy EJB: cabinBean from cabin.jar:
weblogic.common.ConnectDeadException: failed to make new pool connection: webloic.common.ResourceException:
Could not create pool connection. The DBMS driver exception was:
java.sql.SQLException: [Microsoft][ODBC Driver Manager] Data source name not fo
nd and no default driver specified
at sun.jdbc.odbc.JdbcOdbc.createSQLException(JdbcOdbc.java:6026)
at sun.jdbc.odbc.JdbcOdbc.standardError(JdbcOdbc.java:6183)
at sun.jdbc.odbc.JdbcOdbc.SQLDriverConnect(JdbcOdbc.java:2453)
at sun.jdbc.odbc.JdbcOdbcConnection.initialize(JdbcOdbcConnection.java:
15)
at sun.jdbc.odbc.JdbcOdbcDriver.connect(JdbcOdbcDriver.java:158)
Apart from this error it sometimes also says error with Datasource with the JNDI name: data could not be located ?.
Please tell me what shall I write in data-source-name element. For your idea I copy paste the weblogic-cmp-rdbms-jar.xml file.
<!DOCTYPE weblogic-rdbms-jar PUBLIC
'-//BEA Systems, Inc.//DTD WebLogic 6.0.0 EJB RDBMS Persistence//EN'
'C://Sun/weblogic/ejb20/cmp/rdbms/weblogic-rdbms20-persistence-600.dtd'>
<weblogic-rdbms-jar>
<weblogic-rdbms-bean>
<ejb-name>cabinBean</ejb-name>
<data-source-name>data</data-source-name>
<table-name>Cabin</table-name>
<field-map>
<cmp-field>id</cmp-field>
<dbms-column>ID</dbms-column>
</field-map>
<field-map>
<cmp-field>ship</cmp-field>
<dbms-column>SHIP_ID</dbms-column>
</field-map>
<field-map>
<cmp-field>bedCount</cmp-field>
<dbms-column>BED_COUNT</dbms-column>
</field-map>
<field-map>
<cmp-field>name</cmp-field>
<dbms-column>NAME</dbms-column>
</field-map>
<field-map>
<cmp-field>deckLevel</cmp-field>
<dbms-column>DECK_LEVEL</dbms-column>
</field-map>
</weblogic-rdbms-bean>
<create-default-dbms-tables>True</create-default-dbms-tables>
</weblogic-rdbms-jar>
I had created a data ODBC driver in sun directory of my Hard disk. Whiich has the access to my MsAccess database. Please also tell me whether I had to mention JNDI name in administrative control of Data Source the same as the name of my data which is the ODBC driver or something else ?.
thank you,
 
Consider Paul's rocket mass heater.
 
subject: Data Source and JNDI problem
 
Similar Threads
DataSource Error and Connection Pool Settings(URGENT)
Help needed
datasource and connectionpool problem :weblogic6.1 and oracle8.1.5.0
Unable to deploy cmp bean
Error with creation of data source