camel-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Robert Liguori (Confluence)" <conflue...@apache.org>
Subject [CONF] Apache Camel > JPA
Date Wed, 11 Sep 2013 01:56:00 GMT
<html>
<head>
    <base href="https://cwiki.apache.org/confluence">
            <link rel="stylesheet" href="/confluence/s/en/2176/1/1/_/styles/combined.css?spaceKey=CAMEL&amp;forWysiwyg=true"
type="text/css">
    </head>
<body style="background: white;" bgcolor="white" class="email-body">
<div id="pageContent">
<div id="notificationFormat">
<div class="wiki-content">
<div class="email">
    <h2><a href="https://cwiki.apache.org/confluence/display/CAMEL/JPA">JPA</a></h2>
    <h4>Page <b>edited</b> by             <a href="https://cwiki.apache.org/confluence/display/~gliesian">Robert
Liguori</a>
    </h4>
        <br/>
                         <h4>Changes (1)</h4>
                                 
    
<div id="page-diffs">
                    <table class="diff" cellpadding="0" cellspacing="0">
    
            <tr><td class="diff-snipped" >...<br></td></tr>
            <tr><td class="diff-unchanged" > <br>{code} <br></td></tr>
            <tr><td class="diff-changed-lines" ><span class="diff-deleted-words"style="color:#999;background-color:#fdd;text-decoration:line-through;">jpa:[entityClassName][?options]</span>
<span class="diff-added-words"style="background-color: #dfd;">jpa:entityClassName[?options]</span>
<br></td></tr>
            <tr><td class="diff-unchanged" >{code} <br> <br></td></tr>
            <tr><td class="diff-snipped" >...<br></td></tr>
    
            </table>
    </div>                            <h4>Full Content</h4>
                    <div class="notificationGreySide">
        <h2><a name="JPA-JPAComponent"></a>JPA Component</h2>

<p>The <b>jpa</b> component enables you to store and retrieve Java objects
from persistent storage using EJB 3's Java Persistence Architecture (JPA), which is a standard
interface layer that wraps Object/Relational Mapping (ORM) products such as OpenJPA, Hibernate,
TopLink, and so on.</p>

<p>Maven users will need to add the following dependency to their <tt>pom.xml</tt>
for this component:</p>
<div class="code panel" style="border-width: 1px;"><div class="codeContent panelContent">
<pre class="theme: Default; brush: xml; gutter: false" style="font-size:12px; font-family:
ConfluenceInstalledFont,monospace;">
&lt;dependency&gt;
    &lt;groupId&gt;org.apache.camel&lt;/groupId&gt;
    &lt;artifactId&gt;camel-jpa&lt;/artifactId&gt;
    &lt;version&gt;x.x.x&lt;/version&gt;
    &lt;!-- use the same version as your Camel core version --&gt;
&lt;/dependency&gt;
</pre>
</div></div>

<h3><a name="JPA-Sendingtotheendpoint"></a>Sending to the endpoint</h3>

<p>You can store a Java entity bean in a database by sending it to a JPA producer endpoint.
The body of the <em>In</em> message is assumed to be an entity bean (that is,
a POJO with an <a href="http://java.sun.com/javaee/5/docs/api/javax/persistence/Entity.html"
class="external-link" rel="nofollow">@Entity</a> annotation on it) or a collection
or array of entity beans. </p>

<p>If the body does not contain one of the previous listed types, put a <a href="/confluence/display/CAMEL/Message+Translator"
title="Message Translator">Message Translator</a> in front of the endpoint to perform
the necessary conversion first.</p>

<h3><a name="JPA-Consumingfromtheendpoint"></a>Consuming from the endpoint</h3>

<p>Consuming messages from a JPA consumer endpoint removes (or updates) entity beans
in the database. This allows you to use a database table as a logical queue: consumers take
messages from the queue and then delete/update them to logically remove them from the queue.</p>

<p>If you do not wish to delete the entity bean when it has been processed (and when
routing is done), you can specify <tt>consumeDelete=false</tt> on the URI. This
will result in the entity being processed each poll.</p>

