The build path is incomplete. Cannot find class file for javax / servlet / ServletContext

very new to java. Work on the hibernate CRUD spring (sts) project. When setting up the xml file, I get the error message "The build path is not completed. Cannot find the class file for javax / servlet / ServletContext", bybean id = "viewResolver". How to put this on the build path. amuses.

<context:annotation-config /> <context:component-scan base-package="com.ger" /> <bean id="propertyConfigurer" class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer" p:location="/WEB-INF/jdbc.properties" /> <bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource" destroy-method="close" p:driverClassName="${jdbc.driverClassName}" p:url="${jdbc.databaseurl}" p:username="${jdbc.username}" p:password="${jdbc.password}" /> <bean id="sessionFactory" class="org.springframework.orm.hibernate3.LocalSessionFactoryBean"> <property name="dataSource" ref="dataSource" /> <property name="configLocation"> <value>classpath:hibernate.cfg.xml</value> </property> <property name="configurationClass"> <value>org.hibernate.cfg.AnnotationConfiguration</value> </property> <property name="hibernateProperties"> <props> <prop key="hibernate.dialect">${jdbc.dialect}</prop> <prop key="hibernate.show_sql">true</prop> </props> </property> </bean> <bean id="viewResolver" class="org.springframework.web.servlet.view.UrlBasedViewResolver"> <property name="viewClass" value="org.springframework.web.servlet.view.JstlView"/> <property name="prefix" value="/WEB-INF/jsp/"/> <property name="suffix" value=".jsp"/> </bean> <tx:annotation-driven /> <bean id="transactionManager" class="org.springframework.orm.hibernate3.HibernateTransactionManager"> <property name="sessionFactory" ref="sessionFactory" /> </bean> 

+4
source share
4 answers

One of the jars from servlet-api.jar , jsp-api.jar , el-api.jar , j2ee.jar , javaee.jar j2ee.jar be javaee.jar . And you do not need to copy and paste them into the classpath. When the application is deployed to the server, you will receive them. First of all, you will never manually copy / load / move / enable individual libraries specific to servlet containers.

If you run this project from the IDE, check your server configuration.

+3
source
  • Windows 8.1, Maven 3.2.3
  • Spring STS 3.6.3.SR1
  • Maven integration for Eclipse m2e 1.5.1.20150109
  • Spring IDE Plugin 3.6.3.201411271034-RELEASE etc.

Had a similar problem for several days. He said that some classes were missing from the dependent project (but they were present) that was open, and this was a problem with the Spring AOP plugin (?). When you close a project, the dependency is correctly viewed in the Maven repository. The problem does not occur when executing the maven build from the command line, only in STS.

I have tried different things. One of them that seems to work is to open the applicationcontext.xml file with the Spring Config Editor, go to the Namespaces tab, unselect the context namespace, save (maybe do some cleaning), then select context namespace, save again. To pray or to dance your favorite rain dance will also help :) The line where I saw this error was:

 <context:component-scan base-package="aaa.bbb" /> 
+3
source

The problem is that JIT in Eclipse does not work the same as the Java JDK, which you can use on the command line with something like Maven. To fix this, simply add the following to your pom.xml file.

  <dependency> <groupId>javax.servlet</groupId> <artifactId>javax.servlet-api</artifactId> <version>3.1.0</version> </dependency> <dependency> <groupId>javax.servlet</groupId> <artifactId>jsp-api</artifactId> <version>2.0</version> </dependency> <dependency> <groupId>javax.servlet</groupId> <artifactId>jstl</artifactId> <version>1.2</version> </dependency> 
+2
source

For WAR projects, this is a common mistake when you did not transfer the * .war file to the deployment folder ... obviously, the server cannot find what it does not know about.

If you are using the Eclipse integrated environment, simply right-click on the server on which you are deploying, on the Servers tab, then select Add and Remove, and then move your .war file to the deployment folder. Reboot the server and go to the URL to see if this fixes the problem.

-1
source

Source: https://habr.com/ru/post/1481066/


All Articles