Here is a sample configuration for the usage of the Spagic advanced JDBC component.

This is the servicemix.xml of the SU:

<beans xmlns:sm="http://servicemix.apache.org/config/1.0"; xmlns:lwcontainer="servicemix-lwcontainer" xmlns:Test_v_0="urn:eng:spagic:processes:Test:v0">
  <classpath>
     <location>.</location>
  </classpath>

  <bean id="metadb" class="org.springframework.jndi.JndiObjectFactoryBean">
     <property name="jndiName" value="java:comp/env/jdbc/metadb" />
  </bean>

  <sm:serviceunit id="jbi">
     <sm:activationSpecs>
<sm:activationSpec componentName="Test.myJdbcQueryadvancedJDBC_v_0" service="Test_v_0:Test.myJdbcQueryadvancedJDBC_v_0" destinationService="Test_v_0:Test.myScreenOutputsimpleJDBC_v_0">
           <sm:component>
<bean xmlns="http://xbean.org/schemas/spring/1.0"; class="org.spagic.smx.components.jdbcquery.JDBCAdvancedQueryComponent">
                 <property name="connConfig">
<bean class="org.spagic.smx.components.jdbcquery.JDBCConnectionConfig">
                       <property name="datasource" ref="metadb" />
                    </bean>
                 </property>

                 <property name="queryConfig">
<bean class="org.spagic.smx.components.jdbcquery.JDBCQueryConfig"> <property name="query" value="SELECT * FROM TABLE" />

                       <property name="enrichMessage" value="false" />
                       <property name="xmlEnvelope" value="" />
                       <property name="rowsXmlEnvelope" value="rows" />
                       <property name="rowXmlEnvelope" value="row" />
<property name="faultManagement" value="FAULT_JBI" />
                       <property name="queryParams">
                          <list>
                          </list>
                       </property>
                    </bean>
                 </property>
              </bean>
           </sm:component>
        </sm:activationSpec>
     </sm:activationSpecs>
  </sm:serviceunit>
</beans>


This is the datasource defined in jndi.xml:

   <entry key="java:comp/env/jdbc/metadb">
       <bean id="metadb-ds"
             class="org.apache.commons.dbcp.BasicDataSource"
             destroy-method="close">
<property name="driverClassName" value="com.mysql.jdbc.Driver"/> <property name="url" value="jdbc:mysql://localhost:3306/spagic"/>
             <property name="username" value="spagic"/>
             <property name="password" value="spagic"/>
       </bean>
   </entry>

Obviously there are a lot of different configuration that you can use in the component. For the details you can see the document "Spagic_JBI_Components" in the Spagic documentation. <http://forge.objectweb.org/project/download.php?group_id=298&file_id=11589>

Regards
Gianfranco Boccalon

Berndt Sevcik ha scritto:
Is it possible to post the full working configuration including the 
servicemix.xml, jndi.xml and the pom.xml file of the SU?

Thanks in advance.

Berndt


