-
1. Re: Second datasource not recognized
adrian.brock Apr 26, 2004 4:47 AM (in response to grobert)Your post falls into the "IT DOES NOT WORK" category.
Read "READ THIS FIRST" for details on how to get your question answered. -
2. Re: Second datasource not recognized
grobert Apr 26, 2004 5:04 AM (in response to grobert)firebird-ds.xml
<?xml version="1.0" encoding="UTF-8"?>
<!-- ==================================================================== -->
<!-- New ConnectionManager setup for firebird dbs using jca-jdbc xa driver-->
<!-- Build jmx-api (build/build.sh all) and view for config documentation -->
<!-- ==================================================================== -->
<connection-factories>
<!--FBManager can be used to create and drop databases.
Drop is especially useful during testing, since it
assures a clean start next time. -->
D:\\Pracovny\\Projekty\\Java\\EJB\\data\\EJB.FDB
sysdba
masterkey
false
false
<tx-connection-factory>
<jndi-name>FirebirdDS</jndi-name>
<xa-transaction/>
<adapter-display-name>Firebird Database Connector</adapter-display-name>
<config-property name="Database" type="java.lang.String">127.0.0.1/3050:D:\\Pracovny\\Projekty\\Java\\EJB\\data\\EJB.FDB</config-property>
<user-name>sysdba</user-name>
masterkey
<!--additional properties. only use one way of setting tx isolation, please
<config-property name="TransactionIsolation"></config-property>
<config-property name="TransactionIsolationName">TRANSACTION_READ_COMMITTED</config-property>
<config-property name="BlobBufferLength"></config-property>
-->
<config-property name="Encoding">ASCII</config-property>
<min-pool-size>0</min-pool-size>
<!-- sql to call when connection is created
<new-connection-sql>some arbitrary sql</new-connection-sql>
-->
<!-- sql to call on an existing pooled connection when it is obtained from pool
<check-valid-connection-sql>some arbitrary sql</check-valid-connection-sql>
-->
</tx-connection-factory>
</connection-factories>
exceptions
java.sql.SQLException: Table not found: ORDERID in statement [SELECT COUNT(*) FROM ORDERID WHERE id=20]
at org.hsqldb.Trace.getError(Unknown Source)
at org.hsqldb.jdbcResultSet.(Unknown Source)
at org.hsqldb.jdbcConnection.executeStandalone(Unknown Source)
at org.hsqldb.jdbcConnection.execute(Unknown Source)
at org.hsqldb.jdbcStatement.fetchResult(Unknown Source)
at org.hsqldb.jdbcStatement.executeQuery(Unknown Source)
at org.hsqldb.jdbcPreparedStatement.executeQuery(Unknown Source)
at org.jboss.resource.adapter.jdbc.WrappedPreparedStatement.executeQuery(WrappedPreparedStatement.java:304)
at org.jboss.ejb.plugins.cmp.jdbc.JDBCInsertPKCreateCommand.beforeInsert(JDBCInsertPKCreateCommand.java:83)
at org.jboss.ejb.plugins.cmp.jdbc.JDBCAbstractCreateCommand.execute(JDBCAbstractCreateCommand.java:137)
at org.jboss.ejb.plugins.cmp.jdbc.JDBCStoreManager.createEntity(JDBCStoreManager.java:554)
at org.jboss.ejb.plugins.CMPPersistenceManager.createEntity(CMPPersistenceManager.java:208)
at org.jboss.resource.connectionmanager.CachedConnectionInterceptor.createEntity(CachedConnectionInterceptor.java:269)
at org.jboss.ejb.EntityContainer.createHome(EntityContainer.java:737)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:324)
at org.jboss.ejb.EntityContainer$ContainerInterceptor.invokeHome(EntityContainer.java:1043)
at org.jboss.ejb.plugins.AbstractInterceptor.invokeHome(AbstractInterceptor.java:88)
at org.jboss.ejb.plugins.EntitySynchronizationInterceptor.invokeHome(EntitySynchronizationInterceptor.java:197)
at org.jboss.resource.connectionmanager.CachedConnectionInterceptor.invokeHome(CachedConnectionInterceptor.java:214)
at org.jboss.ejb.plugins.AbstractInterceptor.invokeHome(AbstractInterceptor.java:88)
at org.jboss.ejb.plugins.EntityInstanceInterceptor.invokeHome(EntityInstanceInterceptor.java:89)
at org.jboss.ejb.plugins.EntityLockInterceptor.invokeHome(EntityLockInterceptor.java:61)
at org.jboss.ejb.plugins.EntityCreationInterceptor.invokeHome(EntityCreationInterceptor.java:28)
at org.jboss.ejb.plugins.AbstractTxInterceptor.invokeNext(AbstractTxInterceptor.java:88)
at org.jboss.ejb.plugins.TxInterceptorCMT.runWithTransactions(TxInterceptorCMT.java:267)
at org.jboss.ejb.plugins.TxInterceptorCMT.invokeHome(TxInterceptorCMT.java:98)
at org.jboss.ejb.plugins.SecurityInterceptor.invokeHome(SecurityInterceptor.java:92)
at org.jboss.ejb.plugins.LogInterceptor.invokeHome(LogInterceptor.java:120)
at org.jboss.ejb.plugins.ProxyFactoryFinderInterceptor.invokeHome(ProxyFactoryFinderInterceptor.java:93)
at org.jboss.ejb.EntityContainer.internalInvokeHome(EntityContainer.java:483)
at org.jboss.ejb.Container.invoke(Container.java:720)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:324)
at org.jboss.mx.capability.ReflectedMBeanDispatcher.invoke(ReflectedMBeanDispatcher.java:284)
at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:546)
at org.jboss.invocation.jrmp.server.JRMPInvoker.invoke(JRMPInvoker.java:367)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.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:460)
at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run(TCPTransport.java:701)
at java.lang.Thread.run(Thread.java:534) -
3. Re: Second datasource not recognized
grobert Apr 26, 2004 5:08 AM (in response to grobert)ejb-jar.xml
<?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>[CDATA[No Description.]]</description> <display-name>Generated by XDoclet</display-name> <enterprise-beans> <!-- Session Beans --> <!-- To add session beans that you have deployment descriptor info for, add a file to your XDoclet merge directory called session-beans.xml that contains the <session></session> markup for those beans. --> <!-- Entity Beans --> <entity > <description>[CDATA[]]</description> <ejb-name>CmpExample</ejb-name> <home>gigi.ejb.ContainerManagedPersistance.CmpExampleHome</home> <remote>gigi.ejb.ContainerManagedPersistance.CmpExample</remote> <ejb-class>gigi.ejb.ContainerManagedPersistance.CmpExampleBean</ejb-class> <persistence-type>Container</persistence-type> <prim-key-class>gigi.ejb.ContainerManagedPersistance.CmpExamplePK</prim-key-class> <reentrant>false</reentrant> <cmp-version>2.x</cmp-version> <abstract-schema-name>orderidSchema</abstract-schema-name> <cmp-field > <description>[CDATA[]]</description> <field-name>id</field-name> </cmp-field> <cmp-field > <description>[CDATA[]]</description> <field-name>desc</field-name> </cmp-field> <resource-ref > <res-ref-name>jdbc/FirebirdDS</res-ref-name> <res-type>javax.sql.DataSource</res-type> <res-auth>Container</res-auth> </resource-ref> <query> <description>[CDATA[Find by description]]</description> <query-method> <method-name>findByDesc</method-name> <method-params> <method-param>java.lang.String</method-param> </method-params> </query-method> <result-type-mapping>Remote</result-type-mapping> <ejb-ql>[CDATA[SELECT OBJECT(o) FROM orderidSchema AS o WHERE o.desc = ?1]]</ejb-ql> </query> <!-- Write a file named ejb-finders-CmpExampleBean.xml if you want to define extra finders. --> </entity> <!-- To add entity beans that you have deployment descriptor info for, add a file to your XDoclet merge directory called entity-beans.xml that contains the <entity></entity> markup for those beans. --> <!-- Message Driven Beans --> <!-- To add message driven beans that you have deployment descriptor info for, add a file to your XDoclet merge directory called message-driven-beans.xml that contains the <message-driven></message-driven> markup for those beans. --> </enterprise-beans> <!-- Relationships --> <!-- Assembly Descriptor --> <assembly-descriptor > <!-- To add additional assembly descriptor info here, add a file to your XDoclet merge directory called assembly-descriptor.xml that contains the <assembly-descriptor></assembly-descriptor> markup. --> <!-- finder permissions --> <!-- transactions --> <!-- finder transactions --> </assembly-descriptor> </ejb-jar>
jbosscmp-jdbc.xml<?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE jbosscmp-jdbc PUBLIC "-//JBoss//DTD JBOSSCMP-JDBC 3.2//EN" "http://www.jboss.org/j2ee/dtd/jbosscmp-jdbc_3_2.dtd"> <jbosscmp-jdbc> <defaults> </defaults> <enterprise-beans> <!-- To add beans that you have deployment descriptor info for, add a file to your XDoclet merge directory called jbosscmp-jdbc-beans.xml that contains the <entity></entity> markup for those beans. --> <entity> <ejb-name>CmpExample</ejb-name> <datasource>java:comp/env/jdbc/FirebirdDS</datasource> <datasource-mapping>Firebird</datasource-mapping> <create-table>false</create-table> <remove-table>false</remove-table> <table-name>orderid</table-name> <cmp-field> <field-name>id</field-name> <column-name>id</column-name> </cmp-field> <cmp-field> <field-name>desc</field-name> <column-name>dsc</column-name> </cmp-field> <!-- jboss 3.2 features --> <!-- optimistic locking does not express the exclusions needed --> </entity> </enterprise-beans> </jbosscmp-jdbc>
-
4. Re: Second datasource not recognized
adrian.brock Apr 26, 2004 5:28 AM (in response to grobert)<datasource>java:/FirebirdDS</datasource>
-
5. Re: Second datasource not recognized
grobert Apr 26, 2004 6:16 AM (in response to grobert)Thank you.
It helped.
But I do not uderstand. In previous version of code I had everythink(jms, jdbc) mapped to DefaultDS which was MySQL. Datasource was mapped to java:comp/env/jdbc/ tree. I just added another datasource and bound it to simple FirebirdDS just as the orig datasourca was bound to simple DefaultDS. Why is the Firebird datasource not mapped to java:comp/env/jdbc/ tree. I have made no other configaration. ... as far as I know... . Or do I miss somethig importatnt like chapters from "Configuring DataSources in JBoss"?
Regards
Robert -
6. Re: Second datasource not recognized
adrian.brock Apr 26, 2004 6:22 AM (in response to grobert)The ENC java:comp/env jndi namespace is one of the last things to configured
for an EJB.
When the CMP engine is reading your jbosscmp-jdbc.xml it will not exist,
so you must use the "global" jndi name - the real binding.
Inside your bean, the ENC will be configured. -
7. Re: Second datasource not recognized
grobert Apr 26, 2004 6:41 AM (in response to grobert)Sorry Adrian, but it seems that eaither I do not exactly understand the problem or it is not correct information, or there is bug in JBoss.
1. I have BMP example code which uses java:comp/env/jdbc/FirebirdDS inside and it doesn`t work unless I change JNDI lookup string to java:/FirebirdDS So it seems that even in the inside of Bean it is not configured.
2. It works fine with DefaultDS. So it means that namespace java:comp/env is configured when CMP engine reads jbosscmp-jdbc.xml. Why is this two way behaviour for datasources different from DefaultDS.
Regards
Robert -
8. Re: Second datasource not recognized
adrian.brock Apr 26, 2004 6:59 AM (in response to grobert)You are posting "IT DOES NOT WORK" again. Please stop wasting people's time
with incomplete posts.
Post the resource-ref config from ejb-jar.xml and jboss.xml for your BMP bean
if you have no resource-ref in jboss.xml, jboss will use java:/DefaultDS