package org.apache.commons.lang does not exist - Spring - spring

I'm working on a Spring Boot Project. Everything was okay on yesterday. But today I woke up and open my VScode to remote server to continue my project. I get an error
In my POM.xml, there's already a dependency,
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-lang3</artifactId>
<version>3.11</version>
</dependency>
I also try "mvn install -U". It throws me error,
package org.apache.commons.lang does not exist
I also searched on the internet, I've found some help from StackOverflow to use a command "mvn dependency:tree" to check there's a dependency exists or not. And here is it !
I'm stuck for an hour. Please help.

Finally fixed it ! It happened because I remove Eureka Client dependency.
After removing Eureka Client dependency, I need to change
import org.apache.commons.lang.StringUtils;
to
import org.apache.commons.lang3.StringUtils;

Related

How to resolve lombok error "log cannot be resolved"?

I have errors in the project (springboot) with all code "log." I have followed the advise from the link below (in my case using eclipse with spring tools):
enter link description here
I spent 2 hours delete the project and reopen, clean, build everything and nothing working. I also did mvn compile from command line and this seem to work fine, so it's clearly eclipse problem.
code from pom:
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<optional>true</optional>
</dependency>
Eclipse ini file:
I run the jar (java application) and specify the ini file. The jar is added
to the eclispe directory but it has no version on it.
Also lombok should appeared in the eclipse about screen and it's not.
Thanks.
In order to solve this problem I had to use STS4 and the same indtallation
for eclpise is work for STS.
lombok is added to the about screen, all good now.

import of amqp from org.springframework get error

I'm working on existing Scala project which using the spring framework and I need to import org.springframework.amqp but when I tried to build the project I get:
Error:(15, 28) object amqp is not a member of package
org.springframework import org.springframework.amqp
It is really strange since I can see it in the formal website and I can see it in lot of examples in the web.
Any idea what is the problem?
A Maven dependency was missing. This is what I was need to add:
<dependency>
<groupId>org.springframework.amqp</groupId>
<artifactId>spring-amqp</artifactId>
<version>2.1.2.RELEASE</version>
</dependency>

unable to resolve dependency for akamai edgegrid API

I am trying to use akamai edgegrid API for invalidating akamai chache. I have added below dependency in my pom.xml, but my bundle keeps in installed state. Below are more details-
pom.xml dependency-
<dependency>
<groupId>com.akamai.edgegrid</groupId>
<artifactId>edgegrid-signer-apache-http-client</artifactId>
<version>2.1.0</version>
<scope>provided</scope>
</dependency>
Bundle is in installed state, on felix console it says-
Imported Packages com.akamai.edgegrid.signer -- Cannot be resolved
error.log says -
Unable to resolve 497.82: missing requirement [497.82] osgi.wiring.package; (osgi.wiring.package=com.akamai.edgegrid.signer)
You have used <scope>provided</scope> , it means this jar will be used during compile time and during run time it will use the jar available on the run time environment. Unfortunately edgegrid-signer-apache-http-client-2.1.0.jar is not available on the AEM instance.
To resolve the issue, Do not use <scope>provided</scope> .
Updated POM -
<dependency>
<groupId>com.akamai.edgegrid</groupId>
<artifactId>edgegrid-signer-apache-http-client</artifactId>
<version>2.1.0</version>
</dependency>
Before deploying the bundle on AEM, extract the jar and check edgegrid-signer-apache-http-client.jar , edgegrid-signer-core.jar, httpclient.jar, httpcore.jar should be part of the bundle.
Hopefully it will solve your issue. All the best.
Please let me know if you still face any issue.
-Mrutyunjaya

java.lang.NoSuchMethodError: com.google.common.collect.Sets$SetView.iterator()Lcom/google/common/collect/UnmodifiableIterator;

