You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by StanZ <st...@eagleriversolutions.com> on 2013/01/21 22:39:22 UTC

HL7 component works in Eclipse IDE but not when exported to JAR

Hi,

This is my first post to this forum. Appreciate any help. I have a program
that processes inbound HL7 V2.4 data using Camel and the HL7 component from
File to my Java bean for DB storing. I've added Mina and  ActiveMQ JMS
components also to process streaming data and return an ACK/NAK response in
addition to File processing. It works fine in my Eclipse IDE for both file
and streaming using a test sender program. But when I export it from Eclipse
as JAR files using the Eclipse wizard it fails for both File and Stream
somewhere in the HAPI parsing area of code.

When reviewing the log file from both the program in Eclipse and the
exported JAR, I see the log from Camel to the HAPI parser is not the same
for the JAR. I've attached a copy of both logs for comparison, code snippet
from my routes, and details of the version of my components.

It appears that the HL7 is not parsed correctly and my program fails when I
try to access the data from the HAPI object. I've tried many different
things from removing JMS, using different versions of components in my Maven
POM.xml file, changing options for JMS. Even trying the latest 2.11-SNAPSHOT
and HAPI 2.0. But it still fails from the JAR where it works fine in
Eclipse. I searched for this issue but didn't see anything similar in this
forum nor the web. I've updated to the latest version of Java JDK/JRE.
Thanks.

Stanley

Windows 7 SP1 64-bit OS
JDK/JRE 7u11-windows-x64
Eclipse Java EE IDE - Indigo Service Release 1
Build id: 20110916-0149

Maven dependencies and version:
camel-core  2.10.3 - Also tried 2.95 and 2.9.2
camel-hl7  2.10.3
camel-mina  2.10.3
camel-jms  2.10.3
camel-spring  2.10.3
activemq-camel  5.7.0 Also tried 5.2.0
activemq-pool  5.7.0
xbean-spring  3.12
hapi-structures-v24  1.2 - Also tried 2.0 with Camel 2.11-SNAPSHOT
org.apache.servicemix.bundles.hapi  0.5.1_1
slf4j-log4j12  1.6.6

Camel-HL7_routes.txt
<http://camel.465427.n5.nabble.com/file/n5725936/Camel-HL7_routes.txt>  
erspochl7-Eclipse-GOOD2.log
<http://camel.465427.n5.nabble.com/file/n5725936/erspochl7-Eclipse-GOOD2.log>  
erspochl7-JAR-BAD2.log
<http://camel.465427.n5.nabble.com/file/n5725936/erspochl7-JAR-BAD2.log>  



--
View this message in context: http://camel.465427.n5.nabble.com/HL7-component-works-in-Eclipse-IDE-but-not-when-exported-to-JAR-tp5725936.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: HL7 component works in Eclipse IDE but not when exported to JAR

Posted by StanZ <st...@eagleriversolutions.com>.
Thanks Claus. I will check this as well.



--
View this message in context: http://camel.465427.n5.nabble.com/HL7-component-works-in-Eclipse-IDE-but-not-when-exported-to-JAR-tp5725936p5726006.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: HL7 component works in Eclipse IDE but not when exported to JAR

Posted by Claus Ibsen <cl...@gmail.com>.
On Tue, Jan 22, 2013 at 6:49 AM, StanZ
<st...@eagleriversolutions.com> wrote:
> Thanks Christian.
>
> I confirmed the hapi-base-1.2.jar was in the exported JAR lib. But
> removing org.apache.servicemix.bundles.hapi  0.5.1_1 as you suggested
> seems to have fixed the issue. It now works when I ran the program from
> the JAR as well as from Eclipse.
>
> I used the servicemix based off the code sample from Roger Searjeant's
> post from 2009 at
> http://searjeant.blogspot.com/2009/02/camel-routes-and-hl7.html.
> He has a code sample to generate an ACK based on the HL7 message.
> The SourceGenerator uses ServiceMix. I searched but could not find a
> recent code sample for generating an ACK from the message. The Camel
> site has one but is for 2.11 which doesn't work in my 2.10.3 code. I also
> viewed the HAPI site but didn't find what I'm needing.
>
> Any recommendations on how to create the ACK similar to Roger's 2009 post
> using the received HL7 message/version as the basis?
>

