You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@servicemix.apache.org by bmccabe <wm...@kboservices.com> on 2011/11/15 17:40:17 UTC

Blueprint postgresql camel-jdbc newbie question

Greetings all,

I'm new to servicemix, coming from the apache/mod_perl world, and am trying
to get up to speed. I've been through a lot of the tutorial material, and am
now trying to set a really basic route using blueprint and camel-jdbc which
makes a simple call to a postgres DB. I feel like I'm almost there but can't
quite get it. It builds fine if I include an
<Import-Package>org.postgresql.jdbc</Import-Package>, but when I try to
osgi:start it fails because it can't find "org.postgresql.Driver, though
it's there in the driver jar. Can anyone tip me off to what I'm missing? 

Here's my blueprint statement, which is just a modified version of the
camel-blueprint example, (I've change the db server hostname though):
<blueprint
    xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0"
    xmlns:cm="http://aries.apache.org/blueprint/xmlns/blueprint-cm/v1.0.0"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://www.osgi.org/xmlns/blueprint/v1.0.0
http://www.osgi.org/xmlns/blueprint/v1.0.0/blueprint.xsd">

    <cm:property-placeholder persistent-id="org.apache.servicemix.examples">
        <cm:default-properties>
            <cm:property name="prefix" value="Blueprint-Example"/>
        </cm:default-properties>
    </cm:property-placeholder>

    <camelContext xmlns="http://camel.apache.org/schema/blueprint">
        <route>
            <from uri="timer://myTimer?fixedRate=true&amp;period=5000" />
	 <setBody>
	<constant>select current_timestamp</constant>
	</setBody>
           <to uri="jdbc:pgdb" />
            
            <to uri="log:ExampleRouterBlueprint" />
        </route>
    </camelContext>
	<bean id="pgdb"
class="org.springframework.jdbc.datasource.DriverManagerDataSource">
	 <property name="driverClassName" value="org.postgresql.Driver"/>
	 <property name="url"
value="jdbc:postgresql://myhost.mycompany.com/smx_test01"/>
	 <property name="username" value="smx"/>
	 <property name="password" value="smx"/>
	</bean>
    <bean id="myTransform"
class="org.apache.servicemix.examples.camel.MyTransform">
        <property name="prefix" value="${prefix}" />
    </bean>

</blueprint>

and I've added the this to the pom.xml:
<dependency>
 <groupId>postgresql</groupId>
 <artifactId>postgresql</artifactId>
 <version>8.2-504.jdbc3</version>
</dependency>



--
View this message in context: http://servicemix.396122.n5.nabble.com/Blueprint-postgresql-camel-jdbc-newbie-question-tp4994862p4994862.html
Sent from the ServiceMix - User mailing list archive at Nabble.com.

Re: Blueprint postgresql camel-jdbc newbie question

Posted by bmccabe <wm...@kboservices.com>.
Thanks for your help. I'm sure it's some kind of omission or mismatch. I'll
keep at it.

Bill

--
View this message in context: http://servicemix.396122.n5.nabble.com/Blueprint-postgresql-camel-jdbc-newbie-question-tp4994862p4995729.html
Sent from the ServiceMix - User mailing list archive at Nabble.com.

Re: Blueprint postgresql camel-jdbc newbie question

Posted by aj...@virginia.edu.
Erm. Well, you've outrun my minimal troubleshooting skills. (I, too, am a newbie.)

Perhaps check to see that you don't have a version mismatch between exported and imported package?

---
A. Soroka
Online Library Environment
the University of Virginia Library




On Nov 15, 2011, at 2:24 PM, bmccabe wrote:

> Sorry, yes, that's the first item on the export-package list.
> 
> --
> View this message in context: http://servicemix.396122.n5.nabble.com/Blueprint-postgresql-camel-jdbc-newbie-question-tp4994862p4995456.html
> Sent from the ServiceMix - User mailing list archive at Nabble.com.


Re: Blueprint postgresql camel-jdbc newbie question

Posted by bmccabe <wm...@kboservices.com>.
Sorry, yes, that's the first item on the export-package list.

--
View this message in context: http://servicemix.396122.n5.nabble.com/Blueprint-postgresql-camel-jdbc-newbie-question-tp4994862p4995456.html
Sent from the ServiceMix - User mailing list archive at Nabble.com.

Re: Blueprint postgresql camel-jdbc newbie question

Posted by aj...@virginia.edu.
I'm afraid I'm not quite sure from your reply whether the exported headers, in the container (from the PostgreSQL bundle), actually included org.postgresql, or not?

---
A. Soroka
Online Library Environment
the University of Virginia Library




On Nov 15, 2011, at 2:15 PM, bmccabe wrote:

> osgi:headers lists out the exported packages, so I've changed the
> <Import-Package> list to include org.postgresql, it still builds ok, but
> fails to run with org.postgresql.Driver not found exception in the log. If I
> look at the contents of the jar file itself with an editor, the
> "org/postgresql/Driver" driver class is the first thing listed.
> 
> Thanks,
> Bill
> 
> --
> View this message in context: http://servicemix.396122.n5.nabble.com/Blueprint-postgresql-camel-jdbc-newbie-question-tp4994862p4995425.html
> Sent from the ServiceMix - User mailing list archive at Nabble.com.


Re: Blueprint postgresql camel-jdbc newbie question

Posted by bmccabe <wm...@kboservices.com>.
osgi:headers lists out the exported packages, so I've changed the
<Import-Package> list to include org.postgresql, it still builds ok, but
fails to run with org.postgresql.Driver not found exception in the log. If I
look at the contents of the jar file itself with an editor, the
"org/postgresql/Driver" driver class is the first thing listed.

Thanks,
Bill

--
View this message in context: http://servicemix.396122.n5.nabble.com/Blueprint-postgresql-camel-jdbc-newbie-question-tp4994862p4995425.html
Sent from the ServiceMix - User mailing list archive at Nabble.com.

Re: Blueprint postgresql camel-jdbc newbie question

Posted by aj...@virginia.edu.
Can you try using the osgi:headers command to make sure that the bundle is exporting the package you need?

---
A. Soroka
Online Library Environment
the University of Virginia Library




On Nov 15, 2011, at 1:11 PM, bmccabe wrote:

> I did:
> osgi:install -s wrap:mvn:postgresql/postgresql/8.2-504.jdbc3 
> which I saw in another thread and then started that package, but I didn't
> solve it. 
> 
> --
> View this message in context: http://servicemix.396122.n5.nabble.com/Blueprint-postgresql-camel-jdbc-newbie-question-tp4994862p4995206.html
> Sent from the ServiceMix - User mailing list archive at Nabble.com.


Re: Blueprint postgresql camel-jdbc newbie question

Posted by bmccabe <wm...@kboservices.com>.
I did:
osgi:install -s wrap:mvn:postgresql/postgresql/8.2-504.jdbc3 
which I saw in another thread and then started that package, but I didn't
solve it. 

--
View this message in context: http://servicemix.396122.n5.nabble.com/Blueprint-postgresql-camel-jdbc-newbie-question-tp4994862p4995206.html
Sent from the ServiceMix - User mailing list archive at Nabble.com.

Re: Blueprint postgresql camel-jdbc newbie question

Posted by aj...@virginia.edu.
Is the PostgreSQL driver bundle started in your container?

Is it exporting that package?

---
A. Soroka
Online Library Environment
the University of Virginia Library




On Nov 15, 2011, at 11:40 AM, bmccabe wrote:

> Greetings all,
> 
> I'm new to servicemix, coming from the apache/mod_perl world, and am trying
> to get up to speed. I've been through a lot of the tutorial material, and am
> now trying to set a really basic route using blueprint and camel-jdbc which
> makes a simple call to a postgres DB. I feel like I'm almost there but can't
> quite get it. It builds fine if I include an
> <Import-Package>org.postgresql.jdbc</Import-Package>, but when I try to
> osgi:start it fails because it can't find "org.postgresql.Driver, though
> it's there in the driver jar. Can anyone tip me off to what I'm missing? 
> 
> Here's my blueprint statement, which is just a modified version of the
> camel-blueprint example, (I've change the db server hostname though):
> <blueprint
>    xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0"
>    xmlns:cm="http://aries.apache.org/blueprint/xmlns/blueprint-cm/v1.0.0"
>    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
>    xsi:schemaLocation="http://www.osgi.org/xmlns/blueprint/v1.0.0
> http://www.osgi.org/xmlns/blueprint/v1.0.0/blueprint.xsd">
> 
>    <cm:property-placeholder persistent-id="org.apache.servicemix.examples">
>        <cm:default-properties>
>            <cm:property name="prefix" value="Blueprint-Example"/>
>        </cm:default-properties>
>    </cm:property-placeholder>
> 
>    <camelContext xmlns="http://camel.apache.org/schema/blueprint">
>        <route>
>            <from uri="timer://myTimer?fixedRate=true&amp;period=5000" />
> 	 <setBody>
> 	<constant>select current_timestamp</constant>
> 	</setBody>
>           <to uri="jdbc:pgdb" />
> 
>            <to uri="log:ExampleRouterBlueprint" />
>        </route>
>    </camelContext>
> 	<bean id="pgdb"
> class="org.springframework.jdbc.datasource.DriverManagerDataSource">
> 	 <property name="driverClassName" value="org.postgresql.Driver"/>
> 	 <property name="url"
> value="jdbc:postgresql://myhost.mycompany.com/smx_test01"/>
> 	 <property name="username" value="smx"/>
> 	 <property name="password" value="smx"/>
> 	</bean>
>    <bean id="myTransform"
> class="org.apache.servicemix.examples.camel.MyTransform">
>        <property name="prefix" value="${prefix}" />
>    </bean>
> 
> </blueprint>
> 
> and I've added the this to the pom.xml:
> <dependency>
> <groupId>postgresql</groupId>
> <artifactId>postgresql</artifactId>
> <version>8.2-504.jdbc3</version>
> </dependency>
> 
> 
> 
> --
> View this message in context: http://servicemix.396122.n5.nabble.com/Blueprint-postgresql-camel-jdbc-newbie-question-tp4994862p4994862.html
> Sent from the ServiceMix - User mailing list archive at Nabble.com.


Re: Blueprint postgresql camel-jdbc newbie question

Posted by Rohit <bk...@gmail.com>.
Hi ,

I sorted out this issue after hours of scratching my brain cell. First, 
I used "SimpleDriverDataSource" class instead of 
"DriverManagerDataSource". Property name "driverClassName" will be now 
"driveClass". So the bean would look like as below

    <bean id="pgdb" 
class="org.springframework.jdbc.datasource.SimpleDriverDataSource">
 	 <property name="driverClass" value="org.postgresql.Driver"/>
 	 <property name="url"
value="jdbc:postgresql://myhost.mycompany.com/smx_test01"/>
 	 <property name="username" value="smx"/>
 	 <property name="password" value="smx"/>
     </bean>


Now, in the pom.xml I added two dependency as below

        <dependency>
		<groupId>org.springframework</groupId>
		<artifactId>spring-jdbc</artifactId>
		<version>4.1.6.RELEASE</version>
	</dependency>
	
	<dependency>
		<groupId>org.postgresql</groupId>
		<artifactId>postgresql</artifactId>
		<version>9.3-1100-jdbc41</version>
	</dependency>


again in the same file, under the plugins, the plugin with groupId 
org.apache.felix should have the required import-package as below

           <plugin>
	      <groupId>org.apache.felix</groupId>
	      <artifactId>maven-bundle-plugin</artifactId>
	      <version>1.4.0</version>
	      <extensions>true</extensions>
	      <configuration>
	          <instructions>
	              <Bundle-
SymbolicName>${pom.groupId}.${pom.artifactId}</Bundle-SymbolicName>
	              <Bundle-Name>${pom.artifactId}</Bundle-Name>
	              <Bundle-Version>1.0.0</Bundle-Version>
	              <Import-Package>
                          <!--Required for the driver solution-->
	                  org.springframework.jdbc,
	                  org.springframework.jdbc.datasource,
	                  org.postgresql, 
                          <!--If you are using camel also-->
	                  org.apache.camel.builder, 
	                  org.apache.camel.main,
	                  org.apache.camel.model,
	                  org.apache.log4j
	              </Import-Package>
	              
	          </instructions>
	      </configuration>
	  </plugin>


Also, at the top of your pom.xml, mention the packaging as bundle

  <groupId>your.groupId</groupId>
  <artifactId>your.artifaceId</artifactId>
  <packaging>bundle</packaging>
  <version>0.0.1-SNAPSHOT</version>


Now we are done with pom.xml file. Go ahead and build the project using 
"Run as" --> maven clean install.


Next part is to install the bundle in servicemix. Before doing this, I 
installed spring-jdbc and postgresql by running the below commands one 
by one in servicemix

osgi:install wrap:mvn:org.springframework/spring-jdbc/4.1.6.RELEASE

osgi:start 224 (give the ID which got generated)

osgi:install wrap:mvn:org.postgresql/postgresql/9.3-1100-jdbc41

osgi:start 225 (give the ID which got generated)


Now I installed my bundle as below

osgi:install wrap:mvn:your.groupId/your.artifaceId/0.0.1-SNAPSHOT

osgi:start 226 (give the ID which got generated)


This is it. This fixed the error. The OSGi bundle started successfully 
and it was able to find "org.postgresql.Driver". So no error like "Could 
not load JDBC driver class [org.postgresql.Driver]" occured this time.

Hope this helps. Thanks for bearing in the long solution.


Re: Blueprint postgresql camel-jdbc newbie question

Posted by bmccabe <wm...@kboservices.com>.
Hi Ioannis,

I attemped to update to Camel version 2.8.3, but got an error message:
"Error executing command: No feature named 'spring' with version '[3,4)'
available "
which stems from a need to upgrade to karaf 2.2.x which apparently is not
possible within servicemix 4.3.0.
This has been discussed here, and the solution seems to be to run 4.4
Snapshot. 

I'll give that a try.

Thanks very much for your help,
Bill

--
View this message in context: http://servicemix.396122.n5.nabble.com/Blueprint-postgresql-camel-jdbc-newbie-question-tp4994862p5049762.html
Sent from the ServiceMix - User mailing list archive at Nabble.com.

Re: Blueprint postgresql camel-jdbc newbie question

Posted by Ioannis Canellos <io...@gmail.com>.
I checked the source of spring-jdbc and I think that we guided you falsly.
Sorry for that.

spring-jdbc uses by default the Thread context class loader in order to
load your driver class (in your case the postgres driver).
If no thread context class loader is used, then it delegates to spring-core
classloader (why makes creating a fragment for spring-jdbc useless).

So, the problem in your case is that the thread context classloader is not
set. As of camel 2.8.0, the Thread context classloader is properlly set for
blueprint routes.

I would propose you to update to camel 2.8.0+ and I think that it will work
(even without a fragment).
An other option is not to initialize the driver by using the class for name
apporach (directly instantiate the datasource using the class provided by
your driver).


-- 
*Ioannis Canellos*
*
FuseSource <http://fusesource.com>

**
Blog: http://iocanel.blogspot.com
**
Apache Karaf <http://karaf.apache.org/> Committer & PMC
Apache Camel <http://camel.apache.org/> Committer
Apache ServiceMix <http://servicemix.apache.org/>  Committer
Apache Gora <http://incubator.apache.org/gora/> Committer
Apache DirectMemory <http://incubator.apache.org/directmemory/> Committer
*

Re: Blueprint postgresql camel-jdbc newbie question

Posted by bmccabe <wm...@kboservices.com>.
Hi Freeman,

It's just a postgresql fragment bundle that uses the spring-jdbc bundle as
the host. It's just badly named. The customer bundle with the camel router
is separate, and includes spring-jdbc as a dependency. It builds fine but
still can't find org.postgresql.Driver.

Here's the fragment bundle:

<?xml version="1.0" encoding="UTF-8" ?> 
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
http://maven.apache.org/maven-v4_0_0.xsd">
  <modelVersion>4.0.0</modelVersion> 
  
  <dependencies>
    <dependency>
      <groupId>postgresql</groupId>
      <artifactId>postgresql</artifactId>
      <version>8.2-504.jdbc3</version>
    </dependency>
  </dependencies>
  <groupId>camel-blueprint-jdbc</groupId> 
  <artifactId>postgresql-bundle-frag</artifactId> 
  <version>0.9.10</version> 
  <packaging>jar</packaging> 
  <name>Camel Blueprint Postgresql Fragment Bundle</name> 
  <description>fragment bundle.</description> 
    <build>
      <plugins>
        <plugin>
          <groupId>org.apache.maven.plugins</groupId> 
          <artifactId>maven-jar-plugin</artifactId> 
          <configuration>
            <archive>
              <index>true</index> 
              <manifest>
                <addClasspath>false</addClasspath> 
              </manifest>
              <manifestEntries>
                <Bundle-Version>0.9.11</Bundle-Version> 
               
<Bundle-Description>${project.description}</Bundle-Description> 
                <Bundle-Name>${project.name}</Bundle-Name> 
                <Bundle-DocURL>http://www.apache.org/</Bundle-DocURL> 
                <Bundle-ManifestVersion>2</Bundle-ManifestVersion> 
                <Bundle-Vendor>Apache Software Foundation</Bundle-Vendor> 
                <Fragment-Host>org.springframework.jdbc</Fragment-Host> 
               
<Bundle-SymbolicName>${project.artifactId}</Bundle-SymbolicName> 
                <Export-Package>
                  org.postgresql,
                  org.postgresql.core,
                  org.postgresql.core.types,
                  org.postgresql.core.v2,
                  org.postgresql.core.v3,
                  org.postgresql.ds,
                  org.postgresql.ds.common,
                  org.postgresql.ds.jdbc23,
                  org.postgresql.fastpath,
                  org.postgresql.geometric,
                  org.postgresql.jdbc2,
                  org.postgresql.jdbc2.optional,
                  org.postgresql.jdbc3,
                  org.postgresql.largeobject,
                  org.postgresql.ssl,
                  org.postgresql.translation,
                  org.postgresql.util,
                  org.postgresql.xa
                </Export-Package> 
              </manifestEntries>
            </archive>
          </configuration>
        </plugin>
      </plugins>
    </build>
</project>

--
View this message in context: http://servicemix.396122.n5.nabble.com/Blueprint-postgresql-camel-jdbc-newbie-question-tp4994862p5038849.html
Sent from the ServiceMix - User mailing list archive at Nabble.com.

Re: Blueprint postgresql camel-jdbc newbie question

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

Could you elaborate what's the Camel Blueprint Postgresql Fragment  
Bundle?

Is it the Postgresql jdbc bundle or the bundle include your camel  
router?

You need
1. a Postgresql jdbc bundle as fragment bundle
2. spring-jdbc bundle as host
3. your customer bundle which have camel router.

spring-jdbc bundle will init the Postgresql jdbc driver so you need  
ensure the Postgresql jdbc driver is available in spring-jdbc bundle,  
so spring-jdbc bundle needn't export org.postgresql package.

Freeman


On 2011-12-1, at 上午3:55, bmccabe wrote:

> I got a chance to redo it and I think it's correct. Here's what it  
> shows now:
> [ 232] [Active     ] [            ] [       ] [   60] Spring JDBC
> (3.0.5.RELEASE)
>                                       Fragments: 290
> [ 290] [Resolved   ] [            ] [       ] [   60] Camel Blueprint
> Postgresql Fragment Bundle (0.9.11)
>                                       Hosts: 232
>
> karaf@root> packages:exports 232
>    ID Packages
>   232 org.springframework.jdbc
>   232 org.springframework.jdbc.config
>   232 org.springframework.jdbc.core
>   232 org.springframework.jdbc.core.metadata
>   232 org.springframework.jdbc.core.namedparam
>   232 org.springframework.jdbc.core.simple
>   232 org.springframework.jdbc.core.support
>   232 org.springframework.jdbc.datasource
>   232 org.springframework.jdbc.datasource.embedded
>   232 org.springframework.jdbc.datasource.init
>   232 org.springframework.jdbc.datasource.lookup
>   232 org.springframework.jdbc.object
>   232 org.springframework.jdbc.support
>   232 org.springframework.jdbc.support.incrementer
>   232 org.springframework.jdbc.support.lob
>   232 org.springframework.jdbc.support.nativejdbc
>   232 org.springframework.jdbc.support.rowset
>   232 org.springframework.jdbc.support.xml
>   232 org.postgresql
>   232 org.postgresql.core
>   232 org.postgresql.core.types
>   232 org.postgresql.core.v2
>   232 org.postgresql.core.v3
>   232 org.postgresql.ds
>   232 org.postgresql.ds.common
>   232 org.postgresql.ds.jdbc23
>   232 org.postgresql.fastpath
>   232 org.postgresql.geometric
>   232 org.postgresql.jdbc2
>   232 org.postgresql.jdbc2.optional
>   232 org.postgresql.jdbc3
>   232 org.postgresql.largeobject
>   232 org.postgresql.ssl
>   232 org.postgresql.translation
>   232 org.postgresql.util
>   232 org.postgresql.xa
>
> Unfortunately I'm still getting the "ClassNotFoundException:
> org.postgresql.Driver" error when I try to start my bundle. I've  
> included
> all of the postgresql packages in my <Import-Package> section and  
> added
> org.springframework as a depndency in the pom, but no joy. Any  
> suggestions
> as to why it might not be picking it up?
>
> Thanks again,
> Bill
>
> --
> View this message in context: http://servicemix.396122.n5.nabble.com/Blueprint-postgresql-camel-jdbc-newbie-question-tp4994862p5036590.html
> Sent from the ServiceMix - User mailing list archive at Nabble.com.

---------------------------------------------
Freeman Fang

FuseSource
Email:ffang@fusesource.com
Web: fusesource.com
Twitter: freemanfang
Blog: http://freemanfang.blogspot.com










Re: Blueprint postgresql camel-jdbc newbie question

Posted by bmccabe <wm...@kboservices.com>.
I got a chance to redo it and I think it's correct. Here's what it shows now:
[ 232] [Active     ] [            ] [       ] [   60] Spring JDBC
(3.0.5.RELEASE)
                                       Fragments: 290
[ 290] [Resolved   ] [            ] [       ] [   60] Camel Blueprint
Postgresql Fragment Bundle (0.9.11)
                                       Hosts: 232

karaf@root> packages:exports 232
    ID Packages                                
   232 org.springframework.jdbc                
   232 org.springframework.jdbc.config         
   232 org.springframework.jdbc.core           
   232 org.springframework.jdbc.core.metadata  
   232 org.springframework.jdbc.core.namedparam
   232 org.springframework.jdbc.core.simple    
   232 org.springframework.jdbc.core.support   
   232 org.springframework.jdbc.datasource     
   232 org.springframework.jdbc.datasource.embedded
   232 org.springframework.jdbc.datasource.init
   232 org.springframework.jdbc.datasource.lookup
   232 org.springframework.jdbc.object         
   232 org.springframework.jdbc.support        
   232 org.springframework.jdbc.support.incrementer
   232 org.springframework.jdbc.support.lob    
   232 org.springframework.jdbc.support.nativejdbc
   232 org.springframework.jdbc.support.rowset 
   232 org.springframework.jdbc.support.xml    
   232 org.postgresql                          
   232 org.postgresql.core                     
   232 org.postgresql.core.types               
   232 org.postgresql.core.v2                  
   232 org.postgresql.core.v3                  
   232 org.postgresql.ds                       
   232 org.postgresql.ds.common                
   232 org.postgresql.ds.jdbc23                
   232 org.postgresql.fastpath                 
   232 org.postgresql.geometric                
   232 org.postgresql.jdbc2                    
   232 org.postgresql.jdbc2.optional           
   232 org.postgresql.jdbc3                    
   232 org.postgresql.largeobject              
   232 org.postgresql.ssl                      
   232 org.postgresql.translation              
   232 org.postgresql.util                     
   232 org.postgresql.xa 

Unfortunately I'm still getting the "ClassNotFoundException:
org.postgresql.Driver" error when I try to start my bundle. I've included
all of the postgresql packages in my <Import-Package> section and added
org.springframework as a depndency in the pom, but no joy. Any suggestions
as to why it might not be picking it up?

Thanks again,
Bill

--
View this message in context: http://servicemix.396122.n5.nabble.com/Blueprint-postgresql-camel-jdbc-newbie-question-tp4994862p5036590.html
Sent from the ServiceMix - User mailing list archive at Nabble.com.

Re: Blueprint postgresql camel-jdbc newbie question

Posted by Ioannis Canellos <io...@gmail.com>.
I agree with Freeman, I think that the postgres driver has not been
properly attached and thus it cannot be loaded from spring-jdbc.


-- 
*Ioannis Canellos*
*
FuseSource <http://fusesource.com>

**
Blog: http://iocanel.blogspot.com
**
Apache Karaf <http://karaf.apache.org/> Committer & PMC
Apache Camel <http://camel.apache.org/> Committer
Apache ServiceMix <http://servicemix.apache.org/>  Committer
Apache Gora <http://incubator.apache.org/gora/> Committer
Apache DirectMemory <http://incubator.apache.org/directmemory/> Committer
*

Re: Blueprint postgresql camel-jdbc newbie question

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

 From the bundle list, I can see you didn't correctly understand my  
suggestion.

I suggest you create fragment bundle for postgresql jdbc driver and  
attachment it to spring-jdbc bundle(play the role as host bundle),
So
[ 246] [Active     ] [            ] [       ] [   60]
wrap_mvn_postgresql_postgresql_8.2-504.jdbc3 (0)
shouldn't be here at all.
Also you can't start a fragment bundle, the expected status for  
fragment bundle is "Resolved", you may need refresh the host(spring- 
jdbc) bundle here after you install the fragment bundle to pick the  
fragment bundle up.

The correct pair of fragment/host bundle should looks like
[  45] [Active     ] [Created     ] [       ] [   60] activemq-core  
(5.5.1.fuse-01-06)
                                        Fragments: 62
[  62] [Resolved   ] [            ] [       ] [   60] activemq- 
blueprint (5.5.1.fuse-01-06)
                                        Hosts: 45

Here 45 is host bundle and 62 is fragment bundle.

If you think create a fragment bundle is too hard for you now you can  
consider to use
Option2. enable dynamic import for spring-jdbc I mentioned before,  
from console do "dynamic-import spring-jdbc-id", this can also make  
postgresql driver package available for the spring-jdbc.
Freeman
On 2011-11-23, at 上午3:43, bmccabe wrote:

> Hi Ioannis, Thanks for responding. I added the import-package just  
> to see if
> it would help. Also, if I try to start the bundle fragment it says  
> it's not
> allowed. I assume that's as expected.
>
> Here's the last 3 lines of the osgi:list output:
> [ 246] [Active     ] [            ] [       ] [   60]
> wrap_mvn_postgresql_postgresql_8.2-504.jdbc3 (0)
> [ 273] [Installed  ] [            ] [       ] [   60] Camel Blueprint
> Postgresql Fragment Bundle (0.9.10)
> [ 274] [Active     ] [Failure     ] [       ] [   60] Apache  
> ServiceMix ::
> Features :: Examples :: Camel Blueprint JDBC (4.3.0)
>
> Here's the packages:exports output (if I uninstall bundle 246 the  
> command
> then it returns nothing):
> karaf@root> packages:exports | grep org.postgresql
>   246 org.postgresql
>   246 org.postgresql.core
>   246 org.postgresql.core.types
>   246 org.postgresql.core.v2
>   246 org.postgresql.core.v3
>   246 org.postgresql.ds
>   246 org.postgresql.ds.common
>   246 org.postgresql.ds.jdbc23
>   246 org.postgresql.fastpath
>   246 org.postgresql.geometric
>   246 org.postgresql.jdbc2
>   246 org.postgresql.jdbc2.optional
>   246 org.postgresql.jdbc3
>   246 org.postgresql.largeobject
>   246 org.postgresql.ssl
>   246 org.postgresql.translation
>   246 org.postgresql.util
>   246 org.postgresql.xa
>
> When I try to start the bundle (274) in the karaf console, I don't  
> get any
> feed back, it just returns the prompt with no log output. When I  
> redeploy
> the bundle I get this as log output:
> 13:57:35,202 | INFO  | rint Extender: 2 |  
> Activator                        |
> 68 - org.apache.camel.camel-core - 2.6.0 | Found 1 @Converter  
> classes to
> load
> 13:57:35,203 | INFO  | rint Extender: 2 |  
> Activator                        |
> 68 - org.apache.camel.camel-core - 2.6.0 | Found 1 @Converter  
> classes to
> load
> 13:57:35,204 | INFO  | rint Extender: 2 |  
> Activator                        |
> 68 - org.apache.camel.camel-core - 2.6.0 | Found 2 @Converter  
> classes to
> load
> 13:57:35,212 | INFO  | rint Extender: 2 |  
> Activator                        |
> 68 - org.apache.camel.camel-core - 2.6.0 | Found 13 @Converter  
> classes to
> load
> 13:57:35,217 | INFO  | rint Extender: 2 |  
> Activator                        |
> 68 - org.apache.camel.camel-core - 2.6.0 | Found 1 @Converter  
> classes to
> load
> 13:57:35,219 | INFO  | rint Extender: 2 |  
> Activator                        |
> 68 - org.apache.camel.camel-core - 2.6.0 | Found 0 @Converter  
> classes to
> load
> 13:57:35,219 | INFO  | rint Extender: 2 |  
> BlueprintCamelContext            |
> 68 - org.apache.camel.camel-core - 2.6.0 | JMX enabled. Using
> ManagedManagementStrategy.
> 13:57:35,220 | INFO  | rint Extender: 2 |  
> BlueprintCamelContext            |
> 68 - org.apache.camel.camel-core - 2.6.0 | Apache Camel 2.6.0  
> (CamelContext:
> 275-camel-131) is starting
> 13:57:35,376 | INFO  | rint Extender: 2 |  
> BlueprintCamelContext            |
> 68 - org.apache.camel.camel-core - 2.6.0 | Apache Camel 2.6.0
> (CamelContext:275-camel-131) is shutting down
> 13:57:35,376 | INFO  | rint Extender: 2 |  
> DefaultShutdownStrategy          |
> 68 - org.apache.camel.camel-core - 2.6.0 | Starting to graceful  
> shutdown 0
> routes (timeout 300 seconds)
> 13:57:35,377 | INFO  | rint Extender: 2 |  
> DefaultShutdownStrategy          |
> 68 - org.apache.camel.camel-core - 2.6.0 | Graceful shutdown of 0  
> routes
> completed in 0 seconds
> 13:57:35,377 | INFO  | rint Extender: 2 |  
> DefaultInflightRepository        |
> 68 - org.apache.camel.camel-core - 2.6.0 | Shutting down with no  
> inflight
> exchanges.
> 13:57:35,377 | INFO  | rint Extender: 2 |  
> BlueprintCamelContext            |
> 68 - org.apache.camel.camel-core - 2.6.0 | Uptime: 0.157 seconds
> 13:57:35,377 | INFO  | rint Extender: 2 |  
> BlueprintCamelContext            |
> 68 - org.apache.camel.camel-core - 2.6.0 | Apache Camel 2.6.0  
> (CamelContext:
> 275-camel-131) is shutdown in 0.001 seconds
> 13:57:35,378 | ERROR | rint Extender: 2 |  
> BlueprintContainerImpl           |
> 7 - org.apache.aries.blueprint - 0.2.0.incubating | Unable to start
> blueprint container for bundle camel-blueprint-jdbc
> org.osgi.service.blueprint.container.ComponentDefinitionException:  
> Unable to
> intialize bean camel-129
>        at
> org 
> .apache 
> .aries 
> .blueprint.container.BeanRecipe.runBeanProcInit(BeanRecipe.java:635) 
> [7:org.apache.aries.blueprint:0.2.0.incubating]
>        at
> org 
> .apache 
> .aries.blueprint.container.BeanRecipe.internalCreate(BeanRecipe.java: 
> 744)[7:org.apache.aries.blueprint:0.2.0.incubating]
>        at
> org 
> .apache.aries.blueprint.di.AbstractRecipe.create(AbstractRecipe.java: 
> 64)[7:org.apache.aries.blueprint:0.2.0.incubating]
>        at
> org 
> .apache 
> .aries 
> .blueprint 
> .container 
> .BlueprintRepository.createInstances(BlueprintRepository.java:219) 
> [7:org.apache.aries.blueprint:0.2.0.incubating]
>        at
> org 
> .apache 
> .aries 
> .blueprint 
> .container 
> .BlueprintRepository.createInstance(BlueprintRepository.java:198) 
> [7:org.apache.aries.blueprint:0.2.0.incubating]
>        at
> org 
> .apache 
> .aries 
> .blueprint 
> .container.BlueprintRepository.create(BlueprintRepository.java:137) 
> [7:org.apache.aries.blueprint:0.2.0.incubating]
>        at
> org 
> .apache 
> .aries 
> .blueprint 
> .container 
> .BlueprintContainerImpl 
> .getComponentInstance(BlueprintContainerImpl.java:702) 
> [7:org.apache.aries.blueprint:0.2.0.incubating]
>        at
> org.apache.camel.blueprint.handler.CamelNamespaceHandler 
> $CamelDependenciesFinder.process(CamelNamespaceHandler.java:499) 
> [76:org.apache.camel.camel-blueprint:2.6.0]
>        at
> org 
> .apache 
> .aries 
> .blueprint 
> .container 
> .BlueprintContainerImpl 
> .processProcessors(BlueprintContainerImpl.java:479) 
> [7:org.apache.aries.blueprint:0.2.0.incubating]
>        at
> org 
> .apache 
> .aries 
> .blueprint 
> .container.BlueprintContainerImpl.doRun(BlueprintContainerImpl.java: 
> 299)[7:org.apache.aries.blueprint:0.2.0.incubating]
>        at
> org 
> .apache 
> .aries 
> .blueprint 
> .container.BlueprintContainerImpl.run(BlueprintContainerImpl.java: 
> 213)[7:org.apache.aries.blueprint:0.2.0.incubating]
>        at
> java.util.concurrent.Executors$RunnableAdapter.call(Executors.java: 
> 471)[:1.6.0_20]
>        at
> java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:334)[: 
> 1.6.0_20]
>        at
> java.util.concurrent.FutureTask.run(FutureTask.java:166)[:1.6.0_20]
>        at
> java.util.concurrent.ScheduledThreadPoolExecutor 
> $ScheduledFutureTask.access$101(ScheduledThreadPoolExecutor.java:165) 
> [:1.6.0_20]
>        at
> java.util.concurrent.ScheduledThreadPoolExecutor 
> $ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:266)[: 
> 1.6.0_20]
>        at
> java 
> .util 
> .concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java: 
> 1110)[:1.6.0_20]
>        at
> java.util.concurrent.ThreadPoolExecutor 
> $Worker.run(ThreadPoolExecutor.java:603)[:1.6.0_20]
>        at java.lang.Thread.run(Thread.java:636)[:1.6.0_20]
> Caused by: org.apache.camel.FailedToCreateRouteException: Failed to  
> create
> route route44 at: >>> To[jdbc:pgdb] <<< in route:
> Route[[From[timer://myTimer?fixedRate=true&period=5000]] -> ...  
> because of
> Failed to resolve endpoint: jdbc://pgdb due to:
> org.osgi.service.blueprint.container.ComponentDefinitionException:  
> Error
> setting property: PropertyDescriptor <name: driverClassName, getter:  
> null,
> setter: [public void
> org 
> .springframework 
> .jdbc 
> .datasource 
> .DriverManagerDataSource.setDriverClassName(java.lang.String)]
>        at
> org 
> .apache.camel.model.RouteDefinition.addRoutes(RouteDefinition.java: 
> 759)
>        at
> org 
> .apache.camel.model.RouteDefinition.addRoutes(RouteDefinition.java: 
> 160)
>        at
> org 
> .apache 
> .camel.impl.DefaultCamelContext.startRoute(DefaultCamelContext.java: 
> 701)
>        at
> org 
> .apache 
> .camel 
> .impl 
> .DefaultCamelContext.startRouteDefinitions(DefaultCamelContext.java: 
> 1623)
>        at
> org 
> .apache 
> .camel 
> .impl.DefaultCamelContext.doStartCamel(DefaultCamelContext.java:1412)
>        at
> org 
> .apache 
> .camel.impl.DefaultCamelContext.doStart(DefaultCamelContext.java:1321)
>        at
> org.apache.camel.impl.ServiceSupport.start(ServiceSupport.java:65)
>        at
> org.apache.camel.impl.ServiceSupport.start(ServiceSupport.java:52)
>        at
> org 
> .apache 
> .camel.impl.DefaultCamelContext.start(DefaultCamelContext.java:1299)
>        at
> org 
> .apache 
> .camel 
> .blueprint 
> .BlueprintCamelContext.maybeStart(BlueprintCamelContext.java:77)
>        at
> org 
> .apache 
> .camel 
> .blueprint.BlueprintCamelContext.init(BlueprintCamelContext.java:72)
>        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native
> Method)[:1.6.0_20]
>        at
> sun 
> .reflect 
> .NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)[: 
> 1.6.0_20]
>        at
> sun 
> .reflect 
> .DelegatingMethodAccessorImpl 
> .invoke(DelegatingMethodAccessorImpl.java:43)[:1.6.0_20]
>        at java.lang.reflect.Method.invoke(Method.java:616)[:1.6.0_20]
>        at
> org 
> .apache 
> .aries.blueprint.utils.ReflectionUtils.invoke(ReflectionUtils.java: 
> 221)[7:org.apache.aries.blueprint:0.2.0.incubating]
>        at
> org 
> .apache.aries.blueprint.container.BeanRecipe.invoke(BeanRecipe.java: 
> 844)[7:org.apache.aries.blueprint:0.2.0.incubating]
>        at
> org 
> .apache 
> .aries 
> .blueprint.container.BeanRecipe.runBeanProcInit(BeanRecipe.java:633) 
> [7:org.apache.aries.blueprint:0.2.0.incubating]
>        ... 18 more
> Caused by: org.apache.camel.ResolveEndpointFailedException: Failed to
> resolve endpoint: jdbc://pgdb due to:
> org.osgi.service.blueprint.container.ComponentDefinitionException:  
> Error
> setting property: PropertyDescriptor <name: driverClassName, getter:  
> null,
> setter: [public void
> org 
> .springframework 
> .jdbc 
> .datasource 
> .DriverManagerDataSource.setDriverClassName(java.lang.String)]
>        at
> org 
> .apache 
> .camel.impl.DefaultCamelContext.getEndpoint(DefaultCamelContext.java: 
> 449)
>        at
> org 
> .apache 
> .camel 
> .util 
> .CamelContextHelper.getMandatoryEndpoint(CamelContextHelper.java:47)
>        at
> org 
> .apache 
> .camel.model.RouteDefinition.resolveEndpoint(RouteDefinition.java:175)
>        at
> org 
> .apache 
> .camel 
> .impl.DefaultRouteContext.resolveEndpoint(DefaultRouteContext.java: 
> 110)
>        at
> org 
> .apache 
> .camel 
> .impl.DefaultRouteContext.resolveEndpoint(DefaultRouteContext.java: 
> 116)
>        at
> org 
> .apache 
> .camel.model.SendDefinition.resolveEndpoint(SendDefinition.java:64)
>        at
> org 
> .apache 
> .camel.model.SendDefinition.createProcessor(SendDefinition.java:58)
>        at
> org 
> .apache 
> .camel 
> .model.ProcessorDefinition.makeProcessor(ProcessorDefinition.java:403)
>        at
> org 
> .apache 
> .camel.model.ProcessorDefinition.addRoutes(ProcessorDefinition.java: 
> 174)
>        at
> org 
> .apache.camel.model.RouteDefinition.addRoutes(RouteDefinition.java: 
> 756)
>        ... 35 more
> Caused by: org.apache.camel.RuntimeCamelException:
> org.osgi.service.blueprint.container.ComponentDefinitionException:  
> Error
> setting property: PropertyDescriptor <name: driverClassName, getter:  
> null,
> setter: [public void
> org 
> .springframework 
> .jdbc 
> .datasource 
> .DriverManagerDataSource.setDriverClassName(java.lang.String)]
>        at
> org 
> .apache 
> .camel.util.ObjectHelper.wrapRuntimeCamelException(ObjectHelper.java: 
> 1139)
>        at
> org 
> .apache 
> .camel 
> .impl 
> .PropertyPlaceholderDelegateRegistry 
> .lookup(PropertyPlaceholderDelegateRegistry.java:56)
>        at
> org 
> .apache.camel.util.CamelContextHelper.lookup(CamelContextHelper.java: 
> 105)
>        at
> org 
> .apache 
> .camel 
> .util.CamelContextHelper.mandatoryLookup(CamelContextHelper.java:123)
>        at
> org 
> .apache 
> .camel 
> .component.jdbc.JdbcComponent.createEndpoint(JdbcComponent.java:49)
>        at
> org 
> .apache 
> .camel.impl.DefaultComponent.createEndpoint(DefaultComponent.java:75)
>        at
> org 
> .apache 
> .camel.impl.DefaultCamelContext.getEndpoint(DefaultCamelContext.java: 
> 431)
>        ... 44 more
> Caused by:
> org.osgi.service.blueprint.container.ComponentDefinitionException:  
> Error
> setting property: PropertyDescriptor <name: driverClassName, getter:  
> null,
> setter: [public void
> org 
> .springframework 
> .jdbc 
> .datasource 
> .DriverManagerDataSource.setDriverClassName(java.lang.String)]
>        at
> org 
> .apache 
> .aries.blueprint.container.BeanRecipe.setProperty(BeanRecipe.java: 
> 827)[7:org.apache.aries.blueprint:0.2.0.incubating]
>        at
> org 
> .apache 
> .aries.blueprint.container.BeanRecipe.setProperties(BeanRecipe.java: 
> 793)[7:org.apache.aries.blueprint:0.2.0.incubating]
>        at
> org 
> .apache 
> .aries.blueprint.container.BeanRecipe.setProperties(BeanRecipe.java: 
> 774)[7:org.apache.aries.blueprint:0.2.0.incubating]
>        at
> org 
> .apache 
> .aries.blueprint.container.BeanRecipe.internalCreate(BeanRecipe.java: 
> 740)[7:org.apache.aries.blueprint:0.2.0.incubating]
>        at
> org 
> .apache.aries.blueprint.di.AbstractRecipe.create(AbstractRecipe.java: 
> 64)[7:org.apache.aries.blueprint:0.2.0.incubating]
>        at
> org 
> .apache 
> .aries 
> .blueprint 
> .container 
> .BlueprintRepository.createInstances(BlueprintRepository.java:219) 
> [7:org.apache.aries.blueprint:0.2.0.incubating]
>        at
> org 
> .apache 
> .aries 
> .blueprint 
> .container 
> .BlueprintRepository.createInstance(BlueprintRepository.java:198) 
> [7:org.apache.aries.blueprint:0.2.0.incubating]
>        at
> org 
> .apache 
> .aries 
> .blueprint 
> .container.BlueprintRepository.create(BlueprintRepository.java:137) 
> [7:org.apache.aries.blueprint:0.2.0.incubating]
>        at
> org 
> .apache 
> .aries 
> .blueprint 
> .container 
> .BlueprintContainerImpl 
> .getComponentInstance(BlueprintContainerImpl.java:702) 
> [7:org.apache.aries.blueprint:0.2.0.incubating]
>        at
> org 
> .apache 
> .camel 
> .blueprint 
> .BlueprintContainerRegistry.lookup(BlueprintContainerRegistry.java:43)
>        at
> org 
> .apache.camel.impl.CompositeRegistry.lookup(CompositeRegistry.java:47)
>        at
> org 
> .apache 
> .camel 
> .impl 
> .PropertyPlaceholderDelegateRegistry 
> .lookup(PropertyPlaceholderDelegateRegistry.java:54)
>        ... 49 more
> Caused by: java.lang.IllegalStateException: Could not load JDBC  
> driver class
> [org.postgresql.Driver]
>        at
> org 
> .springframework 
> .jdbc 
> .datasource 
> .DriverManagerDataSource 
> .setDriverClassName(DriverManagerDataSource.java:150)
>        at sun.reflect.GeneratedMethodAccessor514.invoke(Unknown  
> Source)
>        at
> sun 
> .reflect 
> .DelegatingMethodAccessorImpl 
> .invoke(DelegatingMethodAccessorImpl.java:43)[:1.6.0_20]
>        at java.lang.reflect.Method.invoke(Method.java:616)[:1.6.0_20]
>        at
> org.apache.aries.blueprint.utils.ReflectionUtils 
> $MethodPropertyDescriptor.internalSet(ReflectionUtils.java:416)
>        at
> org.apache.aries.blueprint.utils.ReflectionUtils 
> $PropertyDescriptor.set(ReflectionUtils.java:302)
>        at
> org 
> .apache 
> .aries.blueprint.container.BeanRecipe.setProperty(BeanRecipe.java: 
> 825)[7:org.apache.aries.blueprint:0.2.0.incubating]
>        ... 60 more
> Caused by: java.lang.ClassNotFoundException: org.postgresql.Driver
>        at java.net.URLClassLoader$1.run(URLClassLoader.java:217)[: 
> 1.6.0_20]
>        at java.security.AccessController.doPrivileged(Native
> Method)[:1.6.0_20]
>        at
> java.net.URLClassLoader.findClass(URLClassLoader.java:205)[:1.6.0_20]
>        at java.lang.ClassLoader.loadClass(ClassLoader.java:321)[: 
> 1.6.0_20]
>        at
> sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:294)[: 
> 1.6.0_20]
>        at java.lang.ClassLoader.loadClass(ClassLoader.java:266)[: 
> 1.6.0_20]
>        at java.lang.Class.forName0(Native Method)[:1.6.0_20]
>        at java.lang.Class.forName(Class.java:264)[:1.6.0_20]
>        at
> org 
> .springframework 
> .jdbc 
> .datasource 
> .DriverManagerDataSource 
> .setDriverClassName(DriverManagerDataSource.java:147)
>        ... 66 more
>
>
> --
> View this message in context: http://servicemix.396122.n5.nabble.com/Blueprint-postgresql-camel-jdbc-newbie-question-tp4994862p5014505.html
> Sent from the ServiceMix - User mailing list archive at Nabble.com.

