Hi,

Thanks for the suggestions.

I already tried with followings. May be something is wrong in the way I
specified them.

1) import the com.mysql.jdbc pacakage

<mysql.import.version.range>[5.1.35, 5.1.38)</mysql.import.version.range>
com.mysql.jdbc.*;version="${mysql.import.version.range}"

2) Adding dynamic import

<DynamicImport-Package>*</DynamicImport-Package>

I have attached my pom.xml file herewith.



On Tue, Mar 1, 2016 at 3:45 PM, Aruna Karunarathna <[email protected]> wrote:

> Hi Anupama,
>
> Since you are doing a class.forName();, you have to do dynamic import
> package.
>
> Can you try adding that to your pom.xml?
>
> Regards,
> Aruna
>
> On Tue, Mar 1, 2016 at 2:54 PM, Thusitha Thilina Dayaratne <
> [email protected]> wrote:
>
>> Hi Anupama,
>>
>> Are you importing the com.mysql.jdbc package inside your bundle which
>> uses mysql?
>>
>> Thanks
>> Thusitha
>>
>> On Tue, Mar 1, 2016 at 2:49 PM, Anupama Pathirage <[email protected]>
>> wrote:
>>
>>> Hi,
>>>
>>> I need to query MySQL database with Carbon 5 based product and I added
>>> the mysql-connector-java-5.1.35.jar [1]  file to the osgi/droppings
>>> directory. Since the jar file is already an osgi bundle I copied it
>>> directly to osgi/droppings folder.
>>>
>>> But when I load the class as below it gives the
>>> java.lang.ClassNotFoundException.
>>>
>>> Class.forName("com.mysql.jdbc.Driver");
>>>
>>> Is there any missing step I followed which can cause this error?
>>>
>>>
>>> java.lang.ClassNotFoundException: com.mysql.jdbc.Driver cannot be found
>>> by org.wso2.carbon.ibus_1.0.0.SNAPSHOT
>>>     at
>>> org.eclipse.osgi.internal.loader.BundleLoader.findClassInternal(BundleLoader.java:432)
>>>     at
>>> org.eclipse.osgi.internal.loader.BundleLoader.findClass(BundleLoader.java:345)
>>>     at
>>> org.eclipse.osgi.internal.loader.BundleLoader.findClass(BundleLoader.java:337)
>>>     at
>>> org.eclipse.osgi.internal.loader.ModuleClassLoader.loadClass(ModuleClassLoader.java:160)
>>>     at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
>>>     at java.lang.Class.forName0(Native Method)
>>>     at java.lang.Class.forName(Class.java:264)
>>>     at org.wso2.carbon.ibus.Activator.start(Activator.java:55)
>>>     at
>>> org.eclipse.osgi.internal.framework.BundleContextImpl$3.run(BundleContextImpl.java:771)
>>>     at
>>> org.eclipse.osgi.internal.framework.BundleContextImpl$3.run(BundleContextImpl.java:1)
>>>     at java.security.AccessController.doPrivileged(Native Method)
>>>     at
>>> org.eclipse.osgi.internal.framework.BundleContextImpl.startActivator(BundleContextImpl.java:764)
>>>     at
>>> org.eclipse.osgi.internal.framework.BundleContextImpl.start(BundleContextImpl.java:721)
>>>     at
>>> org.eclipse.osgi.internal.framework.EquinoxBundle.startWorker0(EquinoxBundle.java:936)
>>>     at
>>> org.eclipse.osgi.internal.framework.EquinoxBundle$EquinoxModule.startWorker(EquinoxBundle.java:319)
>>>     at org.eclipse.osgi.container.Module.doStart(Module.java:571)
>>>     at org.eclipse.osgi.container.Module.start(Module.java:439)
>>>     at
>>> org.eclipse.osgi.internal.framework.EquinoxBundle.start(EquinoxBundle.java:393)
>>>     at
>>> org.eclipse.osgi.internal.framework.EquinoxBundle.start(EquinoxBundle.java:412)
>>>     at
>>> org.eclipse.equinox.internal.simpleconfigurator.ConfigApplier.startBundles(ConfigApplier.java:438)
>>>     at
>>> org.eclipse.equinox.internal.simpleconfigurator.ConfigApplier.install(ConfigApplier.java:111)
>>>     at
>>> org.eclipse.equinox.internal.simpleconfigurator.SimpleConfiguratorImpl.applyConfiguration(SimpleConfiguratorImpl.java:191)
>>>     at
>>> org.eclipse.equinox.internal.simpleconfigurator.SimpleConfiguratorImpl.applyConfiguration(SimpleConfiguratorImpl.java:205)
>>>     at
>>> org.eclipse.equinox.internal.simpleconfigurator.Activator.start(Activator.java:60)
>>>     at
>>> org.eclipse.osgi.internal.framework.BundleContextImpl$3.run(BundleContextImpl.java:771)
>>>     at
>>> org.eclipse.osgi.internal.framework.BundleContextImpl$3.run(BundleContextImpl.java:1)
>>>     at java.security.AccessController.doPrivileged(Native Method)
>>>     at
>>> org.eclipse.osgi.internal.framework.BundleContextImpl.startActivator(BundleContextImpl.java:764)
>>>     at
>>> org.eclipse.osgi.internal.framework.BundleContextImpl.start(BundleContextImpl.java:721)
>>>     at
>>> org.eclipse.osgi.internal.framework.EquinoxBundle.startWorker0(EquinoxBundle.java:936)
>>>     at
>>> org.eclipse.osgi.internal.framework.EquinoxBundle$EquinoxModule.startWorker(EquinoxBundle.java:319)
>>>     at org.eclipse.osgi.container.Module.doStart(Module.java:571)
>>>     at org.eclipse.osgi.container.Module.start(Module.java:439)
>>>     at
>>> org.eclipse.osgi.internal.framework.EquinoxBundle.start(EquinoxBundle.java:393)
>>>     at
>>> org.eclipse.osgi.internal.framework.EquinoxBundle.start(EquinoxBundle.java:412)
>>>     at
>>> org.wso2.carbon.launcher.CarbonServer.loadInitialBundles(CarbonServer.java:243)
>>>     at org.wso2.carbon.launcher.CarbonServer.start(CarbonServer.java:84)
>>>     at org.wso2.carbon.launcher.Main.main(Main.java:83)
>>>
>>>
>>> [1] http://mvnrepository.com/artifact/mysql/mysql-connector-java/5.1.35
>>>
>>>
>>> Thanks.
>>> --
>>> Anupama Pathirage
>>> Associate Technical Lead
>>> WSO2, Inc.  http://wso2.com/
>>> Email: [email protected]
>>> Mobile:+94 71 8273 979
>>>
>>>
>>>
>>> _______________________________________________
>>> Dev mailing list
>>> [email protected]
>>> http://wso2.org/cgi-bin/mailman/listinfo/dev
>>>
>>>
>>
>>
>> --
>> Thusitha Dayaratne
>> Software Engineer
>> WSO2 Inc. - lean . enterprise . middleware |  wso2.com
>>
>> Mobile  +94712756809
>> Blog      alokayasoya.blogspot.com
>> About    http://about.me/thusithathilina
>>
>>
>> _______________________________________________
>> Dev mailing list
>> [email protected]
>> http://wso2.org/cgi-bin/mailman/listinfo/dev
>>
>>
>
>
> --
>
> *Aruna Sujith Karunarathna *
> WSO2, Inc | lean. enterprise. middleware.
> #20, Palm Grove, Colombo 03, Sri Lanka
> Mobile: +94 71 9040362 | Work: +94 112145345
> Email: [email protected] | Web: www.wso2.com
>
>



