bmccabe <wmccabe@...> 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&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.