<p>If you would rather perform some update on the entity to mark it as processed (such
as to exclude it from a future query) then you can annotate a method with <a href="http://camel.apache.org/maven/current/camel-jpa/apidocs/org/apache/camel/component/jpa/Consumed.html"
class="external-link" rel="nofollow">@Consumed</a> which will be invoked on your
entity bean when the entity bean when it has been processed (and when routing is done).</p>

<h3><a name="JPA-URIformat"></a>URI format</h3>

<div class="code panel" style="border-width: 1px;"><div class="codeContent panelContent">
<pre class="theme: Default; brush: java; gutter: false" style="font-size:12px; font-family:
ConfluenceInstalledFont,monospace;">
jpa:entityClassName[?options]
</pre>
</div></div>

<p>For sending to the endpoint, the <em>entityClassName</em> is optional.
If specified, it helps the <a href="/confluence/display/CAMEL/Type+Converter" title="Type
Converter">Type Converter</a> to ensure the body is of the correct type.</p>

<p>For consuming, the <em>entityClassName</em> is mandatory.</p>

<p>You can append query options to the URI in the following format, <tt>?option=value&amp;option=value&amp;...</tt></p>

<h3><a name="JPA-Options"></a>Options</h3>
<div class="confluenceTableSmall"><div class='table-wrap'>
<table class='confluenceTable'><tbody>
<tr>
<th class='confluenceTh'> Name </th>
<th class='confluenceTh'> Default Value </th>
<th class='confluenceTh'> Description </th>
</tr>
<tr>
<td class='confluenceTd'> <tt>entityType</tt> </td>
<td class='confluenceTd'> <em>entityClassName</em> </td>
<td class='confluenceTd'> Overrides the <em>entityClassName</em> from the
URI. </td>
</tr>
<tr>
<td class='confluenceTd'> <tt>persistenceUnit</tt> </td>
<td class='confluenceTd'> <tt>camel</tt> </td>
<td class='confluenceTd'> The JPA persistence unit used by default. </td>
</tr>
<tr>
<td class='confluenceTd'> <tt>consumeDelete</tt> </td>
<td class='confluenceTd'> <tt>true</tt> </td>
<td class='confluenceTd'> <b>JPA consumer only:</b> If <tt>true</tt>,
the entity is deleted after it is consumed; if <tt>false</tt>, the entity is not
deleted. </td>
</tr>
<tr>
<td class='confluenceTd'> <tt>consumeLockEntity</tt> </td>
<td class='confluenceTd'> <tt>true</tt> </td>
<td class='confluenceTd'> <b>JPA consumer only:</b> Specifies whether or
not to set an exclusive lock on each entity bean while processing the results from polling.
</td>
</tr>
<tr>
<td class='confluenceTd'> <tt>flushOnSend</tt> </td>
<td class='confluenceTd'> <tt>true</tt> </td>
<td class='confluenceTd'> <b>JPA producer only:</b> Flushes the <a href="http://java.sun.com/javaee/5/docs/api/javax/persistence/EntityManager.html"
class="external-link" rel="nofollow">EntityManager</a> after the entity bean has
been persisted. </td>
</tr>
<tr>
<td class='confluenceTd'> <tt>maximumResults</tt> </td>
<td class='confluenceTd'> <tt>-1</tt> </td>
<td class='confluenceTd'>  <b>JPA consumer only:</b> Set the maximum number
of results to retrieve on the <a href="http://java.sun.com/javaee/5/docs/api/javax/persistence/Query.html"
class="external-link" rel="nofollow">Query</a>. </td>
</tr>
<tr>
<td class='confluenceTd'> <tt>transactionManager</tt> </td>
<td class='confluenceTd'> <tt>null</tt> </td>
<td class='confluenceTd'> This option is <a href="/confluence/display/CAMEL/Registry"
title="Registry">Registry</a> based which requires the <tt>#</tt> notation
so that the given <tt>transactionManager</tt> being specified can be looked up
properly, e.g. <tt>transactionManager=#myTransactionManager</tt>. It specifies
the transaction manager to use. If none provided, Camel will use a <tt>JpaTransactionManager</tt>
by default. Can be used to set a JTA transaction manager (for integration with an EJB container).
</td>
</tr>
<tr>
<td class='confluenceTd'> <tt>consumer.delay</tt> </td>
<td class='confluenceTd'> <tt>500</tt> </td>
<td class='confluenceTd'> <b>JPA consumer only:</b> Delay in milliseconds
between each poll. </td>
</tr>
<tr>
<td class='confluenceTd'> <tt>consumer.initialDelay</tt> </td>
<td class='confluenceTd'> <tt>1000</tt> </td>
<td class='confluenceTd'> <b>JPA consumer only:</b> Milliseconds before
polling starts. </td>
</tr>
<tr>
<td class='confluenceTd'> <tt>consumer.useFixedDelay</tt> </td>
<td class='confluenceTd'> <tt>false</tt> </td>
<td class='confluenceTd'> <b>JPA consumer only:</b> Set to <tt>true</tt>
to use fixed delay between polls, otherwise fixed rate is used. See <a href="http://java.sun.com/j2se/1.5.0/docs/api/java/util/concurrent/ScheduledExecutorService.html"
class="external-link" rel="nofollow">ScheduledExecutorService</a> in JDK for details.
</td>
</tr>
<tr>
<td class='confluenceTd'> <tt>maxMessagesPerPoll</tt> </td>
<td class='confluenceTd'> <tt>0</tt> </td>
<td class='confluenceTd'> <b>JPA consumer only:</b> An integer value to
define the maximum number of messages to gather per poll. By default, no maximum is set. Can
be used to avoid polling many thousands of messages when starting up the server. Set a value
of 0 or negative to disable. </td>
</tr>
<tr>
<td class='confluenceTd'> <tt>consumer.query</tt> </td>
<td class='confluenceTd'>&nbsp;</td>
<td class='confluenceTd'> <b>JPA consumer only:</b> To use a custom query
when consuming data. </td>
</tr>
<tr>
<td class='confluenceTd'> <tt>consumer.namedQuery</tt> </td>
<td class='confluenceTd'>&nbsp;</td>
<td class='confluenceTd'> <b>JPA consumer only:</b> To use a named query
when consuming data. </td>
</tr>
<tr>
<td class='confluenceTd'> <tt>consumer.nativeQuery</tt> </td>
<td class='confluenceTd'>&nbsp;</td>
<td class='confluenceTd'> <b>JPA consumer only:</b> To use a custom native
query when consuming data. You may want to use the option <tt>consumer.resultClass</tt>
also when using native queries. </td>
</tr>
<tr>
<td class='confluenceTd'> <tt>consumer.parameters</tt> </td>
<td class='confluenceTd'>&nbsp;</td>
<td class='confluenceTd'> <b>Camel 2.12: JPA consumer only:</b> the parameters
map which will be used for building the query. The parameters is an instance of Map which
key is String and value is Object. </td>
</tr>
<tr>
<td class='confluenceTd'> <tt>consumer.resultClass</tt> </td>
<td class='confluenceTd'>&nbsp;</td>
<td class='confluenceTd'> <b>Camel 2.7: JPA consumer only:</b> Defines the
type of the returned payload (we will call <tt>entityManager.createNativeQuery(nativeQuery,
resultClass)</tt> instead of <tt>entityManager.createNativeQuery(nativeQuery)</tt>).
Without this option, we will return an object array. Only has an affect when using in conjunction
with native query when consuming data. </td>
</tr>
<tr>
<td class='confluenceTd'> <tt>consumer.transacted</tt> </td>
<td class='confluenceTd'> <tt>false</tt> </td>
<td class='confluenceTd'> <b>Camel 2.7.5/2.8.3/2.9: JPA consumer only:</b>
Whether to run the consumer in transacted mode, by which all messages will either commit or
rollback, when the entire batch has been processed. The default behavior (false) is to commit
all the previously successfully processed messages, and only rollback the last failed message.
</td>
</tr>
<tr>
<td class='confluenceTd'> <tt>consumer.lockModeType</tt> </td>
<td class='confluenceTd'> <tt>WRITE</tt> </td>
<td class='confluenceTd'> <b>Camel 2.11.2/2.12:</b> To configure the lock
mode on the consumer. The possible values is defined in the enum <tt>javax.persistence.LockModeType</tt>.
</td>
</tr>
<tr>
<td class='confluenceTd'> <tt>usePersist</tt> </td>
<td class='confluenceTd'> <tt>false</tt> </td>
<td class='confluenceTd'> <b>Camel 2.5: JPA producer only:</b> Indicates
to use <tt>entityManager.persist(entity)</tt> instead of <tt>entityManager.merge(entity)</tt>.
Note: <tt>entityManager.persist(entity)</tt> doesn't work for detached entities
(where the EntityManager has to execute an UPDATE instead of an INSERT query)! </td>
</tr>
</tbody></table>
</div>
</div>