-- 
Anupama Pathirage
Associate Technical Lead
WSO2, Inc.  http://wso2.com/
Email: [email protected]
Mobile:+94 71 8273 979
Blog:http://mycodeideas.blogspot.com/
<?xml version="1.0" encoding="UTF-8"?>
<!--
  ~ /*
  ~ * Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
  ~ *
  ~ * Licensed under the Apache License, Version 2.0 (the "License");
  ~ * you may not use this file except in compliance with the License.
  ~ * You may obtain a copy of the License at
  ~ *
  ~ * http://www.apache.org/licenses/LICENSE-2.0
  ~ *
  ~ * Unless required by applicable law or agreed to in writing, software
  ~ * distributed under the License is distributed on an "AS IS" BASIS,
  ~ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  ~ * See the License for the specific language governing permissions and
  ~ * limitations under the License.
  ~ */
  -->
<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/xsd/maven-4.0.0.xsd";>
    <modelVersion>4.0.0</modelVersion>

    <parent>
        <groupId>org.wso2.carbon.ibus</groupId>
        <artifactId>org.wso2.carbon.ibus.parent</artifactId>
        <version>1.0.0-SNAPSHOT</version>
        <relativePath>../../../pom.xml</relativePath>
    </parent>

    <artifactId>org.wso2.carbon.ibus</artifactId>
    <packaging>bundle</packaging>

    <name>WSO2 Carbon - Integration Bus Component</name>
    <description>WSO2 Integration Bus</description>
    <url>http://maven.apache.org</url>

    <licenses>
        <license>
            <name>The Apache Software License, Version 2.0</name>
            <url>http://www.apache.org/licenses/LICENSE-2.0.txt</url>
        </license>
    </licenses>

    <developers>
        <developer>
            <name>WSO2</name>
            <email>[email protected]</email>
            <organization>WSO2 Inc</organization>
            <organizationUrl>https://github.com/wso2/product-gw</organizationUrl>
        </developer>
    </developers>

    <distributionManagement>
        <repository>
            <id>sonatype.release</id>
            <url>https://oss.sonatype.org/service/local/staging/deploy/maven2</url>
        </repository>
        <snapshotRepository>
            <id>sonatype.snapshots</id>
            <url>https://oss.sonatype.org/content/repositories/snapshots</url>
        </snapshotRepository>
    </distributionManagement>

    <dependencies>
        <dependency>
            <groupId>org.wso2.eclipse.osgi</groupId>
            <artifactId>org.eclipse.osgi</artifactId>
        </dependency>
        <dependency>
            <groupId>org.wso2.eclipse.osgi</groupId>
            <artifactId>org.eclipse.osgi.services</artifactId>
        </dependency>
        <dependency>
            <groupId>org.slf4j</groupId>
            <artifactId>slf4j-api</artifactId>
        </dependency>
        <dependency>
            <groupId>org.slf4j</groupId>
            <artifactId>slf4j-log4j12</artifactId>
        </dependency>
        <dependency>
            <groupId>org.wso2.carbon.messaging</groupId>
            <artifactId>org.wso2.carbon.messaging</artifactId>
        </dependency>
        <dependency>
            <groupId>org.wso2.orbit.org.antlr</groupId>
            <artifactId>antlr4-runtime</artifactId>
        </dependency>
        <dependency>
            <groupId>mysql</groupId>
            <artifactId>mysql-connector-java</artifactId>
            <version>5.1.35</version>
        </dependency>
    </dependencies>

    <build>
        <pluginManagement>
            <plugins>
                <!-- Compiler -->
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-compiler-plugin</artifactId>
                    <version>3.3</version>
                    <configuration>
                        <source>1.8</source>
                        <target>1.8</target>
                        <compilerArgs>
                            <arg>-Xlint</arg>
                        </compilerArgs>
                    </configuration>
                </plugin>

                <!-- License RAT check -->
                <plugin>
                    <groupId>org.apache.rat</groupId>
                    <artifactId>apache-rat-plugin</artifactId>
                    <version>0.10</version>
                    <executions>
                        <execution>
                            <id>rat-check</id>
                            <phase>validate</phase>
                            <goals>
                                <goal>check</goal>
                            </goals>
                            <configuration>
                                <excludes>
                                    <exclude>LICENSE</exclude>
                                    <exclude>build-number.txt</exclude>
                                </excludes>
                            </configuration>
                        </execution>
                    </executions>
                </plugin>

                <!-- ANTLR Plugin -->
                <plugin>
                    <groupId>org.antlr</groupId>
                    <artifactId>antlr4-maven-plugin</artifactId>
                    <version>4.5.1</version>
                    <executions>
                        <execution>
                            <goals>
                                <goal>antlr4</goal>
                            </goals>
                            <configuration>
                                <!--<sourceDirectory>${antlr.dir}</sourceDirectory>-->
                                <listener>true</listener>
                                <visitor>false</visitor>
                            </configuration>
                        </execution>
                    </executions>
                </plugin>

                <!-- Surefire -->
                <!--                <plugin>
                                    <groupId>org.apache.maven.plugins</groupId>
                                    <artifactId>maven-surefire-plugin</artifactId>
                                    <version>2.14.1</version>
                                    <configuration>
                                        <argLine>-Xmx512m</argLine>
                                        <redirectTestOutputToFile>${surefire.redirectTestOutputToFile}</redirectTestOutputToFile>
                                        <systemPropertyVariables>
                                            <java.io.tmpdir>${project.build.directory}</java.io.tmpdir>
                                        </systemPropertyVariables>
                                        <includes>
                                            <include>**/*TestSuite.java</include>
                                            <include>**/Test*.java</include>
                                            <include>**/*Test.java</include>
                                            <include>**/*TestCase.java</include>
                                        </includes>
                                    </configuration>
                                </plugin>
                -->

                <!-- Deploy plugin -->
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-deploy-plugin</artifactId>
                    <version>2.8</version>
                    <configuration>
                        <deployAtEnd>true</deployAtEnd>
                    </configuration>
                </plugin>
            </plugins>
        </pluginManagement>

        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>3.3</version>
            </plugin>
            <plugin>
                <groupId>org.apache.rat</groupId>
                <artifactId>apache-rat-plugin</artifactId>
                <version>0.10</version>
            </plugin>
            <!--plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-checkstyle-plugin</artifactId>
            </plugin-->
            <plugin>
                <groupId>org.antlr</groupId>
                <artifactId>antlr4-maven-plugin</artifactId>
                <version>4.5.1</version>
            </plugin>
            <!--
                        <plugin>
                            <groupId>org.apache.maven.plugins</groupId>
                            <artifactId>maven-surefire-plugin</artifactId>
                            <version>2.14.1</version>
                        </plugin>
            -->
            <!--plugin>
                <groupId>org.codehaus.mojo</groupId>
                <artifactId>findbugs-maven-plugin</artifactId>
            </plugin-->
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-deploy-plugin</artifactId>
                <version>2.8</version>
            </plugin>
        </plugins>
    </build>

    <profiles>
        <!-- Profile for generating coverage report -->
        <profile>
            <id>coverage</id>
            <build>
                <pluginManagement>
                    <plugins>
                        <plugin>
                            <groupId>org.apache.maven.plugins</groupId>
                            <artifactId>maven-surefire-plugin</artifactId>
                            <version>2.14.1</version>
                            <configuration>
                                <argLine>${argLine} -Xmx512m</argLine>
                            </configuration>
                        </plugin>
                        <plugin>
                            <groupId>org.jacoco</groupId>
                            <artifactId>jacoco-maven-plugin</artifactId>
                            <version>0.7.1.201405082137</version>
                            <executions>
                                <execution>
                                    <id>prepare-agent</id>
                                    <goals>
                                        <goal>prepare-agent</goal>
                                    </goals>
                                </execution>
                                <execution>
                                    <id>report</id>
                                    <phase>prepare-package</phase>
                                    <goals>
                                        <goal>report</goal>
                                    </goals>
                                </execution>
                            </executions>
                        </plugin>
                    </plugins>
                </pluginManagement>

                <plugins>
                    <plugin>
                        <groupId>org.jacoco</groupId>
                        <artifactId>jacoco-maven-plugin</artifactId>
                        <version>0.7.1.201405082137</version>
                    </plugin>
                </plugins>
            </build>
        </profile>

        <!-- Profile for creating all deployment artifacts -->
        <profile>
            <id>release</id>
            <build>
                <pluginManagement>
                    <plugins>
                        <!-- Source jar -->
                        <plugin>
                            <groupId>org.apache.maven.plugins</groupId>
                            <artifactId>maven-source-plugin</artifactId>
                            <version>2.2.1</version>
                            <configuration>
                                <excludeResources>true</excludeResources>
                            </configuration>
                            <executions>
                                <execution>
                                    <id>attach-sources</id>
                                    <phase>package</phase>
                                    <goals>
                                        <goal>jar-no-fork</goal>
                                    </goals>
                                </execution>
                            </executions>
                        </plugin>

                        <!-- Javadoc jar -->
                        <plugin>
                            <groupId>org.apache.maven.plugins</groupId>
                            <artifactId>maven-javadoc-plugin</artifactId>
                            <version>2.9</version>
                            <configuration>
                                <detectJavaApiLink>true</detectJavaApiLink>
                                <links>
                                    <link>http://docs.oracle.com/javaee/6/api/</link>
                                </links>
                                <excludePackageNames>*.internal.*</excludePackageNames>
                                <bottom>
                                    <![CDATA[Copyright {currentYear} WSO2, Inc.
                                        <a href="http://www.apache.org/licenses/LICENSE-2.0";>
                                            Licensed under the Apache License, Version 2.0</a>]]>
                                </bottom>
                            </configuration>
                            <executions>
                                <execution>
                                    <id>attach-javadoc</id>
                                    <phase>package</phase>
                                    <goals>
                                        <goal>jar</goal>
                                    </goals>
                                </execution>
                            </executions>
                        </plugin>

                        <!-- GPG signature -->
                        <plugin>
                            <groupId>org.apache.maven.plugins</groupId>
                            <artifactId>maven-gpg-plugin</artifactId>
                            <version>1.5</version>
                            <configuration>
                                <passphrase>${gpg.passphrase}</passphrase>
                                <useAgent>${gpg.useagent}</useAgent>
                            </configuration>
                            <executions>
                                <execution>
                                    <goals>
                                        <goal>sign</goal>
                                    </goals>
                                </execution>
                            </executions>
                        </plugin>

                        <!-- Nexus deploy plugin -->
                        <plugin>
                            <groupId>org.sonatype.plugins</groupId>
                            <artifactId>nexus-staging-maven-plugin</artifactId>
                            <version>1.6.2</version>
                            <extensions>true</extensions>
                            <configuration>
                                <nexusUrl>https://oss.sonatype.org</nexusUrl>
                                <serverId>sonatype.release</serverId>
                                <stagingProfileId>655dc88dc770c3</stagingProfileId>
                            </configuration>
                        </plugin>

                    </plugins>
                </pluginManagement>

                <plugins>
                    <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-source-plugin</artifactId>
                        <version>2.2.1</version>
                    </plugin>
                    <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-javadoc-plugin</artifactId>
                        <version>2.9.1</version>
                    </plugin>
                    <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-gpg-plugin</artifactId>
                        <version>1.5</version>
                    </plugin>
                </plugins>
            </build>
        </profile>

    </profiles>
    <properties>
        <bundle.activator>org.wso2.carbon.ibus.Activator</bundle.activator>
        <mysql.import.version.range>[5.1.35, 5.1.38)</mysql.import.version.range>
        <export.package>
            org.wso2.carbon.ibus.*;version="${carbon.ibus.package.export.version}"
        </export.package>
        <import.package>
            org.osgi.framework.*;version="${osgi.framework.import.version.range}",
            org.osgi.util.tracker;version="${osgi.service.tracker.import.version.range}",
            org.wso2.carbon.kernel.transports.*;version="${carbon.kernel.package.import.version.range}",
            org.wso2.carbon.kernel.deployment.*;version="${carbon.kernel.package.import.version.range}",
            org.slf4j.*;version="${slf4j.logging.package.import.version.range}",
            org.antlr.v4.runtime.*,
            com.mysql.jdbc.*;version="${mysql.import.version.range}",
            org.wso2.carbon.messaging.*;version="${carbon.messaging.package.import.version.range}"
        </import.package>
	<DynamicImport-Package>*</DynamicImport-Package>
    </properties>

</project>
_______________________________________________
Dev mailing list
[email protected]
http://wso2.org/cgi-bin/mailman/listinfo/dev

Reply via email to