---------------------------------------------
Freeman Fang

FuseSource
Email:ffang@fusesource.com
Web: fusesource.com
Twitter: freemanfang
Blog: http://freemanfang.blogspot.com










Re: Blueprint postgresql camel-jdbc newbie question

Posted by bmccabe <wm...@kboservices.com>.
Hi Ioannis, Thanks for responding. I added the import-package just to see if
it would help. Also, if I try to start the bundle fragment it says it's not
allowed. I assume that's as expected.

Here's the last 3 lines of the osgi:list output:
[ 246] [Active     ] [            ] [       ] [   60]
wrap_mvn_postgresql_postgresql_8.2-504.jdbc3 (0)
[ 273] [Installed  ] [            ] [       ] [   60] Camel Blueprint
Postgresql Fragment Bundle (0.9.10)
[ 274] [Active     ] [Failure     ] [       ] [   60] Apache ServiceMix ::
Features :: Examples :: Camel Blueprint JDBC (4.3.0)

Here's the packages:exports output (if I uninstall bundle 246 the command
then it returns nothing):
karaf@root> packages:exports | grep org.postgresql
   246 org.postgresql                          
   246 org.postgresql.core                     
   246 org.postgresql.core.types               
   246 org.postgresql.core.v2                  
   246 org.postgresql.core.v3                  
   246 org.postgresql.ds                       
   246 org.postgresql.ds.common                
   246 org.postgresql.ds.jdbc23                
   246 org.postgresql.fastpath                 
   246 org.postgresql.geometric                
   246 org.postgresql.jdbc2                    
   246 org.postgresql.jdbc2.optional           
   246 org.postgresql.jdbc3                    
   246 org.postgresql.largeobject              
   246 org.postgresql.ssl                      
   246 org.postgresql.translation              
   246 org.postgresql.util                     
   246 org.postgresql.xa     

