0 Replies Latest reply on Sep 17, 2002 4:56 AM by svgkraju

    Jboss3.0.2, Oracle 8i connection

    svgkraju Newbie

      Hi I am using

      Jboss 3.0.2
      Oracle 8i
      JDeveloper 9.0.2
      Windows 2000 Workstation

      1) In Oracle 8i using SQL+ I have created a table like this:

      create table address (Name varchar(2) not null, Phone number(10) not null);
      No constraints. It created a table.
      The database SID is tools.

      2) In JDeveloper a new connection called "Ora" is created to access the table. This step is successful.

      3) Now in JDeveloper an EJB is created with Container-managed entity-beans with tables by selecting the "address" table. So, it has created AddressHome, AddressBean, Address, AddressPK, java files. I did't modify these files. Also in orian-ejb-jar.xml file I have seen the following xml tag.
      <entity-deployment name="Address" data-source="jdbc/OraDS" table="ADDRESS">
      Where "Ora" is connection name.

      4) Now created a Sample java client using "Connect to OC4J Embedded in JDeveloper" and tried to created the bean using the following command.
      address = addressHome.create("mohan", 5500412);

      It successfully added a row in the "address" table.

      5) Now I am trying to deploy this bean in JBoss3.0.2. For that I need to configure the connection between JBoss and Oracle.

      5.1) First I copied classes12.zip JBoss_Home\server\default\lib

      5.2) Added the following code to the login-config.xml file.
      <application-policy name = "OracleDbRealm">

      <login-module code = "org.jboss.resource.security.ConfiguredIdentityLoginModule" flag = "required">
      <module-option name = "principal">scott</module-option>
      <module-option name = "userName">scott</module-option>
      <module-option name = "password">tiger</module-option>
      <module-option name = "managedConnectionFactoryName">jboss.jca:service=LocalTxCM,name=OracleDS</module-option>
      </login-module>

      </application-policy>

      What name should be selected for the application-policy name in my case. Is it mandatory that OracleDbRealm should be used?

      5.3) Modified the oracle-service.xml file to provide the database specific properties. and copied to the Jboss_home\server\default\deploy

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

      <!-- ===================================================================== -->
      <!-- -->
      <!-- JBoss Server Configuration -->
      <!-- -->
      <!-- ===================================================================== -->



      <!-- ==================================================================== -->
      <!-- ConnectionManager setup for Oracle dbs -->
      <!-- Build jmx-api (build/build.sh all) and view for config documentation -->
      <!-- Thanks to Steven Coy -->
      <!-- ==================================================================== -->




      <!-- Include a login module configuration named OracleDbRealm.
      Update your login-conf.xml, here is an example for a
      ConfiguredIdentityLoginModule:

      <application-policy name = "OracleDbRealm">

      <login-module code = "org.jboss.resource.security.ConfiguredIdentityLoginModule" flag = "required">
      <module-option name = "principal">yourprincipal</module-option>
      <module-option name = "userName">yourusername</module-option>
      <module-option name = "password">yourpassword</module-option>
      <module-option name = "managedConnectionFactoryName">jboss.jca:service=LocalTxCM,name=OracleDS</module-option>
      </login-module>

      </application-policy>

      NOTE: the application-policy name attribute must match SecurityDomainJndiName, and the
      module-option name = "managedConnectionFactoryName"
      must match the object name of the ConnectionManager you are configuring here.
      -->

      <!--uncomment out this line if you are using the OracleDbRealm above
      -->
      OracleDbRealm

      <depends optional-attribute-name="ManagedConnectionFactoryName">
      <!--embedded mbean-->


      OracleDS



      <config-property name="ConnectionURL" type="java.lang.String">jdbc:oracle:thin:@svgk:1521:tools</config-property>
      <config-property name="DriverClass" type="java.lang.String">oracle.jdbc.driver.OracleDriver</config-property>
      <!--set these only if you want only default logins, not through JAAS -->
      <config-property name="UserName" type="java.lang.String">scott</config-property>
      <config-property name="Password" type="java.lang.String">tiger</config-property>




      <!--Below here are advanced properties -->
      <!--hack-->
      <depends optional-attribute-name="OldRarDeployment">jboss.jca:service=RARDeployment,name=JBoss LocalTransaction JDBC Wrapper



      <depends optional-attribute-name="ManagedConnectionPool">
      <!--embedded mbean-->


      0
      50
      5000
      15
      <!--criteria indicates if Subject (from security domain) or app supplied
      parameters (such as from getConnection(user, pw)) are used to distinguish
      connections in the pool. Choices are
      ByContainerAndApplication (use both),
      ByContainer (use Subject),
      ByApplication (use app supplied params only),
      ByNothing (all connections are equivalent, usually if adapter supports
      reauthentication)-->
      ByContainerAndApplication



      <depends optional-attribute-name="CachedConnectionManager">jboss.jca:service=CachedConnectionManager

      <depends optional-attribute-name="JaasSecurityManagerService">jboss.security:name=JaasSecurityManager

      java:/TransactionManager

      <!--make the rar deploy! hack till better deployment-->
      jboss.jca:service=RARDeployer






      Is this configuration correct?

      5.4) Modified the line in standardjbosscmp-jdbc to specify the default connection
      java:/DefaultDS
      to
      java:/OraDS

      Is this correct?

      5.5) Now to deploy the EJB I created another client in JDeveloper using "Connection to Remote App Server" option. Followed the steps given by otn.oracle.com to deploy EJB to JBoss. I have added the following line
      address = addressHome.create("raju", 5600412);

      5.6) Now I run the JBoss, I got the following message regarding oracle-service.xml

      13:22:04,214 INFO [MainDeployer] Starting deployment of package: file:/C:/jboss
      -3.0.2/server/default/deploy/oracle-service.xml
      13:22:04,314 WARN [ServiceController] jboss.jca:service=LocalTxDS,name=OracleDS
      does not implement any Service methods
      13:22:04,324 INFO [JBossManagedConnectionPool] Creating
      13:22:04,324 INFO [JBossManagedConnectionPool] Created
      13:22:04,324 INFO [LocalTxConnectionManager] Creating
      13:22:04,334 INFO [LocalTxConnectionManager] Created
      13:22:04,334 INFO [JBossManagedConnectionPool] Starting
      13:22:04,344 INFO [JBossManagedConnectionPool] Started
      13:22:04,344 INFO [LocalTxConnectionManager] Starting
      13:22:04,384 INFO [JaasSecurityManagerService] Created securityMgr=org.jboss.se
      curity.plugins.JaasSecurityManager@280
      13:22:04,394 INFO [JaasSecurityManagerService] setCachePolicy, c=org.jboss.util
      .TimedCachePolicy@281
      13:22:04,404 INFO [JaasSecurityManagerService] Added OracleDbRealm, org.jboss.s
      ecurity.plugins.SecurityDomainContext@282 to map
      13:22:04,444 INFO [OracleDS] Bound connection factory for resource adapter 'JBo
      ss LocalTransaction JDBC Wrapper' to JNDI name 'java:/OracleDS'
      13:22:04,454 INFO [LocalTxConnectionManager] Started
      13:22:04,454 INFO [MainDeployer] Deployed package: file:/C:/jboss-3.0.2/server/
      default/deploy/oracle-service.xml

      How do I know from these message whether JBoss is connected to the database correctly or not?

      5.7) After I copied the the created jar file into the deploy directory the following message has shown up.

      13:27:59,995 INFO [MainDeployer] Starting deployment of package: file:/C:/jboss
      -3.0.2/server/default/deploy/address.jar
      13:28:09,169 INFO [STDOUT] I am in equals
      13:28:09,179 INFO [EJBDeployer]
      Bean : Address
      Section: 9.2.9
      Warning: The primary key class must override equals().

      13:28:09,189 INFO [STDOUT] I am in hashCode
      13:28:09,189 INFO [STDOUT] I am in hashCode
      13:28:09,189 INFO [EJBDeployer]
      Bean : Address
      Section: 9.2.9
      Warning: The primary key class must override hashCode().

      13:28:09,209 INFO [EjbModule] Creating
      13:28:09,219 INFO [EjbModule] Deploying Address
      13:28:10,741 INFO [JDBCInitCommand] Created table 'Address' successfully.
      13:28:10,761 INFO [EjbModule] Created
      13:28:10,761 INFO [EjbModule] Starting
      13:28:10,811 INFO [EjbModule] Started
      13:28:10,821 INFO [MainDeployer] Deployed package: file:/C:/jboss-3.0.2/server/
      default/deploy/address.jar

      Do we have any problem witht the warning messages?

      5.8) Now when I run the 2nd client (i.e. remote ...) in JDeveloper I am getting the following error.

      C:\JDeveloper\jdk\bin\javaw.exe -ojvm -classpath D:\Documents and Settings\svgk\My Documents\JDeveloper\Test\Cmp\classes;C:\jboss-3.0.0_tomcat-4.0.3\client\concurrent.jar;C:\jboss-3.0.0_tomcat-4.0.3\client\gnu-regexp.jar;C:\jboss-3.0.0_tomcat-4.0.3\client\jaas.jar;C:\jboss-3.0.0_tomcat-4.0.3\client\jacorb.jar;C:\jboss-3.0.0_tomcat-4.0.3\client\jboss-client.jar;C:\jboss-3.0.0_tomcat-4.0.3\client\jboss-common-client.jar;C:\jboss-3.0.0_tomcat-4.0.3\client\jboss-iiop-client.jar;C:\jboss-3.0.0_tomcat-4.0.3\client\jboss-j2ee.jar;C:\jboss-3.0.0_tomcat-4.0.3\client\jboss-jsr77.jar;C:\jboss-3.0.0_tomcat-4.0.3\client\jboss-net-client.jar;C:\jboss-3.0.0_tomcat-4.0.3\client\jboss-system-client.jar;C:\jboss-3.0.0_tomcat-4.0.3\client\jbossha-client.jar;C:\jboss-3.0.0_tomcat-4.0.3\client\jbossmq-client.jar;C:\jboss-3.0.0_tomcat-4.0.3\client\jbossmqha.jar;C:\jboss-3.0.0_tomcat-4.0.3\client\jbosssx-client.jar;C:\jboss-3.0.0_tomcat-4.0.3\client\jcert.jar;C:\jboss-3.0.0_tomcat-4.0.3\client\jmx-connector-client-factory.jar;C:\jboss-3.0.0_tomcat-4.0.3\client\jmx-ejb-connector-client.jar;C:\jboss-3.0.0_tomcat-4.0.3\client\jmx-rmi-connector-client.jar;C:\jboss-3.0.0_tomcat-4.0.3\client\jnet.jar;C:\jboss-3.0.0_tomcat-4.0.3\client\jnp-client.jar;C:\jboss-3.0.0_tomcat-4.0.3\client\jsse.jar;C:\jboss-3.0.0_tomcat-4.0.3\client\log4j.jar;C:\JDeveloper\jdev\lib\jdev-rt.jar;C:\JDeveloper\lib\xmlparserv2.jar;C:\JDeveloper\lib\xmlcomp.jar -Dhttp.proxyHost=proxy.iidc.lucent.com -Dhttp.proxyPort=8000 Samplemypackage1.AddressClient2
      javax.ejb.DuplicateKeyException: Entity with key mypackage1.AddressPK@2e2 already exists

      void sun.rmi.transport.StreamRemoteCall.exceptionReceivedFromServer(java.lang.Exception)

      void sun.rmi.transport.StreamRemoteCall.executeCall()

      java.lang.Object sun.rmi.server.UnicastRef.invoke(java.rmi.Remote, java.lang.reflect.Method, java.lang.Object[], long)

      java.lang.Object org.jboss.invocation.jrmp.server.JRMPInvoker_Stub.invoke(org.jboss.invocation.Invocation)

      java.lang.Object org.jboss.invocation.jrmp.interfaces.JRMPInvokerProxy.invoke(org.jboss.invocation.Invocation)

      java.lang.Object org.jboss.invocation.InvokerInterceptor.invoke(org.jboss.invocation.Invocation)

      java.lang.Object org.jboss.proxy.TransactionInterceptor.invoke(org.jboss.invocation.Invocation)

      java.lang.Object org.jboss.proxy.SecurityInterceptor.invoke(org.jboss.invocation.Invocation)

      java.lang.Object org.jboss.proxy.ejb.HomeInterceptor.invoke(org.jboss.invocation.Invocation)

      java.lang.Object org.jboss.proxy.ClientContainer.invoke(java.lang.Object, java.lang.reflect.Method, java.lang.Object[])

      mypackage1.Address $Proxy0.create(java.lang.String, long)

      void Samplemypackage1.AddressClient2.main(java.lang.String[])

      I am not getting why this error is coming. No primary keys used in the table. Is my Oracle, Jboss connection proceduce correct? Pl. help me.

      regds
      -raju