Consider the below scenario where i am getting an unexpected error and unable to fix it.
In Opendaylight architype project, I just used a class(Say test.class from io-example dependency) when I just declared only one dependency (i.e io-example) in the pom.xml, there is no error.
But if i add one more dependency (io-example-api) in the pom.xml, I am getting java.lang.NoClassDefFoundError: io/example/test.class
at org.opendaylight.gnmi.impl.base.OpenconfigInter
..................................................
..................................................
Caused by: java.lang.ClassNotFoundException: io.example.Test cannot be found by org.opendaylight
I found that io.example-api has the io-example as the dependency.. Summarize the issue, If i have the io-example alone in the pom.xml, there is no issue. If I have both io-example and io-example-api in the pom.xml, I am getting the NoclassDef error.
Even I have tried the exclusion option in the dependency section, Nothing works.
Thanks in advance...
Edited:
classname : io.grpc.Context
Dependencies :
<dependency>
<groupId>io.grpc</groupId>
<artifactId>grpc-context</artifactId>
<version>1.38.0</version>
</dependency>
<dependency>
<groupId>io.grpc</groupId>
<artifactId>grpc-api</artifactId>
<version>1.38.0</version>
</dependency>
In karaf container, I ran the "package:exports" commands and the results are,
opendaylight-user#root>package:exports -p io.grpc
io.grpc 0.0.0 354 wrap_file__home_verizon_gnmi_gnmi_karaf_target_assembly_system_io_grpc_grpc-api_1.38.0_grpc-api-1.38.0.jar
io.grpc 0.0.0 355 wrap_file__home_verizon_gnmi_gnmi_karaf_target_assembly_system_io_grpc_grpc-context_1.38.0_grpc-context-1.38.0.ja
opendaylight-user#root>package:exports -d
io.grpc 0.0.0 354 355
You can see that, io.grpc package exported by two bundles (354 and
355)..
A common cause for ClassNotFoundException in OSGi and Karaf is that multiple bundles export the same package with the same version. This causes only one of them be imported which may or may not contain your Test class.
Check which packages export io.example with package:exports command:
packages:exports -p io.example
I am guessing that adding the dependency causes your bundle to import the package io.example from io-example-api instead of io-example.
Solution for this would be to make sure only one bundle exports io.example package.
[Edit] I am unfamiliar with grpc but there seems to be issue on github about this and some workarounds that you could look in to.
You could also try creating a bundle that embeds these problematic dependencies and exports the packages for other bundles to use.
Create a new bundle project using archetype karaf-bundle-archetype
Add grpc-context and grpc-api dependencies
Configure maven-bundle-plugin to emped the grpc dependencies and export io.grpc package along with its sub packages.
<plugin>
<groupId>org.apache.felix</groupId>
<artifactId>maven-bundle-plugin</artifactId>
<version>${maven-bundle-plugin.version}</version>
<extensions>true</extensions>
<configuration>
<instructions>
<Bundle-SymbolicName>
${project.groupId}.${project.artifactId}
</Bundle-SymbolicName>
<Bundle-Version>${project.version}</Bundle-Version>
<Bundle-Activator>com.example.Activator</Bundle-Activator>
<Import-Package>
*;resolution:=optional
</Import-Package>
<Export-Package>
io.grpc*;-split-package:=merge-first
</Export-Package>
<Emped-Dependency>
grpc-context;scope=compile|runtime;inline=true,
grpc-api;scope=compile|runtime;inline=true
</Emped-Dependency>
</instructions>
</configuration>
</plugin>
Managed to install the bundle successfully to Karaf 4.2.11 and "use" the exported io.grpc.Context class in the bundle and in another bundle.
Simply called this from the Activator of two bundles
Context grpcContext = Context.current();
System.out.println(grpcContext.getClass().getName());
Using Drupal, we've tried to import the configuration files from the solr_api_search module. When importing them and trying to initialize the core, I see the following error (Solr 7.7.2):
Could not load conf for core testcore: Can't load schema /data/solr_data/data/testcore/conf/schema.xml: Plugin init failure for [schema.xml] fieldType \"collated_ar\": Error loading class 'solr.ICUCollationField'
This is what the inside of the solrcore.properties file looks like. I added the solr.install.dir option after some people with similar issues reported that it fixed their problem:
solr.replication.master=false
solr.replication.slave=false
solr.replication.pollInterval=00:00:60
solr.replication.masterUrl=http://localhost:8983/solr
solr.replication.confFiles=schema.xml,schema_extra_types.xml,schema_extra_fields.xml,elevate.xml,stopwords_ar.txt,synonyms_ar.txt,nouns_ar.txt,protwords_ar.txt,accents_ar.txt,stopwords_en.txt,synonyms_en.txt,protwords_en.txt,accents_en.txt,stopwords_fr.txt,synonyms_fr.txt,nouns_fr.txt,protwords_fr.txt,accents_fr.txt,stopwords_de.txt,synonyms_de.txt,nouns_de.txt,protwords_de.txt,accents_de.txt,stopwords_el.txt,synonyms_el.txt,nouns_el.txt,protwords_el.txt,accents_el.txt,stopwords_hi.txt,synonyms_hi.txt,nouns_hi.txt,protwords_hi.txt,accents_hi.txt,stopwords_it.txt,synonyms_it.txt,nouns_it.txt,protwords_it.txt,accents_it.txt,stopwords_und.txt,synonyms_und.txt,protwords_und.txt,accents_und.txt,stopwords_pl.txt,synonyms_pl.txt,nouns_pl.txt,protwords_pl.txt,accents_pl.txt,stopwords_pt-br.txt,synonyms_pt-br.txt,nouns_pt-br.txt,protwords_pt-br.txt,accents_pt-br.txt,stopwords_ru.txt,synonyms_ru.txt,nouns_ru.txt,protwords_ru.txt,accents_ru.txt,stopwords_es.txt,synonyms_es.txt,nouns_es.txt,protwords_es.txt,accents_es.txt,stopwords_tr.txt,synonyms_tr.txt,nouns_tr.txt,protwords_tr.txt,accents_tr.txt
solr.luceneMatchVersion=7.7
solr.install.dir=/opt/solr
This is the process running with ps -ef:
java -server -Xms512m -Xmx512m -XX:NewRatio=3 -XX:SurvivorRatio=4 -XX:TargetSurvivorRatio=90 -XX:MaxTenuringThreshold=8 -XX:+UseConcMarkSweepGC -XX:+UseParNewGC -XX:ConcGCThreads=4 -XX:ParallelGCThreads=4 -XX:+CMSScavengeBeforeRemark -XX:PretenureSizeThreshold=64m -XX:+UseCMSInitiatingOccupancyOnly -XX:CMSInitiatingOccupancyFraction=50 -XX:CMSMaxAbortablePrecleanTime=6000 -XX:+CMSParallelRemarkEnabled -XX:+ParallelRefProcEnabled -verbose:gc -XX:+PrintHeapAtGC -XX:+PrintGCDetails -XX:+PrintGCDateStamps -XX:+PrintGCTimeStamps -XX:+PrintTenuringDistribution -XX:+PrintGCApplicationStoppedTime -Xloggc:/data/solr_data/logs/solr_gc.log -XX:+UseGCLogFileRotation -XX:NumberOfGCLogFiles=9 -XX:GCLogFileSize=20M -Dsolr.log.dir=/data/solr_data/logs -Djetty.port=8983 -DSTOP.PORT=7983 -DSTOP.KEY=solrrocks -Duser.timezone=UTC -Djetty.home=/opt/solr/server -Dsolr.solr.home=/data/solr_data/data -Dsolr.data.home= -Dsolr.install.dir=/opt/solr -Dsolr.default.confdir=/opt/solr/server/solr/configsets/_default/conf -Dlog4j.configurationFile=file:/data/solr_data/log4j.properties -Xss256k -Xss256k -Dsolr.jetty.https.port=8983 -Dsolr.log.muteconsole -XX:OnOutOfMemoryError=/opt/solr/bin/oom_solr.sh 8983 /data/solr_data/logs -jar start.jar --module=http
I have the following libraries inside of /opt/solr/contrib/analysis-extras/lib
-rw-r--r--. 1 solr solr 12370975 Jun 20 2018 icu4j-62.1.jar
-rw-r--r--. 1 solr solr 20140 Feb 18 2018 morfologik-fsa-2.1.5.jar
-rw-r--r--. 1 solr solr 1886867 Feb 18 2018 morfologik-polish-2.1.5.jar
-rw-r--r--. 1 solr solr 53644 Feb 18 2018 morfologik-stemming-2.1.5.jar
-rw-r--r--. 1 solr solr 1245779 Jun 29 2018 opennlp-tools-1.9.0.jar
Is there some option that I am missing in order to get Solr to load the .jar files?
SOlr requires different features that require an optional libraries. All of these are comes with Solr. You need to adjust solr.install.dir like already mentioned in file named INSTALL.md
Updating path to solr.install.dir=/opt/solr in solrcore.properties to fix the issue.
Check the jar named as "icu4j-62.1.jar". Check the path of the same is mentioned in solrConfig.xml and check it the lib is getting loaded.
I got this error even i have created a shared lib on was 9, this lib contains all the hibernate 5.4.3 dependency including javax.persistence 2.2
Do you really needs JPA 2.2 ?
I was able to deploy my EAR under WAS 9 using hibernate 5.2.17 (starting from 5.3 hibernate is JPA 2.2 compliant)
WAS 9 it seems compatible only with JPA 2.0 and JPA 2.1
I created the shared lib using following lists of jars
E:\hibernate-release-5.2.17.Final\lib\envers\hibernate-envers-5.2.17.Final.jar
E:\hibernate-release-5.2.17.Final\lib\jpa-metamodel-generator\hibernate-jpamodelgen-5.2.17.Final.jar
E:\hibernate-release-5.2.17.Final\lib\optional\c3p0\c3p0-0.9.5.2.jar
E:\hibernate-release-5.2.17.Final\lib\optional\c3p0\hibernate-c3p0-5.2.17.Final.jar
E:\hibernate-release-5.2.17.Final\lib\optional\c3p0\mchange-commons-java-0.2.11.jar
E:\hibernate-release-5.2.17.Final\lib\optional\ehcache\ehcache-2.10.3.jar
E:\hibernate-release-5.2.17.Final\lib\optional\ehcache\hibernate-ehcache-5.2.17.Final.jar
E:\hibernate-release-5.2.17.Final\lib\optional\ehcache\slf4j-api-1.7.7.jar
E:\hibernate-release-5.2.17.Final\lib\optional\infinispan\hibernate-infinispan-5.2.17.Final.jar
E:\hibernate-release-5.2.17.Final\lib\optional\infinispan\infinispan-commons-8.2.5.Final.jar
E:\hibernate-release-5.2.17.Final\lib\optional\infinispan\infinispan-core-8.2.5.Final.jar
E:\hibernate-release-5.2.17.Final\lib\optional\infinispan\jboss-marshalling-osgi-1.4.10.Final.jar
E:\hibernate-release-5.2.17.Final\lib\optional\infinispan\jgroups-3.6.7.Final.jar
E:\hibernate-release-5.2.17.Final\lib\optional\proxool\hibernate-proxool-5.2.17.Final.jar
E:\hibernate-release-5.2.17.Final\lib\optional\proxool\proxool-0.8.3.jar
E:\hibernate-release-5.2.17.Final\lib\osgi\byte-buddy-1.6.14.jar
E:\hibernate-release-5.2.17.Final\lib\osgi\hibernate-osgi-5.2.17.Final.jar
E:\hibernate-release-5.2.17.Final\lib\osgi\javax.interceptor-api-1.2.jar
E:\hibernate-release-5.2.17.Final\lib\osgi\org.osgi.compendium-4.3.1.jar
E:\hibernate-release-5.2.17.Final\lib\osgi\org.osgi.core-4.3.1.jar
E:\hibernate-release-5.2.17.Final\lib\required\antlr-2.7.7.jar
E:\hibernate-release-5.2.17.Final\lib\required\classmate-1.3.0.jar
E:\hibernate-release-5.2.17.Final\lib\required\dom4j-1.6.1.jar
E:\hibernate-release-5.2.17.Final\lib\required\hibernate-commons-annotations-5.0.1.Final.jar
E:\hibernate-release-5.2.17.Final\lib\required\hibernate-core-5.2.17.Final.jar
E:\hibernate-release-5.2.17.Final\lib\required\jandex-2.0.3.Final.jar
E:\hibernate-release-5.2.17.Final\lib\required\javassist-3.22.0-GA.jar
E:\hibernate-release-5.2.17.Final\lib\required\jboss-logging-3.3.1.Final.jar
It is important on the Shared Lib def to check "Class Loading - Use an isolated class loader for this shared library"
and on the Applicatiion --> Class Loader --> Class Loader Order --> select Classes Loaded with Local Class Loader First (Parent Last)
I'm looking too to use up-to-date Hibernate 5.4.x (stable) and in the future the 6.x.. but having similar issue
If eventually you was able to use Hibernate 5.4.x.. can you share ?
Regards
I changed my struts2 version from 2.3.14 to 2.3.16.1, it seems that newest version does not support ServletRequestAware and ServletResponseAware anymore, what should I do? I could not find anything online.
<dependency>
<groupId>org.apache.struts</groupId>
<artifactId>struts2-core</artifactId>
<version>2.3.16.1</version>
<type>jar</type>
</dependency>
Code
import org.apache.struts2.interceptor.ServletRequestAware;
public class MyExample implements ServletRequestAware, ServletResponseAware {
Error
package org.apache.struts2.interceptor does not exist.
When I try to find a dependency for it Maven shows the latest version of Struts2 which is supporting it is 2.3.14!
You probably have some problem with the libraries included in your project;
Be sure to erase all the old JARs from the classpath (your WAR / EAR and shared libs on the AS;
run Clean Project in your IDE;
download Struts2.3.16.1 from Maven or manually from here;
check out the ServletRequestAware and ServletResponseAware Interfaces at
/struts-2.3.16.1/src/core/src/main/java/org/apache/struts2/interceptor/
, exactly where they were before ;)
E.g., output from 2.3.16.3 distribution:
$ jar tvf struts2-core-2.3.16.3.jar | grep ServletRequest
223 Fri May 02 17:23:44 EDT 2014 org/apache/struts2/interceptor/ServletRequestAware.class
It's also in the 2.3.16.1 jars.
At the Step 3 of Welcome to Struts2 add the following dependency to your pom.xml
<dependency>
<groupId>org.apache.struts</groupId>
<artifactId>struts2-core</artifactId>
<version>X.X.X.X</version>
</dependency>
Check the file version X.X.X.X is available in the repository and downloaded to your hard drive.
We have an SBT 0.13.0 multi-project build with 17 projects: 1 leaf project, 15 modules that depend on the leaf (but not each other), and 1 aggregator that depends on the 15 modules.
Here's a very rough idea of what the Build.scala file looks like:
val deps: Seq[Setting[_]] = Seq(libraryDependencies ++= Seq(
"com.foo" % "foo" % "1.0.0",
"com.bar" % "bar" % "1.0.0"
))
val leaf = Project("leaf").settings(deps:_*)
val module1 = Project("module1").dependsOn(leaf).settings(deps:_*)
val module2 = Project("module2").dependsOn(leaf).settings(deps:_*)
...
val module15 = Project("module15").dependsOn(leaf).settings(deps:_*)
val aggregator = Project("aggregator)".dependsOn(
module1,
module2,
...
module15
).settings(deps:_*)
All of these projects list exactly the same set of external dependencies as libraryDependencies. For some reason, when we run the update command in the aggregator, it takes on the order of a minute per project (~15 minutes total!), even though there is no single new dependency to resolve or download.
Worse yet, we recently added one more dependency and now the update command causes SBT to swell up to ~5GB of memory and sometimes hang completely during resolution. How do we debug this?
We tried YourKit to profile it and, it may be a read herring, but so far, the only thing we see is some sbt.MultiLogger class spending a ton of time in a BufferedOutputStream.flush call.
If some of your external dependiencies are actually your own libraries pushed to a local repository and their version is set to "latest" then this hanging is expected. The reason is that ivy tries all repositories for all dependencies when "latest" version is required. Since your libraries are not pushed to public repositories then checking for them on public repositories ends in timeout (it is an ivy issue apparently).
I tried to replicate your setup and created an sbt project with leaf, 15 modules, aggregator and a few external dependencies. It all resolves quite quickly. You can check it out at
https://github.com/darkocerdic/sbt-multiproject-resolving