When I try to start the bundle (274) in the karaf console, I don't get any
feed back, it just returns the prompt with no log output. When I redeploy
the bundle I get this as log output:
13:57:35,202 | INFO  | rint Extender: 2 | Activator                        |
68 - org.apache.camel.camel-core - 2.6.0 | Found 1 @Converter classes to
load
13:57:35,203 | INFO  | rint Extender: 2 | Activator                        |
68 - org.apache.camel.camel-core - 2.6.0 | Found 1 @Converter classes to
load
13:57:35,204 | INFO  | rint Extender: 2 | Activator                        |
68 - org.apache.camel.camel-core - 2.6.0 | Found 2 @Converter classes to
load
13:57:35,212 | INFO  | rint Extender: 2 | Activator                        |
68 - org.apache.camel.camel-core - 2.6.0 | Found 13 @Converter classes to
load
13:57:35,217 | INFO  | rint Extender: 2 | Activator                        |
68 - org.apache.camel.camel-core - 2.6.0 | Found 1 @Converter classes to
load
13:57:35,219 | INFO  | rint Extender: 2 | Activator                        |
68 - org.apache.camel.camel-core - 2.6.0 | Found 0 @Converter classes to
load
13:57:35,219 | INFO  | rint Extender: 2 | BlueprintCamelContext            |
68 - org.apache.camel.camel-core - 2.6.0 | JMX enabled. Using
ManagedManagementStrategy.
13:57:35,220 | INFO  | rint Extender: 2 | BlueprintCamelContext            |
68 - org.apache.camel.camel-core - 2.6.0 | Apache Camel 2.6.0 (CamelContext:
275-camel-131) is starting
13:57:35,376 | INFO  | rint Extender: 2 | BlueprintCamelContext            |
68 - org.apache.camel.camel-core - 2.6.0 | Apache Camel 2.6.0
(CamelContext:275-camel-131) is shutting down
13:57:35,376 | INFO  | rint Extender: 2 | DefaultShutdownStrategy          |
68 - org.apache.camel.camel-core - 2.6.0 | Starting to graceful shutdown 0
routes (timeout 300 seconds)
13:57:35,377 | INFO  | rint Extender: 2 | DefaultShutdownStrategy          |
68 - org.apache.camel.camel-core - 2.6.0 | Graceful shutdown of 0 routes
completed in 0 seconds
13:57:35,377 | INFO  | rint Extender: 2 | DefaultInflightRepository        |
68 - org.apache.camel.camel-core - 2.6.0 | Shutting down with no inflight
exchanges.
13:57:35,377 | INFO  | rint Extender: 2 | BlueprintCamelContext            |
68 - org.apache.camel.camel-core - 2.6.0 | Uptime: 0.157 seconds
13:57:35,377 | INFO  | rint Extender: 2 | BlueprintCamelContext            |
68 - org.apache.camel.camel-core - 2.6.0 | Apache Camel 2.6.0 (CamelContext:
275-camel-131) is shutdown in 0.001 seconds
13:57:35,378 | ERROR | rint Extender: 2 | BlueprintContainerImpl           |
7 - org.apache.aries.blueprint - 0.2.0.incubating | Unable to start
blueprint container for bundle camel-blueprint-jdbc
org.osgi.service.blueprint.container.ComponentDefinitionException: Unable to
intialize bean camel-129
        at
