I do use Groovy and Gradle with Camel.
I haven't used the uber-jar with Gradle though, I am using the fatjar
plugin instead - https://github.com/musketyr/gradle-fatjar-plugin

You didn't provide any information about which versions you are using, for
instance in Camel the ".process { closure }" works since 2.11 and not
before.
(If you try it in earlier versions you get a groovy missing method
exception.)

It would help seeing a log printout, you say that you get all the logging
messages you expect except that you get the ExecResult.toString() instead
of the expected XML string, but it would be much easier to try help you if
I (we) can see what happens.


2013/5/1 Speck, Dan <dsp...@bna.com>

> I'm having trouble deploying my Camel application. It works fine when I
> build the java classpath manually (including all of the dependent jars) but
> when I follow the instructions for creating an executable jar in gradle,
> the app only works partially. Some of the routes work but others don't. I
> also get errors when using groovy closures as arguments to .process() (I
> need to use the { ... } as Processor syntax to get the route to run).
>
> Here is one of the routes that doesn't work when running the executable
> jar (it takes a multipart form with an input file parameter containing an
> SGML file and translates it to XML via an exec() component):
>
> from("jetty:http://0.0.0.0:$port/convert/psdm/toXml";)
>     .process(new MultipartFormSingleFileExtractor())
>     .choice()
>       .when(header('origFileName'))
>       .to('file:///tmp')
>       .setHeader(ExecBinding.EXEC_COMMAND_ARGS, simple('--indent -o
> /dev/stdout /tmp/${id}'))
>       .setHeader('TempFilename', simple('/tmp/${id}'))
>       .to('exec:ps2000_sgml2xml')
>       .process(
>         { Exchange ex ->
>           def tempFile = new File(ex.in.headers.TempFileName).delete()
>           if ( ex.in.headers[ExecBinding.EXEC_EXIT_VALUE] == 0 ) {
>             log.info "yay! file ${ex.in.headers.origFilename} was valid!"
>             ex.out.body = ex.in.getBody(String.class)
>             ex.out.headers[Exchange.HTTP_RESPONSE_CODE] = 200
>             ex.out.headers['Content-Type'] = 'application/xml'
>           }
>           else {
>             String msgText =
> ex.in.headers[ExecBinding.EXEC_STDERR].getText()
>             .replaceAll(ex.in.headers.TempFilename,
> ex.in.headers.origFilename)
>             ex.out = new ErrorMessage(errorCode:
> ex.in.headers[ExecBinding.EXEC_EXIT_VALUE],
>                                       httpResponseCode: 400,
>                                       message: msgText).toMessage()
>           }
>         } as Processor
>       )
>     .end()
>
> When I run this using the manually constructed java command I get the
> expected output, i.e., an XML document, but when I run the executable jar I
> get the string:
> org.apache.camel.component.exec.ExecResult@eabd2f<mailto:
> org.apache.camel.component.exec.ExecResult@eabd2f>
> Aside from the incorrect output, the route seems to be working-I get the
> logging messages I expect.
>
> Here is the "uberjar" task that I am using in my build.gradle:
> task uberjar(type: Jar) {
>
>   from files(sourceSets.main.output.classesDir)
>   from 'src/main/resources'
>
>   from { configurations.compile.asFileTree.files.collect { zipTree(it) } }
> {
>     exclude "META-INF/*.SF"
>     exclude "META-INF/*.DSA"
>     exclude "META-INF/*.RSA"
>   }
>
>   from { configurations.runtime.asFileTree.files.collect { zipTree(it) } }
> {
>     exclude "META-INF/*.SF"
>     exclude "META-INF/*.DSA"
>     exclude "META-INF/*.RSA"
>   }
>
>   manifest {
>     attributes 'Main-Class': mainClassName,
>     'Built-By': System.getProperty('user.name'),
>     'Built-Date': new Date(),
>     'Built-JDK': System.getProperty('java.version')
>   }
> }
>
> Has anyone had a similar issue? Does anyone else use groovy/gradle with
> Camel?
>
> -dan
>
> >>>>>>>>>>>>>>>>>>>>>>>>>>
> Daniel Speck
> Software Development Manager
> Publishing Systems, PR&D
>
> Bloomberg BNA
>
> Direct 703.341.3118
> Mobile 202.329.7449
> dsp...@bna.com<mailto:dsp...@bna.com>
>
>

Reply via email to