Uploaded image for project: 'Camel'
  1. Camel
  2. CAMEL-10818

Unable to use JPA in camel 2.18.1 on Karaf 4.0.8

    XMLWordPrintableJSON

Details

    • Task
    • Status: Resolved
    • Major
    • Resolution: Invalid
    • 2.18.1
    • 2.18.1
    • camel-jpa, karaf
    • Windows 10, Karaf 4.0.8

    • Moderate

    Description

      Hello,

      I am creating a simple camel project to connect MySQL Database using JPA with Java code. Their is no issue in installing the bundle but when i try to start the bundle on Karaf. Below error show:

      2017-02-13 13:00:04,248 | ERROR | nsole user karaf | ShellUtil | 43 - org.apache.karaf.shell.core - 4.0.8 | Exception caught while executing command
      org.apache.karaf.shell.support.MultiException: Error executing command on bundles:
      Error starting bundle 52: Unable to resolve in.test.jpatest [52](R 52.0): missing requirement [in.test.jpatest [52](R 52.0)] osgi.wiring.package; (&(osgi.wiring.package=javax.persistence)(version>=2.1.0)(!(version>=3.0.0))) Unresolved requirements: [[in.test.jpatest [52](R 52.0)] osgi.wiring.package; (&(osgi.wiring.package=javax.persistence)(version>=2.1.0)(!(version>=3.0.0)))]
      at org.apache.karaf.shell.support.MultiException.throwIf(MultiException.java:61)
      at org.apache.karaf.bundle.command.BundlesCommand.doExecute(BundlesCommand.java:69)[23:org.apache.karaf.bundle.core:4.0.8]
      at org.apache.karaf.bundle.command.BundlesCommand.execute(BundlesCommand.java:54)[23:org.apache.karaf.bundle.core:4.0.8]
      at org.apache.karaf.shell.impl.action.command.ActionCommand.execute(ActionCommand.java:83)[43:org.apache.karaf.shell.core:4.0.8]
      at org.apache.karaf.shell.impl.console.osgi.secured.SecuredCommand.execute(SecuredCommand.java:67)[43:org.apache.karaf.shell.core:4.0.8]
      at org.apache.karaf.shell.impl.console.osgi.secured.SecuredCommand.execute(SecuredCommand.java:87)[43:org.apache.karaf.shell.core:4.0.8]
      at org.apache.felix.gogo.runtime.Closure.executeCmd(Closure.java:480)[43:org.apache.karaf.shell.core:4.0.8]
      at org.apache.felix.gogo.runtime.Closure.executeStatement(Closure.java:406)[43:org.apache.karaf.shell.core:4.0.8]
      at org.apache.felix.gogo.runtime.Pipe.run(Pipe.java:108)[43:org.apache.karaf.shell.core:4.0.8]
      at org.apache.felix.gogo.runtime.Closure.execute(Closure.java:182)[43:org.apache.karaf.shell.core:4.0.8]
      at org.apache.felix.gogo.runtime.Closure.execute(Closure.java:119)[43:org.apache.karaf.shell.core:4.0.8]
      at org.apache.felix.gogo.runtime.CommandSessionImpl.execute(CommandSessionImpl.java:94)[43:org.apache.karaf.shell.core:4.0.8]
      at org.apache.karaf.shell.impl.console.ConsoleSessionImpl.run(ConsoleSessionImpl.java:274)[43:org.apache.karaf.shell.core:4.0.8]
      at java.lang.Thread.run(Thread.java:745)[:1.8.0_101]
      Caused by: java.lang.Exception: Error starting bundle 52: Unable to resolve in.test.jpatest [52](R 52.0): missing requirement [in.test.jpatest [52](R 52.0)] osgi.wiring.package; (&(osgi.wiring.package=javax.persistence)(version>=2.1.0)(!(version>=3.0.0))) Unresolved requirements: [[in.test.jpatest [52](R 52.0)] osgi.wiring.package; (&(osgi.wiring.package=javax.persistence)(version>=2.1.0)(!(version>=3.0.0)))]
      at org.apache.karaf.bundle.command.BundlesCommand.doExecute(BundlesCommand.java:66)[23:org.apache.karaf.bundle.core:4.0.8]
      ... 12 more
      Caused by: org.osgi.framework.BundleException: Unable to resolve in.test.jpatest [52](R 52.0): missing requirement [in.test.jpatest [52](R 52.0)] osgi.wiring.package; (&(osgi.wiring.package=javax.persistence)(version>=2.1.0)(!(version>=3.0.0))) Unresolved requirements: [[in.test.jpatest [52](R 52.0)] osgi.wiring.package; (&(osgi.wiring.package=javax.persistence)(version>=2.1.0)(!(version>=3.0.0)))]
      at org.apache.felix.framework.Felix.resolveBundleRevision(Felix.java:4111)[org.apache.felix.framework-5.6.1.jar:]
      at org.apache.felix.framework.Felix.startBundle(Felix.java:2117)[org.apache.felix.framework-5.6.1.jar:]
      at org.apache.felix.framework.BundleImpl.start(BundleImpl.java:998)[org.apache.felix.framework-5.6.1.jar:]
      at org.apache.karaf.bundle.command.Start.executeOnBundle(Start.java:38)[23:org.apache.karaf.bundle.core:4.0.8]
      at org.apache.karaf.bundle.command.BundlesCommand.doExecute(BundlesCommand.java:64)[23:org.apache.karaf.bundle.core:4.0.8]
      ... 12 more

      POM:
      <?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>

      <groupId>in.test</groupId>
      <artifactId>jpatest</artifactId>
      <version>0.0.1</version>
      <packaging>jar</packaging>

      <name>jpatest</name>

      <properties>
      <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
      <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
      </properties>

      <dependencyManagement>
      <dependencies>
      <dependency>
      <groupId>org.apache.camel</groupId>
      <artifactId>camel-parent</artifactId>
      <version>2.18.1</version>
      <scope>import</scope>
      <type>pom</type>
      </dependency>
      </dependencies>
      </dependencyManagement>

      <dependencies>

      <!-- Camel -->
      <dependency>
      <groupId>org.apache.camel</groupId>
      <artifactId>camel-core</artifactId>
      </dependency>
      <dependency>
      <groupId>org.apache.camel</groupId>
      <artifactId>camel-blueprint</artifactId>
      </dependency>

      <!-- Testing -->
      <dependency>
      <groupId>org.apache.camel</groupId>
      <artifactId>camel-test-blueprint</artifactId>
      <scope>test</scope>
      </dependency>

      <!-- logging -->
      <dependency>
      <groupId>org.apache.logging.log4j</groupId>
      <artifactId>log4j-api</artifactId>
      <scope>test</scope>
      </dependency>
      <dependency>
      <groupId>org.apache.logging.log4j</groupId>
      <artifactId>log4j-core</artifactId>
      <scope>test</scope>
      </dependency>
      <dependency>
      <groupId>org.apache.logging.log4j</groupId>
      <artifactId>log4j-slf4j-impl</artifactId>
      <scope>test</scope>
      </dependency>

      <!-- JPA -->
      <dependency>
      <groupId>org.apache.camel</groupId>
      <artifactId>camel-jpa</artifactId>
      </dependency>
      <dependency>
      <groupId>org.eclipse.persistence</groupId>
      <artifactId>eclipselink</artifactId>
      <version>2.5.2</version>
      </dependency>
      <dependency>
      <groupId>org.eclipse.persistence</groupId>
      <artifactId>org.eclipse.persistence.jpa.modelgen.processor</artifactId>
      <version>2.5.2</version>
      <scope>provided</scope>
      </dependency>
      </dependencies>

      <build>
      <plugins>

      <!-- compiler plugin -->
      <plugin>
      <groupId>org.apache.maven.plugins</groupId>
      <artifactId>maven-compiler-plugin</artifactId>
      <version>3.5.1</version>
      <configuration>
      <source>1.8</source>
      <target>1.8</target>
      </configuration>
      </plugin>
      <plugin>
      <groupId>org.apache.maven.plugins</groupId>
      <artifactId>maven-resources-plugin</artifactId>
      <version>3.0.1</version>
      <configuration>
      <encoding>UTF-8</encoding>
      </configuration>
      </plugin>

      <!-- to generate the MANIFEST.MF of the bundle -->
      <plugin>
      <groupId>org.apache.felix</groupId>
      <artifactId>maven-bundle-plugin</artifactId>
      <version>3.2.0</version>
      <extensions>false</extensions>
      <executions>
      <execution>
      <id>bundle-manifest</id>
      <phase>prepare-package</phase>
      <goals>
      <goal>manifest</goal>
      </goals>
      </execution>
      </executions>
      </plugin>
      <!-- to include MANIFEST.MF in the bundle -->
      <plugin>
      <groupId>org.apache.maven.plugins</groupId>
      <artifactId>maven-jar-plugin</artifactId>
      <version>2.6</version>
      <configuration>
      <archive>
      <manifestFile>${project.build.outputDirectory}/META-INF/MANIFEST.MF</manifestFile>
      </archive>
      </configuration>
      </plugin>

      <!-- to run the example using mvn camel:run -->
      <plugin>
      <groupId>org.apache.camel</groupId>
      <artifactId>camel-maven-plugin</artifactId>
      <version>2.18.1</version>
      </plugin>
      </plugins>
      </build>

      </project>

      Camel BluePrint:
      <?xml version="1.0" encoding="UTF-8"?>
      <blueprint xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0"
      xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
      xmlns:cm="http://aries.apache.org/blueprint/xmlns/blueprint-cm/v1.1.0"
      xsi:schemaLocation="
      http://www.osgi.org/xmlns/blueprint/v1.0.0 https://www.osgi.org/xmlns/blueprint/v1.0.0/blueprint.xsd
      http://camel.apache.org/schema/blueprint http://camel.apache.org/schema/blueprint/camel-blueprint.xsd
      http://aries.apache.org/blueprint/xmlns/blueprint-cm/v1.1.0 http://aries.apache.org/schemas/blueprint-cm/blueprint-cm-1.1.0.xsd">

      <cm:property-placeholder persistent-id="HelloBean" update-strategy="reload">
      <cm:default-properties>
      <cm:property name="greeting" value="Hi from Camel" />
      </cm:default-properties>
      </cm:property-placeholder>

      <bean id="helloBean" class="in.test.jpatest.HelloBean">
      <property name="say" value="${greeting}"/>
      </bean>

      <camelContext id="blueprint-bean-context" xmlns="http://camel.apache.org/schema/blueprint">
      <route id="timerToLog">
      <from uri="timer:foo?period=5000"/>
      <setBody>
      <method ref="helloBean" method="hello"/>
      </setBody>
      <log message="The message contains ${body}"/>
      <setBody>
      <method ref="test" method="jpatest"/>
      </setBody>
      <log message="The jpa message contains ${body}"/>
      <to uri="mock:result"/>
      </route>
      </camelContext>

      <bean id="test" class="in.test.jpatest.Test"></bean>

      <bean id="jpa" class="org.apache.camel.component.jpa.JpaComponent">
      <property name="entityManagerFactory" ref="entityManagerFactory" />
      <property name="transactionManager" ref="transactionManager" />
      </bean>

      <bean id="mysqltestDataSource"
      class="org.springframework.jdbc.datasource.DriverManagerDataSource">
      <property name="driverClassName" value="com.mysql.jdbc.Driver" />
      <property name="url" value="127.0.0.1:3306" />
      <property name="username" value="test" />
      <property name="password" value="test" />
      </bean>

      <bean id="entityManagerFactory"
      class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean">
      <property name="dataSource" ref="mysqltestDataSource" />
      <property name="persistenceUnitName" value="testMysql" />
      </bean>
      </blueprint>

      Persistance:
      <?xml version="1.0" encoding="UTF-8"?>
      <persistence version="2.1" xmlns="http://xmlns.jcp.org/xml/ns/persistence" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/persistence http://xmlns.jcp.org/xml/ns/persistence/persistence_2_1.xsd">
      <persistence-unit name="testMysql" transaction-type="RESOURCE_LOCAL">
      <!-<provider>org.eclipse.persistence.jpa.PersistenceProvider</provider>->
      <provider>org.hibernate.ejb.HibernatePersistence</provider>
      <class>in.test.jpatest.TransactionLog</class>
      <!--<properties>
      <property name="javax.persistence.jdbc.url" value="jdbc:mysql://localhost:3306/addpro?zeroDateTimeBehavior=convertToNull"/>
      <property name="javax.persistence.jdbc.user" value="root"/>
      <property name="javax.persistence.jdbc.driver" value="com.mysql.jdbc.Driver"/>
      <property name="javax.persistence.jdbc.password" value="Addverb@123!"/>
      </properties>-->
      <properties>
      <property name="hibernate.dialect" value="org.hibernate.dialect.MySQL5InnoDBDialect"/>
      <property name="hibernate.show_sql" value="true"/>
      </properties>
      </persistence-unit>
      </persistence>

      I have done the same with Camel 2.10.0 and Jboss fuse and JPA version 1.0 but now it is not working.

      Attachments

        Activity

          People

            Unassigned Unassigned
            DeepakIndoriya Deepak Indoriya
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: