java.lang.ang.NoClassDefFoundError: org/hibernate/util/DTDEntityResolver - java

I am getting this error while deploying my maven build struts2-spring-hibernate web application.Does anyone know which maven dependencies are required to resolve the issue below??
11:52:00.479 [main] ERROR o.s.web.context.ContextLoader - Context initialization
failed
org.springframework.beans.factory.BeanCreationException: Error creating bean wit
h name 'sampleSessionFactory' defined in ServletContext resource [/WEB-INF/appli
cationContext.xml]: Invocation of init method failed; nested exception is java.l
ang.NoClassDefFoundError: org/hibernate/util/DTDEntityResolver
at org.springframework.beans.factory.support.AbstractAutowireCapableBean
Factory.initializeBean(AbstractAutowireCapableBeanFactory.java:1455) ~[spring-be
ans-3.1.1.RELEASE.jar:3.1.1.RELEASE]
at org.springframework.beans.factory.support.AbstractAutowireCapableBean
Factory.doCreateBean(AbstractAutowireCapableBeanFactory.java:519) ~[spring-beans
-3.1.1.RELEASE.jar:3.1.1.RELEASE]
at org.springframework.beans.factory.support.AbstractAutowireCapableBean
Factory.createBean(AbstractAutowireCapableBeanFactory.java:456) ~[spring-beans-3
.1.1.RELEASE.jar:3.1.1.RELEASE]
at org.springframework.beans.factory.support.AbstractBeanFactory$1.getOb
ject(AbstractBeanFactory.java:294) ~[spring-beans-3.1.1.RELEASE.jar:3.1.1.RELEAS
E]
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistr
y.getSingleton(DefaultSingletonBeanRegistry.java:225) ~[spring-beans-3.1.1.RELEA
SE.jar:3.1.1.RELEASE]
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBe
an(AbstractBeanFactory.java:291) ~[spring-beans-3.1.1.RELEASE.jar:3.1.1.RELEASE]
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean
(AbstractBeanFactory.java:193) ~[spring-beans-3.1.1.RELEASE.jar:3.1.1.RELEASE]
at org.springframework.beans.factory.support.DefaultListableBeanFactory.
preInstantiateSingletons(DefaultListableBeanFactory.java:567) ~[spring-beans-3.1
.1.RELEASE.jar:3.1.1.RELEASE]
I'm using currently the dependencies mentioned below but still getting the error.
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-core</artifactId>
<version>4.0.1.Final</version>
</dependency>
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-entitymanager</artifactId>
<version>4.0.1.Final</version>
</dependency>
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-tools</artifactId>
<version>4.0.0-CR1</version>
</dependency>
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>jtidy</artifactId>
<version>r8-20060801</version>
</dependency>
<dependency>
<groupId>org.beanshell</groupId>
<artifactId>bsh</artifactId>
<version>2.0b5</version>
</dependency>
<dependency>
<groupId>freemarker</groupId>
<artifactId>freemarker</artifactId>
<version>2.3.9</version>
</dependency>

Try rolling back to hibernate 3, it appears the class you are looking for is not included in the Hibernate 4 library. Something has a dependency on Hibernate 3.
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate</artifactId>
<version>3.2.7.ga</version>
</dependency>
After doing some further research, I learned that it is JTidy that has the dependency on Hibernate 3.

i had compile 'org.hibernate:hibernate-core:4.1.9'
i replaced it with compile 'org.hibernate:hibernate-core:3.3.2.GA'
in my build.gradle
this is gradle syntax, converting to maven isnt difficult , this solved the problem

The artifact hibernate-tools version 4.0.0-CR1, which you've added as dependency, uses hibernate-commons-annotations 3.2.0-Final, which uses DTDEntityResolver. You must change the version of hibernate-tools for 4.3.1.CR1 (notice the dot, not dash, before C), which uses hibernate-commons-annotations 4.0.4.Final, then you'll not have this error anymore.

Related

java.lang.NoClassDefFoundError: javax/el/ELManager

I'm working on a webapp in Spring using Spring Tool Suite. If I build and deploy the application there using the IDE onto the provided Pivotal tc Server, it works just fine. However, if I do a manual "mvn clean package" build and attempt to deploy it to a standalone Tomcat server (using newest Tomcat 7), it throws the following exception:
2017-08-23 15:24:13 WARN AnnotationConfigWebApplicationContext:551 - Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'requestMappingHandlerAdapter' defined in org.springframework.web.servlet.config.annotation.DelegatingWebMvcConfiguration: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter]: Factory method 'requestMappingHandlerAdapter' threw exception; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'mvcValidator' defined in org.springframework.web.servlet.config.annotation.DelegatingWebMvcConfiguration: Invocation of init method failed; nested exception is java.lang.NoClassDefFoundError: javax/el/ELManager
2017-08-23 15:24:13 ERROR DispatcherServlet:502 - Context initialization failed
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'requestMappingHandlerAdapter' defined in org.springframework.web.servlet.config.annotation.DelegatingWebMvcConfiguration: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter]: Factory method 'requestMappingHandlerAdapter' threw exception; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'mvcValidator' defined in org.springframework.web.servlet.config.annotation.DelegatingWebMvcConfiguration: Invocation of init method failed; nested exception is java.lang.NoClassDefFoundError: javax/el/ELManager
Upon further inspection, it does complain few lines higher above about not loading jars:
sie 23, 2017 3:24:12 PM org.apache.catalina.startup.HostConfig deployWAR
INFO: Deploying web application archive D:\Apache-Tomcat-7.0\webapps\TestApp-0.0.1-SNAPSHOT.war
sie 23, 2017 3:24:12 PM org.apache.catalina.loader.WebappClassLoader validateJarFile
INFO: validateJarFile(D:\Apache-Tomcat-7.0\webapps\TestApp-0.0.1-SNAPSHOT\WEB-INF\lib\el-api-2.2.jar) - jar not loaded. See Servlet Spec 2.3, section 9.7.2. Offending class: javax/el/Expression.class
sie 23, 2017 3:24:12 PM org.apache.catalina.loader.WebappClassLoader validateJarFile
INFO: validateJarFile(D:\Apache-Tomcat-7.0\webapps\TestApp-0.0.1-SNAPSHOT\WEB-INF\lib\javax.servlet-api-3.1.0.jar) - jar not loaded. See Servlet Spec 2.3, section 9.7.2. Offending class: javax/servlet/Servlet.class
sie 23, 2017 3:24:12 PM org.apache.catalina.loader.WebappClassLoader validateJarFile
INFO: validateJarFile(D:\Apache-Tomcat-7.0\webapps\TestApp-0.0.1-SNAPSHOT\WEB-INF\lib\tomcat-el-api-8.0.21.jar) - jar not loaded. See Servlet Spec 2.3, section 9.7.2. Offending class: javax/el/Expression.class
2017-08-23 15:24:13 INFO ContextLoader:304 - Root WebApplicationContext: initialization started
My pom.xml:
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.exmaple.mvc</groupId>
<artifactId>TestApp</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>war</packaging>
<dependencies>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-core</artifactId>
<version>4.3.10.RELEASE</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-webmvc</artifactId>
<version>4.3.10.RELEASE</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-web</artifactId>
<version>4.3.10.RELEASE</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-test</artifactId>
<version>4.3.10.RELEASE</version>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-log4j12</artifactId>
<version>1.6.6</version>
</dependency>
<dependency>
<groupId>log4j</groupId>
<artifactId>log4j</artifactId>
<version>1.2.17</version>
<exclusions>
<exclusion>
<artifactId>jms</artifactId>
<groupId>javax.jms</groupId>
</exclusion>
<exclusion>
<artifactId>jmxri</artifactId>
<groupId>com.sun.jmx</groupId>
</exclusion>
<exclusion>
<artifactId>jmxtools</artifactId>
<groupId>com.sun.jdmk</groupId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>jstl</groupId>
<artifactId>jstl</artifactId>
<version>1.2</version>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.12</version>
<scope>test</scope>
</dependency>
<!-- https://mvnrepository.com/artifact/org.mockito/mockito-all -->
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-all</artifactId>
<version>1.9.5</version>
<scope>test</scope>
</dependency>
<!-- https://mvnrepository.com/artifact/commons-lang/commons-lang -->
<dependency>
<groupId>commons-lang</groupId>
<artifactId>commons-lang</artifactId>
<version>2.3</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.hibernate/hibernate-validator -->
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-validator</artifactId>
<version>6.0.1.Final</version>
</dependency>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>javax.servlet-api</artifactId>
<version>3.1.0</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.1</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
</plugins>
</build>
</project>
What's the reason for this behavior and how can I solve this?
EDIT More information:
Adding <scope>provided</scope> to javax.servlet-api seems to fix the warning about javax.servlet-api not being loaded at the start. Problem with el-api still remains.
I've checked the tomcat/lib directory and it already contains el-api.jar in it, which is likely why it tells me it's not going to load the one I list in pom.xml. The thing is, adding <scope>provided</scope> doesn't fix it either. Whatever I do, it still complains gives me the same java.lang.NoClassDefFoundError: javax/el/ELManager error.
SOLUTION
In addition to the part in the edit above regarding javax.servlet-api the problem with el-api was that I was running a Tomcat 7 with provided el-api jar in version 2.2. The missing class was introduced in el-api 3.0. Running the same webapp in Tomcat 8 (with el-api 3.0 jar) works properly.
You miss the javax.el-api as dependency. Add:
<dependency>
<groupId>javax.el</groupId>
<artifactId>javax.el-api</artifactId>
<version>3.0.0</version>
</dependency>
to your pom.xml
Hibernate Validator 6.x -> Bean Validation 2.0 (JSR 380) -> EL3.0
Hibernate Validator 5.x -> Bean Validation 1.1 (JSR 349) -> EL2.2
Bean Validation 1.0 (JSR 303) -> (I'm not sure)
so,it also influence others version (tomcat,jdk,jsp,servlet)
such as tomcat7, if you want to use Hibernate Validator, should use Hibernate Validator 5.x, el 2.2 (and servlet 3.0, jsp 2.2 and jdk 6+)
Downgrade hibernate-validator to version 5 and it will work fine with Tomcat 7.
In my case I add next dependency to my pom:
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-validator</artifactId>
<version>5.4.3.Final</version>
</dependency>
Or you can add newer el-api.jat to tomcat lib folder.
Please refer to Hibernate validation "Unable to initialize javax.el.ExpressionFactory" error
use
<dependency>
<groupId>org.glassfish</groupId>
<artifactId>javax.el</artifactId>
<version>3.0.1-b08</version>
</dependency>
I'm using Tomcat 7.0.9 and couldn't change to any newer one due my company bureaucracy. Importing EL as a dependency didn't solve it either.
At Tomcat's root folder -> lib I replaced old el-api (2.2 version of it) with a new 3.0 (from local .m2\repository\javax\el\javax.el-api\3.0.0). Then, isolating tomcat's dependencies correctly (as shown here) made my WAR be correctly deployed at Tomcat 7.0.9
Adding my answer for those having Tomcat 7 and trying to apply selected answer.
If adding dependency does not help you and you continue getting
java.lang.NoClassDefFoundError: javax/el/ELManager
that's because Tomcat 7 will not allow you to load a more modern jar with objects from javax.* package. It will print to the log:
jakarta.el-3.0.3.jar - jar not loaded. See Servlet Spec 3.0, section 10.7.2. Offending class: javax/el/Expression.class
The solution will be to either upgrade your Tomcat or downgrade hibernate-validator to the latest 5.x version. Another (less preferred from my POV) option would be to try to replace jars in your tomcat7/lib folder.
In my case,
Commented out this dependency,
<!-- <dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-validator</artifactId>
<version>6.0.8.Final</version>
</dependency> -->
and added
<dependency>
<groupId>javax.el</groupId>
<artifactId>javax.el-api</artifactId>
<version>3.0.0</version>
<scope>provided</scope>
</dependency>
This solved my issue
Try the following:
Add javax.eland javax.el-api to the pom.xml as others mention
If you have different classloaders - as often the case when using OSGi - you need to temporarily set the context to the one holding the implementation. Wrap your call with:
ClassLoader originalClassLoader = Thread.currentThread().getContextClassLoader();
try {
Class<?> currentClass = this.getClass(); // or any class that is in a bundle with the dependency
Thread.currentThread().setContextClassLoader(currentClass.getClassLoader());
// execute library call
} finally {
Thread.currentThread().setContextClassLoader(originalClassLoader); // back to original context
}
Add a service to META-INF/services/
Add a property to $java.home/lib/el.properties
Use the system property with the factoryId
When the library is instantiating the ExpressionFactory via > ELManager.newInstance(..) > FactoryFinder.find(..) it has several strategies to find an implementation. The call is hardcoded like this:
public static ExpressionFactory newInstance(Properties properties) {
return (ExpressionFactory) FactoryFinder.find(
"javax.el.ExpressionFactory", "com.sun.el.ExpressionFactoryImpl", properties);
}
See source of javax.el.FactoryFinder.find(..) for further information

Hibernate NoSuchMethodError for addPackage method

i use Hibernate for connecting to my db and i configure my database in side of my dbConnector class:
public static SessionFactory connectingHibernate(){
Properties database=new Properties();
database.setProperty("hibernate.connection.driver_class",PROPERTY_NAME_DATABASE_DRIVER);
database.setProperty("hibernate.connection.username",USERNAME);
database.setProperty("hibernate.connection.password",PASSWORD);
database.setProperty("hibernate.connection.url",url);
database.setProperty("hibernate.dialect",DIALECT);
Configuration cfg=new Configuration()
.setProperties(database)
.addPackage("androidapi.model")
.addAnnotatedClass(User.class)
.addAnnotatedClass(Product.class)
.addAnnotatedClass(PriceProduct.class)
.addAnnotatedClass(CoinPrice.class)
.addAnnotatedClass(SellPage.class)
.addAnnotatedClass(Setting.class)
.addAnnotatedClass(Message.class);
StandardServiceRegistryBuilder ssrb=new StandardServiceRegistryBuilder()
.applySettings(cfg.getProperties());
sessionFactory=cfg.buildSessionFactory(ssrb.build());
return sessionFactory;
}
when i run my application from inside of my ide my code works correctly but after making war file with maven i got this exception on methods that use my db! how can i fix this?
exception:
"error": "Internal Server Error",
"exception": "java.lang.NoSuchMethodError",
"message": "org.hibernate.cfg.Configuration.addPackage(Ljava/lang/String;)Lorg/hibernate/cfg/Configuration;",
after removeing this line: .addPackage("androidapi.model") i got this exception:
"exception": "java.lang.NoSuchMethodError",
"message": "org.hibernate.cfg.Configuration.addAnnotatedClass(Ljava/lang/Class;)Lorg/hibernate/cfg/Configuration;",
"path": "/myinsta/admin_api/mGetAllUser"
my pom.xml Hibernate dependencies:
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>5.1.6</version>
</dependency>
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate</artifactId>
<version>LATEST</version>
<type>pom</type>
</dependency>
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-core</artifactId>
<version>LATEST</version>
</dependency>
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-search</artifactId>
<version>LATEST</version>
</dependency>
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-entitymanager</artifactId>
<version>LATEST</version>
</dependency>
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-commons-annotations</artifactId>
<version>LATEST</version>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
<version>LATEST</version>
</dependency>
solved! read answer and its good to know that you should use compatible version of hibernate that can find here at meaven part:
Maven dependency
You have multiple versions of hibernate on your classpath (at the time of this writing this: most likely 3.6.0.beta2 and at 5.2.1.Final)
Remove:
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate</artifactId>
<version>LATEST</version>
<type>pom</type>
</dependency>
This is pulling in an older version.
You don't need this line
addPackage("androidapi.model")
The method addPackage() doesn't scan a package. It is for reading "package-level metadata" (.package-info- files).
Looks like, you use Hibernate 5. You can't use Hibernate 4 configuration code with Hibernate 5
https://stackoverflow.com/a/32711654/3405171
If you want to scan packages
https://stackoverflow.com/a/35248061/3405171
To use a valid Hibernate version just check this page with Hibernate core
versions:
https://mvnrepository.com/artifact/org.hibernate/hibernate-core
and add it to the pom.xml (if you use Maven). For example for Hibernate 5.2.1.Final (It uses Java 8):
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-core</artifactId>
<version>5.2.1.Final</version>
</dependency>
A dependency from hibernate-core is pretty enough, because of all other libraries will be loaded by Maven as transitive dependences. However, to use logger you need to add an additional dependency.
If you want to download an archive with all required jars, you can check the Hibernate download page:
http://hibernate.org/orm/downloads/

Embedded Neo4j SPI Class (lucene PostingsFormat) Error

I've embedded Neo4j 3.0.1 into a Java 8 application, but I've been running into SPI issues.
Running from within IntelliJ produces the correct results as expected, but as soon as I build the artifact to a JAR, run it and attempt to write to Neo4j, I get the following exception:
Caused by: org.neo4j.kernel.impl.store.UnderlyingStorageException: java.lang.IllegalArgumentException: An SPI class of type org.apache.lucene.codecs.PostingsFormat with name 'BlockTreeOrds' does not exist. You need to add the corresponding JAR file supporting this SPI to your classpath. The current classpath supports the following names: [Lucene50]
at org.neo4j.kernel.impl.transaction.command.LabelUpdateWork.apply(LabelUpdateWork.java:62)
at org.neo4j.kernel.impl.transaction.command.LabelUpdateWork.apply(LabelUpdateWork.java:33)
at org.neo4j.concurrent.WorkSync.doSynchronizedWork(WorkSync.java:121)
at org.neo4j.concurrent.WorkSync.apply(WorkSync.java:90)
at org.neo4j.kernel.impl.transaction.command.IndexBatchTransactionApplier.close(IndexBatchTransactionApplier.java:105)
at org.neo4j.kernel.impl.api.BatchTransactionApplierFacade.close(BatchTransactionApplierFacade.java:70)
at org.neo4j.kernel.impl.storageengine.impl.recordstorage.RecordStorageEngine.apply(RecordStorageEngine.java:336)
at org.neo4j.kernel.impl.api.TransactionRepresentationCommitProcess.applyToStore(TransactionRepresentationCommitProcess.java:78)
... 25 more
There seems to be no exception starting Neo4j so I'm assuming that certain dependencies are not being resolved with the Maven build.
I have the following in my pom.xml file:
<dependency>
<groupId>com.sparkjava</groupId>
<artifactId>spark-core</artifactId>
<version>2.5</version>
</dependency>
<dependency>
<groupId>org.neo4j</groupId>
<artifactId>neo4j</artifactId>
<version>3.0.1</version>
<type>pom</type>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-simple</artifactId>
<version>1.7.21</version>
</dependency>
<dependency>
<groupId>org.apache.lucene</groupId>
<artifactId>lucene-codecs</artifactId>
<version>5.5.0</version>
</dependency>
<dependency>
<groupId>org.neo4j</groupId>
<artifactId>neo4j-slf4j</artifactId>
<version>3.0.0-M02</version>
</dependency>
<dependency>
<groupId>com.google.code.gson</groupId>
<artifactId>gson</artifactId>
<version>2.6.2</version>
</dependency>
<dependency>
<groupId>com.github.jknack</groupId>
<artifactId>handlebars</artifactId>
<version>4.0.5</version>
</dependency>
<dependency>
<groupId>com.opencsv</groupId>
<artifactId>opencsv</artifactId>
<version>3.7</version>
</dependency>
<dependency>
<groupId>commons-codec</groupId>
<artifactId>commons-codec</artifactId>
<version>1.10</version>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId>
<version>${jackson.version}</version>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-annotations</artifactId>
<version>${jackson.version}</version>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-core</artifactId>
<version>${jackson.version}</version>
</dependency>
How do I resolve this issue?
UPDATE:
I've re-created this issue with a really simple blank project, source can be found here if you'd like to run it on your end: https://github.com/SeanNieuwoudt/neo4j-spi
I took your project and executed in my eclipse. I have no issues. Here are below console logs after starting:
[Thread-0] INFO org.eclipse.jetty.util.log - Logging initialized #473ms
[Thread-0] INFO spark.embeddedserver.jetty.EmbeddedJettyServer - == Spark has ignited ...
[Thread-0] INFO spark.embeddedserver.jetty.EmbeddedJettyServer - >> Listening on 0.0.0.0:8080
[Thread-0] INFO org.eclipse.jetty.server.Server - jetty-9.3.6.v20151106
[Thread-0] INFO org.eclipse.jetty.server.ServerConnector - Started ServerConnector#5aa07ed2{HTTP/1.1,[http/1.1]}{0.0.0.0:8080}
[Thread-0] INFO org.eclipse.jetty.server.Server - Started #772ms
While accessing - http://localhost:8080/
I got output printed as 'Hello World"
Steps i followed:
1) Downloaded your project from your github url
2) Imported as maven projects pointing to java 8
3) Maven install was successful
3) Ran main class
4) Saw the output in the browser.
Am i missing any steps to replicate actual issue?
Or is something to do with your maven. May be check your maven dependencies after running maven install to see if the expected jars are downloaded.
Good luck.
Try to add the following dependency:
<dependency>
<groupId>org.apache.lucene</groupId>
<artifactId>lucene-backward-codecs</artifactId>
<version>5.5.0</version>
</dependency>
This is my solution. https://stackoverflow.com/a/38623295/6579110. You can also check https://maven.apache.org/plugins/maven-shade-plugin/examples/resource-transformers.html#ServicesResourceTransformer for more details.