Sometimes looking in the unit test of the Camel components can give some help.

For the 2.10 branch you can peek in the code of camel-hl7
https://svn.apache.org/repos/asf/camel/branches/camel-2.10.x/components/camel-hl7/

Maybe it can help you on the way.


>
>
>
> --
> View this message in context: http://camel.465427.n5.nabble.com/HL7-component-works-in-Eclipse-IDE-but-not-when-exported-to-JAR-tp5725936p5725955.html
> Sent from the Camel - Users mailing list archive at Nabble.com.



-- 
Claus Ibsen
-----------------
Red Hat, Inc.
FuseSource is now part of Red Hat
Email: cibsen@redhat.com
Web: http://fusesource.com
Twitter: davsclaus
Blog: http://davsclaus.com
Author of Camel in Action: http://www.manning.com/ibsen

Re: HL7 component works in Eclipse IDE but not when exported to JAR

Posted by StanZ <st...@eagleriversolutions.com>.
Adam,

Thanks. I confirmed in the new 2.11-SNAPSHOT in development it is using HAPI
2.0 compared to 1.2 in the current versions of Camel.



--
View this message in context: http://camel.465427.n5.nabble.com/HL7-component-works-in-Eclipse-IDE-but-not-when-exported-to-JAR-tp5725936p5726001.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: HL7 component works in Eclipse IDE but not when exported to JAR

Posted by Christian Ohr <ch...@gmail.com>.
Yes, the camel-hl7 component of the upcoming Camel 2.11 release will 
depend on HAPI 2.0.

Christian

