Can I have a look at your class path ?
Please make sure you are using camel-spring and not using camel-spring-osgi when you run your code from executable jar file.
My classpath does not have camel-osgi.jar/camel-spring-osgi.jar
Here are the jars on my classpath: lib/java/junit-3.8.1.jar, lib/java/log4j-1.2.9.jar, programs/eclipse/mysql-connector-java-5.1.6-bin.jar, programs/log4j/log4j.properties, programs/log4j/log4jproperties.jar, programs/spring-framework-2.5.5/dist/spring.jar, programs/spring-framework-2.5.5/lib/jakarta-commons/commons-logging.jar, programs/spring-framework-2.5.5/lib/log4j-1.2.15.jar, programs/eclipse/mysql-connector-java-5.1.6-bin.jar.
Edited by: asilchenko on May 12, 2010 1:56 PM
How do you exactly start your app as a jar file?
java -jar target/myJar-1.0-SNAPSHOT.one-jar.jar
I am using onejar-maven-plugin to generate jar. I have used this many times before to generate jar with dependencies. It always works fine but not when I am using Camel File Component.
This morning I tried changing route to
And got similar but little different error:
ERROR - Caused by: [org.apache.camel.InvalidPayloadException - No body available of type: java.io.InputStream but has value: GenericFile[myFileName] of type: org.apache.camel.component.file.GenericFile on: GenericFileMessage with file: GenericFile[myFileName]. Caused by: No type converter available to convert from type: org.apache.camel.component.file.GenericFile to the required type: java.io.InputStream with value GenericFile[myFileName]. Exchange[GenericFileMessage with file: GenericFile[myFileName]]. Caused by: [org.apache.camel.NoTypeConversionAvailableException - No type converter available to convert from type: org.apache.camel.component.file.GenericFile to the required type: java.io.InputStream with value GenericFile[myFileName]]]
Thank you very much for your time!
Edited by: asilchenko on May 12, 2010 3:57 PM
Edited by: asilchenko on May 12, 2010 3:58 PM
Edited by: asilchenko on May 12, 2010 4:00 PM
Maybe that onejar maven tool do only put .class files in the one big JAR. You have to include files from META-INF as well.
And I suspect it can't merge the META-INF .../TypeConverter file which tells Camel which converters it should find in this JAR.
So start it in normal situations using a -cp and provide the classpath.
Or if using maven, you can just use mvn camel:run
My project does not have META-INF directory or TypeConverter file. It works without it in Eclipse. Do I need to create META-INF directory in my project? I need to get Camel Component running from jar without maven.
Thank you very much!
Edited by: asilchenko on May 12, 2010 4:43 PM
Dont mess with the .jars.
Just start it using a script which sets the classpath and then invoke you main class.
I was hoping to satisfy a requirement by using executable jar file but looks like it might not be a best way.
Edited by: asilchenko on May 12, 2010 6:40 PM
I am trying to add missing TypeConverter to classpath. I am seeing TypeConverter in camel-core-2.2.0.jar and some other jars. Could you please let me know which one gets used? Which jar I need to include for TypeConverter?
Thank you very much!
Edited by: asilchenko on May 13, 2010 8:11 PM
You cannot do this.
Its a special file in META-INF/services/org/apache/camel named TypeConverter which has a list of the package names it should scan.
And if you merge many .jars -> 1 jar then the TypeConverter file should be merged as well to include all the package names from all the jars. Right now I bet it just add the TypeConverter file from either the first or last .jar.
Thank you for your response. I could not get META-INF/services/org/apache/camel to work. But I got around my problem by sending message thought bean processor class. And, everything works now from executable jar file.
public InputStream convertBody(GenericFile file)
InputStream inputStream = null;
inputStream = new BufferedInputStream(new FileInputStream((File)file.getFile()));
catch (FileNotFoundException e)
// TODO Auto-generated catch block
Thank you very much,