Jump to content


Check out our Community Blogs

Register and join over 40,000 other developers!


Recent Status Updates

View All Updates

Photo
- - - - -

Problem With Url Mapping In Spring Hibernate Wb Application

springhibernate url tomcat spring-mvc hibernate

  • Please log in to reply
34 replies to this topic

#25 dlinx90

dlinx90

    CC Regular

  • Member
  • PipPipPip
  • 34 posts

Posted 26 April 2012 - 05:31 AM

For some reason I'm not entering the controller now. Any idea what the problem could be?
  • 0

#26 wim DC

wim DC

    Roar

  • Expert Member
  • PipPipPipPipPipPipPipPip
  • 2681 posts
  • Programming Language:Java, JavaScript, PL/SQL
  • Learning:Python

Posted 26 April 2012 - 05:37 AM

Did you change your dispatcher servlet name in the web.xml?
  • 0

#27 dlinx90

dlinx90

    CC Regular

  • Member
  • PipPipPip
  • 34 posts

Posted 26 April 2012 - 05:47 AM

this is what it is right now:

<servlet-mapping>
  <servlet-name>spring</servlet-name>
  <url-pattern>/mistest/*</url-pattern>
  </servlet-mapping>

the dispatcher servlet is "spring-servlet.xml"
  • 0

#28 wim DC

wim DC

    Roar

  • Expert Member
  • PipPipPipPipPipPipPipPip
  • 2681 posts
  • Programming Language:Java, JavaScript, PL/SQL
  • Learning:Python

Posted 26 April 2012 - 05:49 AM

Spring will look for <DispathcerServletName>-servlet.xml by default.
If you want a different name then do:
<servlet>
	    <servlet-name>dispatcherServlet</servlet-name>
	    <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
	    <init-param>
		    <param-name>contextConfigLocation</param-name>
		    <param-value>/WEB-INF/spring/mvc-config.xml</param-value>
	    </init-param>
    </servlet>

  • 0

#29 dlinx90

dlinx90

    CC Regular

  • Member
  • PipPipPip
  • 34 posts

Posted 26 April 2012 - 05:58 AM

Well this is what my web.xml file looks like now:

<?xml version="1.0" encoding="UTF-8"?>
<web-app id="WebApp_ID" version="2.4"
	  xmlns="http://java.sun.com/xml/ns/j2ee"
	  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
	  xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee
	  http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd">
   <servlet>
    <servlet-name>spring</servlet-name>
    <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
    <load-on-startup>1</load-on-startup>
  </servlet>
<servlet-mapping>
  <servlet-name>spring</servlet-name>
  <url-pattern>/mistest/*</url-pattern>
  </servlet-mapping>

<context-param>
	    <param-name>contextConfigLocation</param-name>
	    <param-value>/WEB-INF/applicationContext.xml</param-value>
    </context-param>

    <listener>
		    <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
    </listener>

</web-app>

Is there something i should change there? The dispatcher seems to be working fine but the controller isn't loading.
  • 0

#30 wim DC

wim DC

    Roar

  • Expert Member
  • PipPipPipPipPipPipPipPip
  • 2681 posts
  • Programming Language:Java, JavaScript, PL/SQL
  • Learning:Python

Posted 26 April 2012 - 06:00 AM

Is there something i should change there?

No.

And spring-servlet.xml is right next to web.xml, right?
  • 0

#31 dlinx90

dlinx90

    CC Regular

  • Member
  • PipPipPip
  • 34 posts

Posted 26 April 2012 - 06:03 AM

yes they are both in the WEB-INF folder
  • 0

#32 wim DC

wim DC

    Roar

  • Expert Member
  • PipPipPipPipPipPipPipPip
  • 2681 posts
  • Programming Language:Java, JavaScript, PL/SQL
  • Learning:Python

Posted 26 April 2012 - 06:11 AM

You'll need a component-scan of your controllers in the spring-servlet.xml

Even though I'm not sure why, as the spring-servlet.xml should be a child of the main application context.
  • 0

#33 dlinx90

dlinx90

    CC Regular

  • Member
  • PipPipPip
  • 34 posts

Posted 26 April 2012 - 06:28 AM

I added a component-scan to the spring-servlet.xml. now i get a 500 error when I try to access the webpage:

HTTP Status 500 -
type Exception report
message
description The server encountered an internal error () that prevented it from fulfilling this request.
exception
javax.servlet.ServletException: Servlet.init() for servlet spring threw exception
org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:100)
org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:541)
org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:383)
org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:243)
org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:188)
org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:288)
java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
java.lang.Thread.run(Unknown Source)
root cause
org.springframework.beans.factory.xml.XmlBeanDefinitionStoreException: Line 14 in XML document from ServletContext resource [/WEB-INF/spring-servlet.xml] is invalid; nested exception is org.xml.sax.SAXParseException; lineNumber: 14; columnNumber: 31; cvc-complex-type.2.4.c: The matching wildcard is strict, but no declaration can be found for element 'context:annotation-config'.
org.springframework.beans.factory.xml.XmlBeanDefinitionReader.doLoadBeanDefinitions(XmlBeanDefinitionReader.java:396)
org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:334)
org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:302)
org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:174)
org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:209)
org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:180)
org.springframework.web.context.support.XmlWebApplicationContext.loadBeanDefinitions(XmlWebApplicationContext.java:125)
org.springframework.web.context.support.XmlWebApplicationContext.loadBeanDefinitions(XmlWebApplicationContext.java:94)
org.springframework.context.support.AbstractRefreshableApplicationContext.refreshBeanFactory(AbstractRefreshableApplicationContext.java:131)
org.springframework.context.support.AbstractApplicationContext.obtainFreshBeanFactory(AbstractApplicationContext.java:522)
org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:436)
org.springframework.web.servlet.FrameworkServlet.configureAndRefreshWebApplicationContext(FrameworkServlet.java:631)
org.springframework.web.servlet.FrameworkServlet.createWebApplicationContext(FrameworkServlet.java:588)
org.springframework.web.servlet.FrameworkServlet.createWebApplicationContext(FrameworkServlet.java:645)
org.springframework.web.servlet.FrameworkServlet.initWebApplicationContext(FrameworkServlet.java:508)
org.springframework.web.servlet.FrameworkServlet.initServletBean(FrameworkServlet.java:449)
org.springframework.web.servlet.HttpServletBean.init(HttpServletBean.java:133)
javax.servlet.GenericServlet.init(GenericServlet.java:160)
org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:100)
org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:541)
org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:383)
org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:243)
org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:188)
org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:288)
java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
java.lang.Thread.run(Unknown Source)
root cause
org.xml.sax.SAXParseException; lineNumber: 14; columnNumber: 31; cvc-complex-type.2.4.c: The matching wildcard is strict, but no declaration can be found for element 'context:annotation-config'.
com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper.createSAXParseException(Unknown Source)
com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper.error(Unknown Source)
com.sun.org.apache.xerces.internal.impl.XMLErrorReporter.reportError(Unknown Source)
com.sun.org.apache.xerces.internal.impl.XMLErrorReporter.reportError(Unknown Source)
com.sun.org.apache.xerces.internal.impl.XMLErrorReporter.reportError(Unknown Source)
com.sun.org.apache.xerces.internal.impl.xs.XMLSchemaValidator$XSIErrorReporter.reportError(Unknown Source)
com.sun.org.apache.xerces.internal.impl.xs.XMLSchemaValidator.reportSchemaError(Unknown Source)
com.sun.org.apache.xerces.internal.impl.xs.XMLSchemaValidator.handleStartElement(Unknown Source)
com.sun.org.apache.xerces.internal.impl.xs.XMLSchemaValidator.emptyElement(Unknown Source)
com.sun.org.apache.xerces.internal.impl.XMLNSDocumentScannerImpl.scanStartElement(Unknown Source)
com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl$FragmentContentDriver.next(Unknown Source)
com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerImpl.next(Unknown Source)
com.sun.org.apache.xerces.internal.impl.XMLNSDocumentScannerImpl.next(Unknown Source)
com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanDocument(Unknown Source)
com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(Unknown Source)
com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(Unknown Source)
com.sun.org.apache.xerces.internal.parsers.XMLParser.parse(Unknown Source)
com.sun.org.apache.xerces.internal.parsers.DOMParser.parse(Unknown Source)
com.sun.org.apache.xerces.internal.jaxp.DocumentBuilderImpl.parse(Unknown Source)
org.springframework.beans.factory.xml.DefaultDocumentLoader.loadDocument(DefaultDocumentLoader.java:75)
org.springframework.beans.factory.xml.XmlBeanDefinitionReader.doLoadBeanDefinitions(XmlBeanDefinitionReader.java:388)
org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:334)
org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:302)
org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:174)
org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:209)
org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:180)
org.springframework.web.context.support.XmlWebApplicationContext.loadBeanDefinitions(XmlWebApplicationContext.java:125)
org.springframework.web.context.support.XmlWebApplicationContext.loadBeanDefinitions(XmlWebApplicationContext.java:94)
org.springframework.context.support.AbstractRefreshableApplicationContext.refreshBeanFactory(AbstractRefreshableApplicationContext.java:131)
org.springframework.context.support.AbstractApplicationContext.obtainFreshBeanFactory(AbstractApplicationContext.java:522)
org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:436)
org.springframework.web.servlet.FrameworkServlet.configureAndRefreshWebApplicationContext(FrameworkServlet.java:631)
org.springframework.web.servlet.FrameworkServlet.createWebApplicationContext(FrameworkServlet.java:588)
org.springframework.web.servlet.FrameworkServlet.createWebApplicationContext(FrameworkServlet.java:645)
org.springframework.web.servlet.FrameworkServlet.initWebApplicationContext(FrameworkServlet.java:508)
org.springframework.web.servlet.FrameworkServlet.initServletBean(FrameworkServlet.java:449)
org.springframework.web.servlet.HttpServletBean.init(HttpServletBean.java:133)
javax.servlet.GenericServlet.init(GenericServlet.java:160)
org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:100)
org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:541)
org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:383)
org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:243)
org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:188)
org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:288)
java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
java.lang.Thread.run(Unknown Source)

  • 0

#34 wim DC

wim DC

    Roar

  • Expert Member
  • PipPipPipPipPipPipPipPip
  • 2681 posts
  • Programming Language:Java, JavaScript, PL/SQL
  • Learning:Python

Posted 26 April 2012 - 06:36 AM

missing xsd on top of the XML
  • 0

#35 dlinx90

dlinx90

    CC Regular

  • Member
  • PipPipPip
  • 34 posts

Posted 26 April 2012 - 06:45 AM

fixed it but now I'm back to this error :

HTTP Status 404 -

type Status report
message
description The requested resource () is not available.

I don't see why I'm not entering my controller.. could there be something wrong with my build?

<?xml version="1.0"?>
<project name="MIS" default="build" basedir=".">
<!-- Configure the build properties file which contains properties to access the Manager application -->
<property file="build.properties"/>

<!-- Configure the directory into which the web application is built -->
<property name="build.dir" value="${basedir}/build"/>

<!-- Configure source directory that contains the java code -->
<property name="src.dir" value="src"/>

<!-- Configure web directory -->
<property name="web.dir" value="WebContent"/>

<!--Configure the context path for the application -->
<property name="path" value="/mistest"/>

<!-- Add all the lib files inside the WebContent/WEB-INF/lib directory as well as the tomcat lib files to the classpath -->
<path id="master-classpath">
  <fileset dir="${web.dir}/WEB-INF/lib">
   <include name="*.jar"/>
  </fileset>
  <fileset dir="${appserver.lib}"> <!-- Apache Tomcat lib. ${appserver.lib} comes from the build.properties file -->
   <include name="servlet*.jar"/>
  </fileset>
  <pathelement path="${build.dir}"/>
</path>
<!-- Configure Catalina jars that are needed for tomcat -->
<path id="catalina-ant-classpath">
  <fileset dir="${appserver.lib}">
   <include name="catalina-ant.jar"/>
  </fileset>
</path>

<!--Configure the custom Ant tasks for the Manager application -->
<taskdef name="deploy" classname="org.apache.catalina.ant.DeployTask">
  <classpath refid="catalina-ant-classpath"/>
</taskdef>
<taskdef name="undeploy" classname="org.apache.catalina.ant.UndeployTask">
  <classpath refid="catalina-ant-classpath"/>
</taskdef>
<taskdef name="start" classname="org.apache.catalina.ant.StartTask">
  <classpath refid="catalina-ant-classpath"/>
</taskdef>
<taskdef name="stop" classname="org.apache.catalina.ant.StopTask">
  <classpath refid="catalina-ant-classpath"/>
</taskdef>
<taskdef name="reload" classname="org.apache.catalina.ant.ReloadTask">
  <classpath refid="catalina-ant-classpath"/>
</taskdef>
<!-- Executable Targets -->
<target name="init" description="Creates build directory">
  <mkdir dir="${build.dir}"/>
</target>

<target name="build" depends="init" description="Compiles the java files in the main source tree and creates a war file">
  <javac destdir="${build.dir}" debug="true" srcdir="${src.dir}">
   <classpath refid="master-classpath"/>
  </javac>
	    <war destfile="${build.dir}/${path}.war"
		 webxml="${web.dir}/WEB-INF/web.xml">
		 <fileset dir="${web.dir}">
			 <include name="**/*.*"/>
		    </fileset>
	    </war>