Am 22.01.2013 14:19, schrieb Adam Szczepaniak:
> Just an observation...
> Perhaps it is worth upgrading Hapi dependency on camel to Hapi 2+, as the
> HL7 Message in 2+ is fully serializable,
> so no need to do any extra hl7 marshalling/unmarshalling on passing msgs
> between queues and endpoinds. etc.
> thanks
> Adam
>
> On Tue, Jan 22, 2013 at 12:49 PM, Christian Ohr <ch...@gmail.com>wrote:
>
>> To generate an acknowledgement, you can call one of the
>> generateAcknowledgement() methods of the
>> ca.uhn.hl7v2.model.(Abstract)Message class.
>>
>> If you like, you can also address pure/detailed HAPI questions to the
>> HAPI mailing list (see http://hl7api.sourceforge.net/mail-lists.html),
>> which is subscribed by more HAPI users than this list.
>>
>> Christian
>>
>> 2013/1/22 StanZ <st...@eagleriversolutions.com>:
>>> Thanks Christian.
>>>
>>> I confirmed the hapi-base-1.2.jar was in the exported JAR lib. But
>>> removing org.apache.servicemix.bundles.hapi  0.5.1_1 as you suggested
>>> seems to have fixed the issue. It now works when I ran the program from
>>> the JAR as well as from Eclipse.
>>>
>>> I used the servicemix based off the code sample from Roger Searjeant's
>>> post from 2009 at
>>> http://searjeant.blogspot.com/2009/02/camel-routes-and-hl7.html.
>>> He has a code sample to generate an ACK based on the HL7 message.
>>> The SourceGenerator uses ServiceMix. I searched but could not find a
>>> recent code sample for generating an ACK from the message. The Camel
>>> site has one but is for 2.11 which doesn't work in my 2.10.3 code. I also
>>> viewed the HAPI site but didn't find what I'm needing.
>>>
>>> Any recommendations on how to create the ACK similar to Roger's 2009 post
>>> using the received HL7 message/version as the basis?
>>>
>>>
>>>
>>>
>>> --
>>> View this message in context:
>> http://camel.465427.n5.nabble.com/HL7-component-works-in-Eclipse-IDE-but-not-when-exported-to-JAR-tp5725936p5725955.html
>>> Sent from the Camel - Users mailing list archive at Nabble.com.


Re: HL7 component works in Eclipse IDE but not when exported to JAR

Posted by Adam Szczepaniak <a4...@gmail.com>.
Just an observation...
Perhaps it is worth upgrading Hapi dependency on camel to Hapi 2+, as the
HL7 Message in 2+ is fully serializable,
so no need to do any extra hl7 marshalling/unmarshalling on passing msgs
between queues and endpoinds. etc.
thanks
Adam

On Tue, Jan 22, 2013 at 12:49 PM, Christian Ohr <ch...@gmail.com>wrote:

> To generate an acknowledgement, you can call one of the
> generateAcknowledgement() methods of the
> ca.uhn.hl7v2.model.(Abstract)Message class.
>
> If you like, you can also address pure/detailed HAPI questions to the
> HAPI mailing list (see http://hl7api.sourceforge.net/mail-lists.html),
> which is subscribed by more HAPI users than this list.
>
> Christian
>
> 2013/1/22 StanZ <st...@eagleriversolutions.com>:
> > Thanks Christian.
> >
> > I confirmed the hapi-base-1.2.jar was in the exported JAR lib. But
> > removing org.apache.servicemix.bundles.hapi  0.5.1_1 as you suggested
> > seems to have fixed the issue. It now works when I ran the program from
> > the JAR as well as from Eclipse.
> >
> > I used the servicemix based off the code sample from Roger Searjeant's
> > post from 2009 at
> > http://searjeant.blogspot.com/2009/02/camel-routes-and-hl7.html.
> > He has a code sample to generate an ACK based on the HL7 message.
> > The SourceGenerator uses ServiceMix. I searched but could not find a
> > recent code sample for generating an ACK from the message. The Camel
> > site has one but is for 2.11 which doesn't work in my 2.10.3 code. I also
> > viewed the HAPI site but didn't find what I'm needing.
> >
> > Any recommendations on how to create the ACK similar to Roger's 2009 post
> > using the received HL7 message/version as the basis?
> >
> >
> >
> >
> > --
> > View this message in context:
> http://camel.465427.n5.nabble.com/HL7-component-works-in-Eclipse-IDE-but-not-when-exported-to-JAR-tp5725936p5725955.html
> > Sent from the Camel - Users mailing list archive at Nabble.com.
>

Re: HL7 component works in Eclipse IDE but not when exported to JAR

Posted by StanZ <st...@eagleriversolutions.com>.
Thank you Christian. I'll look at this as well as the HAPI list.



--
View this message in context: http://camel.465427.n5.nabble.com/HL7-component-works-in-Eclipse-IDE-but-not-when-exported-to-JAR-tp5725936p5726007.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: HL7 component works in Eclipse IDE but not when exported to JAR

Posted by StanZ <st...@eagleriversolutions.com>.
Reviewed the HAPI API and confirmed the Message class has the generateAck
methods as you pointed out. That should help. Thanks all!


HAPI ca.uhn.hl7v2.model.Message class API:

public Message generateACK() throws HL7Exception, IOException;
public Message generateACK(String theAcknowldegementCode, HL7Exception
theException) throws HL7Exception, IOException;



--
View this message in context: http://camel.465427.n5.nabble.com/HL7-component-works-in-Eclipse-IDE-but-not-when-exported-to-JAR-tp5725936p5726011.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: HL7 component works in Eclipse IDE but not when exported to JAR

Posted by Christian Ohr <ch...@gmail.com>.
To generate an acknowledgement, you can call one of the
generateAcknowledgement() methods of the
ca.uhn.hl7v2.model.(Abstract)Message class.

If you like, you can also address pure/detailed HAPI questions to the
HAPI mailing list (see http://hl7api.sourceforge.net/mail-lists.html),
which is subscribed by more HAPI users than this list.

Christian

2013/1/22 StanZ <st...@eagleriversolutions.com>:
> Thanks Christian.
>
> I confirmed the hapi-base-1.2.jar was in the exported JAR lib. But
> removing org.apache.servicemix.bundles.hapi  0.5.1_1 as you suggested
> seems to have fixed the issue. It now works when I ran the program from
> the JAR as well as from Eclipse.
>
> I used the servicemix based off the code sample from Roger Searjeant's
> post from 2009 at
> http://searjeant.blogspot.com/2009/02/camel-routes-and-hl7.html.
> He has a code sample to generate an ACK based on the HL7 message.
> The SourceGenerator uses ServiceMix. I searched but could not find a
> recent code sample for generating an ACK from the message. The Camel
> site has one but is for 2.11 which doesn't work in my 2.10.3 code. I also
> viewed the HAPI site but didn't find what I'm needing.
>
> Any recommendations on how to create the ACK similar to Roger's 2009 post
> using the received HL7 message/version as the basis?
>
>
>
>
> --
> View this message in context: http://camel.465427.n5.nabble.com/HL7-component-works-in-Eclipse-IDE-but-not-when-exported-to-JAR-tp5725936p5725955.html
> Sent from the Camel - Users mailing list archive at Nabble.com.

Re: HL7 component works in Eclipse IDE but not when exported to JAR

Posted by StanZ <st...@eagleriversolutions.com>.
Thanks Christian.

I confirmed the hapi-base-1.2.jar was in the exported JAR lib. But 
removing org.apache.servicemix.bundles.hapi  0.5.1_1 as you suggested 
seems to have fixed the issue. It now works when I ran the program from 
the JAR as well as from Eclipse.

I used the servicemix based off the code sample from Roger Searjeant's 
post from 2009 at
http://searjeant.blogspot.com/2009/02/camel-routes-and-hl7.html. 
He has a code sample to generate an ACK based on the HL7 message. 
The SourceGenerator uses ServiceMix. I searched but could not find a 
recent code sample for generating an ACK from the message. The Camel 
site has one but is for 2.11 which doesn't work in my 2.10.3 code. I also 
viewed the HAPI site but didn't find what I'm needing. 

Any recommendations on how to create the ACK similar to Roger's 2009 post 
using the received HL7 message/version as the basis?




--
View this message in context: http://camel.465427.n5.nabble.com/HL7-component-works-in-Eclipse-IDE-but-not-when-exported-to-JAR-tp5725936p5725955.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: HL7 component works in Eclipse IDE but not when exported to JAR

Posted by Christian Ohr <ch...@gmail.com>.
Ah now I get your point.

>From your initial list of dependencies you list
org.apache.servicemix.bundles.hapi  0.5.1_1.
HAPI 0.5.1 was released about 6 (!) years ago, and it certainly does
not match with the 2.4 structures lib of the HAPI 1.2 release. Make
sure your classpath contains hapi-base-1.2.jar instead. Probably your
Eclipse project finds it somewhere on the classpath and the "exported"
version does not contain it.

Christian


2013/1/21 StanZ <st...@eagleriversolutions.com>:
> When I step through and debug in Eclipse it is fine. I've added print
> statements to the console to list various values extracted from the MSH HAPI
> and it fails when attempting to print the first data from the DATE field in
> the MSH header when running the JAR. But in Eclipse it goes through just
> fine and print out all the values. and completes the whole cycle
> successfully.
>
> What stands out in the GOOD log is line 199 of the Camel parsing does not
> appear in the JAR/BAD log:
>
> "2013-01-20 21:47:05,865 INFO Camel (camel-1) thread #1 - JmsConsumer[hl7]
> ca.uhn.hl7v2.VersionLogger - HAPI version is: 1.2"
>
> Nor do the lines 212 - 215. It's as if it's using a different Parser:
>
> 2013-01-20 21:47:05,942 DEBUG Camel (camel-1) thread #1 - JmsConsumer[hl7]
> ca.uhn.hl7v2.parser.MessageIterator - hasNext() for direction MSH
> 2013-01-20 21:47:05,942 DEBUG Camel (camel-1) thread #1 - JmsConsumer[hl7]
> ca.uhn.hl7v2.parser.MessageIterator - hasNext() current position:
> Root:SIU_S12(0)
> 2013-01-20 21:47:05,942 DEBUG Camel (camel-1) thread #1 - JmsConsumer[hl7]
> ca.uhn.hl7v2.parser.MessageIterator - hasNext() current position:
> SIU_S12:MSH(-1)
>
> It looks like the HL7 was not parsed successfully or correctlry by the time
> it reaches my Bean.
> 2013-01-20 21:47:05,942 DEBUG Camel (camel-1) thread #1 - JmsConsumer[hl7]
> ca.uhn.hl7v2.parser.MessageIterator - hasNext() for direction MSH
>
>
>
> --
> View this message in context: http://camel.465427.n5.nabble.com/HL7-component-works-in-Eclipse-IDE-but-not-when-exported-to-JAR-tp5725936p5725945.html
> Sent from the Camel - Users mailing list archive at Nabble.com.

Re: HL7 component works in Eclipse IDE but not when exported to JAR

Posted by StanZ <st...@eagleriversolutions.com>.
When I step through and debug in Eclipse it is fine. I've added print
statements to the console to list various values extracted from the MSH HAPI
and it fails when attempting to print the first data from the DATE field in
the MSH header when running the JAR. But in Eclipse it goes through just
fine and print out all the values. and completes the whole cycle
successfully.

What stands out in the GOOD log is line 199 of the Camel parsing does not
appear in the JAR/BAD log:

"2013-01-20 21:47:05,865 INFO Camel (camel-1) thread #1 - JmsConsumer[hl7]
ca.uhn.hl7v2.VersionLogger - HAPI version is: 1.2"

Nor do the lines 212 - 215. It's as if it's using a different Parser:

2013-01-20 21:47:05,942 DEBUG Camel (camel-1) thread #1 - JmsConsumer[hl7]
ca.uhn.hl7v2.parser.MessageIterator - hasNext() for direction MSH
2013-01-20 21:47:05,942 DEBUG Camel (camel-1) thread #1 - JmsConsumer[hl7]
ca.uhn.hl7v2.parser.MessageIterator - hasNext() current position:
Root:SIU_S12(0)
2013-01-20 21:47:05,942 DEBUG Camel (camel-1) thread #1 - JmsConsumer[hl7]
ca.uhn.hl7v2.parser.MessageIterator - hasNext() current position:
SIU_S12:MSH(-1)

It looks like the HL7 was not parsed successfully or correctlry by the time
it reaches my Bean.
2013-01-20 21:47:05,942 DEBUG Camel (camel-1) thread #1 - JmsConsumer[hl7]
ca.uhn.hl7v2.parser.MessageIterator - hasNext() for direction MSH



--
View this message in context: http://camel.465427.n5.nabble.com/HL7-component-works-in-Eclipse-IDE-but-not-when-exported-to-JAR-tp5725936p5725945.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: HL7 component works in Eclipse IDE but not when exported to JAR

Posted by Christian Ohr <ch...@gmail.com>.
Did you check/debug what happens inside
com.eagleriversolutions.app.erspoc.hl7v2.ProcessHl7V24Message#transformHl7Message?
The "bad" log reports the error after the bean is called.

cheers
Christian



2013-01-20 21:58:54,878 DEBUG Camel (camel-1) thread #1 -
JmsConsumer[hl7] org.apache.camel.processor.SendProcessor - >>>>
Endpoint[bean://com.eagleriversolutions.app.erspoc.hl7v2.ProcessHl7V24Message?method=transformHl7Message]
Exchange[JmsMessage[JmsMessageID:
ID:Dan-HP-58626-1358737130534-3:3:1:1:1]]
2013-01-20 21:58:55,001 DEBUG Camel (camel-1) thread #1 -
JmsConsumer[hl7] org.apache.camel.processor.DefaultErrorHandler -
Failed delivery for (MessageId:
queue_hl7_ID_Dan-HP-58626-1358737130534-3_3_1_1_1 on ExchangeId:
ID-Dan-HP-58616-1358737129438-0-4). On delivery attempt: 0 caught:
org.apache.camel.CamelExecutionException: Exception occurred during
execution on the exchange: Exchange[JmsMessage[JmsMessageID:
ID:Dan-HP-58626-1358737130534-3:3:1:1:1]]


2013/1/21 StanZ <st...@eagleriversolutions.com>:
> Extra note is that the program worked fine from JAR exports up until recently
> when I added the streaming feature. But now stream nor file options work.
>
>
>
> --
> View this message in context: http://camel.465427.n5.nabble.com/HL7-component-works-in-Eclipse-IDE-but-not-when-exported-to-JAR-tp5725936p5725940.html
> Sent from the Camel - Users mailing list archive at Nabble.com.

Re: HL7 component works in Eclipse IDE but not when exported to JAR

Posted by StanZ <st...@eagleriversolutions.com>.
Extra note is that the program worked fine from JAR exports up until recently
when I added the streaming feature. But now stream nor file options work. 



--
View this message in context: http://camel.465427.n5.nabble.com/HL7-component-works-in-Eclipse-IDE-but-not-when-exported-to-JAR-tp5725936p5725940.html
Sent from the Camel - Users mailing list archive at Nabble.com.