org.apache.aries.blueprint.container.BeanRecipe.runBeanProcInit(BeanRecipe.java:635)[7:org.apache.aries.blueprint:0.2.0.incubating]
        at
org.apache.aries.blueprint.container.BeanRecipe.internalCreate(BeanRecipe.java:744)[7:org.apache.aries.blueprint:0.2.0.incubating]
        at
org.apache.aries.blueprint.di.AbstractRecipe.create(AbstractRecipe.java:64)[7:org.apache.aries.blueprint:0.2.0.incubating]
        at
org.apache.aries.blueprint.container.BlueprintRepository.createInstances(BlueprintRepository.java:219)[7:org.apache.aries.blueprint:0.2.0.incubating]
        at
org.apache.aries.blueprint.container.BlueprintRepository.createInstance(BlueprintRepository.java:198)[7:org.apache.aries.blueprint:0.2.0.incubating]
        at
org.apache.aries.blueprint.container.BlueprintRepository.create(BlueprintRepository.java:137)[7:org.apache.aries.blueprint:0.2.0.incubating]
        at
org.apache.aries.blueprint.container.BlueprintContainerImpl.getComponentInstance(BlueprintContainerImpl.java:702)[7:org.apache.aries.blueprint:0.2.0.incubating]
        at
org.apache.camel.blueprint.handler.CamelNamespaceHandler$CamelDependenciesFinder.process(CamelNamespaceHandler.java:499)[76:org.apache.camel.camel-blueprint:2.6.0]
        at
org.apache.aries.blueprint.container.BlueprintContainerImpl.processProcessors(BlueprintContainerImpl.java:479)[7:org.apache.aries.blueprint:0.2.0.incubating]
        at
org.apache.aries.blueprint.container.BlueprintContainerImpl.doRun(BlueprintContainerImpl.java:299)[7:org.apache.aries.blueprint:0.2.0.incubating]
        at
org.apache.aries.blueprint.container.BlueprintContainerImpl.run(BlueprintContainerImpl.java:213)[7:org.apache.aries.blueprint:0.2.0.incubating]
        at
java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:471)[:1.6.0_20]
        at
java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:334)[:1.6.0_20]
        at
java.util.concurrent.FutureTask.run(FutureTask.java:166)[:1.6.0_20]
        at
java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$101(ScheduledThreadPoolExecutor.java:165)[:1.6.0_20]
        at
java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:266)[:1.6.0_20]
        at
java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1110)[:1.6.0_20]
        at
java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:603)[:1.6.0_20]
        at java.lang.Thread.run(Thread.java:636)[:1.6.0_20]
Caused by: org.apache.camel.FailedToCreateRouteException: Failed to create
route route44 at: >>> To[jdbc:pgdb] <<< in route:
Route[[From[timer://myTimer?fixedRate=true&period=5000]] -> ... because of
Failed to resolve endpoint: jdbc://pgdb due to:
org.osgi.service.blueprint.container.ComponentDefinitionException: Error
setting property: PropertyDescriptor <name: driverClassName, getter: null,
setter: [public void
org.springframework.jdbc.datasource.DriverManagerDataSource.setDriverClassName(java.lang.String)]
        at
org.apache.camel.model.RouteDefinition.addRoutes(RouteDefinition.java:759)
        at
org.apache.camel.model.RouteDefinition.addRoutes(RouteDefinition.java:160)
        at
org.apache.camel.impl.DefaultCamelContext.startRoute(DefaultCamelContext.java:701)
        at
org.apache.camel.impl.DefaultCamelContext.startRouteDefinitions(DefaultCamelContext.java:1623)
        at
org.apache.camel.impl.DefaultCamelContext.doStartCamel(DefaultCamelContext.java:1412)
        at
org.apache.camel.impl.DefaultCamelContext.doStart(DefaultCamelContext.java:1321)
        at
org.apache.camel.impl.ServiceSupport.start(ServiceSupport.java:65)
        at
org.apache.camel.impl.ServiceSupport.start(ServiceSupport.java:52)
        at
org.apache.camel.impl.DefaultCamelContext.start(DefaultCamelContext.java:1299)
        at
org.apache.camel.blueprint.BlueprintCamelContext.maybeStart(BlueprintCamelContext.java:77)
        at
org.apache.camel.blueprint.BlueprintCamelContext.init(BlueprintCamelContext.java:72)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native
Method)[:1.6.0_20]
        at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)[:1.6.0_20]
        at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)[:1.6.0_20]
        at java.lang.reflect.Method.invoke(Method.java:616)[:1.6.0_20]
        at
