You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@servicemix.apache.org by pawan269 <pa...@gmail.com> on 2010/03/05 04:16:22 UTC

JDBC

Hi,

I am having SMX4 at ubuntu, facing a problem with JDBC.

First let me explain what I am trying to achieve here.

1. I am reading from a queue (ActiveMQ) and Parsing data
2. Calling a JDBC Bean from parser to insert into postgres database.

Both of these components are installed in SMX using maven

Problem -
It always gives me a "java.lang.ClassNotFoundException:
org.postgresql.Driver" this exception is generated at the point where i have
following code -

		try {
			Class.forName("org.postgresql.Driver");
		} catch (Exception e) {
			result += "Exception 1 : " + e.toString()+"\r\n";
			return result;
		}

My Classpath and jar present in the folder are - 

# echo $CLASSPATH
.:/usr/local/apache-servicemix-4.0.0/lib:/usr/local/apache-servicemix-4.0.0/lib/htmlconverter.jar:/usr/local/apache-servicemix-4.0.0/lib/jconsole.jar:/usr/local/apache-servicemix-4.0.0/lib/postgresql-8.4-701.jdbc4.jar:/usr/local/apache-servicemix-4.0.0/lib/sa-jdi.jar:/usr/local/apache-servicemix-4.0.0/lib/servicemix.jar:/usr/local/apache-servicemix-4.0.0/lib/servicemix-client.jar:/usr/local/apache-servicemix-4.0.0/lib/servicemix-jaas-boot.jar:/usr/local/apache-servicemix-4.0.0/lib/servicemix-version.jar:/usr/local/apache-servicemix-4.0.0/lib/tools.jar

However to check if I have postgres driver, I have written a piece of code
to pull database datetime and print, using very simple java code, which
works as expected.

I am not sure if I am missing any feature installed on SMX or any other
basic. 

Please help me identifying the problem and any possible solution - 

Many Thanks
Pawan
-- 
View this message in context: http://old.nabble.com/JDBC-tp27789540p27789540.html
Sent from the ServiceMix - User mailing list archive at Nabble.com.


Re: JDBC

Posted by pawan269 <pa...@gmail.com>.
hi Freeman,

Thanks for your quick responses. I have uncommented the section of pom.xml
generated by my eclipse and did little modifications as following - 

    <!-- alternative maven-bundle-plugin configuration -->
    <!-- see http://felix.apache.org/site/maven-bundle-plugin-bnd.html for
more info -->

   
            <plugin>
                <groupId>org.apache.felix</groupId>
                <artifactId>maven-bundle-plugin</artifactId>
                <version>1.4.0</version>
                <extensions>true</extensions>
                <configuration>
                    <obrRepository>NONE</obrRepository>
                    <manifestLocation>META-INF</manifestLocation>
                    <instructions>
                        <Export-Package>
                           
!com.ttylll.pso.jdbc_ttylll.internal,com.ttylll.pso.ttylll*
                        </Export-Package>

                        <Import-Package>org.postgresql,*</Import-Package>
<!--this is what i have modified-->

                       
<Include-Resource>src/main/resources</Include-Resource>
                    </instructions>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.apache.felix</groupId>
                <artifactId>maven-bundle-plugin</artifactId>
                <executions>
                    <execution>
                        <id>bundle-manifest</id>
                        <phase>package</phase>
                        <goals>
                            <goal>bundle</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
        </plugins>

when i did osgi/header it has given me following 

Manifest-Version = 1.0
Bnd-LastModified = 1267787625938
Tool = Bnd-0.0.238
Bundle-Name = JDBCttylll
Built-By = root
Import-Package = com.ttylll.pso.jdbc_ttylll,org.postgresql
Bundle-SymbolicName = com.ttylll.pso.jdbc-ttylll
Export-Package = com.ttylll.pso.jdbc_ttylll
Bundle-Version = 0.0.1.SNAPSHOT
Build-Jdk = 1.6.0_15
Created-By = Apache Maven Bundle Plugin
Bundle-ManifestVersion = 2

It works as a charm.... I can't explain how happy i am, :jumping:

Many thanks for bearing me ...
-- 
View this message in context: http://old.nabble.com/JDBC-tp27789540p27792978.html
Sent from the ServiceMix - User mailing list archive at Nabble.com.


Re: JDBC