-----Ursprüngliche Nachricht-----
Von: subh [mailto:[EMAIL PROTECTED]
Gesendet: Donnerstag, 20. November 2008 03:34
An: [email protected]
Betreff: Re: Advanced JDBC by Spargic


Just to let you know, I got it working. I was not using the xpath properly.

anyways, thanks for looking


subh wrote:
Hi,

I am trying to use the Advanced JDBC Component by Spagic to call a SP. I
have configured the component as below

<sm:activationSpec componentName="jdbcPricingService"
service="myesb:jdbcPricingService" destinationService="myesb:echoService">
<sm:component>
<bean
class="org.spagic.smx.components.jdbcstore.JDBCStoreProcedureComponent">
<property name="connConfig">
<bean class="org.spagic.smx.components.jdbcquery.JDBCConnectionConfig">
<!-- <property name="databaseVendor" value="MySQL" /> -->
<property name="datasource" ref="pricingDS"/>
</bean>
</property>
<property name="queryConfig">
<bean class="org.spagic.smx.components.jdbcquery.JDBCQueryConfig">
<property name="query" value="{call payment($paymentAmount, $sellerId)}"
/>
<property name="enrichMessage" value="FALSE" />
<property name="xmlEnvelope" value="store-results" />
<property name="queryParams">
<list>
<bean class="org.spagic.smx.components.jdbcquery.QueryParameterConfig" >
<property name="placeHolder" value="paymentAmount" />
<property name="outputParam" value="TRUE" />
<!-- <property name="XPath" value="null" /> -->
<property name="paramType" value="java.lang.String" />
</bean>
<bean class="org.spagic.smx.components.jdbcquery.QueryParameterConfig" >
<property name="placeHolder" value="sellerId" />
<property name="outputParam" value="TRUE" />
<!-- <property name="XPath" value="null" /> -->
<property name="paramType" value="java.lang.String" />
</bean>
</list>
</property>
</bean>
</property>
</bean>
</sm:component>
</sm:activationSpec>

As you can see, my SP needs 2 params ($paymentAmount, $sellerId), I would
like to know how could I pass these params while calling this component.
If I pass them as

<?xml version="1.0" encoding="UTF-8"?>
<queryConfig>
<paymentAmount>100</paymentAmount>
<sellerId>1</sellerId>
</queryConfig>

I get the following error

ERROR
======

DEBUG - SedaQueue                      -
[EMAIL PROTECTED] dequeued
exchange: InOnly[
  id: ID:10.30.9.159-11db6eca25c-11:13
  status: Active
  role: provider
  service: {http://com.mycompany.myesb/esb}jdbcPricingService
  endpoint: jdbcPricingService
  in: <?xml version="1.0" encoding="UTF-8"?><queryConfig>
<paymentAmount>100</paymentAmount>
<sellerId>1</sellerId>
</queryConfig>
]
DEBUG - DeliveryChannelImpl            - Send
ID:10.30.9.159-11db6eca25c-11:13 in DeliveryChannel{jdbcPricingService}
DEBUG - SecuredBroker                  - send exchange with secure broker
DEBUG - SedaFlow                       - Called Flow send
DEBUG - SedaQueue                      -
[EMAIL PROTECTED] dequeued
exchange: InOnly[
  id: ID:10.30.9.159-11db6eca25c-11:13
  status: Error
  role: consumer
  service: {http://com.mycompany.myesb/esb}jdbcPricingService
  endpoint: jdbcPricingService
  in: <?xml version="1.0" encoding="UTF-8"?><queryConfig>
<paymentAmount>100</paymentAmount>
<sellerId>1</sellerId>
</queryConfig>
  error: java.lang.NullPointerException
]
DEBUG - DeliveryChannelImpl            - Notifying exchange
ID:10.30.9.159-11db6eca25c-11:13(14e7ecf) in
DeliveryChannel{servicemix-file} from processInboundSynchronousEx
change
DEBUG - DeliveryChannelImpl            - Notified:
ID:10.30.9.159-11db6eca25c-11:13(14e7ecf) in
DeliveryChannel{servicemix-file} from sendSync
ERROR - FileComponent                  - Failed to process file:
PriceFeeds\TestJDBC.xml. Reason: java.lang.NullPointerException
java.lang.NullPointerException
        at java.lang.StringBuffer.<init>(StringBuffer.java:104)
        at
org.apache.commons.dbutils.QueryRunner.rethrow(QueryRunner.java:347)
        at
org.spagic.smx.components.jdbcstore.NewStoreProcedureRunner.call(NewStoreProcedureRunner.java:77)
        at
org.spagic.smx.components.jdbcstore.JDBCStoreProcedureComponent.transform(JDBCStoreProcedureComponent.java:92)
        at
org.apache.servicemix.components.util.TransformComponentSupport.onMessageExchange(TransformComponentSupport.java:71)
        at
org.apache.servicemix.jbi.messaging.DeliveryChannelImpl.processInBound(DeliveryChannelImpl.java:610)
        at
org.apache.servicemix.jbi.nmr.flow.AbstractFlow.doRouting(AbstractFlow.java:172)
        at
org.apache.servicemix.jbi.nmr.flow.seda.SedaFlow.doRouting(SedaFlow.java:167)
        at
org.apache.servicemix.jbi.nmr.flow.seda.SedaQueue$1.run(SedaQueue.java:134)
        at
java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:650)
        at
java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:675)
        at java.lang.Thread.run(Thread.java:595)

Will appreciate any help.

rgds
subh


Berndt Sevcik wrote:
I try to use the Advanced JDBC Component by Spargic in Servicemix. When I
deploy the Component I get the following error:
<
loc-message>org.springframework.beans.factory.parsing.BeanDefinitionParsingException:
Configuration problem: Class that bean class
[org.spagic.smx.components.jdbcquery.JDBCAdvancedQueryComponent] depends
on not found
Offending resource: file
[C:\apache-servicemix-3.2.2\data\smx\service-assemblies\tutorial-jdbc-sa\version_20\sus\servicemix-lwcontainer\tutorial-adv_jdbc-su\servicemix.xml]
Bean ''; nested exception is java.lang.NoClassDefFoundError:
org/springframework/jdbc/CannotGetJdbcConnectionException</loc-message>

Has someone an idea? In the following the steps I have done to configure
it.

First I copied:
commons-dbutils-1.1.jar and mysql-connector-java-5.0.7-bin.jar to the
lib/ directory
and spagic-advanced-jdbc-2.3.0.jar to the lib/optional directory of
Servicemix (like in Spagic).

In jndi.xml I added:
  <entry key="java:comp/env/jdbc/servicemixDB">
    <!-- <bean id="mysql-ds"
class="org.springframework.jdbc.datasource.DriverManagerDataSource"> -->
        <bean id="mysql-ds"
class="org.apache.commons.dbcp.BasicDataSource">
        <property name="driverName" value="com.mysql.jdbc.Driver"/>
        <property name="url" value="jdbc:mysql://localhost/NameInfo"/>
        <property name="user" value="user"/>
        <property name="password" value="password"/>
    </bean>
  </entry>

Then I created a servicemix.xml file that looks like this:
<beans xmlns:sm="http://servicemix.apache.org/config/1.0";
       xmlns:foo="http://servicemix.apache.org/foo";
       xmlns="http://www.springframework.org/schema/beans";
       xmlns:xsi="http://http://www.w3.org/2001/XMLSchema-instance";
       xsi:schemaLocation="http://servicemix.apache.org/config/1.0
http://servicemix.apache.org/schema/servicemix-core-3.2.2.xsd
       http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-2.0.xsd";>

  <!-- This is the Spring configuration of a datasource defined in
SERVICE_MIX_HOME/conf/jndi.xml -->
  <bean id="mySql"
class="org.springframework.jndi.JndiObjectFactoryBean">
    <property name="jndiName" value="java:comp/env/jdbc/servicemixDB"/>
  </bean>

  <classpath>
    <location>.</location>
  </classpath>


  <sm:serviceunit id="jbi">
      <!-- Put lw components here -->
      <!-- Note that JDBC Endpoint declare a property ref to the
dataSource defined by the bean above -->
      <!-- ####################### myJDBCdbAndrea
######################## -->
          <sm:activationSpecs>
        <sm:activationSpec componentName="myJdbcQueryadvJdbcDatasource2"
service="foo:myJdbcQueryadvJdbcDatasource2"
destinationService="foo:myScreenOutputadvJdbcDatasource2">
          <sm:component>
            <bean
class="org.spagic.smx.components.jdbcquery.JDBCAdvancedQueryComponent">
              <property name="connConfig">
                <bean
class="org.spagic.smx.components.jdbcquery.JDBCConnectionConfig">
                  <property name="datasource" ref="mysql"/>
                </bean>
              </property>
              <property name="queryConfig">
                <bean
class="org.spagic.smx.components.jdbcquery.JDBCQueryConfig">
                  <property name="query" value="SELECT * FROM user where
SecondName like $name" />
                  <property name="enrichMessage" value="TRUE" />
                  <property name="xmlEnvelope" value="Customer" />
                  <property name="queryParams">
                    <list>
                      <bean
class="org.spagic.smx.components.jdbcquery.QueryParameterConfig" >
                        <property name="placeHolder" value="name" />
                        <property name="outputParam" value="FALSE" />
                        <property name="XPath"
value="/nameinfo/givenName" />
                        <property name="paramType"
value="java.lang.String" />
                      </bean>
                    </list>
                  </property>
                </bean>
              </property>
            </bean>
          </sm:component>
        </sm:activationSpec>
      </sm:activationSpecs>
  </sm:serviceunit>

</beans>

With mvn install I created my Service Assembly.

--
Dipl.-Ing. Berndt Sevcik
TU Wien
Institut für Computertechnik
Gußhausstraße 27-29/384 - 1040 Wien
Tel.: +43 1 58801 38436
Mail: [EMAIL PROTECTED]
URL: http://www.ict.tuwien.ac.at






--
View this message in context: 
http://www.nabble.com/Advanced-JDBC-by-Spargic-tp20538155p20593965.html
Sent from the ServiceMix - User mailing list archive at Nabble.com.


Reply via email to