I've been trying to connect kafka to elasticsearch using kafka-connect api.Kafka version is 0.11.0.0.These are the steps I followed:
1.Buiding Elasticsearch Connector:
https://github.com/confluentinc/kafka-connect-elasticsearch.git
2.Build the connector
$ cd kafka-connect-elasticsearch
$ mvn clean package
3.Finally running the script:
$ bin/connect-standalone.sh config/connect-standalone.properties config/elasticsearch-connect.properties
It throws the following exception:
Exception in thread "main" java.lang.NoSuchMethodError: com.google.common.collect.Sets$SetView.iterator()Lcom/google/common/collect/UnmodifiableIterator;
at org.reflections.Reflections.expandSuperTypes(Reflections.java:380)
at org.reflections.Reflections.<init>(Reflections.java:126)
at org.apache.kafka.connect.runtime.isolation.DelegatingClassLoader.scanPluginPath(DelegatingClassLoader.java:221)
at org.apache.kafka.connect.runtime.isolation.DelegatingClassLoader.scanUrlsAndAddPlugins(DelegatingClassLoader.java:198)
at org.apache.kafka.connect.runtime.isolation.DelegatingClassLoader.initLoaders(DelegatingClassLoader.java:159)
at org.apache.kafka.connect.runtime.isolation.Plugins.<init>(Plugins.java:47)
at org.apache.kafka.connect.cli.ConnectStandalone.main(ConnectStandalone.java:68)
Can't understand what's going wrong.
From experience, this error means that you are bringing an older version of guava earlier in your classpath. Connect worker requires guava >= 20 for org.reflections to work correctly.
kafka-connect-elasticsearch or any other connector that brings with it guava 18.0 or older will prohibit the worker from starting up. This error message means that the older guava jar was encountered first in the classpath.
Two solutions:
Indeed, as Hans Jespersen mentions, using classloading isolation by setting your plugin.path in Connect worker's configuration, will allow the connector to work as-is without interfering with the Connect framework.
If adding the connector to the CLASSPATH is your only option, make sure it's added after Kafka Connect's dependencies, so that the most recent guava will be picked up.
This appears to describe the answer for your problem https://github.com/confluentinc/kafka-connect-elasticsearch/issues/104
It's a little confusing, but after you build the connector there are a
number of things in the target directory. The
kafka-connect-elasticsearch-.jar is only the JAR file with
the connector code, but that doesn't include all the libraries. One of
those directories in the target directory, namely
target/kafka-connect-elasticsearch-*-development/share/java/kafka-connect-elasticsearch/,
does contain all the libraries. Add this directory to the Kafka
Connect worker's classpath, or copy all of those JAR files into a
directory that is already on the classpath.
For future readers, I have a similar issue w/ no usage for kafka. I spent a lot of hours to try to figure out the issue, and finally, I have a pattern.
In my project, I used ro.isdc.wro4j:wro4j-extensions:1.8.0, and org.reflections:reflections:0.9.11
<dependency>
<groupId>ro.isdc.wro4j</groupId>
<artifactId>wro4j-extensions</artifactId>
<version>1.8.0</version>
</dependency>
<dependency>
<groupId>org.reflections</groupId>
<artifactId>reflections</artifactId>
<version>0.9.11</version>
</dependency>
The conflict happened becuase ro.isdc.wro4j:wro4j-extensions:1.8.0 used com.google.javascript:closure-compiler:jar:v20160315, I solved it by exclude com.google.javascript:closure-compiler:jar:v20160315 from the pom.
<dependency>
<groupId>ro.isdc.wro4j</groupId>
<artifactId>wro4j-extensions</artifactId>
<version>1.8.0</version>
<exclusions>
<exclusion>
<groupId>com.google.javascript</groupId>
<artifactId>closure-compiler</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.reflections</groupId>
<artifactId>reflections</artifactId>
<version>0.9.11</version>
</dependency>
However, the problem is a build-dependent which we don't know which jar may cause the conflict. In this case, you need to know the location of the jar by running something like the following:
CodeSource source = com.google.common.collect.Sets.class.getProtectionDomain().getCodeSource();
if(source != null)
logger.warn(source.getLocation().toString());
and see what is the output. In my case, the output is
file:/tmp/jetty-0.0.0.0-8087-ROOT.war-_-any-1541284168668078443.dir/webapp/WEB-INF/lib/closure-compiler-v20160315.jar
Hopefully, the answer will help you to find a way to solve the issue,
Mughrabi
I ran into this error recently (Jan 2020) on my localhost (macOS Catalina) and was able to resolve this by updating my .zprofile file (zsh shell). If you have bash shell, you can make changes to .bash_profile or .bashrc file.
• Error was caused because my jvm.classpath was including dependencies of guava verison < 20. My .zprofile file had exports to hadoop-3.1.1 and apache-hive-3.1.1 which was the issue for error.
• I am using kafka_2.12-2.0.0. So, I just commented the hadoop-3.1.1 & apache-hive-3.1.1in my .zprofile and ran my twitter kafka connector successfully.
• I was able to trace this error by following the comments in this thread by #Konstantine Karantasis.
Hope this is helpful.

Setting javax.xml.ws.Service from JDK, instead of javaee-api with maven

I'm facing with this problem:
The method getPort(QName, Class<T>) in the type Service is not applicable for the arguments (QName, Class<AcessoDadosGeolocalizacao>, WebServiceFeature[])
I used wsimport to generate my clients, but now my maven application is using the class javax.xml.ws.Service from
<dependency>
<groupId>javaee</groupId>
<artifactId>javaee-api</artifactId>
<version>5</version>
<scope>provided</scope>
</dependency>
How can I use the javax.xml.ws.Service from the JDK 6?
I've added the webservices-api to my pom.xml and the problem is gone.
<dependency>
<groupId>javax.xml</groupId>
<artifactId>webservices-api</artifactId>
<version>2.1-b14</version>
</dependency>
If I am adding this entry(webservices-api) ;it is giving run time error while accessing JAXB-API.I found that the JDK6 should be the first in the order of classpath and then maven library.I moved up the JDK6 above the Maven library.Then it worked.
I ran into a similar issue with Eclipse and a Dynamic Web Application. Its not Maven related however googling for that error gets you all of about 7 results in Google as of today's date with about three or more of them being relisting at other websites of the same stack exchange question - so I thought in case others had a similar issue I'd add what helped me. The WAR was set to use JBoss AS5, the VM was set to use Java 6. Because its eclipse and I had already consumed the web service - the error was not occurring on import as the stubs had already been created. I ensured the Java facet was set to use 1.6 (it had been 1.5), I cleaned and built but the error persisted. I then noticed I had a reference on my build path to Java EE 1.5. I removed this, cleaned and built and the error went away.
Hope this helps anyone else faced with the same issue!

Resources