java, apache-camel,cassandra, jboss fuse - java

From my existing application, i am trying to connect to caasandra but facing some maven issues. Here is what i did:
Added in Maven:
<dependency>
<groupId>org.apache.camel</groupId>
<artifactId>camel-cassandraql</artifactId>
<version>2.15.1.redhat-620133</version>
<!-- use the same version as your Camel core version -->
</dependency>
In camel:
<route="test">
<to uri="cql://127.0.0.1/empdetails?cql=select * from employee;&consistencyLevel=quorum"/>
</route>
But i am experiencing :
Exception in thread "SpringOsgiExtenderThread-9"
org.apache.camel.RuntimeCamelException: org.apache.camel.FailedToCreate
1/empdetails?cql=select * from employee;&consistencyLevel=quorum] <<< in route:
Route(test)[[From[direct:route
mpdetails?consistencyLevel=quorum&cql=select+*+from+employee%3B due to:
No component found with scheme: cql "
I am i on the right track, please suggest me.

Related

In AWS EC2 , java.lang.NoClassDefFoundError: org/apache/http/config/Lookup is thrown

I use Apache HTTP to outsource certain parts of my program to AWS Lamda.
When I run this locally on a Windows system, everything works.
But when the program is deployed (EC2 Instance - ubuntu environment) and a request is started via apache http. I get the following error message:
java.lang.NoClassDefFoundError: org/apache/http/config/Lookup
I use the following maven dependencies:
<dependency>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpcore</artifactId>
<version>4.4.15</version>
</dependency>
<dependency>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpclient</artifactId>
<version>4.5.13</version>
</dependency>
At the following point in the code the error is thrown:
this.client = HttpClients.createDefault();
I have also tried other versions of Apache HTTP.
If you need more info let me know.
Can anyone tell me what I need to consider or what I may be doing wrong?

Failed to resolve endpoint: json-validator in Apache camel

I am getting the below error, while running the following statement in Apache Camel
<to id="jsoncheck" uri="json-validator:classpath:jsonschema.json" />
Caused by: org.apache.camel.FailedToCreateRouteException: Failed to create route route3 at: >>> DoTry[[To[json-validator:classpath:jsonschema.json], DoCatch[ null -> []]]] <<< in route: Route(route3)[[From[file:///D:/jsonfiles/file?noop=true]] ->... because of Failed to resolve endpoint: json-validator://classpath:jsonschema.json due to: No component found with scheme: json-validator
at org.apache.camel.model.RouteDefinition.addRoutes(RouteDefinition.java:912)
at org.apache.camel.model.RouteDefinition.addRoutes(RouteDefinition.java:177)
at org.apache.camel.impl.DefaultCamelContext.startRoute(DefaultCamelContext.java:778)
at org.apache.camel.impl.DefaultCamelContext.startRouteDefinitions(DefaultCamelContext.java:1955)
at org.apache.camel.impl.DefaultCamelContext.doStartCamel(DefaultCamelContext.java:1705)
at org.apache.camel.impl.DefaultCamelContext.doStart(DefaultCamelContext.java:1579)
at org.apache.camel.support.ServiceSupport.start(ServiceSupport.java:61)
at org.apache.camel.impl.DefaultCamelContext.start(DefaultCamelContext.java:1547)
at org.apache.camel.spring.SpringCamelContext.maybeStart(SpringCamelContext.java:221)
at org.apache.camel.spring.SpringCamelContext.onApplicationEvent(SpringCamelContext.java:118)
... 10 more
Dependency added
<dependency>
<groupId>org.apache.camel</groupId>
<artifactId>camel-json-validator</artifactId>
</dependency>
Seems you miss a version.
I've tried the following and all works fine.
<dependency>
<groupId>org.apache.camel</groupId>
<artifactId>camel-json-validator</artifactId>
<version>3.13.0</version>
</dependency>

MicroProfile Metrics do not show custom metrics on Wildfly 25

I am experimenting with Javax/JaxRs and I am using the WildFly 25 server, which I am not quite familiar with.
Searching for something similar to Spring's Actuator, I stumbled across the metrics & health endpoints the server exposes by default, and its ability to add custom counters, gauges etc. to application endpoints.
However, whatever I do, these custom endpoints are not exposed under the default http://localhost:9990/metrics URL.
I am following the guide provided by WildFly under the GitHub repository:
https://github.com/wildfly/quickstart/tree/main/microprofile-metrics
There are some "red flags" on the tutorial that do not seem to be working with whatever I try to do.
The guide suggests that if we want to get the metrics in JSON format, we need to use the following header: "Accepted: application/json", which still returns the default Prometheus format, both in Postman and Curl.
The guide also suggests that metrics/vendor, metrics/application, metrics/base return metrics of different scopes, which to my test, they all return the same.
As far as the tutorial code is concerned, I tried running it on the Jakarta EE 8 Full & Web Distribution but it throws the following error:
Artifact microprofile-metrics:war exploded: java.lang.Exception: {"WFLYCTL0080: Failed services" => {"jboss.deployment.unit.\"microprofile-metrics.war\".undertow-deployment" => "java.lang.NoClassDefFoundError: org/eclipse/microprofile/metrics/Counter Caused by: java.lang.NoClassDefFoundError: org/eclipse/microprofile/metrics/Counter
I tried compiling the code with different versions of Java (1.8, 11, 17) hoping that it may fix the problem but to no avail.
However, using the WildFly Preview EE 9.1 Distribution seems to stop throwing the error, but the custom metrics still do not to work.
There are the subsystems that I added to both distributions during my tries (taken from standalone.xml):
<extension module="org.wildfly.extension.health"/>
<extension module="org.wildfly.extension.metrics"/>
<extension module="org.wildfly.extension.microprofile.config-smallrye"/>
<extension module="org.wildfly.extension.microprofile.fault-tolerance-smallrye"/>
<extension module="org.wildfly.extension.microprofile.health-smallrye"/>
<extension module="org.wildfly.extension.microprofile.jwt-smallrye"/>
<extension module="org.wildfly.extension.microprofile.metrics-smallrye"/>
<extension module="org.wildfly.extension.microprofile.openapi-smallrye"/>
<extension module="org.wildfly.extension.microprofile.opentracing-smallrye"/>
<extension module="org.wildfly.extension.undertow"/>
(others omitted for brevity)
I also tried enabling the statistics by creating the following bat and launching it:
call standalone.bat -Dwildfly.statistics-enabled=true
I am using IntelliJ, so I tried doing the same from within the IDE:
(the "enable statistics" option was added both to VM options & on the bat during launch to make sure it works)
Here are the dependencies that I am using, based on my server's version:
<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.wildfly.bom</groupId>
<artifactId>wildfly-microprofile</artifactId>
<version>25.0.0.Final</version>
<type>pom</type>
<scope>import</scope>
</dependency>
<dependency>
<groupId>org.wildfly.bom</groupId>
<artifactId>wildfly-jakartaee8-with-tools</artifactId>
<version>25.0.0.Final</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>
<dependencies>
<!-- Import the MicroProfile Metrics API, we use provided scope as the API is included in the server -->
<dependency>
<groupId>org.eclipse.microprofile.metrics</groupId>
<artifactId>microprofile-metrics-api</artifactId>
<scope>provided</scope>
</dependency>
<!-- Import the CDI API, we use provided scope as the API is included in the server -->
<dependency>
<groupId>jakarta.enterprise</groupId>
<artifactId>jakarta.enterprise.cdi-api</artifactId>
<scope>provided</scope>
</dependency>
<!-- Import the Jakarta REST API, we use provided scope as the API is included in the server -->
<dependency>
<groupId>org.jboss.spec.javax.ws.rs</groupId>
<artifactId>jboss-jaxrs-api_2.1_spec</artifactId>
<scope>provided</scope>
</dependency>
</dependencies>
John. I'm the Metrics/MP Metrics component lead for WildFly, so hopefully I can help get you sorted out.
Before I get too excited about digging through the WF source, can you confirm which configuration you're using? It looks like you're using standalone.xml configuration. While that does have a metrics extension, it's not MP Metrics. For that, you would need to use standalone-microprofile.xml.
Hopefully, your issue is as simple as that. If not, let me know, and we'll dig deeper. :)

I'm using JakartaEE and making a "hello world" kind of restfulAPI, can't get a return string by visiting URL

Providing every step I took with this short video:
https://youtu.be/hbSr8sRYuOk
Project code here: https://github.com/LJonn/restapiHelloWorld
Running everything on a local server on tomcat.
I'm having this issue for quite some time and ran out of ideas where the problem might be...
I tried URL's such as these: "http://localhost:8080/api/hello" and "http://localhost:8080/helloworld/api/hello" and expected one of these to work.
Running http://localhost:8080/manager/text/list shows that helloworld.war is deployed fine and working:
OK - Listed applications for virtual host [localhost]
/:running:0:ROOT
/helloworld:running:0:helloworld
/examples:running:0:examples
/host-manager:running:0:host-manager
/manager:running:0:manager
/docs:running:0:docs
So why I still get a HTTP Status 404 page? What could I try to do to find the issue?
These are my project's Maven dependencies:
<dependencies>
<dependency>
<groupId>jakarta.platform</groupId>
<artifactId>jakarta.jakartaee-web-api</artifactId>
<version>9.1.0</version>
<scope>provided</scope>
</dependency>
</dependencies>
Thanks to Nikos Paraskevopoulos comment it looks like changing from Tomcat to TomEE might fix the issue, but now I'm running into a problem where the .war file can't be deployed/started, probably some sort of versions compatibility issue, tomcat manager GUI gives this error when trying to start the .war file:
FAIL - Application at context path [/helloworld] could not be started
FAIL - Encountered exception [org.apache.catalina.LifecycleException: Failed to start component [StandardEngine[Catalina].StandardHost[localhost].StandardContext[/helloworld]]]
Looking to manager logs It looks like it has something to do with annotations and Java 16 maybe?:
...
Caused by: java.lang.IllegalArgumentException: Unsupported class file major version 60
at org.apache.xbean.asm7.ClassReader.<init>(ClassReader.java:195)
at org.apache.xbean.asm7.ClassReader.<init>(ClassReader.java:176)
at org.apache.xbean.asm7.ClassReader.<init>(ClassReader.java:162)
at org.apache.xbean.asm7.ClassReader.<init>(ClassReader.java:283)
at org.apache.xbean.finder.AnnotationFinder.readClassDef(AnnotationFinder.java:1176)
... 52 more
01-Sep-2021 15:25:02.185 INFO [http-nio-8080-exec-3] org.apache.catalina.core.ApplicationContext.log HTMLManager: list: Listing contexts for virtual host 'localhost'
I've tried to check JRE version on Eclipse and it's 16.0.2 and it looks to me that the same version is running on tomcat.
Tomcat 10.0 and 10.1 are not full Jakarta EE 9.1 application servers: you shouldn't use the jakarta.jakartaee-web-api artifact, which would imply that the runtime supports all Jakarta EE 9.1 Web Profile technologies.
Tomcat does not implement all the specs required in Web Profile. At least four other products do. See this list for Jakarta Web Profile 9.1:
Apache TomEE
Eclipse Glassfish
IBM Open Liberty
Red Hat WildFly
You can find the list of supported technologies on Tomcat's web site and for Tomcat 10 they translate to this list shown as a Maven POM snippet.
<dependency>
<groupId>jakarta.servlet</groupId>
<artifactId>jakarta.servlet-api</artifactId>
<version>5.0.0</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>jakarta.servlet.jsp</groupId>
<artifactId>jakarta.servlet.jsp-api</artifactId>
<version>3.0.0</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>jakarta.el</groupId>
<artifactId>jakarta.el-api</artifactId>
<version>4.0.0</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>jakarta.websocket</groupId>
<artifactId>jakarta.websocket-api</artifactId>
<version>2.0.0</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>jakarta.security.auth.message</groupId>
<artifactId>jakarta.security.auth.message-api</artifactId>
<version>2.0.0-RC1</version>
<scope>provided</scope>
</dependency>
Since Servlet 3.0, additional Jakarta EE specifications can be added using the servlet pluggability mechanism. To use JAX-RS you need to add:
<dependency>
<groupId>org.glassfish.jersey.containers</groupId>
<artifactId>jersey-container-servlet</artifactId>
<version>3.0.2</version>
</dependency>
<dependency>
<groupId>org.glassfish.jersey.inject</groupId>
<artifactId>jersey-hk2</artifactId>
<version>3.0.2</version>
</dependency>
or an equivalent configuration using other JAX-RS implementations.

Connect SMB endpoint with Camel v3 and the camel-jcifs from camel-extra

I have the following maven versions in my pom.xml (among others):
<dependency>
<groupId>org.apache.camel.springboot</groupId>
<artifactId>camel-spring-boot-starter</artifactId>
<version>3.7.0</version>
</dependency>
<dependency>
<groupId>org.apache.camel</groupId>
<artifactId>camel-core</artifactId>
<version>3.7.0</version>
</dependency>
<dependency>
<groupId>org.apache-extras.camel-extra</groupId>
<artifactId>camel-jcifs</artifactId>
<version>2.25.2</version>
<exclusions>
<exclusion>
<groupId>com.sun.xml.bind</groupId>
<artifactId>jaxb-impl</artifactId>
</exclusion>
</exclusions>
</dependency>
Camel spring-boot version = 3.7.0 and I want to connect to a SMB endpoint like this:
smb://sharedriveuser#server-instance.sub.domain.net/folder?initialDelay=0&delay=9000&autoCreate=false&noop=true&idempotent=true&password=ThePassWorD&filter=#csvFileFilter
I read the Camel 3 Migration Guide and found nothing regarding this camel-extras.
When trying to connect, I get an error like the password option is not supported anymore:
Caused by: org.apache.camel.ResolveEndpointFailedException: Failed to resolve endpoint: smb://sharedriveuser#server-instance.sub.domain.net/folder?initialDelay=0&delay=9000&autoCreate=false&noop=true&idempotent=true&password=xxxxxx&filter=#csvFileFilter due to: There are 1 parameters that couldn't be set on the endpoint. Check the uri if the parameters are spelt correctly and that they are properties of the endpoint. Unknown parameters=[{password=ThePassWorD}]
The actual documentation link google found many times, seems dead.
From Maven central, there is no version 3.x of the lib camel-jcifs and I am wondering if the lib is still compatible with Camel 3.x.x, otherwise is there another alternative with Camel 3?
I also tried to downgrade the camel-jcifs to 2.24.3 with the same error.
Camel-extras is a separated project from the Apache Camel. There is some work in place in the camel-extra repository to support camel 3[1], but it is still to be completed and there is no release in sight.
[1] https://github.com/camel-extra/camel-extra/commit/f028dfdfaa467958c58abea0d604f8fe2f17be04
There is now a pull request to add camel-jcifs to the 3.x version:
https://github.com/camel-extra/camel-extra/pull/39
You might also get my fork and build it yourself:
https://github.com/bebbo/camel-extra *
It got merged and is in the official repository:
https://github.com/camel-extra/camel-extra
To use it with quarkus, you have to convert some List types to arrays.

Categories

Resources