It is there in the earlier mail at the end...
My custom convertor code...
---------------------------------------------------
@Converter
public class LogTransformer {
private static final transient Log LOG =
LogFactory.getLog(LogTransformer.class);
private JpaTemplate template;
public LogTransformer(JpaTemplate template) {
this.template = template;
}
/**
* A transformation method to convert a LogInfo into a LogEntity
* entity
*/
@Converter
public LogEntity toJobLog(LogInfo doc) {
String jobId = doc.getJobId();
LogEntity jobLog = findLogEntityByJobId(jobId);
// lets convert information from the document into the entity
bean
jobLog.setStepId(doc.getStepId());
jobLog.setDate(doc.getDate());
jobLog.setStatus(doc.getStatus());
LOG.debug("Created jobLog: " + jobLog);
return jobLog;
}
/**
* Finds a customer for the given username, or creates and inserts
a new one
*/
protected LogEntity findLogEntityByJobId(String jobId) {
LOG.debug("Log Entity: Job Id" + jobId);
List<LogEntity> list = template.find("select x from " +
LogEntity.class.getName() + " x where x.jobId = ?1", jobId);
if (list.isEmpty()) {
LogEntity answer = new LogEntity();
answer.setJobId(jobId);
template.persist(answer);
return answer;
} else {
return list.get(0);
}
}
}
--------------------------
-----Original Message-----
From: Gert Vanthienen [mailto:[EMAIL PROTECTED]
Sent: Wednesday, March 26, 2008 2:20 PM
To: [email protected]
Subject: Re: TypeConverters not available when using Camel JBI Endpoint
from ServiceMix
Rabi,
And what does your typeconverter code look like?
Gert
[EMAIL PROTECTED] wrote:
- In 3.2.1 it thows the following error.
----------------------------------------------------------
8:51:32,140 | ERROR | pool-flow.seda.servicemix-camel-thread-1 |
DeadLetterChannel | .apache.camel.processor.Logger 143 | On
delivery attempt: 0 caught: org.apache.camel.RuntimeCamelException:
javax.xml.bind.UnmarshalException: unexpected element (uri:"",
local:"log"). Expected elements are <{}jobLog>
org.apache.camel.RuntimeCamelException:
javax.xml.bind.UnmarshalException: unexpected element (uri:"",
local:"log"). Expected elements are <{}jobLog>
at
org.apache.camel.converter.jaxb.FallbackTypeConverter.convertTo(Fallba
ck
TypeConverter.java:70)
at
org.apache.camel.impl.converter.DefaultTypeConverter.convertTo(Default
Ty
peConverter.java:68)
at
org.apache.camel.impl.MessageSupport.getBody(MessageSupport.java:50)
at
org.apache.camel.component.jpa.JpaEndpoint$1.evaluate(JpaEndpoint.java
:2
02)
at
org.apache.camel.component.jpa.JpaProducer.process(JpaProducer.java:47)
at
org.apache.camel.impl.converter.AsyncProcessorTypeConverter$ProcessorT
oA
synProcessorBridge.process(AsyncProcessorTypeConverter.java:44)
at
org.apache.camel.processor.SendProcessor.process(SendProcessor.java:73)
at
org.apache.camel.processor.DeadLetterChannel.process(DeadLetterChannel
.j
ava:136)
at
org.apache.camel.processor.DeadLetterChannel.process(DeadLetterChannel
.j
ava:86)
at
org.apache.camel.processor.Pipeline.process(Pipeline.java:103)
at org.apache.camel.processor.Pipeline.process(Pipeline.java:87)
at
org.apache.camel.processor.UnitOfWorkProcessor.process(UnitOfWorkProce
ss
or.java:40)
at
org.apache.camel.util.AsyncProcessorHelper.process(AsyncProcessorHelper.
java:44)
at
org.apache.camel.processor.DelegateAsyncProcessor.process(DelegateAsyn
cP
rocessor.java:68)
at
org.apache.servicemix.camel.CamelJbiEndpoint.processInOnly(CamelJbiEnd
po
int.java:64)
at
org.apache.servicemix.common.endpoints.ProviderEndpoint.process(Provid
er
Endpoint.java:100)
at
org.apache.servicemix.common.AsyncBaseLifeCycle.doProcess(AsyncBaseLif
eC
ycle.java:538)
at
org.apache.servicemix.common.AsyncBaseLifeCycle.processExchange(AsyncB
as
eLifeCycle.java:490)
at
org.apache.servicemix.common.BaseLifeCycle.onMessageExchange(BaseLifeC
yc
le.java:46)
at
org.apache.servicemix.jbi.messaging.DeliveryChannelImpl.processInBound
(D
eliveryChannelImpl.java:610)
at
org.apache.servicemix.jbi.nmr.flow.AbstractFlow.doRouting(AbstractFlow
.j
ava:170)
at
org.apache.servicemix.jbi.nmr.flow.seda.SedaFlow.doRouting(SedaFlow.ja
va
:167)
at
org.apache.servicemix.jbi.nmr.flow.seda.SedaQueue$1.run(SedaQueue.java
:1
34)
at
java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecu
to
r.java:650)
at
java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.
ja
va:675)
at java.lang.Thread.run(Thread.java:595)
Caused by: javax.xml.bind.UnmarshalException: unexpected element
(uri:"", local:"log"). Expected elements are <{}jobLog>
----------------------------------------------------------------------
--
--------------------------------------------------
- But, in 3.3-SNAPHOT it is not giving any eror. But inserting null
values in the tables. I removed the cusotomconverter and and modified
the message inline with expected by the Entity bean and it worked
fine.
But I require a custom convertor:)
My custom convertor code...
---------------------------------------------------
@Converter
public class LogTransformer {
private static final transient Log LOG =
LogFactory.getLog(LogTransformer.class);
private JpaTemplate template;
public LogTransformer(JpaTemplate template) {
this.template = template;
}
/**
* A transformation method to convert a LogInfo into a LogEntity
* entity
*/
@Converter
public LogEntity toJobLog(LogInfo doc) {
String jobId = doc.getJobId();
LogEntity jobLog = findLogEntityByJobId(jobId);
// lets convert information from the document into the entity
bean
jobLog.setStepId(doc.getStepId());
jobLog.setDate(doc.getDate());
jobLog.setStatus(doc.getStatus());
LOG.debug("Created jobLog: " + jobLog);
return jobLog;
}
/**
* Finds a customer for the given username, or creates and inserts
a new one
*/
protected LogEntity findLogEntityByJobId(String jobId) {
LOG.debug("Log Entity: Job Id" + jobId);
List<LogEntity> list = template.find("select x from " +
LogEntity.class.getName() + " x where x.jobId = ?1", jobId);
if (list.isEmpty()) {
LogEntity answer = new LogEntity();
answer.setJobId(jobId);
template.persist(answer);
return answer;
} else {
return list.get(0);
}
}
}
--------------------------
Also TypeConverter is part of the camel-su.
Regards,
Rabi Mishra,
Wipro Technologies,Office: +91-20-39104549, VOIP:842
2545,CELL+91(0)9765391877
http://rabisblog.blogspot.com/
Dreams give vision, vision gives thoughts and thoughts lead to action
-----Original Message-----
From: Gert Vanthienen [mailto:[EMAIL PROTECTED]
Sent: Wednesday, March 26, 2008 1:43 PM
To: [email protected]
Subject: Re: TypeConverters not available when using Camel JBI
Endpoint from ServiceMix
Rabi,
Could you post the log info to the mailing list as well? Where is the
TypeConverter class -- is it part of the Camel SU itself or did you
add it as a JAR file?
Gert
[EMAIL PROTECTED] wrote:
It seems to me like a classloading issue. I can not even see the
TypeConverters loaded in the debug log. I can see them in the debug
log with the all camel example.
-----Original Message-----
From: rabi [mailto:[EMAIL PROTECTED]
Sent: Wednesday, March 26, 2008 1:13 PM
To: [email protected]
Subject: Re: TypeConverters not available when using Camel JBI
Endpoint from ServiceMix
Gret,
I am using Servicemix 3.3-SNAPSHOT build from trunk and Camel 3.1
SNAPSHOT.
Here are the deatils..
--------------------------
All Camel example with the following Route works fine
from("file:inbox/data1?noop=true").convertBodyTo(PersonDocument.class)
// .intercept(transactionInterceptor())
.to("jpa:org.apache.camel.example.etl.CustomerEntity");
When I change this use smx filepoller with the following route, this
gives me errors as it is not able to convert the types. I am using a
servicemix-bean inbetween (passthrough)
from("jbi:endpoint:http://camel.apache.org/example/etl/persist/person"
)
.convertBodyTo(PersonDocument.class)
// .intercept(transactionInterceptor())
.to("jpa:org.apache.camel.example.etl.CustomerEntity");
fillePoller su config..
-------------------------
<beans xmlns:file="http://servicemix.apache.org/file/1.0"
xmlns:ls="http://servicemix.apache.org/samples/logging-sample">
<file:poller service="ls:filePoller"
endpoint="poller"
targetService="ls:beanRouter"
targetEndpoint="router"
file="inbox/data1"> </file:poller> </beans>
Bean su
----------------
<beans xmlns:bean="http://servicemix.apache.org/bean/1.0"
xmlns:ls="http://servicemix.apache.org/samples/logging-sample">
<bean:endpoint service="ls:beanRouter" endpoint="router">
<bean:bean>
<bean
class="org.apache.servicemix.samples.logging.BeanRouter"
/>
</bean:bean>
</bean:endpoint>
</beans>
Bean su code..
----------------------
public void onMessageExchange(MessageExchange exchange) throws
MessagingException {
InOnly in = (InOnly) exchange;
if (in.getStatus() == ExchangeStatus.DONE) {
return;
} else if (in.getStatus() == ExchangeStatus.ERROR) {
return;
}
System.err.println(in.getService().getLocalPart() + "
requested");
try {
NormalizedMessage message = exchange.getMessage("in");
Source content = message.getContent();
QName targetService = new
QName("http://camel.apache.org/example/etl","persist");
MessageExchangeFactory exchangeFact =
channel.createExchangeFactoryForService(targetService);
InOnly response = exchangeFact.createInOnlyExchange();
NormalizedMessage jpaMessage = response.createMessage();
jpaMessage.setContent(content);
response.setInMessage(jpaMessage);
channel.sendSync(response);
exchange.setStatus(ExchangeStatus.DONE);
channel.send(exchange);
} catch (Exception e) {
in.setError(e);
channel.sendSync(in);
}
}
Regards,
Rabi
Gert Vanthienen wrote:
Rabi Mishra,
What version of ServiceMix are you using? This sounds like an issue
from ServiceMix 3.2.0, which has been solved in 3.2.1 however. Can
you post the xbean.xml for the file SU as well as the Camel route?
Regards,
Gert
[EMAIL PROTECTED] wrote:
Hi,
TypeConverters (including the custom TypeConverters) are not loaded
when using "Camel JBI Endpoint" from as a target from servicemix
component.
servicemix-file->camel-jpa
This issue does not arise when the complete flow is in Camel (in
the
RouteBuilder).
camel-file->camel-jpa
Any thoughts..
Regards,
Rabi Mishra
Wipro Technologies
Hinjewadi, Pune
Cell: +91(0)9765391877
http://rabisblog.blogspot.com/
The information contained in this electronic message and any
attachments to this message are intended for the exclusive use of
the
addressee(s) and may contain proprietary, confidential or
privileged
information. If you are not the intended recipient, you should not
disseminate, distribute or copy this e-mail. Please notify the
sender
immediately and destroy all copies of this message and any
attachments.
WARNING: Computer viruses can be transmitted via email. The
recipient
should check this email and any attachments for the presence of
viruses.
The company accepts no liability for any damage caused by any virus
transmitted by this email.
www.wipro.com
-----
---
Gert Vanthienen
http://www.anova.be
--
View this message in context:
http://www.nabble.com/TypeConverters-not-available-when-using-Camel-J
B
I- Endpoint-from-ServiceMix-tp16277241s12049p16297034.html
Sent from the ServiceMix - User mailing list archive at Nabble.com.
The information contained in this electronic message and any
attachments to this message are intended for the exclusive use of the
addressee(s) and may contain proprietary, confidential or privileged
information. If you are not the intended recipient, you should not
disseminate, distribute or copy this e-mail. Please notify the sender
immediately and destroy all copies of this message and any
attachments.
WARNING: Computer viruses can be transmitted via email. The recipient
should check this email and any attachments for the presence of
viruses.
The company accepts no liability for any damage caused by any virus
transmitted by this email.
www.wipro.com
The information contained in this electronic message and any
attachments to this message are intended for the exclusive use of the
addressee(s) and may contain proprietary, confidential or privileged
information. If you are not the intended recipient, you should not
disseminate, distribute or copy this e-mail. Please notify the sender
immediately and destroy all copies of this message and any attachments.
WARNING: Computer viruses can be transmitted via email. The recipient
should check this email and any attachments for the presence of viruses.
The company accepts no liability for any damage caused by any virus
transmitted by this email.
www.wipro.com
The information contained in this electronic message and any attachments to this message are intended for the exclusive use of the addressee(s) and may contain proprietary, confidential or privileged information. If you are not the intended recipient, you should not disseminate, distribute or copy this e-mail. Please notify the sender immediately and destroy all copies of this message and any attachments.
WARNING: Computer viruses can be transmitted via email. The recipient should
check this email and any attachments for the presence of viruses. The company
accepts no liability for any damage caused by any virus transmitted by this
email.
www.wipro.com