Announcement Announcement Module
Collapse
No announcement yet.
No mapping found for HTTP request with URI Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • No mapping found for HTTP request with URI

    Hi All
    Can someone please point to me what am I doing wrong here, this is the error message I'm getting;
    Code:
    WARN : org.springframework.web.servlet.PageNotFound - No mapping found for HTTP request with URI [/logicalideasJPA/contacts.html] in DispatcherServlet with name 'appServlet'
    servlet-context.xml
    Code:
    <?xml version="1.0" encoding="UTF-8"?>
    <beans:beans xmlns="http://www.springframework.org/schema/mvc"
    	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:beans="http://www.springframework.org/schema/beans"
    	xmlns:context="http://www.springframework.org/schema/context" xmlns:tx="http://www.springframework.org/schema/tx"
    	xsi:schemaLocation="http://www.springframework.org/schema/beans 
    	http://www.springframework.org/schema/beans/spring-beans-3.0.xsd  
    	http://www.springframework.org/schema/mvc 
    	http://www.springframework.org/schema/mvc/spring-mvc-3.0.xsd
    	http://www.springframework.org/schema/context 
    	http://www.springframework.org/schema/context/spring-context-3.0.xsd
    	http://www.springframework.org/schema/tx
    	http://www.springframework.org/schema/tx/spring-tx-3.0.xsd">
    
    	<context:property-placeholder location="classpath:hibernate.properties" />
    
    	<!-- DispatcherServlet Context: defines this servlet's request-processing 
    		infrastructure -->
    
    	<!-- Enables the Spring MVC @Controller programming model -->
    	<annotation-driven />
    
    	<!-- Handles HTTP GET requests for /resources/** by efficiently serving 
    		up static resources in the ${webappRoot}/resources directory -->
    	<resources mapping="/resources/**" location="/resources/" />
    
    	<!-- Resolves views selected for rendering by @Controllers to .jsp resources 
    		in the /WEB-INF/views directory -->
    	<beans:bean
    		class="org.springframework.web.servlet.view.InternalResourceViewResolver">
    		<beans:property name="prefix" value="/WEB-INF/views/" />
    		<beans:property name="suffix" value=".jsp" />
    	</beans:bean>
    
    	<context:component-scan base-package="com.logicalideasJPA.persistence" />
    	<context:component-scan base-package="com.logicalideasJPA.controller" />
    	<context:component-scan base-package="com.logicalideasJPA.dao" />
    
    	<!-- Enables the Spring MVC @Controller programming model -->
    	<tx:annotation-driven transaction-manager="transactionManager" />
    	
    	<!-- Declare a JPA entityManagerFactory -->
    	<beans:bean id="entityManagerFactory"
    		class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean">
    		<beans:property name="dataSource" ref="dataSource" />
    		<beans:property name="packagesToScan" value="com.logicalideasJPA.persistence" />
    		<beans:property name="loadTimeWeaver">
    			<beans:bean class="org.springframework.instrument.classloading.InstrumentationLoadTimeWeaver" />
    		</beans:property>
    		<beans:property name="jpaVendorAdapter">
    			<beans:bean
    				class="org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter">
    				<beans:property name="showSql" value="true" />
    			</beans:bean>
    		</beans:property>
    	</beans:bean>
    
    	<!-- Declare a transaction manager -->
    	<beans:bean id="transactionManager"
    		class="org.springframework.orm.jpa.JpaTransactionManager">
    		<beans:property name="entityManagerFactory" ref="entityManagerFactory" />
    		<beans:property name="dataSource" ref="dataSource" />
    	</beans:bean>
    
    	<beans:bean id="dataSource"
    		class="org.springframework.jdbc.datasource.DriverManagerDataSource">
    		<beans:property name="driverClassName" value="${database.driver}" />
    		<beans:property name="url" value="${database.url}" />
    		<beans:property name="username" value="${database.user}" />
    		<beans:property name="password" value="${database.password}" />
    	</beans:bean>
    </beans:beans>
    contacts.java
    Code:
    @Repository("contactsDao")
    @Transactional(readOnly = true)
    public class ContactsImp implements ContactsDAO {
    
    	private EntityManager em;	
    	
    	@PersistenceContext
    	public void setEntityManager(EntityManager em) {
    		this.em = em;
    	}
    	
    	public boolean addNewContacts(Contacts contacts) {
    		em.getTransaction().begin();
    		em.persist(contacts);
    		em.getTransaction().commit();
    		return true;
    	}
    }
    Some help will be greatly appreciated.
    Many thanks

  • #2
    Are you aware of the Spring Data REST project, which exposes your JPA Repositories over HTTP for doing CRUD and querying?

    http://www.springsource.org/spring-data/rest

    Might be easier to integrate that with your app than building your own custom CRUD Controllers. You can tie into CRUD events in the ApplicationContext, as well, so you can add custom behaviour or validation to your application if you need to.

    An example app for it is here:

    https://github.com/springsource/spring-data-rest-webmvc

    Comment

    Working...
    X