<h3><a name="JPA-MessageHeaders"></a>Message Headers</h3>
<p>Camel adds the following message headers to the exchange:</p>
<div class="confluenceTableSmall"><div class='table-wrap'>
<table class='confluenceTable'><tbody>
<tr>
<th class='confluenceTh'> Header </th>
<th class='confluenceTh'> Type </th>
<th class='confluenceTh'> Description </th>
</tr>
<tr>
<td class='confluenceTd'> <tt>CamelJpaTemplate</tt> </td>
<td class='confluenceTd'> <tt>JpaTemplate</tt> </td>
<td class='confluenceTd'> The <tt>JpaTemplate</tt> object that is used to
access the entity bean. You need this object in some situations, for instance in a type converter
or when you are doing some custom processing. </td>
</tr>
</tbody></table>
</div>
</div>

<h3><a name="JPA-ConfiguringEntityManagerFactory"></a>Configuring EntityManagerFactory</h3>
<p>Its strongly advised to configure the JPA component to use a specific <tt>EntityManagerFactory</tt>
instance. If failed to do so each <tt>JpaEndpoint</tt> will auto create their
own instance of <tt>EntityManagerFactory</tt> which most often is not what you
want.</p>

<p>For example, you can instantiate a JPA component that references the <tt>myEMFactory</tt>
entity manager factory, as follows:</p>
<div class="code panel" style="border-width: 1px;"><div class="codeContent panelContent">
<pre class="theme: Default; brush: xml; gutter: false" style="font-size:12px; font-family:
ConfluenceInstalledFont,monospace;">
&lt;bean id="jpa" class="org.apache.camel.component.jpa.JpaComponent"&gt;
   &lt;property name="entityManagerFactory" ref="myEMFactory"/&gt;
