I am trying to get the following project running in a standalone Jetty instance:
https://github.com/stilkov/jetty-weld-jersey-sample
Running the mentioned Maven goal jetty:run works as expected.
I am using Jetty_9_4_28_v20200408 (the mentioned project uses a different version - I tested updating the Jetty version mentioned in pom.xml and I am still able to run jetty:run).
I modified the pom.xml to reflect the changes needed for a standalone server:
<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/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.innoq.sample</groupId>
<artifactId>jetty-weld-jersey-sample</artifactId>
<version>0.1-SNAPSHOT</version>
<packaging>war</packaging>
<name>Jetty Weld Jersey Sample Web App</name>
<properties>
<jettyVersion>9.4.28.v20200408</jettyVersion>
<weldVersion>2.2.9.Final</weldVersion>
<jerseyVersion>2.6</jerseyVersion>
<JerseyGlassfishCDIVersion>2.6</JerseyGlassfishCDIVersion>
</properties>
<dependencies>
<dependency>
<groupId>javax.inject</groupId>
<artifactId>javax.inject</artifactId>
<version>1</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>javax.ws.rs</groupId>
<artifactId>javax.ws.rs-api</artifactId>
<version>2.0.1</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.jboss.weld.servlet</groupId>
<artifactId>weld-servlet</artifactId>
<version>${weldVersion}</version>
<type>jar</type>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>org.glassfish.jersey.containers</groupId>
<artifactId>jersey-container-servlet</artifactId>
<version>${jerseyVersion}</version>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>org.glassfish.jersey.containers.glassfish</groupId>
<artifactId>jersey-gf-cdi</artifactId>
<version>${JerseyGlassfishCDIVersion}</version>
<scope>runtime</scope>
</dependency>
</dependencies>
</project>
However, this results in the following error on startup (starting Jetty from IntelliJ):
[2020-05-13 11:44:23,833] Artifact jetty-weld-jersey-sample:war: Artifact is being deployed, please wait...
2020-05-13 23:44:25.512:WARN:oejw.WebAppContext:Scanner-1: Failed startup of context o.e.j.w.WebAppContext#6a6c5585{/jetty-weld-jersey-sample-0.1-SNAPSHOT,file:///$PROJECT_DIR/jetty-weld-jersey-sample-master/target/jetty-weld-jersey-sample-0.1-SNAPSHOT/,UNAVAILABLE}{$PROJECT_DIR/jetty-weld-jersey-sample-master/target/jetty-weld-jersey-sample-0.1-SNAPSHOT.war}
java.lang.ArrayStoreException: sun.reflect.annotation.TypeNotPresentExceptionProxy
at sun.reflect.annotation.AnnotationParser.parseClassArray(AnnotationParser.java:724)
at sun.reflect.annotation.AnnotationParser.parseArray(AnnotationParser.java:531)
at sun.reflect.annotation.AnnotationParser.parseMemberValue(AnnotationParser.java:355)
at sun.reflect.annotation.AnnotationParser.parseAnnotation2(AnnotationParser.java:286)
at sun.reflect.annotation.AnnotationParser.parseAnnotations2(AnnotationParser.java:120)
at sun.reflect.annotation.AnnotationParser.parseAnnotations(AnnotationParser.java:72)
at java.lang.Class.createAnnotationData(Class.java:3521)
at java.lang.Class.annotationData(Class.java:3510)
at java.lang.Class.getAnnotation(Class.java:3415)
at org.eclipse.jetty.annotations.AnnotationConfiguration.createServletContainerInitializerAnnotationHandlers(AnnotationConfiguration.java:574)
at org.eclipse.jetty.annotations.AnnotationConfiguration.configure(AnnotationConfiguration.java:343)
at org.eclipse.jetty.webapp.WebAppContext.configure(WebAppContext.java:498)
at org.eclipse.jetty.webapp.WebAppContext.startContext(WebAppContext.java:1404)
at org.eclipse.jetty.server.handler.ContextHandler.doStart(ContextHandler.java:838)
at org.eclipse.jetty.servlet.ServletContextHandler.doStart(ServletContextHandler.java:275)
at org.eclipse.jetty.webapp.WebAppContext.doStart(WebAppContext.java:524)
at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:72)
at org.eclipse.jetty.deploy.bindings.StandardStarter.processBinding(StandardStarter.java:46)
at org.eclipse.jetty.deploy.AppLifeCycle.runBindings(AppLifeCycle.java:188)
at org.eclipse.jetty.deploy.DeploymentManager.requestAppGoal(DeploymentManager.java:513)
at org.eclipse.jetty.deploy.DeploymentManager.addApp(DeploymentManager.java:154)
at org.eclipse.jetty.deploy.providers.ScanningAppProvider.fileAdded(ScanningAppProvider.java:173)
at org.eclipse.jetty.deploy.providers.WebAppProvider.fileAdded(WebAppProvider.java:447)
at org.eclipse.jetty.deploy.providers.ScanningAppProvider$1.fileAdded(ScanningAppProvider.java:66)
at org.eclipse.jetty.util.Scanner.reportAddition(Scanner.java:784)
at org.eclipse.jetty.util.Scanner.reportDifferences(Scanner.java:753)
at org.eclipse.jetty.util.Scanner.scan(Scanner.java:641)
at org.eclipse.jetty.util.Scanner$1.run(Scanner.java:558)
at java.util.TimerThread.mainLoop(Timer.java:555)
at java.util.TimerThread.run(Timer.java:505)
[2020-05-13 11:44:25,904] Artifact jetty-weld-jersey-sample:war: Artifact is deployed successfully
[2020-05-13 11:44:25,905] Artifact jetty-weld-jersey-sample:war: Deploy took 2,072 milliseconds
I can get different errors if I start activating further Jetty modules, but my intuition says that this should probably not be necessary.
Note: In the log, I introduced $PROJECT_DIR for anonymization.
Related
I have created a Spring Boot application, with Spring Security, to expose some REST API endpoints.
I've created the project using the built in IntelliJ Ultimate Spring Initializr.
Spring version: 2.4.4
Type: Maven
Java version: 8
Packaging: War
When I run the application from within IntelliJ and it starts an instance of Tomcat 9.0.44.
Then I created a WAR file, using maven>package, to test in on my PC's local XAMPP installation. (I use Tomcat 8.5.53. The reason is that this is the Tomcat version that is available at our production environment to which I finally want to deploy.)
I deployed using the tomcat manager, and it runs without any problem there as well.
I then moved the war to our production server and used the Tomcat manager UI to deploy.
I can see in the manager that it deployed and that it is running.
Production server Tomcat Manager UI
When I tried to access my endpoints, using Postman, no matter what endpoint I try to access I always get a 404 error...
pom.xml
<?xml version="1.0" encoding="UTF-8"?>
<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 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.4.4</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
<groupId>com.apiauthentication</groupId>
<artifactId>auth-server</artifactId>
<version>1.0.0</version>
<packaging>war</packaging>
<name>FLEET_Authentication_Server</name>
<description>Authentication Server</description>
<properties>
<java.version>1.8</java.version>
<jjwt.version>0.10.6</jjwt.version>
</properties>
<dependencies>
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-core</artifactId>
</dependency>
<dependency>
<groupId>log4j</groupId>
<artifactId>log4j</artifactId>
<version>1.2.12</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-jpa</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-security</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-tomcat</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.springframework.security</groupId>
<artifactId>spring-security-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>io.jsonwebtoken</groupId>
<artifactId>jjwt-api</artifactId>
<version>${jjwt.version}</version>
</dependency>
<dependency>
<groupId>io.jsonwebtoken</groupId>
<artifactId>jjwt-impl</artifactId>
<version>${jjwt.version}</version>
</dependency>
<dependency>
<groupId>io.jsonwebtoken</groupId>
<artifactId>jjwt-jackson</artifactId>
<version>${jjwt.version}</version>
</dependency>
<dependency>
<groupId>joda-time</groupId>
<artifactId>joda-time</artifactId>
<version>2.10.10</version>
</dependency>
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot</artifactId>
<version>2.4.4</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
<finalName>${artifactId}</finalName>
</build>
</project>
main class-AuthServerApplication
#SpringBootApplication
public class AuthServerApplication {
public static void main(String[] args) {
SpringApplication.run(AuthServerApplication.class, args);
}
}
Below are the entries in the Tomcat logs
catalina.log
21-Apr-2021 08:14:09.860 INFO [http-nio-8080-exec-2726] org.apache.catalina.startup.HostConfig.deployWAR Deploying web application archive /opt/tomcat/webapps/auth-server.war
21-Apr-2021 08:14:11.828 INFO [http-nio-8080-exec-2726] org.apache.jasper.servlet.TldScanner.scanJars At least one JAR was scanned for TLDs yet contained no TLDs. Enable debug logging for this logger for a complete list of JARs that were scanned but no TLDs were found in them. Skipping unneeded JARs during scanning can improve startup time and JSP compilation time.
21-Apr-2021 08:14:16.257 INFO [http-nio-8080-exec-2726] org.apache.catalina.startup.HostConfig.deployWAR Deployment of web application archive /opt/tomcat/webapps/auth-server.war has finished in 6,397 ms
localhost.log
21-Apr-2021 08:14:11.839 INFO [http-nio-8080-exec-2726] org.apache.catalina.core.ApplicationContext.log 2 Spring WebApplicationInitializers detected on classpath
21-Apr-2021 08:14:13.419 INFO [http-nio-8080-exec-2726] org.apache.catalina.core.ApplicationContext.log Initializing Spring embedded WebApplicationContext
manager.log
21-Apr-2021 08:12:04.977 INFO [http-nio-8080-exec-2623] org.apache.catalina.core.ApplicationContext.log HTMLManager: list: Listing contexts for virtual host 'localhost'
21-Apr-2021 08:14:09.806 INFO [http-nio-8080-exec-2726] org.apache.catalina.core.ApplicationContext.log HTMLManager: install: Installing web application '/auth-server' from '/tmp-war/auth-server.war'
21-Apr-2021 08:14:16.257 INFO [http-nio-8080-exec-2726] org.apache.catalina.core.ApplicationContext.log HTMLManager: list: Listing contexts for virtual host 'localhost'
In the localhost_access_log file I can see no entries for my attempts to access the newly deployed application.
Some things that I have tried:
Extend SpringBootServletInitializer on my main class and override the configure method
#SpringBootApplication
public class AuthServerApplication extends SpringBootServletInitializer {
public static void main(String[] args) {
SpringApplication.run(AuthServerApplication.class, args);
}
#Override
protected SpringApplicationBuilder configure(SpringApplicationBuilder application) {
return application.sources(AuthServerApplication.class);
}
}
Add start-class in the properties section of the pom.xml
<properties>
...
<start-class>
com.apiauthentication.authserver.AuthServerApplication
</start-class>
</properties>
Add an exclusion to the spring-boot-starter-web, for spring-boot-starter-tomcat
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
<exclusions>
<exclusion>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-tomcat</artifactId>
</exclusion>
</exclusions>
</dependency>
And different combinations of those things as well
Anyone has any hints as to what might be the problem?
Basically I can run on my local XAMPP but not on the production server
Adding the comment from Piotr P. Karwasz as the answer.
What seems strange is the lack of entries in the access log. Are your sure that your production server is not behind a reverse proxy?
The problem was that I was trying to access the application using the domain name, but since the domain was managed using Plesk, and there are other domains on that server as well, I had to go to the Apache settings of the domain and add some new ProxyPass and ProxyPassReverse directives, for HTTP and HTTPS
In my Spring Boot(2.0.5) project I was using Elasticsearch(5.6.9). However, due to some bugs in testing environment we are moving to Spring boot(2.1.0).
When I run the application the following message comes up:
***************************
APPLICATION FAILED TO START
***************************
Description:
An attempt was made to call the method org.elasticsearch.action.admin.indices.mapping.put.PutMappingRequestBuilder.execute()Lorg/elasticsearch/action/ActionFuture; but it does not exist. Its class, org.elasticsearch.action.admin.indices.mapping.put.PutMappingRequestBuilder, is available from the following locations:
jar:file:/C:/Users/User/.m2/repository/org/elasticsearch/elasticsearch/5.6.9/elasticsearch-5.6.9.jar!/org/elasticsearch/action/admin/indices/mapping/put/PutMappingRequestBuilder.class
It was loaded from the following location:
file:/C:/Users/User/.m2/repository/org/elasticsearch/elasticsearch/5.6.9/elasticsearch-5.6.9.jar
Action:
Correct the classpath of your application so that it contains a single, compatible version of org.elasticsearch.action.admin.indices.mapping.put.PutMappingRequestBuilder
Process finished with exit code 0
Current pom.xml file
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.1.0.RELEASE</version>
<relativePath/>
</parent>
<properties>
<elasticsearch.version>5.6.9</elasticsearch.version>
</properties>
<dependencies>
<!--...others...-->
<!--ELASTICSEARCH-->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-elasticsearch</artifactId>
</dependency>
<dependency>
<groupId>org.elasticsearch.client</groupId>
<artifactId>transport</artifactId>
<version>${elasticsearch.version}</version>
</dependency>
<dependency>
<groupId>org.elasticsearch.plugin</groupId>
<artifactId>transport-netty4-client</artifactId>
<version>${elasticsearch.version}</version>
</dependency>
</dependencies>
Previous pom.xml file which worked fine:
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.0.5.RELEASE</version>
<relativePath/>
</parent>
<properties>
<elasticsearch.version>5.6.9</elasticsearch.version>
</properties>
<dependencies>
<!--...others...-->
<!--ELASTICSEARCH-->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-elasticsearch</artifactId>
</dependency>
<dependency>
<groupId>org.elasticsearch.client</groupId>
<artifactId>transport</artifactId>
<version>${elasticsearch.version}</version>
</dependency>
<dependency>
<groupId>org.elasticsearch.plugin</groupId>
<artifactId>transport-netty4-client</artifactId>
<version>${elasticsearch.version}</version>
</dependency>
</dependencies>
Can someone tell which version of elasticsearch is compatible with Spring Boot 2.1.0?
I read through similar questions which were outdated.
Compatible versions of Spring boot,elasticsearch and spring data elasticsearch
You can go to Spring Boot project Github repository and check any dependency version:
In Spring Boot 2.0.x Elasticsearch version is defined as 5.6.16 (link)
In Spring Boot 2.1.x Elasticsearch version is defined as 6.4.3
(link)
Not sure if it's still actual, but the first thing you need to try is to add core Elasticsearch library, because REST client depends on it.
<dependency>
<groupId>org.elasticsearch</groupId>
<artifactId>elasticsearch</artifactId>
<version>6.7.0</version>
</dependency>
I'm using spark 1.5.2 & cassandra 2.2.5. So based on the recommendation, I used cassandra connector 1.5.0. While running my application (save operation), it's throwing this exception:
Exception in thread "main" java.lang.IllegalArgumentException: Failed to get converter for field "getCompanyid" of type java.lang.String in SampleDBOperation$Employee mapped to column "companyid" of "test.employee"
at com.datastax.spark.connector.writer.MappedToGettableDataConverter$$anon$1$$anonfun$5.apply(MappedToGettableDataConverter.scala:157)
at com.datastax.spark.connector.writer.MappedToGettableDataConverter$$anon$1$$anonfun$5.apply(MappedToGettableDataConverter.scala:150)
at scala.collection.TraversableLike$$anonfun$map$1.apply(TraversableLike.scala:244)
at scala.collection.TraversableLike$$anonfun$map$1.apply(TraversableLike.scala:244)
at scala.collection.immutable.Range.foreach(Range.scala:141)
at scala.collection.TraversableLike$class.map(TraversableLike.scala:244)
at scala.collection.AbstractTraversable.map(Traversable.scala:105)
at com.datastax.spark.connector.writer.MappedToGettableDataConverter$$anon$1.<init>(MappedToGettableDataConverter.scala:150)
at com.datastax.spark.connector.writer.MappedToGettableDataConverter$.apply(MappedToGettableDataConverter.scala:20)
at com.datastax.spark.connector.writer.DefaultRowWriter.<init>(DefaultRowWriter.scala:17)
at com.datastax.spark.connector.writer.DefaultRowWriter$$anon$1.rowWriter(DefaultRowWriter.scala:31)
at com.datastax.spark.connector.writer.DefaultRowWriter$$anon$1.rowWriter(DefaultRowWriter.scala:29)
at com.datastax.spark.connector.writer.TableWriter$.apply(TableWriter.scala:269)
at com.datastax.spark.connector.RDDFunctions.saveToCassandra(RDDFunctions.scala:36)
at com.datastax.spark.connector.japi.RDDJavaFunctions.saveToCassandra(RDDJavaFunctions.java:61)
at com.datastax.spark.connector.japi.RDDAndDStreamCommonJavaFunctions$WriterBuilder.saveToCassandra(RDDAndDStreamCommonJavaFunctions.java:443)
Not sure, what's going wrong. Please find my pom.xml details:
<project>
<groupId>edu.berkeley</groupId>
<artifactId>sampledboperation</artifactId>
<modelVersion>4.0.0</modelVersion>
<name>Simple Project for Connecting to Cassandra and doing operations</name>
<packaging>jar</packaging>
<version>1.0</version>
<dependencies>
<dependency> <!-- Spark dependency -->
<groupId>org.apache.spark</groupId>
<artifactId>spark-core_2.10</artifactId>
<version>1.5.2</version>
</dependency>
<!--Spark Cassandra Connector-->
<dependency>
<groupId>com.datastax.spark</groupId>
<artifactId>spark-cassandra-connector_2.10</artifactId>
<version>1.5.0</version>
</dependency>
<dependency>
<groupId>com.datastax.spark</groupId>
<artifactId>spark-cassandra-connector-java_2.10</artifactId>
<version>1.5.0</version>
</dependency>
<dependency>
<groupId>org.apache.spark</groupId>
<artifactId>spark-streaming_2.10</artifactId>
<version>1.5.2</version>
</dependency>
</dependencies>
</project>
I am very new to programming and am working my way through a tutorial for Hibernate that includes using Maven. Everything seemed to be going well until I try to mvn compile or spin up my HSQLDB server using the recommended command in the tutorial:
mvn exec:java -Dexec.mainClass="org.hsqldb.Server" -Dexec.args="-database.0 file:target/data/tutorial"
At that point I get a build failure which I will include below, along with my pom. It seems to be telling me that poms are missing for the dependencies but I have no idea how to correct that problem. Any help will be greatly appreciated so that I can move forward with my learning experience.
<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>org.hibernate.tutorials</groupId>
<artifactId>hibernate-tutorial</artifactId>
<version>1.0.0-snapshot</version>
<name>First Hibernate Tutorial</name>
<build>
<!-- we dont want the version to be part of the generated war file name -->
<finalName>${project.artifactId}</finalName>
</build>
<dependencies>
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-core</artifactId>
<version>5.0.7.final</version>
</dependency>
<!-- Because this is a web app, we also have a dependency on the servlet api. -->
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>servlet-api</artifactId>
<version>3.1.0</version>
</dependency>
<!-- Hibernate uses slf4j for logging, for our purposes here use the simple backend -->
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-simple</artifactId>
<version>1.7.14</version>
</dependency>
<!-- Hibernate gives you a choice of bytecode providers between cglib and javassist -->
<dependency>
<groupId>javassist</groupId>
<artifactId>javassist</artifactId>
<version>3.18.1-GA</version>
</dependency>
</dependencies>
Using search.maven.com, it appears that the Hibernate dependency name is hibernate-core-5.0.7.Final. That is, a capital F in Final. So try with
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-core</artifactId>
<version>5.0.7.Final</version>
</dependency>
instead
I replaced j2ee.jar with servle-api.com from my tomcat 6.0 installation directory:
And that yields the error below. I'm presently trying to figure out the cause. What might the problem be.
I have a the bean defined in a configuration file: Sempedia-service.xml
as follows
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-2.5.xsd">
<bean id="sempediaSearchService"
class="com.service.SempediaSearchManager" />
</beans>
my web.xml specifies the following beans:
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>/WEB-INF/Sempedia-service.xml,/WEB-INF/Sempedia-persistence.xml</param-value>
</context-param>
<listener>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>
Stack Trace
SEVERE: Exception sending context initialized event to listener instance of class org.springframework.web.context.ContextLoaderListener
org.springframework.beans.factory.CannotLoadBeanClassException: Cannot find class [com.service.SempediaSearchManager] for bean with name 'sempediaSearchService' defined in ServletContext resource [/WEB-INF/Sempedia-service.xml]; nested exception is java.lang.ClassNotFoundException: com.service.SempediaSearchManager
at org.springframework.beans.factory.support.AbstractBeanFactory.resolveBeanClass(AbstractBeanFactory.java:1141)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.predictBeanType(AbstractAutowireCapableBeanFactory.java:524)
at org.springframework.beans.factory.support.AbstractBeanFactory.isFactoryBean(AbstractBeanFactory.java:1177)
at org.springframework.beans.factory.support.AbstractBeanFactory.isFactoryBean(AbstractBeanFactory.java:758)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:422)
at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:728)
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:380)
at org.springframework.web.context.ContextLoader.createWebApplicationContext(ContextLoader.java:255)
at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:199)
at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:45)
at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:3934)
at org.apache.catalina.core.StandardContext.start(StandardContext.java:4429)
at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1045)
at org.apache.catalina.core.StandardHost.start(StandardHost.java:722)
at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1045)
at org.apache.catalina.core.StandardEngine.start(StandardEngine.java:443)
at org.apache.catalina.core.StandardService.start(StandardService.java:516)
at org.apache.catalina.core.StandardServer.start(StandardServer.java:710)
at org.apache.catalina.startup.Catalina.start(Catalina.java:583)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:288)
at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:413)
Caused by: java.lang.ClassNotFoundException: com.service.SempediaSearchManager
at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1387)
at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1233)
at org.springframework.util.ClassUtils.forName(ClassUtils.java:211)
at org.springframework.beans.factory.support.AbstractBeanDefinition.resolveBeanClass(AbstractBeanDefinition.java:385)
at org.springframework.beans.factory.support.AbstractBeanFactory.resolveBeanClass(AbstractBeanFactory.java:1138)
... 24 more
The problem is that there is no class called com.service.SempediaSearchManager on your webapp's classpath. The most likely root causes are:
the fully qualified classname is incorrect in /WEB-INF/Sempedia-service.xml; i.e. the class name is something else,
the class is not in your webapp's /WEB-INF/classes directory tree or a JAR file in the /WEB-INF/lib directory.
EDIT : The only other thing that I can think of is that the ClassDefNotFoundException may actually be a result of an earlier class loading / static initialization problem. Check your log files for the first stack trace, and look the nested exceptions, i.e. the "caused by" chain. [If a class load fails one time and you or Spring call Class.forName() again for some reason, then Java won't actually try to load a second time. Instead you will get a ClassDefNotFoundException stack trace that does not explain the real cause of the original failure.]
If you are still stumped, you should take Eclipse out of the picture. Create the WAR file in the form that you are eventually going to deploy it, then from the command line:
manually shutdown Tomcat
clean out your Tomcat webapp directory,
copy the WAR file into the webapp directory,
start Tomcat.
If that doesn't solve the problem directly, look at the deployed webapp directory on Tomcat to verify that the "missing" class is in the right place.
I got the same error and the cause was the directory:
U:.....WEB\WebRoot\WEB-INF\classes\com\yourcompany\cc\dao
was corrupted(directory or file not readable or damaged)..
solved with
renaming the directory WEB-INF\classes as WEB-INF\classes_old
Eclipse's Project menu--> Clean (to recreate directories)
redeploy --> restart server.
Check your dependencies.
<?xml version="1.0" encoding="UTF-8"?>
<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/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>SchoolApp</groupId>
<artifactId>SchoolApp</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>war</packaging>
<properties>
<hibernate.version>4.2.0.Final</hibernate.version>
<mysql.connector.version>5.1.21</mysql.connector.version>
<spring.version>3.2.2.RELEASE</spring.version>
</properties>
<dependencies>
<!-- DB related dependencies -->
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-core</artifactId>
<version>${hibernate.version}</version>
</dependency>
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-entitymanager</artifactId>
<version>${hibernate.version}</version>
</dependency>
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>${mysql.connector.version}</version>
</dependency>
<dependency>
<groupId>commons-dbcp</groupId>
<artifactId>commons-dbcp</artifactId>
<version>1.4</version>
</dependency>
<dependency>
<groupId>javassist</groupId>
<artifactId>javassist</artifactId>
<version>3.12.1.GA</version>
</dependency>
<!-- SPRING -->
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-core</artifactId>
<version>${spring.version}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-web</artifactId>
<version>${spring.version}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-webmvc</artifactId>
<version>${spring.version}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-tx</artifactId>
<version>${spring.version}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-jdbc</artifactId>
<version>${spring.version}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-orm</artifactId>
<version>${spring.version}</version>
</dependency>
<!-- Spring Security -->
<dependency>
<groupId>org.springframework.security</groupId>
<artifactId>spring-security-core</artifactId>
<version>3.1.3.RELEASE</version>
</dependency>
<dependency>
<groupId>org.springframework.security</groupId>
<artifactId>spring-security-web</artifactId>
<version>3.1.3.RELEASE</version>
</dependency>
<dependency>
<groupId>org.springframework.security</groupId>
<artifactId>spring-security-config</artifactId>
<version>3.1.3.RELEASE</version>
</dependency>
<dependency>
<groupId>org.springframework.security</groupId>
<artifactId>spring-security-taglibs</artifactId>
<version>3.1.3.RELEASE</version>
</dependency>
<!-- CGLIB is required to process #Configuration classes -->
<dependency>
<groupId>cglib</groupId>
<artifactId>cglib</artifactId>
<version>2.2.2</version>
</dependency>
<!-- Servlet API and JSTL -->
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>javax.servlet-api</artifactId>
<version>3.0.1</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>jstl</groupId>
<artifactId>jstl</artifactId>
<version>1.2</version>
</dependency>
<!-- Test -->
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.7</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-test</artifactId>
<version>${spring.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-test-mvc</artifactId>
<version>1.0.0.M1</version>
<scope>test</scope>
</dependency>
</dependencies>
<repositories>
<repository>
<id>spring-maven-milestone</id>
<name>Spring Maven Milestone Repository</name>
<url>http://maven.springframework.org/milestone</url>
</repository>
</repositories>
<build>
<finalName>spr-mvc-hib</finalName>
<plugins>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>2.3.2</version>
<configuration>
<source>1.7</source>
<target>1.7</target>
</configuration>
</plugin>
</plugins>
</build>
</project>
I have faced similar problem
So
I just do
1.update Maven Project
2.install maven.
I have the same problem. I checked my /WEB-INF/classes based on Stephen's recommendation:
the class is not in your webapp's /WEB-INF/classes directory tree or a JAR file in the /WEB-INF/lib directory.
I discovered I have an outdated jar file. Replacing it with the latest jar file solved the issue.
i recently experienced this issue when i was trying to build and suddenly the laptop battery ran out of charge. I just removed all the servers from eclipse and then restore it. after doing that, i re-built the war file and it worked.
Just leaving this here for future visitors:
In my case the /WEB-INF/classes directory was missing. If you are using Eclipse, make sure the .settings/org.eclipse.wst.common.component is correct (Deployment Assembly in the project settings).
In my case it was missing
<wb-resource deploy-path="/WEB-INF/classes" source-path="/src/main/resources"/>
<wb-resource deploy-path="/WEB-INF/classes" source-path="/src/test/resources"/>
This file is also a common source of errors as mentioned by Anuj (missing dependencies of other projects).
Otherwise, hopefully the other answers (or the "Problems" tab) will help you.
i dont know whether it is relevant to your issue, i got similar issue which i got solved by
1) In eclipse right click server and clean
if it still didnt work
2) export the project and delete the project create the project with same name and import the project and add the project to server and run.