Posted by Freeman Fang <fr...@gmail.com>.
Hi,

I can't the necessary header like
Import-Package=org.postgresql
I guess this cause the ClassNotFoundException you encountered. You can  
add it with maven-bundle-plugin, you need configure maven-bundle- 
plugin from the pom.xml.
You can get details about how to configure maven-bundle-plugin from  
several smx4 kit examples.

Freeman
On 2010-3-5, at 下午4:11, pawan269 wrote:

>
> Hi Freeman,
>
> here you go
>
> smx@root:/> osgi/headers 270
>
> myjdbc (270)
> ------------
> Spring-DM-Version = 0.0.1-SNAPSHOT
> Manifest-Version = 1.0
> Archiver-Version = Plexus Archiver
> Bundle-Name = myjdbc
> Built-By = root
> Unversioned-Imports = *
> Bundle-SymbolicName = myjdbc
> Export-Package = com.proiam.pso.myjdbc;version="0"
> Bundle-Classpath = .
> Build-Jdk = 1.6.0_0
> Created-By = Apache Maven
> Bundle-ManifestVersion = 2
>
> -- 
> View this message in context: http://old.nabble.com/JDBC-tp27789540p27790958.html
> Sent from the ServiceMix - User mailing list archive at Nabble.com.
>


-- 
Freeman Fang
------------------------
Open Source SOA: http://fusesource.com


Re: JDBC

Posted by pawan269 <pa...@gmail.com>.
Hi Freeman,

here you go 

smx@root:/> osgi/headers 270

myjdbc (270)
------------
Spring-DM-Version = 0.0.1-SNAPSHOT
Manifest-Version = 1.0
Archiver-Version = Plexus Archiver
Bundle-Name = myjdbc
Built-By = root
Unversioned-Imports = *
Bundle-SymbolicName = myjdbc
Export-Package = com.proiam.pso.myjdbc;version="0"
Bundle-Classpath = .
Build-Jdk = 1.6.0_0
Created-By = Apache Maven
Bundle-ManifestVersion = 2

-- 
View this message in context: http://old.nabble.com/JDBC-tp27789540p27790958.html
Sent from the ServiceMix - User mailing list archive at Nabble.com.


Re: JDBC

Posted by Freeman Fang <fr...@gmail.com>.
Hi,

Could you send us the osgi meta data for your application bundle?

you can get it from
osgi:headers bundle-id
assume bundle-id is the id for your application bundle

Freeman
On 2010-3-5, at 下午3:57, pawan269 wrote:

>
>
> hi Freeman,
>
> Yes... both things are in place (if I am correct)
>
> My osgi/list shows following -
>
> [ 262] [Active     ] [       ] [   60] postgresql.osgi (8.3.603.jdbc4)
> [ 271] [Active     ] [       ] [   60]
> mvn:postgresql/postgresql/8.4-701.jdbc4
>
> In my project Referenced Libraries I can see reference of
> postgresql-8.4-701.jdbc4.jar
>
> Is it what you have mentioned
>
> Please let me know if I am missing anything ...
>
> Many thanks
> Pawan
> -- 
> View this message in context: http://old.nabble.com/JDBC-tp27789540p27790871.html
> Sent from the ServiceMix - User mailing list archive at Nabble.com.
>


-- 
Freeman Fang
------------------------
Open Source SOA: http://fusesource.com


Re: JDBC

Posted by pawan269 <pa...@gmail.com>.

hi Freeman,

Yes... both things are in place (if I am correct)

My osgi/list shows following - 

[ 262] [Active     ] [       ] [   60] postgresql.osgi (8.3.603.jdbc4)
[ 271] [Active     ] [       ] [   60]
mvn:postgresql/postgresql/8.4-701.jdbc4

In my project Referenced Libraries I can see reference of
postgresql-8.4-701.jdbc4.jar

Is it what you have mentioned

Please let me know if I am missing anything ... 

Many thanks
Pawan
-- 
View this message in context: http://old.nabble.com/JDBC-tp27789540p27790871.html
Sent from the ServiceMix - User mailing list archive at Nabble.com.


Re: JDBC

Posted by Freeman Fang <fr...@gmail.com>.
Hi,

Do you already install postgresql and org.postgresql.jdbc4 as bundle  
into  osgi container?
And do you already import the org.postgresql package for your  
application bundle(you can do it with maven-bundle-plugin  
configuration)?