&lt;/bean&gt;
</pre>
</div></div>

<p>In <b>Camel 2.3</b> the <tt>JpaComponent</tt> will auto lookup
the <tt>EntityManagerFactory</tt> from the <a href="/confluence/display/CAMEL/Registry"
title="Registry">Registry</a> which means you do not need to configure this on the
<tt>JpaComponent</tt> as shown above. You only need to do so if there is ambiguity,
in which case Camel will log a WARN.</p>

<h3><a name="JPA-ConfiguringTransactionManager"></a>Configuring TransactionManager</h3>
<p>Its strongly advised to configure the <tt>TransactionManager</tt> instance
used by the JPA component. If failed to do so each <tt>JpaEndpoint</tt> will auto
create their own instance of <tt>TransactionManager</tt> which most often is not
what you want.</p>

<p>For example, you can instantiate a JPA component that references the <tt>myTransactionManager</tt>
transaction manager, as follows:</p>
<div class="code panel" style="border-width: 1px;"><div class="codeContent panelContent">
<pre class="theme: Default; brush: xml; gutter: false" style="font-size:12px; font-family:
ConfluenceInstalledFont,monospace;">
&lt;bean id="jpa" class="org.apache.camel.component.jpa.JpaComponent"&gt;
   &lt;property name="entityManagerFactory" ref="myEMFactory"/&gt;
   &lt;property name="transactionManager" ref="myTransactionManager"/&gt;
&lt;/bean&gt;
</pre>
</div></div>

