Solved

not able to connect database in jdeveloper

Posted on 2004-10-26
329 Views
Last Modified: 2008-01-09
I created jpr's for web and EJB's in Jdeveloper;



for EJB this is ejb-jar.xml file

<?xml version="1.0" encoding="UTF-8"?>

<!DOCTYPE ejb-jar PUBLIC '-//Sun Microsystems, Inc.//DTD Enterprise JavaBeans 2.0//EN' 'http://java.sun.com/dtd/ejb-jar_2_0.dtd'>

<ejb-jar>
  <description>No Description</description>
  <display-name>EJB</display-name>
  <small-icon />
  <large-icon />
  <enterprise-beans>
    <session>
      <description>No Description</description>
      <display-name>ESupplyUtilitiesSessionBean</display-name>
      <ejb-name>ESupplyUtilitiesSessionBean</ejb-name>
      <home>com.foursoft.esupply.common.ejb.sls.ESupplyUtilitiesSessionHome</home>
      <remote>com.foursoft.esupply.common.ejb.sls.ESupplyUtilitiesSession</remote>
      <ejb-class>com.foursoft.esupply.common.ejb.sls.ESupplyUtilitiesSessionBean</ejb-class>
      <session-type>Stateless</session-type>
      <transaction-type>Container</transaction-type>
      <resource-ref>
      <description>No Description</description>
      <res-ref-name>jdbc/DB</res-ref-name>
      <res-type>javax.sql.DataSource</res-type>
      <res-auth>Container</res-auth>
      
      </resource-ref>
    </session>
  </enterprise-beans>
</ejb-jar>

orion-ejb-jar.xml

<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE orion-ejb-jar PUBLIC "-//Evermind//DTD Enterprise JavaBeans 1.1 runtime//EN" "http://xmlns.oracle.com/ias/dtds/orion-ejb-jar.dtd">