</target>

<target name="deploy" depends="build" description="Install web application">
  <deploy url="${tomcat.manager.url}"
    username="${tomcat.manager.username}"
    password="${tomcat.manager.password}"
    path="${path}"
    war="${build.dir}${path}.war"/>
</target>

<target name="undeploy" description="Remove web application">
  <undeploy url="${tomcat.manager.url}"
    username="${tomcat.manager.username}"
    password="${tomcat.manager.password}"
    path="${path}"/>
</target>

<target name="start" description="Start web application in Tomcat">
  <start url="${tomcat.manager.url}"
    username="${tomcat.manager.username}"
    password="${tomcat.manager.password}"
    path="${path}"/>
</target>

<target name="stop" description="Stop web application in Tomcat">
  <stop url="${tomcat.manager.url}"
    username="${tomcat.manager.username}"
    password="${tomcat.manager.password}"
    path="${path}"/>
</target>

<target name="reload" depends="deploy" description="Reload web application">
  <reload url="${tomcat.manager.url}"
    username="${tomcat.manager.username}"
    password="${tomcat.manager.password}"
    path="${path}"/>
</target>

</project>

to start the application in tomcat all i have to use is build+deploy
  • 0





Also tagged with one or more of these keywords: springhibernate, url, tomcat, spring-mvc, hibernate

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download