Apache Camel Rest - v3.2.0 - Multipart file upload issue - apache-camel

I am looking forward to achieve the multipart file upload with camel 3.2.0 version and JDK11.
I was able to successfully do the same with the older version of camel 2.x using the below code,
.post("/importFile")
.id("importFile")
.bindingMode(RestBindingMode.off)
.consumes("multipart/form-data")
.produces(IConstants.APPLICATION_JSON)
.outType(String.class)
.to("direct:importFile")
from("direct:importFile")
.unmarshal()
.mimeMultipart()
.split().attachments()
// further processing...
After upgrading the camel version from 2.x to 3.2.0, we were getting an compile time issue in the above code for ".attachments()". As a result, we replaced the from route by,
SplitAttachmentsExpression split = new SplitAttachmentsExpression();
from("direct:importFile")
.unmarshal()
.mimeMultipart()
.split(split)
// further processing...
However, after this when i debug the code i am getting null attachments.
SplitAttachmentsExpression->evaluate()->exchange.getIn(AttachmentMessage.class).hasAttachments() ==> evaluates to false.
Am i missing anything here as part of the upgrade? Has the import file functionality changed with latest version of Camel?
A quick help is highly appreciated as this was working earlier and now we are completely blocked!

Related

Apache camel date

I use camel version 2.12.3
I would like to get yesterday date for file name.
Founded documentation from https://camel.apache.org/components/latest/languages/simple-language.html
So i coded like below :
<setProperty propertyName="exportFileName">
<camel:simple>${date:now-24h:yyyyMMdd}</camel:simple>
</setProperty>
I had this error "java.lang.IllegalArgumentException: Command not supported for dateExpression: now-24h"
Am i missing something here ?
Thanks
Your version is simply too old. This works in current versions of Camel 2.x but not in 2.12.x
By the way: Notice the version switcher in the Camel component docs in the upper right. You have to switch from latest to 2.x to see the correct docs. However, even the 2.x docs describe the current versions of 2.x and so you would have the same problem in this case :-)

Prompt Solr Query using SolrJ

I am trying to structure a solr query using solrj. From my understanding of Solr-7.5.0 all libraries and dependencies for solrj should be included in my solr installation. Below is my /dist folder followed by my /dist/solrj-lib folder
Now, my query will be tied to an html post form but I want to get the solrj working first. Here is the entirety of my solrj
import org.apache.solr.client.solrj.SolrClient;
import org.apache.solr.client.solrj.SolrQuery;
import org.apache.solr.client.solrj.HttpSolrClient;
String queryInput = q;
SolrQuery query = new SolrQuery(queryInput);
SolrClient client = new HttpSolrClient.Builder (
"http://localhost:8983/solr/sqltest")
.build();
QueryResponse response = client.query(query);
SolrDocumentList list = response.getResults();
This will not compile because it does not recognize my classes (SolrClient, SolrQuery, etc). I am sure there are countless issues right now but Im not sure where to start.
As a side question, I was looking into other APIs that are not in compiled code. Would one of these be better used for a web application or is it safe to use solrs native solrj?
You can safely use SolrJ - in fact, if you're writing a Java application, it's the recommended way of interacting with Solr. See Using SolrJ - Building and Running SolrJ Applications for further details than what I've given below.
I've assumed you're on Windows from your screenshots - if you're on Linux or OS X, replace ; with : as the path separator below.
To include the SolrJ jar, you need to include a -classpath ".;path-to-solr-solrj-7.5.0.jar argument when running javac. This is the only jar required to compile your application.
When running it you'll have to include the jars found in the solrj-lib path. You can do this by including a class path argument to java with your files. Use java -classpath ".;path-to-solrj-lib\* to include all the jar files in the directory.

JavaMail not working in OSGI(ServiceMix/Karaf)

