Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

JBoss with Oracle

 
Gurumurthy Ramamurthy
Ranch Hand
Posts: 273
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
I have done the following:
1. Created oracle-ds.xml in the .\server\default\deploy directory
The contents:
<datasources>
<local-tx-datasource>
<jndi-name>OraGuruDS</jndi-name>
<connection-url>jdbc racle:thin:@3.3.3.100:1521 RCL</connection-url>
<driver-class>oracle.jdbc.driver.OracleDriver</driver-class>
<user-name>scott</user-name>
<password>tiger</password>
<exception-sorter-class-name>org.jboss.resource.adapter.jdbc.vendor.OracleExceptionSorter</exception-sorter-class-name>
</local-tx-datasource>
</datasources>

2. Created ejb-jar.xml with the contents: in
<?xml version="1.0"?>
<!DOCTYPE ejb-jar PUBLIC "-//Sun Microsystems, Inc.//DTD Enterprise
JavaBeans 1.1//EN" "http://java.sun.com/dtd/ejb-jar_1_1.dtd">
<ejb-jar>
<enterprise-beans>
<entity>
<ejb-name>Products1</ejb-name>
<home>Products1.ProductHome</home>
<remote>Products1.Product</remote>
<ejb-class>Products1.ProductBean</ejb-class>
<persistence-type>Container</persistence-type>
<prim-key-class>Products1.ProductPK</prim-key-class>
<reentrant>False</reentrant>
<cmp-version>1.x</cmp-version>

<cmp-field>
<field-name>productID</field-name>
</cmp-field>
<cmp-field>
<field-name>name</field-name>
</cmp-field>
<cmp-field>
<field-name>description</field-name>
</cmp-field>
<cmp-field>
<field-name>basePrice</field-name>
</cmp-field>

<resource-ref >
<res-ref-name>OraGuruDS</res-ref-name>
<res-type>java.sql.DataSource</res-type>
<res-auth>Container</res-auth>
</resource-ref>
</entity>
</enterprise-beans>
</ejb-jar>
3. Created jboss.xml with the contents:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE jboss PUBLIC "-//JBoss//DTD JBOSS//EN" "http://www.jboss.org/j2ee/dtd/jboss.dtd">
<jboss>
<enterprise-beans>
<entity>
<ejb-name>Products1</ejb-name>
<jndi-name>Products1</jndi-name>
</entity>
</enterprise-beans>
</jboss>
4. Created jbosscmp-jdbc-oracle.xml with the contents:
<?xml version="1.0" encoding="UTF-8"?>

<!DOCTYPE jbosscmp-jdbc PUBLIC "-//JBoss//DTD JBOSSCMP-JDBC 3.0//EN" "http://www.jboss.org/j2ee/dtd/jbosscmp-jdbc_3_0.dtd">

<jbosscmp-jdbc>
<defaults>
<!--<datasource>java:/DefaultDS</datasource>-->
<!--<type-mapping>Hypersonic SQL</type-mapping>-->
<!--<datasource>java:/mySQLDS</datasource>-->

<datasource>java:/OraGuruDS</datasource>
<type-mapping>Oracle8</type-mapping>
<create-table>true</create-table>
<remove-table>false</remove-table>
<read-only>false</read-only>
<read-time-out>300</read-time-out>
<row-locking>false</row-locking>
<pk-constraint>true</pk-constraint>
<fk-constraint>false</fk-constraint>
<preferred-relation-mapping>foreign-key</preferred-relation-mapping>
<read-ahead>
<strategy>on-load</strategy>
<page-size>1000</page-size>
<eager-load-group>*</eager-load-group>
</read-ahead>
<list-cache-max>1000</list-cache-max>


</defaults>

