Skip to Content
0
Former Member
Apr 28, 2005 at 10:57 AM

problems connecting to SAP DB from BMP EJB

16 Views

Hello,

i wrote an BMP EJB (MyAccountBean), which should connect to the table TMP_ACCOUNT in the SAP DB but i am getting the exception:

com.sap.engine.services.jndi.persistent.exceptions.NameNotFoundException: Path to object does not exist at : java:comp

I created the new table through an sda file that i successfully deployed (i have checked if this table exists with the sql studio).

I create a data-source-aliases.xml in the EAR Project:

<aliases>

<data-source-name>${com.sap.datasource.default}</data-source-name>

<alias>ACCOUNT</alias>

</aliases>

</data-source-aliases>

I defined in the ejb-jar.xml a reference to ACCOUNT:

<enterprise-beans>

<entity>

<ejb-name>MyAccountBean</ejb-name>

<home>account.MyAccountHome</home>

<remote>account.MyAccount</remote>

<local-home>account.MyAccountLocalHome</local-home>

<local>account.MyAccountLocal</local>

<ejb-class>account.MyAccountBean</ejb-class>

<persistence-type>Bean</persistence-type>

<prim-key-class>account.AccountPK</prim-key-class>

<reentrant>False</reentrant>

<resource-ref>

<res-ref-name>ACCOUNT</res-ref-name>

<res-type>javax.sql.DataSource</res-type>

<res-auth>Container</res-auth>

<res-sharing-scope>Shareable</res-sharing- scope>

</resource-ref>

</entity>

</enterprise-beans>

<assembly-descriptor>

<container-transaction>

<method>

<ejb-name>MyAccountBean</ejb-name>

<method-intf>Remote</method-intf>

<method-name>*</method-name>

</method>

<trans-attribute>Required</trans-attribute>

</container-transaction>

</assembly-descriptor>

I created an alias with the Visual Administrator under the topic JDBC: ACCOUNT (deployer: SAP J2EDB DataSource) and i create the connection to the database from MyAccountEJB with:

javax.sql.DataSource ds =

(javax.sql.DataSource) ctx.lookup("java:comp/env/jdbc/ACCOUNT");

The client application initialize the context in this way:

Properties p = new Properties();

p.put(Context.INITIAL_CONTEXT_FACTORY, "com.sap.engine.services.jndi.InitialContextFactoryImpl");

p.put(Context.PROVIDER_URL, "localhost:50004");

p.put(Context.SECURITY_PRINCIPAL, <login>);

p.put(Context.SECURITY_CREDENTIALS, <password>);

could you please help me to know what i am doing wrong?.

Thanks,

SAPLernen