<p>In <b>Camel 2.3</b> the <tt>JpaComponent</tt> will auto lookup
the <tt>TransactionManager</tt> from the <a href="/confluence/display/CAMEL/Registry"
title="Registry">Registry</a> which means you do not need to configure this on the
<tt>JpaComponent</tt> as shown above. You only need to do so if there is ambiguity,
in which case Camel will log a WARN.</p>

<h3><a name="JPA-Usingaconsumerwithanamedquery"></a>Using a consumer with
a named query</h3>
<p>For consuming only selected entities, you can use the <tt>consumer.namedQuery</tt>
URI query option. First, you have to define the named query in the JPA Entity class:</p>
<div class="code panel" style="border-width: 1px;"><div class="codeContent panelContent">
<pre class="theme: Default; brush: java; gutter: false" style="font-size:12px; font-family:
ConfluenceInstalledFont,monospace;">
@Entity
@NamedQuery(name = "step1", query = "select x from MultiSteps x where x.step = 1")
public class MultiSteps {
   ...
}
</pre>
</div></div>

<p>After that you can define a consumer uri like this one:</p>
<div class="code panel" style="border-width: 1px;"><div class="codeContent panelContent">
<pre class="theme: Default; brush: java; gutter: false" style="font-size:12px; font-family:
ConfluenceInstalledFont,monospace;">
from("jpa://org.apache.camel.examples.MultiSteps?consumer.namedQuery=step1")
.to("bean:myBusinessLogic");
</pre>
</div></div>