<orion-ejb-jar deployment-version="9.0.2.0.0" deployment-time="f862b45653">
      <enterprise-beans>
            <session-deployment name="ConsolSessionBean" max-instances="10" location="ConsolSessionBean" >
                  <resource-ref-mapping name="jdbc/DB" location="oraclePool" />
            </session-deployment>
            <session-deployment name="ETCustomerContractSessionBean" max-instances="10" location="ETCustomerContractSessionBean" >
                  <resource-ref-mapping name="jdbc/DB" location="oraclePool" />
            </session-deployment>
            <session-deployment name="ETransGatewaySetupSessionBean" max-instances="10" location="ETransGatewaySetupSessionBean" >
                  <resource-ref-mapping name="jdbc/DB" location="oraclePool" />
            </session-deployment>
            <session-deployment name="QuoteSessionBean" max-instances="10" location="QuoteSessionBean" >
                  <resource-ref-mapping name="jdbc/DB" location="oraclePool" />
            </session-deployment>
            <session-deployment name="ETransHOSuperUserSetupSessionBean" max-instances="10" location="ETransHOSuperUserSetupSessionBean" >
                  <resource-ref-mapping name="jdbc/DB" location="oraclePool" />
            </session-deployment>
            <session-deployment name="ETransHOAdminSetupSessionBean" max-instances="10" location="ETransHOAdminSetupSessionBean" >
                  <resource-ref-mapping name="jdbc/DB" location="oraclePool" />
            </session-deployment>
            <session-deployment name="OceanTariffSessionBean" max-instances="10" location="OceanTariffSessionBean" >
                  <resource-ref-mapping name="jdbc/DB" location="oraclePool" />
            </session-deployment>
            <session-deployment name="ClausesSessionBean" max-instances="10" location="ClausesSessionBean" >
                  <resource-ref-mapping name="jdbc/DB" location="oraclePool" />
            </session-deployment>
            <session-deployment name="TaxEngineBean" max-instances="10" location="TaxEngineBean" >
                  <resource-ref-mapping name="jdbc/DB" location="oraclePool" />
            </session-deployment>
            <session-deployment name="ChargeMasterSessionBean" max-instances="10" location="ChargeMasterSessionBean" >
                  <resource-ref-mapping name="jdbc/DB" location="oraclePool" />
            </session-deployment>
            <session-deployment name="AccessControlSessionBean" max-instances="10" location="AccessControlSessionBean" >
                  <resource-ref-mapping name="jdbc/DB" location="oraclePool" />
            </session-deployment>
            <session-deployment name="UserRoleRegistrationSessionBean" max-instances="10" location="UserRoleRegistrationSessionBean" >
                  <resource-ref-mapping name="jdbc/DB" location="oraclePool" />
            </session-deployment>
            <session-deployment name="ESupplyUtilitiesSessionBean" max-instances="10" location="ESupplyUtilitiesSessionBean" >
                  <resource-ref-mapping name="jdbc/DB" location="oraclePool" />
            </session-deployment>
            <session-deployment name="MailerBean" max-instances="10" location="MailerBean" >
                  <resource-ref-mapping name="mail/MS" location="mailPool" />
            </session-deployment>
            <session-deployment name="ETSSetupSessionBean" max-instances="10" location="ETSSetupSessionBean" >
                  <resource-ref-mapping name="jdbc/DB" location="oraclePool" />
            </session-deployment>
            <session-deployment name="ETDOSessionBean" max-instances="10" location="ETDOSessionBean" >
                  <resource-ref-mapping name="jdbc/DB" location="oraclePool" />
            </session-deployment>
            <session-deployment name="OIDSessionBean" max-instances="10" location="OIDSessionBean" >
                  <resource-ref-mapping name="jdbc/DB" location="oraclePool" />
            </session-deployment>
            <session-deployment name="CustomerReportSessionBean" max-instances="10" location="CustomerReportSessionBean" >
                  <resource-ref-mapping name="jdbc/DB" location="oraclePool" />
            </session-deployment>
            <session-deployment name="OperationalReportSessionBean" max-instances="10" location="OperationalReportSessionBean" >
                  <resource-ref-mapping name="jdbc/DB" location="oraclePool" />
            </session-deployment>
            <session-deployment name="TrackingSessionBean" max-instances="10" location="TrackingSessionBean" >
                  <resource-ref-mapping name="jdbc/DB" location="oraclePool" />
            </session-deployment>
            <session-deployment name="ShipmentEventsSessionBean" max-instances="10" location="ShipmentEventsSessionBean" >
                  <resource-ref-mapping name="jdbc/DB" location="oraclePool" />
            </session-deployment>
            <session-deployment name="GpsSetupSessionBean" max-instances="10" location="GpsSetupSessionBean" >
                  <resource-ref-mapping name="jdbc/DB" location="oraclePool" />
            </session-deployment>
            <session-deployment name="BeyondCostSessionBean" max-instances="10" location="BeyondCostSessionBean" >
                  <resource-ref-mapping name="jdbc/DB" location="oraclePool" />
            </session-deployment>
            <session-deployment name="BillingSessionBean" max-instances="10" location="BillingSessionBean" >
                  <resource-ref-mapping name="jdbc/DB" location="oraclePool" />
            </session-deployment>
            <session-deployment name="BookingSessionBean" max-instances="10" location="BookingSessionBean" >
                  <resource-ref-mapping name="jdbc/DB" location="oraclePool" />
            </session-deployment>
            <session-deployment name="BreakBulkSessionBean" max-instances="10" location="BreakBulkSessionBean" >
                  <resource-ref-mapping name="jdbc/DB" location="oraclePool" />
            </session-deployment>
            <session-deployment name="ProfilesSessionBean" max-instances="10" location="ProfilesSessionBean" >
                  <resource-ref-mapping name="jdbc/DB" location="oraclePool" />
            </session-deployment>
            <session-deployment name="ConsoleSessionBean" max-instances="10" location="ConsoleSessionBean" >
                  <resource-ref-mapping name="jdbc/DB" location="oraclePool" />
            </session-deployment>
            <session-deployment name="HBLSessionBean" max-instances="10" location="HBLSessionBean" >
                  <resource-ref-mapping name="jdbc/DB" location="oraclePool" />
            </session-deployment>
            <session-deployment name="ETSReportsSessionBean" max-instances="10" location="ETSReportsSessionBean" >
                  <resource-ref-mapping name="jdbc/DB" location="oraclePool" />
            </session-deployment>
            <session-deployment name="CustomerSessionBean" max-instances="10" location="CustomerSessionBean" >
                  <resource-ref-mapping name="jdbc/DB" location="oraclePool" />
            </session-deployment>
            <session-deployment name="VendorSessionBean" max-instances="10" location="VendorSessionBean" >
                  <resource-ref-mapping name="jdbc/DB" location="oraclePool" />
            </session-deployment>
            <session-deployment name="HouseDocumentSessionBean" max-instances="10" location="HouseDocumentSessionBean" >
                  <resource-ref-mapping name="jdbc/DB" location="oraclePool" />
            </session-deployment>
            <session-deployment name="MAWBSessionBean" max-instances="10" location="MAWBSessionBean" >
                  <resource-ref-mapping name="jdbc/DB" location="oraclePool" />
            </session-deployment>
            <session-deployment name="ETAReportsSessionBean" max-instances="10" location="ETAReportsSessionBean" >
                  <resource-ref-mapping name="jdbc/DB" location="oraclePool" />
            </session-deployment>
            <session-deployment name="ETUtilitiesSessionBean" max-instances="10" location="ETUtilitiesSessionBean" >
                  <resource-ref-mapping name="jdbc/DB" location="oraclePool" />
            </session-deployment>
            <session-deployment name="ETOperationUtilitiesSessionBean" max-instances="10" location="ETOperationUtilitiesSessionBean" >
                  <resource-ref-mapping name="jdbc/DB" location="oraclePool" />
            </session-deployment>
            <session-deployment name="HouseSessionBean" max-instances="10" location="HouseSessionBean" >
                  <resource-ref-mapping name="jdbc/DB" location="oraclePool" />
            </session-deployment>
            <entity-deployment name="QuoteBean" max-instances="10" location="QuoteBean" >
                  <resource-ref-mapping name="jdbc/DB" location="oraclePool" />
            </entity-deployment>
            <entity-deployment name="OceanTariffBean" max-instances="10" location="OceanTariffBean" >
                  <resource-ref-mapping name="jdbc/DB" location="oraclePool" />
            </entity-deployment>
            <entity-deployment name="RoleMasterBean" max-instances="10" location="RoleMasterBean" >
                  <resource-ref-mapping name="jdbc/DB" location="oraclePool" />
            </entity-deployment>
            <entity-deployment name="UserMasterBean" max-instances="10" location="UserMasterBean" >
                  <resource-ref-mapping name="jdbc/DB" location="oraclePool" />
            </entity-deployment>
            <entity-deployment name="ConsoleEntityBean" max-instances="10" location="ConsoleEntityBean" >
                  <resource-ref-mapping name="jdbc/DB" location="oraclePool" />
            </entity-deployment>
            <entity-deployment name="HAWBEntityBean" max-instances="10" location="HAWBEntityBean" >
                  <resource-ref-mapping name="jdbc/DB" location="oraclePool" />
            </entity-deployment>
            <entity-deployment name="MAWBEntityBean" max-instances="10" location="MAWBEntityBean" >
                  <resource-ref-mapping name="jdbc/DB" location="oraclePool" />
            </entity-deployment>
            <entity-deployment name="HBLEntityBean" max-instances="10" location="HBLEntityBean" >
                  <resource-ref-mapping name="jdbc/DB" location="oraclePool" />
            </entity-deployment>
            <entity-deployment name="HouseEntityBean" max-instances="10" location="HouseEntityBean" >
                  <resource-ref-mapping name="jdbc/DB" location="oraclePool" />
            </entity-deployment>
            <entity-deployment name="BookingEntityBean" max-instances="10" location="BookingEntityBean" >
                  <resource-ref-mapping name="jdbc/DB" location="oraclePool" />
            </entity-deployment>
            <entity-deployment name="CustomerBean" max-instances="10" location="CustomerBean" >
                  <resource-ref-mapping name="jdbc/DB" location="oraclePool" />
            </entity-deployment>
            <entity-deployment name="VendorBean" max-instances="10" location="VendorBean" >
                  <resource-ref-mapping name="jdbc/DB" location="oraclePool" />
            </entity-deployment>
      </enterprise-beans>
      <assembly-descriptor>
            <default-method-access>
                  <security-role-mapping name="&lt;default-ejb-caller-role&gt;" impliesAll="true" />
            </default-method-access>
      </assembly-descriptor>
</orion-ejb-jar>

 ;i will run index.jsp from jdeveloper,this jsp will call  ejb file ;in jdeveloper on what name should i create the connection ?
0
Question by:chaitu chaitu
    1 Comment
     
    LVL 13

    Accepted Solution

    by:
    ok to call ur EJB from ur JSP do the following:

    1- open ur menu (tools --> Embedded OC4J server Preferences ) in the left tree select (Current work space (ur project name) ---> Datasources ) make sure their is a defined datasource with the proper DB connection parameters  and this datasource in the JNDI Names Tab the attribute "EJB Location" value is "oraclePool"

    2- in ur Web module create an ejb reference in ur web.xml as following:

    <ejb-ref>
          <ejb-ref-name>ejb/ESupplyUtilitiesSessionBean</ejb-ref-name>
          <ejb-ref-type>Session</ejb-ref-type>
          <home>com.foursoft.esupply.common.ejb.sls.ESupplyUtilitiesSessionHome</home>
          <remote>com.foursoft.esupply.common.ejb.sls.ESupplyUtilitiesSession</remote>
            <ejb-link>ESupplyUtilitiesSessionBean</ejb-link>
    </ejb-ref>


    3- in ur JSP do the following:
    import the packages javax.naming.* and ur EJB package and then write this sample code:

    Context initCtx;
    initCtx = new InitialContext();
    Object theHomeObject = initCtx.lookup("java:comp/env/ejb/ESupplyUtilitiesSessionBean");
    ESupplyUtilitiesSessionHome thehome= (ESupplyUtilitiesSessionHome ) javax.rmi.PortableRemoteObject.narrow(theHomeObject , ESupplyUtilitiesSessionHome.class);

    ESupplyUtilitiesSession theRemote= thehome.create();
    // Call the RJB Methods
    theRemote.foo()


    0

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    6 Surprising Benefits of Threat Intelligence

    All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

    Suggested Solutions

    Title # Comments Views Activity
    Hibernate 5.1: Is a way to get a connection 2 24
    java ^ examples 8 40
    modThree challenge 4 43
    post4 challenge 28 57
    Java had always been an easily readable and understandable language.  Some relatively recent changes in the language seem to be changing this pretty fast, and anyone that had not seen any Java code for the last 5 years will possibly have issues unde…
    Introduction This article is the first of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article explains our test automation goals. Then rationale is given for the tools we use to a…
    Viewers learn about the “while” loop and how to utilize it correctly in Java. Additionally, viewers begin exploring how to include conditional statements within a while loop and avoid an endless loop. Define While Loop: Basic Example: Explanatio…
    This theoretical tutorial explains exceptions, reasons for exceptions, different categories of exception and exception hierarchy.

    856 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    18 Experts available now in Live!

    Get 1:1 Help Now