java.lang.NoClassDefFoundError: org/apache/http/conn/SchemePortResolver with AmazonHttpClient

All
I am running into this error in my project when I updated aws library to the latest 1.11.3.
Caused by:
java.lang.NoClassDefFoundError: org/apache/http/conn/SchemePortResolver
at com.amazonaws.http.apache.client.impl.ApacheHttpClientFactory.<init>(ApacheHttpClientFactory.java:40)
at com.amazonaws.http.AmazonHttpClient.<clinit>(AmazonHttpClient.java:97)
at com.amazonaws.AmazonWebServiceClient.<init>(AmazonWebServiceClient.java:145)
at com.amazonaws.services.s3.AmazonS3Client.<init>(AmazonS3Client.java:393)
at com.amazonaws.services.s3.AmazonS3Client.<init>(AmazonS3Client.java:373)
at com.amazonaws.services.s3.AmazonS3Client.<init>(AmazonS3Client.java:355)
at com.amazonaws.services.s3.AmazonS3Client.<init>(AmazonS3Client.java:339)
in my pom.xml
<dependency>
<groupId>com.amazonaws</groupId>
<artifactId>aws-java-sdk-core</artifactId>
<version>1.11.3</version>
</dependency>
<dependency>
<groupId>com.amazonaws</groupId>
<artifactId>aws-java-sdk-s3</artifactId>
<version>1.11.3</version>
</dependency>
<dependency>
<groupId>com.amazonaws</groupId>
<artifactId>aws-java-sdk-kms</artifactId>
<version>1.11.3</version>
</dependency>
<dependency>
<groupId>org.bouncycastle</groupId>
<artifactId>bcprov-ext-jdk15on</artifactId>
<version>1.54</version>
</dependency>
<dependency>
<groupId>com.amazonaws</groupId>
<artifactId>aws-encryption-sdk-java</artifactId>
<version>0.0.1-SNAPSHOT</version>
</dependency>
Anyone know what I did wrong?
thanks
I had a similar issue with my grails application. In my case the ClassNotFoundException was being thrown from a deploy script. For me the reason SchemePortResolver wasn't being resolved implicitly was because it wasn't required at compile time, it was needed at runtime. Here's what I added to my BuildConfig.groovy to fix it:
runtime 'org.apache.httpcomponents:httpclient:4.5.2' //Required by BeanstalkDeploy.groovy at runtime
Since the OP's question was for Maven, here's the equivalent include:
<dependency>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpclient</artifactId>
<version>4.5.2</version>
<scope>runtime</scope>
</dependency>
If you add,
<dependency>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpclient</artifactId>
<version>4.5.2</version>
</dependency>
,it should work ok as it contains the missing class definitions.
A common cause would be a Maven dependency conflict. In the example below (pom.xml as viewed in Eclipse's Dependency Hierarchy tab), the POM explicitly includes v4.1 of httpclient, which forces Maven to omit the v4.5.5 that aws-java-sdk-core requires (and thus, causes the similar error java.lang.NoClassDefFoundError: org/apache/http/conn/DnsResolver at com.amazonaws.http.apache.client.impl.ApacheHttpClientFactory...):
In my case I delete the .meta file in eclipse workplace then import the project again thereafter it work like a charm.
Could not know where the problem exactly.
Before delete .meta I add all files from
aws-java-sdk-1.11.606\third-party\lib

java.lang.AbstractMethodError: on Jersey Rest Webservice call after upgrading Weblogic to 12c (12.1.3.0.0)

A part of our application which calls a REST webservice using Jersey Client 2.15 stopped working after we upgraded our Weblogic to Weblogic 12C - 12.1.3.0.0.
The exception trace we were getting was:
java.lang.AbstractMethodError: javax.ws.rs.core.UriBuilder.uri(Ljava/lang/String;)Ljavax/ws/rs/core/UriBuilder;
at javax.ws.rs.core.UriBuilder.fromUri(UriBuilder.java:119)
at org.glassfish.jersey.client.JerseyWebTarget.<init>(JerseyWebTarget.java:71)
at org.glassfish.jersey.client.JerseyClient.target(JerseyClient.java:185)
at org.glassfish.jersey.client.JerseyClient.target(JerseyClient.java:70)
We were sure that it was a javax.ws.rs mismatch between Jersey and Weblogic WS libraries.
Dependencies
<dependency>
<groupId>org.glassfish.jersey.core</groupId>
<artifactId>jersey-client</artifactId>
<version>2.15</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.glassfish.jersey.core</groupId>
<artifactId>jersey-common</artifactId>
<version>2.15</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>javax.ws.rs</groupId>
<artifactId>javax.ws.rs-api</artifactId>
<version>2.0.1</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpclient</artifactId>
<version>4.4</version>
</dependency>
<dependency>
<groupId>org.glassfish.jersey.connectors</groupId>
<artifactId>jersey-apache-connector</artifactId>
<version>2.15</version>
</dependency>
Not longer did we realize that following our application logs with the above stack trace was misleading. So we started looking into Weblogic logs. The domain log did in fact gave as a totally different stack trace:
java.lang.NoSuchMethodError: org.glassfish.hk2.api.ServiceLocatorFactory.create(Ljava/lang/String;Lorg/glassfish/hk2/api/ServiceLocator;Lorg/glassfish/hk2/extension/ServiceLocatorGenerator;Lorg/glassfish/hk2/api/ServiceLocatorFactory$CreatePolicy;)Lorg/glassfish/hk2/api/ServiceLocator;
at org.glassfish.jersey.internal.inject.Injections._createLocator(Injections.java:138)
at org.glassfish.jersey.internal.inject.Injections.createLocator(Injections.java:109)
at org.glassfish.jersey.internal.RuntimeDelegateImpl.<init>(RuntimeDelegateImpl.java:63)
at
So after some firefighting and playing around with weblogic.xml and package overrides the issue was sorted. The following were the final package overrides which actually did solve the problem:
<wls:package-name>com.sun.jersey.*</wls:package-name>
<wls:package-name>org.glassfish.jersey.*</wls:package-name>
<wls:package-name>org.glassfish.hk2.*</wls:package-name>
<wls:package-name>org.jvnet.hk2.*</wls:package-name>
<wls:package-name>jersey.repackaged.org.objectweb.asm.*</wls:package-name>
<wls:package-name>org.objectweb.asm.*</wls:package-name>
<wls:package-name>com.sun.ws.rs.ext.*</wls:package-name>
<wls:package-name>javax.ws.rs.*</wls:package-name>

Categories