org.apache.aries.blueprint.utils.ReflectionUtils.invoke(ReflectionUtils.java:221)[7:org.apache.aries.blueprint:0.2.0.incubating]
        at
org.apache.aries.blueprint.container.BeanRecipe.invoke(BeanRecipe.java:844)[7:org.apache.aries.blueprint:0.2.0.incubating]
        at
org.apache.aries.blueprint.container.BeanRecipe.runBeanProcInit(BeanRecipe.java:633)[7:org.apache.aries.blueprint:0.2.0.incubating]
        ... 18 more
Caused by: org.apache.camel.ResolveEndpointFailedException: Failed to
resolve endpoint: jdbc://pgdb due to:
org.osgi.service.blueprint.container.ComponentDefinitionException: Error
setting property: PropertyDescriptor <name: driverClassName, getter: null,
setter: [public void
org.springframework.jdbc.datasource.DriverManagerDataSource.setDriverClassName(java.lang.String)]
        at
org.apache.camel.impl.DefaultCamelContext.getEndpoint(DefaultCamelContext.java:449)
        at
org.apache.camel.util.CamelContextHelper.getMandatoryEndpoint(CamelContextHelper.java:47)
        at
org.apache.camel.model.RouteDefinition.resolveEndpoint(RouteDefinition.java:175)
        at
org.apache.camel.impl.DefaultRouteContext.resolveEndpoint(DefaultRouteContext.java:110)
        at
org.apache.camel.impl.DefaultRouteContext.resolveEndpoint(DefaultRouteContext.java:116)
        at
org.apache.camel.model.SendDefinition.resolveEndpoint(SendDefinition.java:64)
        at
org.apache.camel.model.SendDefinition.createProcessor(SendDefinition.java:58)
        at
org.apache.camel.model.ProcessorDefinition.makeProcessor(ProcessorDefinition.java:403)
        at
org.apache.camel.model.ProcessorDefinition.addRoutes(ProcessorDefinition.java:174)
        at
org.apache.camel.model.RouteDefinition.addRoutes(RouteDefinition.java:756)
        ... 35 more
Caused by: org.apache.camel.RuntimeCamelException:
org.osgi.service.blueprint.container.ComponentDefinitionException: Error
setting property: PropertyDescriptor <name: driverClassName, getter: null,
setter: [public void
org.springframework.jdbc.datasource.DriverManagerDataSource.setDriverClassName(java.lang.String)]
        at
org.apache.camel.util.ObjectHelper.wrapRuntimeCamelException(ObjectHelper.java:1139)
        at
org.apache.camel.impl.PropertyPlaceholderDelegateRegistry.lookup(PropertyPlaceholderDelegateRegistry.java:56)
        at
org.apache.camel.util.CamelContextHelper.lookup(CamelContextHelper.java:105)
        at
org.apache.camel.util.CamelContextHelper.mandatoryLookup(CamelContextHelper.java:123)
        at
org.apache.camel.component.jdbc.JdbcComponent.createEndpoint(JdbcComponent.java:49)
        at
org.apache.camel.impl.DefaultComponent.createEndpoint(DefaultComponent.java:75)
        at
org.apache.camel.impl.DefaultCamelContext.getEndpoint(DefaultCamelContext.java:431)
        ... 44 more
Caused by:
org.osgi.service.blueprint.container.ComponentDefinitionException: Error
setting property: PropertyDescriptor <name: driverClassName, getter: null,
setter: [public void
org.springframework.jdbc.datasource.DriverManagerDataSource.setDriverClassName(java.lang.String)]
        at
org.apache.aries.blueprint.container.BeanRecipe.setProperty(BeanRecipe.java:827)[7:org.apache.aries.blueprint:0.2.0.incubating]
        at
org.apache.aries.blueprint.container.BeanRecipe.setProperties(BeanRecipe.java:793)[7:org.apache.aries.blueprint:0.2.0.incubating]
        at
org.apache.aries.blueprint.container.BeanRecipe.setProperties(BeanRecipe.java:774)[7:org.apache.aries.blueprint:0.2.0.incubating]
        at
org.apache.aries.blueprint.container.BeanRecipe.internalCreate(BeanRecipe.java:740)[7:org.apache.aries.blueprint:0.2.0.incubating]
        at
org.apache.aries.blueprint.di.AbstractRecipe.create(AbstractRecipe.java:64)[7:org.apache.aries.blueprint:0.2.0.incubating]
        at
org.apache.aries.blueprint.container.BlueprintRepository.createInstances(BlueprintRepository.java:219)[7:org.apache.aries.blueprint:0.2.0.incubating]
        at
org.apache.aries.blueprint.container.BlueprintRepository.createInstance(BlueprintRepository.java:198)[7:org.apache.aries.blueprint:0.2.0.incubating]
        at
org.apache.aries.blueprint.container.BlueprintRepository.create(BlueprintRepository.java:137)[7:org.apache.aries.blueprint:0.2.0.incubating]
        at
org.apache.aries.blueprint.container.BlueprintContainerImpl.getComponentInstance(BlueprintContainerImpl.java:702)[7:org.apache.aries.blueprint:0.2.0.incubating]
        at
org.apache.camel.blueprint.BlueprintContainerRegistry.lookup(BlueprintContainerRegistry.java:43)
        at
org.apache.camel.impl.CompositeRegistry.lookup(CompositeRegistry.java:47)
        at
org.apache.camel.impl.PropertyPlaceholderDelegateRegistry.lookup(PropertyPlaceholderDelegateRegistry.java:54)
        ... 49 more
Caused by: java.lang.IllegalStateException: Could not load JDBC driver class
[org.postgresql.Driver]
        at
org.springframework.jdbc.datasource.DriverManagerDataSource.setDriverClassName(DriverManagerDataSource.java:150)
        at sun.reflect.GeneratedMethodAccessor514.invoke(Unknown Source)
        at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)[:1.6.0_20]
        at java.lang.reflect.Method.invoke(Method.java:616)[:1.6.0_20]
        at
org.apache.aries.blueprint.utils.ReflectionUtils$MethodPropertyDescriptor.internalSet(ReflectionUtils.java:416)
        at
org.apache.aries.blueprint.utils.ReflectionUtils$PropertyDescriptor.set(ReflectionUtils.java:302)
        at
org.apache.aries.blueprint.container.BeanRecipe.setProperty(BeanRecipe.java:825)[7:org.apache.aries.blueprint:0.2.0.incubating]
        ... 60 more
Caused by: java.lang.ClassNotFoundException: org.postgresql.Driver
        at java.net.URLClassLoader$1.run(URLClassLoader.java:217)[:1.6.0_20]
        at java.security.AccessController.doPrivileged(Native
Method)[:1.6.0_20]
        at
java.net.URLClassLoader.findClass(URLClassLoader.java:205)[:1.6.0_20]
        at java.lang.ClassLoader.loadClass(ClassLoader.java:321)[:1.6.0_20]
        at
sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:294)[:1.6.0_20]
        at java.lang.ClassLoader.loadClass(ClassLoader.java:266)[:1.6.0_20]
        at java.lang.Class.forName0(Native Method)[:1.6.0_20]
        at java.lang.Class.forName(Class.java:264)[:1.6.0_20]
        at
org.springframework.jdbc.datasource.DriverManagerDataSource.setDriverClassName(DriverManagerDataSource.java:147)
        ... 66 more


--
View this message in context: http://servicemix.396122.n5.nabble.com/Blueprint-postgresql-camel-jdbc-newbie-question-tp4994862p5014505.html
Sent from the ServiceMix - User mailing list archive at Nabble.com.

Re: Blueprint postgresql camel-jdbc newbie question

Posted by Ioannis Canellos <io...@gmail.com>.
I am not sure I understand the nature of the problem.
Can you please explain how exactly osgi:start fails?
Does it fail to start the bundle, due to unresolved constraints?
Does it fail to create the blueprint context?
Does something else fail?

So would you please paste the exact error message printed by the osgi:start
command, and the full stacktrace from the log?
Also can you please run a package:exports | grep org.postgresql and see if
the package is properly exported by the postgres wrapped bundle?

Now regarding the pom of the wrapper you pasted. Do not import the package
you export.

I am eager to hear your progress on this.

-- 
*Ioannis Canellos*
*
FuseSource <http://fusesource.com>

**
Blog: http://iocanel.blogspot.com
**
Apache Karaf <http://karaf.apache.org/> Committer & PMC
Apache Camel <http://camel.apache.org/> Committer
Apache ServiceMix <http://servicemix.apache.org/>  Committer
Apache Gora <http://incubator.apache.org/gora/> Committer
Apache DirectMemory <http://incubator.apache.org/directmemory/> Committer
*

Re: Blueprint postgresql camel-jdbc newbie question

Posted by bmccabe <wm...@kboservices.com>.
Thanks, Freeman. I made that change and reinstalled it, but there still must
be something incorrect. I bought the OSGI in Action book last night to see
if it could help me understand what I'm not getting in this. Have to say I
would've thought making a simple call out to a remote db using camel-jdbc
would be more trivial than this.

Bill

--
View this message in context: http://servicemix.396122.n5.nabble.com/Blueprint-postgresql-camel-jdbc-newbie-question-tp4994862p5013813.html
Sent from the ServiceMix - User mailing list archive at Nabble.com.

Re: Blueprint postgresql camel-jdbc newbie question

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

One obvious error is that the Fragment-Host should be the Bundle- 
SymbolicName of spring-jdbc bundle, which is org.springframework.jdbc.

Freeman
On 2011-11-22, at 上午3:05, bmccabe wrote:

> After a lot of looking and not finding an newbie-friendly  
> explanation/example
> of setting up a bundle fragment to solve this problem, I managed to  
> patch
> together a fragment (pasted below) from an online posting about  
> version
> numbers in OSGI that installs ok, but it hasn't solved my problem.  
> Am I
> doing something obviously wrong or leaving something out?
>
> Thanks,
> Bill
>
>
> pom.xml========
> <?xml version="1.0" encoding="UTF-8" ?>
> <project xmlns="http://maven.apache.org/POM/4.0.0"
> xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
> xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
> http://maven.apache.org/maven-v4_0_0.xsd">
>  <modelVersion>4.0.0</modelVersion>
>  <parent>
>    <groupId>org.apache.servicemix.examples</groupId>
>    <artifactId>examples</artifactId>
>    <version>4.3.0</version>
>    <relativePath>../camel-blueprint-jdbc</relativePath>
>  </parent>
>  <dependencies>
>    <dependency>
>      <groupId>postgresql</groupId>
>      <artifactId>postgresql</artifactId>
>      <version>8.2-504.jdbc3</version>
>    </dependency>
>  </dependencies>
>  <groupId>camel-blueprint-jdbc</groupId>
>  <artifactId>postgresql-bundle-frag</artifactId>
>  <version>0.9.10</version>
>  <packaging>jar</packaging>
>  <name>Camel Blueprint Postgresql Fragment Bundle</name>
>  <description>Shows how to create a fragment bundle that causes  
> additional
> packages from the JVM environment to be exported. After starting this
> bundle, the OSGi console detail view of the system bundle
> (/system/console/bundles/0) should list two com.example packages as  
> being
> exported. Those packages are just dummy examples, the list of exported
> packages will obviously need to be adapted to create your own fragment
> bundle.</description>
>    <build>
>      <plugins>
>        <plugin>
>
>          <groupId>org.apache.maven.plugins</groupId>
>          <artifactId>maven-jar-plugin</artifactId>
>          <configuration>
>            <archive>
>              <index>true</index>
>              <manifest>
>                <addClasspath>false</addClasspath>
>              </manifest>
>              <manifestEntries>
>                <Bundle-Version>0.9.10</Bundle-Version>
>
> <Bundle-Description>${project.description}</Bundle-Description>
>                <Bundle-Name>${project.name}</Bundle-Name>
>                <Bundle-DocURL>http://www.apache.org/</Bundle-DocURL>
>                <Bundle-ManifestVersion>2</Bundle-ManifestVersion>
>                <Bundle-Vendor>Apache Software Foundation</Bundle- 
> Vendor>
>
> <Fragment-Host>org.apache.servicemix.examples.camel</Fragment-Host>
>
> <Bundle-SymbolicName>${project.artifactId}</Bundle-SymbolicName>
>                <Import-Package>org.postgresql</Import-Package>
>                <Export-Package>org.postgresql;
> version=8.2.504</Export-Package>
>              </manifestEntries>
>            </archive>
>          </configuration>
>        </plugin>
>      </plugins>
>    </build>
> </project>
>
> --
> View this message in context: http://servicemix.396122.n5.nabble.com/Blueprint-postgresql-camel-jdbc-newbie-question-tp4994862p5011360.html
> Sent from the ServiceMix - User mailing list archive at Nabble.com.

---------------------------------------------
Freeman Fang

FuseSource
Email:ffang@fusesource.com
Web: fusesource.com
Twitter: freemanfang
Blog: http://freemanfang.blogspot.com










Re: Blueprint postgresql camel-jdbc newbie question

Posted by bmccabe <wm...@kboservices.com>.
After a lot of looking and not finding an newbie-friendly explanation/example
of setting up a bundle fragment to solve this problem, I managed to patch
together a fragment (pasted below) from an online posting about version
numbers in OSGI that installs ok, but it hasn't solved my problem. Am I
doing something obviously wrong or leaving something out?

Thanks,
Bill


pom.xml========
<?xml version="1.0" encoding="UTF-8" ?> 
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
http://maven.apache.org/maven-v4_0_0.xsd">
  <modelVersion>4.0.0</modelVersion> 
  <parent>
    <groupId>org.apache.servicemix.examples</groupId> 
    <artifactId>examples</artifactId> 
    <version>4.3.0</version> 
    <relativePath>../camel-blueprint-jdbc</relativePath>
  </parent>
  <dependencies>
    <dependency>
      <groupId>postgresql</groupId>
      <artifactId>postgresql</artifactId>
      <version>8.2-504.jdbc3</version>
    </dependency>
  </dependencies>
  <groupId>camel-blueprint-jdbc</groupId> 
  <artifactId>postgresql-bundle-frag</artifactId> 
  <version>0.9.10</version> 
  <packaging>jar</packaging> 
  <name>Camel Blueprint Postgresql Fragment Bundle</name> 
  <description>Shows how to create a fragment bundle that causes additional
packages from the JVM environment to be exported. After starting this
bundle, the OSGi console detail view of the system bundle
(/system/console/bundles/0) should list two com.example packages as being
exported. Those packages are just dummy examples, the list of exported
packages will obviously need to be adapted to create your own fragment
bundle.</description> 
    <build>
      <plugins>
        <plugin>
 
          <groupId>org.apache.maven.plugins</groupId> 
          <artifactId>maven-jar-plugin</artifactId> 
          <configuration>
            <archive>
              <index>true</index> 
              <manifest>
                <addClasspath>false</addClasspath> 
              </manifest>
              <manifestEntries>
                <Bundle-Version>0.9.10</Bundle-Version> 
               
<Bundle-Description>${project.description}</Bundle-Description> 
                <Bundle-Name>${project.name}</Bundle-Name> 
                <Bundle-DocURL>http://www.apache.org/</Bundle-DocURL> 
                <Bundle-ManifestVersion>2</Bundle-ManifestVersion> 
                <Bundle-Vendor>Apache Software Foundation</Bundle-Vendor> 
               
<Fragment-Host>org.apache.servicemix.examples.camel</Fragment-Host> 
               
<Bundle-SymbolicName>${project.artifactId}</Bundle-SymbolicName> 
                <Import-Package>org.postgresql</Import-Package>
                <Export-Package>org.postgresql;
version=8.2.504</Export-Package> 
              </manifestEntries>
            </archive>
          </configuration>
        </plugin>
      </plugins>
    </build>
</project>

--
View this message in context: http://servicemix.396122.n5.nabble.com/Blueprint-postgresql-camel-jdbc-newbie-question-tp4994862p5011360.html
Sent from the ServiceMix - User mailing list archive at Nabble.com.

Re: Blueprint postgresql camel-jdbc newbie question

Posted by bmccabe <wm...@kboservices.com>.
Thanks Freeman, I'll look through it and see if I can learn what exactly to
do.

Bill

--
View this message in context: http://servicemix.396122.n5.nabble.com/Blueprint-postgresql-camel-jdbc-newbie-question-tp4994862p4996473.html
Sent from the ServiceMix - User mailing list archive at Nabble.com.

Re: Blueprint postgresql camel-jdbc newbie question

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

This is actually a common issue when use JDBC driver in OSGi  
container, in your case, it's because spring-jdbc bundle didn't import  
org.postgresql driver package beforehand but try to use  
class.forname() method to init it, hence you see such this exception.