<h3><a name="JPA-Usingaconsumerwithaquery"></a>Using a consumer with a query</h3>
<p>For consuming only selected entities, you can use the <tt>consumer.query</tt>
URI query option. You only have to define the query option:</p>
<div class="code panel" style="border-width: 1px;"><div class="codeContent panelContent">
<pre class="theme: Default; brush: java; gutter: false" style="font-size:12px; font-family:
ConfluenceInstalledFont,monospace;">
from("jpa://org.apache.camel.examples.MultiSteps?consumer.query=select o from org.apache.camel.examples.MultiSteps
o where o.step = 1")
.to("bean:myBusinessLogic");
</pre>
</div></div>

<h3><a name="JPA-Usingaconsumerwithanativequery"></a>Using a consumer with
a native query</h3>
<p>For consuming only selected entities, you can use the <tt>consumer.nativeQuery</tt>
URI query option. You only have to define the native query option:</p>
<div class="code panel" style="border-width: 1px;"><div class="codeContent panelContent">
<pre class="theme: Default; brush: java; gutter: false" style="font-size:12px; font-family:
ConfluenceInstalledFont,monospace;">
from("jpa://org.apache.camel.examples.MultiSteps?consumer.nativeQuery=select * from MultiSteps
where step = 1")
.to("bean:myBusinessLogic");
</pre>
</div></div>

<p>If you use the native query option, you will receive an object array in the message
body.</p>

<h3><a name="JPA-Example"></a>Example</h3>
<p>See <a href="/confluence/display/CAMEL/Tracer+Example" title="Tracer Example">Tracer
Example</a> for an example using <a href="/confluence/display/CAMEL/JPA" title="JPA">JPA</a>
to store traced messages into a database.</p>

<h3><a name="JPA-UsingtheJPAbasedidempotentrepository"></a>Using the JPA
based idempotent repository</h3>
<p>In this section we will use the JPA based idempotent repository.</p>

<p>First we need to setup a <tt>persistence-unit</tt> in the persistence.xml
file:</p>
<div class="code panel" style="border-width: 1px;"><div class="codeContent panelContent">
<script type="syntaxhighlighter" class="theme: Default; brush: xml; gutter: false"><![CDATA[
&lt;persistence-unit name="idempotentDb" transaction-type="RESOURCE_LOCAL"&gt;
  &lt;class&gt;org.apache.camel.processor.idempotent.jpa.MessageProcessed&lt;/class&gt;

  &lt;properties&gt;
    &lt;property name="openjpa.ConnectionURL" value="jdbc:derby:target/idempotentTest;create=true"/&gt;
    &lt;property name="openjpa.ConnectionDriverName" value="org.apache.derby.jdbc.EmbeddedDriver"/&gt;
    &lt;property name="openjpa.jdbc.SynchronizeMappings" value="buildSchema"/&gt;
    &lt;property name="openjpa.Log" value="DefaultLevel=WARN, Tool=INFO"/&gt;
  &lt;/properties&gt;
&lt;/persistence-unit&gt;
]]></script>
</div></div>

<p>Second we have to setup a <tt>org.springframework.orm.jpa.JpaTemplate</tt>
which is used by the <tt>org.apache.camel.processor.idempotent.jpa.JpaMessageIdRepository</tt>:</p>
<div class="code panel" style="border-width: 1px;"><div class="codeContent panelContent">
<script type="syntaxhighlighter" class="theme: Default; brush: xml; gutter: false"><![CDATA[
&lt;!-- this is standard spring JPA configuration --&gt;
&lt;bean id="jpaTemplate" class="org.springframework.orm.jpa.JpaTemplate"&gt;
    &lt;property name="entityManagerFactory" ref="entityManagerFactory"/&gt;
&lt;/bean&gt;

&lt;bean id="entityManagerFactory" class="org.springframework.orm.jpa.LocalEntityManagerFactoryBean"&gt;
    &lt;!-- we use idempotentDB as the persitence unit name defined in the persistence.xml
file --&gt;
    &lt;property name="persistenceUnitName" value="idempotentDb"/&gt;
&lt;/bean&gt;
]]></script>
</div></div>

<p>Afterwards we can configure our <tt>org.apache.camel.processor.idempotent.jpa.JpaMessageIdRepository</tt>:</p>
<div class="code panel" style="border-width: 1px;"><div class="codeContent panelContent">
<script type="syntaxhighlighter" class="theme: Default; brush: xml; gutter: false"><![CDATA[
&lt;!-- we define our jpa based idempotent repository we want to use in the file consumer
--&gt;
&lt;bean id="jpaStore" class="org.apache.camel.processor.idempotent.jpa.JpaMessageIdRepository"&gt;
    &lt;!-- Here we refer to the spring jpaTemplate --&gt;
    &lt;constructor-arg index="0" ref="jpaTemplate"/&gt;
    &lt;!-- This 2nd parameter is the name  (= a cateogry name).
         You can have different repositories with different names --&gt;
    &lt;constructor-arg index="1" value="FileConsumer"/&gt;
&lt;/bean&gt;
]]></script>
</div></div>

<p>And finally we can create our JPA idempotent repository in the spring XML file as
well:</p>
<div class="code panel" style="border-width: 1px;"><div class="codeContent panelContent">
<pre class="theme: Default; brush: xml; gutter: false" style="font-size:12px; font-family:
ConfluenceInstalledFont,monospace;">
&lt;camelContext xmlns="http://camel.apache.org/schema/spring"&gt;	
    &lt;route id="JpaMessageIdRepositoryTest"&gt;
        &lt;from uri="direct:start" /&gt;
        &lt;idempotentConsumer messageIdRepositoryRef="jpaStore"&gt;
            &lt;header&gt;messageId&lt;/camel:header&gt;
            &lt;to uri="mock:result" /&gt;
        &lt;/idempotentConsumer&gt;
    &lt;/route&gt;
&lt;/camelContext&gt;
</pre>
</div></div>

<div class='panelMacro'><table class='infoMacro'><colgroup><col width='24'><col></colgroup><tr><td
valign='top'><img src="/confluence/images/icons/emoticons/information.gif" width="16"
height="16" align="absmiddle" alt="" border="0"></td><td><b>When running
this Camel component tests inside your IDE</b><br />In case you run the <a
href="https://svn.apache.org/repos/asf/camel/trunk/components/camel-jpa/src/test" class="external-link"
rel="nofollow">tests of this component</a> directly inside your IDE (and not necessarily
through Maven itself) then you could spot exceptions like:

<div class="code panel" style="border-width: 1px;"><div class="codeContent panelContent">
<pre class="theme: Default; brush: java; gutter: false" style="font-size:12px; font-family:
ConfluenceInstalledFont,monospace;">
org.springframework.transaction.CannotCreateTransactionException: Could not open JPA EntityManager
for transaction; nested exception is
&lt;openjpa-2.2.1-r422266:1396819 nonfatal user error&gt; org.apache.openjpa.persistence.ArgumentException:
This configuration disallows runtime optimization,
but the following listed types were not enhanced at build time or at class load time with
a javaagent: "org.apache.camel.examples.SendEmail".
	at org.springframework.orm.jpa.JpaTransactionManager.doBegin(JpaTransactionManager.java:427)
	at org.springframework.transaction.support.AbstractPlatformTransactionManager.getTransaction(AbstractPlatformTransactionManager.java:371)
	at org.springframework.transaction.support.TransactionTemplate.execute(TransactionTemplate.java:127)
	at org.apache.camel.processor.jpa.JpaRouteTest.cleanupRepository(JpaRouteTest.java:96)
	at org.apache.camel.processor.jpa.JpaRouteTest.createCamelContext(JpaRouteTest.java:67)
	at org.apache.camel.test.junit4.CamelTestSupport.doSetUp(CamelTestSupport.java:238)
	at org.apache.camel.test.junit4.CamelTestSupport.setUp(CamelTestSupport.java:208)
</pre>
</div></div>

<p>The problem here is that the source has been compiled/recompiled through your IDE
and not through Maven itself which would <a href="https://svn.apache.org/repos/asf/camel/trunk/components/camel-jpa/pom.xml"
class="external-link" rel="nofollow">enhance the byte-code at build time</a>. To
overcome this you would need to enable <a href="http://openjpa.apache.org/entity-enhancement.html#dynamic-enhancement"
class="external-link" rel="nofollow">dynamic byte-code enhancement of OpenJPA</a>.
As an example assuming the current OpenJPA version being used in Camel itself is 2.2.1, then
as running the tests inside your favorite IDE you would need to pass the following argument
to the JVM:</p>

<div class="code panel" style="border-width: 1px;"><div class="codeContent panelContent">
<pre class="theme: Default; brush: java; gutter: false" style="font-size:12px; font-family:
ConfluenceInstalledFont,monospace;"> 
-javaagent:&lt;path_to_your_local_m2_cache&gt;/org/apache/openjpa/openjpa/2.2.1/openjpa-2.2.1.jar
</pre>
</div></div> 

<p>Then it will all become green again <img class="emoticon" src="/confluence/images/icons/emoticons/smile.gif"
height="20" width="20" align="absmiddle" alt="" border="0"/></p></td></tr></table></div>

<h3><a name="JPA-SeeAlso"></a>See Also</h3>
<ul>
	<li><a href="/confluence/display/CAMEL/Configuring+Camel" title="Configuring Camel">Configuring
Camel</a></li>
	<li><a href="/confluence/display/CAMEL/Component" title="Component">Component</a></li>
	<li><a href="/confluence/display/CAMEL/Endpoint" title="Endpoint">Endpoint</a></li>
	<li><a href="/confluence/display/CAMEL/Getting+Started" title="Getting Started">Getting
Started</a></li>
</ul>

<ul class="alternate" type="square">
	<li><a href="/confluence/display/CAMEL/Tracer+Example" title="Tracer Example">Tracer
Example</a></li>
</ul>

    </div>
        <div id="commentsSection" class="wiki-content pageSection">
        <div style="float: right;" class="grey">
                        <a href="https://cwiki.apache.org/confluence/users/removespacenotification.action?spaceKey=CAMEL">Stop
watching space</a>
            <span style="padding: 0px 5px;">|</span>
                <a href="https://cwiki.apache.org/confluence/users/editmyemailsettings.action">Change
email notification preferences</a>
</div>
        <a href="https://cwiki.apache.org/confluence/display/CAMEL/JPA">View Online</a>
        |
        <a href="https://cwiki.apache.org/confluence/pages/diffpagesbyversion.action?pageId=52099&revisedVersion=47&originalVersion=46">View
Changes</a>
                |
        <a href="https://cwiki.apache.org/confluence/display/CAMEL/JPA?showComments=true&amp;showCommentArea=true#addcomment">Add
Comment</a>
            </div>
</div>
</div>
</div>
</div>
</body>
</html>

Mime
View raw message