Freeman
On 2010-3-5, at 下午12:17, pawan269 wrote:

>
> HI Freeman,
>
> Thanks for quick response,
>
> following are 2 dependencies i am using other than many other -
>
>        <dependency>
>        	<groupId>postgresql</groupId>
>        	<artifactId>postgresql</artifactId>
>        	<version>8.4-701.jdbc4</version>
>        </dependency>
>        <dependency>
>        	<groupId>it.cnr.isti.domoware</groupId>
>        	<artifactId>org.postgresql.jdbc4</artifactId>
>        	<version>8.3-603</version>
>        	<type>bundle</type>
>        </dependency>
>
> Regards,
> Pawan
> -- 
> View this message in context: http://old.nabble.com/JDBC-tp27789540p27789790.html
> Sent from the ServiceMix - User mailing list archive at Nabble.com.
>


-- 
Freeman Fang
------------------------
Open Source SOA: http://fusesource.com


Re: JDBC

Posted by pawan269 <pa...@gmail.com>.
HI Freeman,

Thanks for quick response, 

following are 2 dependencies i am using other than many other -

        <dependency>
        	<groupId>postgresql</groupId>
        	<artifactId>postgresql</artifactId>
        	<version>8.4-701.jdbc4</version>
        </dependency>
        <dependency>
        	<groupId>it.cnr.isti.domoware</groupId>
        	<artifactId>org.postgresql.jdbc4</artifactId>
        	<version>8.3-603</version>
        	<type>bundle</type>
        </dependency>

Regards,
Pawan
-- 
View this message in context: http://old.nabble.com/JDBC-tp27789540p27789790.html
Sent from the ServiceMix - User mailing list archive at Nabble.com.


Re: JDBC

Posted by Freeman Fang <fr...@gmail.com>.
Hi,

What't the pom.xml for your application bundle looks like?
Do you already import the org.postgresql package for your application  
bundle?

Freeman
On 2010-3-5, at 上午11:16, pawan269 wrote:

>
> Hi,
>
> I am having SMX4 at ubuntu, facing a problem with JDBC.
>
> First let me explain what I am trying to achieve here.
>
> 1. I am reading from a queue (ActiveMQ) and Parsing data
> 2. Calling a JDBC Bean from parser to insert into postgres database.
>
> Both of these components are installed in SMX using maven
>
> Problem -
> It always gives me a "java.lang.ClassNotFoundException:
> org.postgresql.Driver" this exception is generated at the point  
> where i have
> following code -
>
> 		try {
> 			Class.forName("org.postgresql.Driver");
> 		} catch (Exception e) {
> 			result += "Exception 1 : " + e.toString()+"\r\n";
> 			return result;
> 		}
>
> My Classpath and jar present in the folder are -
>
> # echo $CLASSPATH
> .:/usr/local/apache-servicemix-4.0.0/lib:/usr/local/apache- 
> servicemix-4.0.0/lib/htmlconverter.jar:/usr/local/apache- 
> servicemix-4.0.0/lib/jconsole.jar:/usr/local/apache-servicemix-4.0.0/ 
> lib/postgresql-8.4-701.jdbc4.jar:/usr/local/apache-servicemix-4.0.0/ 
> lib/sa-jdi.jar:/usr/local/apache-servicemix-4.0.0/lib/ 
> servicemix.jar:/usr/local/apache-servicemix-4.0.0/lib/servicemix- 
> client.jar:/usr/local/apache-servicemix-4.0.0/lib/servicemix-jaas- 
> boot.jar:/usr/local/apache-servicemix-4.0.0/lib/servicemix- 
> version.jar:/usr/local/apache-servicemix-4.0.0/lib/tools.jar
>
> However to check if I have postgres driver, I have written a piece  
> of code
> to pull database datetime and print, using very simple java code,  
> which
> works as expected.
>
> I am not sure if I am missing any feature installed on SMX or any  
> other
> basic.
>
> Please help me identifying the problem and any possible solution -
>
> Many Thanks
> Pawan
> -- 
> View this message in context: http://old.nabble.com/JDBC-tp27789540p27789540.html
> Sent from the ServiceMix - User mailing list archive at Nabble.com.
>


-- 
Freeman Fang
------------------------
Open Source SOA: http://fusesource.com