I created a Karaf Instance on a Service Mix(7.0.1) and deployed my bundles into it.
The camel route is starting up properly, but always fails when it should send an email.
With the following exception:
javax.activation.UnsupportedDataTypeException: no object DCH for MIME type multipart/mixed;
I tried several solutions i found from different sources around the web, but cannot actually fix it.
I tried commenting javax.activation out in the jre.properties file of the instance, as well as using a bundle that contains java mail and the osgi friendly version of the activation bundle in the same feature.
Could openJDK be an issue here?
Note: Everything works perfectly fine on a windows/oraclejdk environment, the exception only occurs in a linux/openjdk environment.
My issue stemed from a class loader problem after all and i fixed it by bundling javax.mail/mail/1.4.7 and org.apache.servicemix.specs.activation-api-1.1/2.8.0 in the same bundle.
I also needed to remove every occurence of javax.activation from the jre.properties and config.properties file of the child instance.
I am not sure why it ran per default on a different environment, as in theory the same classloader problems should have occured too, but that might be connected to different JREs being in use.

Vespa Tutorial – HTTP API use-case fails to activate with IllegalArgumentException

I'm currently following the Vespa tutorials, and ran into an issue with the HTTP API use-case. Everything works fine from the mvn install package to the vespa-deploy prepare target/application.zip.
The call to vespa-deploy activate returns normally, but the application then never gets available on localhost:8080. Looking at /opt/vespa/logs/vespa/vespa.log (in the VM) one finds the following stack trace:
Container.com.yahoo.jdisc.core.StandaloneMain error Unexpected:
exception=
java.lang.IllegalArgumentException: Could not create a component with id 'com.mydomain.demo.DemoComponent'.
Tried to load class directly, since no bundle was found for spec: sample-app-http-api-searcher.
If a bundle with the same name is installed, there is a either a version mismatch or the installed bundle's version contains a qualifier string.
at com.yahoo.osgi.OsgiImpl.resolveFromClassPath(OsgiImpl.java:48)
...
This occurred using a fresh Docker image with a clean clone of the sample-apps git repository. Preparing and activating the basic sample as well as the other http example did work seamlessly.
I checked the sources and the xml files for obvious problems but don't have any clue about what is failing and where.
target/application.zip contains
application/components/http-api-using-searcher-1.0.1-deploy.jar
application/hosts.xml
application/searchdefinitions/basic.sd
application/services.xml
And the jar itself does contain a com/mydomain/demo/DemoComponent.class file (among other things).
Potentially related issue on the github tracker: https://github.com/vespa-engine/vespa/issues/3479 I'll be posting a link to this question there as well, but I still think it's worth a SO question, at least to get some action behind the vespa tag :)
The bundle id in the application's services.xml file was wrong. Please pull the application from git and try again now. See also PR: https://github.com/vespa-engine/sample-apps/pull/18
Brief explanation: The bundle id given in the bundle="<id>" declaration in services.xml must match the 'Bundle-SymbolicName' in the bundle's manifest. When the bundle has been built with the Vespa bundle-plugin, the symbolic name is by default the same as the project's artifactId. Hence, in most cases you just have to verify that the bundle id matches the artifactId.

Extracting .docx files with Tika in Apache Solr gives NoSuchMethod error

I have a Solr 4.0 module in my project (basically, a maven web project with all the solr dependencies). It worked pretty well, including content extraction and everything.
But, when I tested it with a .docx document, It gives me the following error:
13:50:34,468 ERROR [org.apache.solr.servlet.SolrDispatchFilter] (http--0.0.0.0-8080-9)
null:java.lang.RuntimeException: java.lang.NoSuchMethodError:
org.apache.poi.openxml4j.opc.PackagePart.getRelatedPart(Lorg/apache/poi/openxml4j/opc/PackageRelationship;)
Lorg/apache/poi/openxml4j/opc/PackagePart;
I tried to manually add the openxml4j dependency to the project. I've downloaded the sources and looked at it, the PackagePart#getRelatedPart really doesn't exist.
What is this error? How can I fix this?
Thanks in advance.
EDIT
I noticed that poi-ooxml already had those classes inside it. Cool, but I also inspected those sources, and still doesn't have the needed method in the PackagePart class.
BTW: I tried to add openxml4j version 1.0-beta.
It was a jarhell related issue.
Thanks, "jarhell related" was the clue I needed!
My project had POI jars prior to import of the Tika app jar, which includes its own POI jars. I deleted the standalone POI jars, and then Tika was able to handle DOCX Word 2013 file without error.
Now hopefully I won't run into a situation where I need both! :|

Resources