This problem generally from a bundle(let's say it bundle A) using some  
code like classForName(jdbc_driver_classname) to init a jdbc driver  
class, this is a big problem in OSGi world, as if BundleA not import  
package for jdbc_driver_classname, you'll see the problem. However  
BundleA actually can't know about package name for  
jdbc_driver_classname beforehand, as the jdbc_driver_classname  
generally is passed in through configuration during runtime, it can't  
be determined during build time, so you can't add correct package  
import when you generate bundle A.

The general solution for this issue is that
Option1.you create JDBC driver as a fragment bundle, and attach it to  
bundle A(bundle A is host bundle now), so that all resource from  
fragment bundle is available for the host bundle.
or
Option2. enable dynamic import for bundle A

Also you can try with Achim's suggestion which just pass in a object,  
but not a classname which avoid the class.forname() thing here.

You can find more details from link [1] and [2]

[1]http://fusesource.com/forums/thread.jspa?messageID=12519
[2]http://fusesource.com/forums/thread.jspa?messageID=9780

Freeman
On 2011-11-16, at 上午7:09, bmccabe wrote:

> Thanks, I'm not familiar with that, so I'll look into it.
> Bill
>
> --
> View this message in context: http://servicemix.396122.n5.nabble.com/Blueprint-postgresql-camel-jdbc-newbie-question-tp4994862p4996103.html
> Sent from the ServiceMix - User mailing list archive at Nabble.com.

---------------------------------------------
Freeman Fang

FuseSource
Email:ffang@fusesource.com
Web: fusesource.com
Twitter: freemanfang
Blog: http://freemanfang.blogspot.com










Re: Blueprint postgresql camel-jdbc newbie question

Posted by bmccabe <wm...@kboservices.com>.
Thanks, I'm not familiar with that, so I'll look into it.
Bill

--
View this message in context: http://servicemix.396122.n5.nabble.com/Blueprint-postgresql-camel-jdbc-newbie-question-tp4994862p4996103.html
Sent from the ServiceMix - User mailing list archive at Nabble.com.

Re: Blueprint postgresql camel-jdbc newbie question

Posted by Achim Nierbeck <bc...@googlemail.com>.
Hi,

AFAIR correctly with the postgres driver it somehow needs to register
itself in the classloader
cause it's actually loaded by reflection, if I remember correctly.
To get this working you need to load the Driver into the classloader,
this can be done either
by custom logic or AFAIR you can do something the like:

<bean class="org.postgresql.Driver" onStart="newInstance"/>

Sorry I couldn't actually remember the correct syntax and I don't have
the sources I used before at hand :(

you might also take a look at this:
http://stackoverflow.com/questions/2502308/osgi-apache-commons-dbcp-classloading-issue

Regards, Achim


Am 15.11.2011 17:40, schrieb bmccabe:
> Greetings all,
>
> I'm new to servicemix, coming from the apache/mod_perl world, and am trying
> to get up to speed. I've been through a lot of the tutorial material, and am
> now trying to set a really basic route using blueprint and camel-jdbc which
> makes a simple call to a postgres DB. I feel like I'm almost there but can't
> quite get it. It builds fine if I include an
> <Import-Package>org.postgresql.jdbc</Import-Package>, but when I try to
> osgi:start it fails because it can't find "org.postgresql.Driver, though
> it's there in the driver jar. Can anyone tip me off to what I'm missing? 
>
> Here's my blueprint statement, which is just a modified version of the
> camel-blueprint example, (I've change the db server hostname though):
> <blueprint
>     xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0"
>     xmlns:cm="http://aries.apache.org/blueprint/xmlns/blueprint-cm/v1.0.0"
>     xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
>     xsi:schemaLocation="http://www.osgi.org/xmlns/blueprint/v1.0.0
> http://www.osgi.org/xmlns/blueprint/v1.0.0/blueprint.xsd">
>
>     <cm:property-placeholder persistent-id="org.apache.servicemix.examples">
>         <cm:default-properties>
>             <cm:property name="prefix" value="Blueprint-Example"/>
>         </cm:default-properties>
>     </cm:property-placeholder>
>
>     <camelContext xmlns="http://camel.apache.org/schema/blueprint">
>         <route>
>             <from uri="timer://myTimer?fixedRate=true&amp;period=5000" />
> 	 <setBody>
> 	<constant>select current_timestamp</constant>
> 	</setBody>
>            <to uri="jdbc:pgdb" />
>             
>             <to uri="log:ExampleRouterBlueprint" />
>         </route>
>     </camelContext>
> 	<bean id="pgdb"
> class="org.springframework.jdbc.datasource.DriverManagerDataSource">
> 	 <property name="driverClassName" value="org.postgresql.Driver"/>
> 	 <property name="url"
> value="jdbc:postgresql://myhost.mycompany.com/smx_test01"/>
> 	 <property name="username" value="smx"/>
> 	 <property name="password" value="smx"/>
> 	</bean>
>     <bean id="myTransform"
> class="org.apache.servicemix.examples.camel.MyTransform">
>         <property name="prefix" value="${prefix}" />
>     </bean>
>
> </blueprint>
>
> and I've added the this to the pom.xml:
> <dependency>
>  <groupId>postgresql</groupId>
>  <artifactId>postgresql</artifactId>
>  <version>8.2-504.jdbc3</version>
> </dependency>
>
>
>
> --
> View this message in context: http://servicemix.396122.n5.nabble.com/Blueprint-postgresql-camel-jdbc-newbie-question-tp4994862p4994862.html
> Sent from the ServiceMix - User mailing list archive at Nabble.com.


-- 
-----

Apache Karaf <http://karaf.apache.org/> Committer & PMC
OPS4J Pax Web <http://wiki.ops4j.org/display/paxweb/Pax+Web/>  Committer & Project Lead


Re: Blueprint postgresql camel-jdbc newbie question

Posted by Rohit <bk...@gmail.com>.
bmccabe <wm...@...> writes:

> 
> Greetings all,
> 
> I'm new to servicemix, coming from the apache/mod_perl world, and am 
trying
> to get up to speed. I've been through a lot of the tutorial material, 
and am
> now trying to set a really basic route using blueprint and camel-jdbc 
which
> makes a simple call to a postgres DB. I feel like I'm almost there but 
can't
> quite get it. It builds fine if I include an
> <Import-Package>org.postgresql.jdbc</Import-Package>, but when I try 
to
> osgi:start it fails because it can't find "org.postgresql.Driver, 
though
> it's there in the driver jar. Can anyone tip me off to what I'm 
missing? 
> 
> Here's my blueprint statement, which is just a modified version of the
> camel-blueprint example, (I've change the db server hostname though):
> <blueprint
>     xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0"
>     xmlns:cm="http://aries.apache.org/blueprint/xmlns/blueprint-
cm/v1.0.0"
>     xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
>     xsi:schemaLocation="http://www.osgi.org/xmlns/blueprint/v1.0.0
> http://www.osgi.org/xmlns/blueprint/v1.0.0/blueprint.xsd">
> 
>     <cm:property-placeholder persistent-
id="org.apache.servicemix.examples">
>         <cm:default-properties>
>             <cm:property name="prefix" value="Blueprint-Example"/>
>         </cm:default-properties>
>     </cm:property-placeholder>
> 
>     <camelContext xmlns="http://camel.apache.org/schema/blueprint">
>         <route>
>             <from uri="timer://myTimer?fixedRate=true&amp;period=5000" 
/>
> 	 <setBody>
> 	<constant>select current_timestamp</constant>
> 	</setBody>
>            <to uri="jdbc:pgdb" />
> 
>             <to uri="log:ExampleRouterBlueprint" />
>         </route>
>     </camelContext>
> 	<bean id="pgdb"
> class="org.springframework.jdbc.datasource.DriverManagerDataSource">
> 	 <property name="driverClassName" 
value="org.postgresql.Driver"/>
> 	 <property name="url"
> value="jdbc:postgresql://myhost.mycompany.com/smx_test01"/>
> 	 <property name="username" value="smx"/>
> 	 <property name="password" value="smx"/>
> 	</bean>
>     <bean id="myTransform"
> class="org.apache.servicemix.examples.camel.MyTransform">
>         <property name="prefix" value="${prefix}" />
>     </bean>
> 
> </blueprint>
> 
> and I've added the this to the pom.xml:
> <dependency>
>  <groupId>postgresql</groupId>
>  <artifactId>postgresql</artifactId>
>  <version>8.2-504.jdbc3</version>
> </dependency>
> 
> --
> View this message in context: 
http://servicemix.396122.n5.nabble.com/Blueprint-postgresql-camel-jdbc-
newbie-question-tp4994862p4994862.html
> Sent from the ServiceMix - User mailing list archive at Nabble.com.
> 
> 

Hi ,

I sorted out this issue after hours of scratching my brain cell. First, 
I used "SimpleDriverDataSource" class instead of 
"DriverManagerDataSource". Property name "driverClassName" will be now 
"driveClass". So the bean would look like as below

    <bean id="pgdb" 
class="org.springframework.jdbc.datasource.SimpleDriverDataSource">
 	 <property name="driverClass" value="org.postgresql.Driver"/>
 	 <property name="url"
value="jdbc:postgresql://myhost.mycompany.com/smx_test01"/>
 	 <property name="username" value="smx"/>
 	 <property name="password" value="smx"/>
     </bean>


Now, in the pom.xml I added two dependency as below

        <dependency>
		<groupId>org.springframework</groupId>
		<artifactId>spring-jdbc</artifactId>
		<version>4.1.6.RELEASE</version>
	</dependency>
	
	<dependency>
		<groupId>org.postgresql</groupId>
		<artifactId>postgresql</artifactId>
		<version>9.3-1100-jdbc41</version>
	</dependency>


again in the same file, under the plugins, the plugin with groupId 
org.apache.felix should have the required import-package as below

           <plugin>
	      <groupId>org.apache.felix</groupId>
	      <artifactId>maven-bundle-plugin</artifactId>
	      <version>1.4.0</version>
	      <extensions>true</extensions>
	      <configuration>
	          <instructions>
	              <Bundle-
SymbolicName>${pom.groupId}.${pom.artifactId}</Bundle-SymbolicName>
	              <Bundle-Name>${pom.artifactId}</Bundle-Name>
	              <Bundle-Version>1.0.0</Bundle-Version>
	              <Import-Package>
                          <!--Required for the driver solution-->
	                  org.springframework.jdbc,
	                  org.springframework.jdbc.datasource,
	                  org.postgresql, 
                          <!--If you are using camel also-->
	                  org.apache.camel.builder, 
	                  org.apache.camel.main,
	                  org.apache.camel.model,
	                  org.apache.log4j
	              </Import-Package>
	              
	          </instructions>
	      </configuration>
	  </plugin>


Also, at the top of your pom.xml, mention the packaging as bundle

  <groupId>your.groupId</groupId>
  <artifactId>your.artifaceId</artifactId>
  <packaging>bundle</packaging> <!-- give the packaging as bundle -->
  <version>0.0.1-SNAPSHOT</version>


Now we are done with pom.xml file. Go ahead and build the project using 
"Run as" --> maven clean install.


Next part is to install the bundle in servicemix. Before doing this, I 
installed spring-jdbc and postgresql by running the below commands one 
by one in servicemix

osgi:install wrap:mvn:org.springframework/spring-jdbc/4.1.6.RELEASE

osgi:start 224 (give the ID which got generated)

osgi:install wrap:mvn:org.postgresql/postgresql/9.3-1100-jdbc41

osgi:start 225 (give the ID which got generated)


Now I installed my bundle as below

osgi:install wrap:mvn:your.groupId/your.artifaceId/0.0.1-SNAPSHOT

osgi:start 226 (give the ID which got generated)


This is it. This fixed the error. The OSGi bundle started successfully 
and it was able to find "org.postgresql.Driver". So no error like "Could 
not load JDBC driver class [org.postgresql.Driver]" occured this time.

Hope this helps. Thanks for bearing in such long solution.


Re: Blueprint postgresql camel-jdbc newbie question

Posted by bkrohit <bk...@gmail.com>.
Hi ,

I sorted out this issue after hours of scratching my brain cell. First, I
used "SimpleDriverDataSource" class instead of "DriverManagerDataSource".
Property name "driverClassName" will be now "driveClass". So the bean would
look like as below

    *<bean id="pgdb"
class="org.springframework.jdbc.datasource.SimpleDriverDataSource">
 	 <property name="driverClass" value="org.postgresql.Driver"/>
 	 <property name="url"
value="jdbc:postgresql://myhost.mycompany.com/smx_test01"/>
 	 <property name="username" value="smx"/>
 	 <property name="password" value="smx"/>
     </bean>*


Now, in the pom.xml I added two dependency as below

        *<dependency>
		<groupId>org.springframework</groupId>
		<artifactId>spring-jdbc</artifactId>
		<version>4.1.6.RELEASE</version>
	</dependency>
	
	<dependency>
		<groupId>org.postgresql</groupId>
		<artifactId>postgresql</artifactId>
		<version>9.3-1100-jdbc41</version>
	</dependency>*


again in the same file, under the plugins, the plugin with groupId
org.apache.felix should have the required import-package as below

           <plugin>
	      <groupId>org.apache.felix</groupId>
	      <artifactId>maven-bundle-plugin</artifactId>
	      <version>1.4.0</version>
	      <extensions>true</extensions>
	      <configuration>
	          <instructions>
	             
<Bundle-SymbolicName>${pom.groupId}.${pom.artifactId}</Bundle-SymbolicName>
	              <Bundle-Name>${pom.artifactId}</Bundle-Name>
	              <Bundle-Version>1.0.0</Bundle-Version>
	              *<Import-Package>
                          
	                  org.springframework.jdbc,
	                  org.springframework.jdbc.datasource,
	                  org.postgresql, 
                          
	                  org.apache.camel.builder, 
	                  org.apache.camel.main,
	                  org.apache.camel.model,
	                  org.apache.log4j
	              </Import-Package>*
	              
	          </instructions>
	      </configuration>
	  </plugin>


Also, at the top of your pom.xml, mention the packaging as bundle

  <groupId>your.groupId</groupId>
  <artifactId>your.artifaceId</artifactId>
  *<packaging>bundle</packaging>*
  <version>0.0.1-SNAPSHOT</version>


Now we are done with pom.xml file. Go ahead and build the project using "Run
as" --> maven clean install.


Next part is to install the bundle in servicemix. Before doing this, I
installed spring-jdbc and postgresql by running the below commands one by
one in servicemix

*osgi:install wrap:mvn:org.springframework/spring-jdbc/4.1.6.RELEASE

osgi:start 224 (give the ID which got generated)

osgi:install wrap:mvn:org.postgresql/postgresql/9.3-1100-jdbc41

osgi:start 225 (give the ID which got generated)*


Now I installed my bundle as below

*osgi:install wrap:mvn:your.groupId/your.artifaceId/0.0.1-SNAPSHOT

osgi:start 226 (give the ID which got generated)*


This is it. This fixed the error. The OSGi bundle started successfully and
it was able to find "org.postgresql.Driver". So no error like "Could not
load JDBC driver class [org.postgresql.Driver]" occured this time.

Hope this helps. Thanks for bearing in the long solution.



--
View this message in context: http://servicemix.396122.n5.nabble.com/Blueprint-postgresql-camel-jdbc-newbie-question-tp4994862p5722661.html
Sent from the ServiceMix - User mailing list archive at Nabble.com.