<enterprise-beans>
<entity>
<ejb-name>Products1</ejb-name>
<table-name>Products1</table-name>
<cmp-field>
<field-name>productID</field-name>
<column-name>PRODUCTID</column-name>
</cmp-field>
<cmp-field>
<field-name>name</field-name>
<column-name>NAME</column-name>
</cmp-field>
<cmp-field>
<field-name>description</field-name>
<column-name>DESCRIPTION</column-name>
</cmp-field>
<cmp-field>
<field-name>basePrice</field-name>
<column-name>BASEPRICE</column-name>
</cmp-field>
</entity>
</enterprise-beans>
</jbosscmp-jdbc>
5. Now, I have created the .jar file out of these latest XML files and the class files.
6. I have deployed this .jar too...it is getting deployed.
7. Now, I run the client, I get the following error:
java ProductClient
---------------------
javax.ejb.CreateException: Could not create entity:java.lang.NullPointerExceptio
n
at org.jboss.ejb.plugins.jaws.jdbc.JDBCCreateEntityCommand.execute(JDBCC
reateEntityCommand.java:146)
at org.jboss.ejb.plugins.jaws.JAWSPersistenceManager.createEntity(JAWSPe
rsistenceManager.java:255)
at org.jboss.ejb.plugins.CMPPersistenceManager.createEntity(CMPPersisten
ceManager.java:225)
at org.jboss.resource.connectionmanager.CachedConnectionInterceptor.crea
teEntity(CachedConnectionInterceptor.java:270)
at org.jboss.ejb.EntityContainer.createHome(EntityContainer.java:725)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.
java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAcces
sorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:324)
at org.jboss.ejb.EntityContainer$ContainerInterceptor.invokeHome(EntityC
ontainer.java:998)
at org.jboss.ejb.plugins.EntitySynchronizationInterceptor.invokeHome(Ent
itySynchronizationInterceptor.java:188)
at org.jboss.resource.connectionmanager.CachedConnectionInterceptor.invo
keHome(CachedConnectionInterceptor.java:215)
at org.jboss.ejb.plugins.AbstractInterceptor.invokeHome(AbstractIntercep
tor.java:88)
at org.jboss.ejb.plugins.EntityInstanceInterceptor.invokeHome(EntityInst
anceInterceptor.java:91)
at org.jboss.ejb.plugins.EntityLockInterceptor.invokeHome(EntityLockInte
rceptor.java:61)
at org.jboss.ejb.plugins.EntityCreationInterceptor.invokeHome(EntityCrea
tionInterceptor.java:28)
at org.jboss.ejb.plugins.AbstractTxInterceptor.invokeNext(AbstractTxInte
rceptor.java:88)
at org.jboss.ejb.plugins.TxInterceptorCMT.runWithTransactions(TxIntercep
torCMT.java:243)
at org.jboss.ejb.plugins.TxInterceptorCMT.invokeHome(TxInterceptorCMT.ja
va:74)
at org.jboss.ejb.plugins.SecurityInterceptor.invokeHome(SecurityIntercep
tor.java:92)
at org.jboss.ejb.plugins.LogInterceptor.invokeHome(LogInterceptor.java:1
20)
at org.jboss.ejb.plugins.ProxyFactoryFinderInterceptor.invokeHome(ProxyF
actoryFinderInterceptor.java:93)
at org.jboss.ejb.EntityContainer.internalInvokeHome(EntityContainer.java
:477)
at org.jboss.ejb.Container.invoke(Container.java:694)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.
java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAcces
sorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:324)
at org.jboss.mx.capability.ReflectedMBeanDispatcher.invoke(ReflectedMBea
nDispatcher.java:284)
at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:549)
at org.jboss.invocation.jrmp.server.JRMPInvoker.invoke(JRMPInvoker.java:
359)
at sun.reflect.GeneratedMethodAccessor58.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAcces
sorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:324)
at sun.rmi.server.UnicastServerRef.dispatch(UnicastServerRef.java:261)
at sun.rmi.transport.Transport$1.run(Transport.java:148)
at java.security.AccessController.doPrivileged(Native Method)
at sun.rmi.transport.Transport.serviceCall(Transport.java:144)
at sun.rmi.transport.tcp.TCPTransport.handleMessages(TCPTransport.java:4
60)
at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run(TCPTransport
.java:701)
at java.lang.Thread.run(Thread.java:536)
at sun.rmi.transport.StreamRemoteCall.exceptionReceivedFromServer(Stream
RemoteCall.java:247)
at sun.rmi.transport.StreamRemoteCall.executeCall(StreamRemoteCall.java:
223)
at sun.rmi.server.UnicastRef.invoke(UnicastRef.java:133)
at org.jboss.invocation.jrmp.server.JRMPInvoker_Stub.invoke(Unknown Sour
ce)
at org.jboss.invocation.jrmp.interfaces.JRMPInvokerProxy.invoke(JRMPInvo
kerProxy.java:135)
at org.jboss.invocation.InvokerInterceptor.invoke(InvokerInterceptor.jav
a:87)
at org.jboss.proxy.TransactionInterceptor.invoke(TransactionInterceptor.
java:46)
at org.jboss.proxy.SecurityInterceptor.invoke(SecurityInterceptor.java:4
5)
at org.jboss.proxy.ejb.HomeInterceptor.invoke(HomeInterceptor.java:173)
at org.jboss.proxy.ClientContainer.invoke(ClientContainer.java:85)
at $Proxy0.create(Unknown Source)
at ProductClient.main(ProductClient.java:24)
Destroying products..
Can anyone you clarify?
Thanks,
Guru
 
norman richards
Author
Ranch Hand
Posts: 367
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Does this only happen with oracle and not other databases?
If you turn on DEBUG logging for this class (see log4j.xml) then you should see the internal exception being logged. That might clarify things. My suspicion is that it's a primary key thing. I notice you don't have a primkey-field. You might want to verify that you are mapping your key correctly.
 
Rashid Darvesh
Ranch Hand
Posts: 189
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi
I did hte same thing, but i get an error which says no resource manager found for java:/OraGuruDS
My bean is working fine. i can create and entity bean and retrieve it only in the application server but it doesn't get properly mapped to the database. below is the message which i am getting

16:02:16,631 WARN [EntityContainer] No resource manager found for java:/OraGurDS
16:02:16,834 INFO [Customer] Table 'CUSTOMER' already exists
16:02:16,834 INFO [EntityInstancePool] Started jboss.j2ee:jndiName=Customer,pl
gin=pool,service=EJB
16:02:16,849 INFO [EntityContainer] Started jboss.j2ee:jndiName=Customer,servi
e=EJB
16:02:16,849 INFO [EjbModule] Started jboss.j2ee:module=Customer.jar,service=E
bModule
16:02:16,849 INFO [EJBDeployer] Deployed: file:/C:/JBOSS/jboss-3.2.3/server/de
ault/deploy/Customer.jar
16:02:16,849 INFO [MainDeployer] Deployed package: file:/C:/JBOSS/jboss-3.2.3/
erver/default/deploy/Customer.jar

i have mentioned oraGuruDS in hte oracle-ds.xml file and also in the jbosscmp-jdbc-oracle.xml file
Any help will be appreicated
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic