Results 1 to 4 of 4

Thread: mappingJarLocations with deployed WAR on Tomcat

  1. #1
    Join Date
    Aug 2004
    Posts
    14

    Default mappingJarLocations with deployed WAR on Tomcat

    Hello All -

    I have a Jar that contains my data objects and their respective mapping files that I am trying to gain access to via mappingJarLocations as so:

    Code:
    	<bean id="sessionFactory" 
    		class="org.springframework.orm.hibernate.LocalSessionFactoryBean">
    		<property name="dataSource">
    			<ref bean="com.aquent.DATA_SOURCE" />
    		</property>
    		<property name="mappingJarLocations">
    			<list>
    				<value>WEB-INF/lib/myhbms.jar</value>		
    			</list>			
    		</property>
    		<property name="hibernateProperties">
    			<props>
    				<prop key="show_sql">true</prop>
    				<prop key="hibernate.dialect"> 
    					net.sf.hibernate.dialect.SybaseDialect</prop>
    				<prop key="hibernate.cglib.use_reflection_optimizer">true</prop>
    				<prop key="hibernate.query.substitutions">true 1, false 0</prop>
    			</props>
    		</property>
    	</bean>
    Unfortunately, when i create a WAR of this application, and attempt to deploy it using the Tomcat ANT deployment tasks, it seemingly cannot find the jar:

    Code:
    2004-12-06 17&#58;57&#58;35 Loading root WebApplicationContext
    2004-12-06 17&#58;57&#58;37 StandardContext&#91;/webservices&#93;&#58; Exception sending context initialized event to listener instance of class org.springframework.web.context.ContextLoaderListener
    org.springframework.beans.factory.BeanCreationException&#58; Error creating bean with name 'sessionFactory' defined in ServletContext resource &#91;/WEB-INF/applicationContext.xml&#93;&#58; Initialization of bean failed; nested exception is java.io.FileNotFoundException&#58; ServletContext resource &#91;/WEB-INF/lib/aquent-model.jar&#93; cannot be resolved to absolute file path - web application archive not expanded?
    java.io.FileNotFoundException&#58; ServletContext resource &#91;/WEB-INF/lib/myhbms.jar&#93; cannot be resolved to absolute file path - web application archive not expanded?
    	at org.springframework.web.context.support.ServletContextResource.getFile&#40;ServletContextResource.java&#58;111&#41;
    	at org.springframework.orm.hibernate.LocalSessionFactoryBean.afterPropertiesSet&#40;LocalSessionFactoryBean.java&#58;391&#41;
    	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods&#40;AbstractAutowireCapableBeanFactory.java&#58;990&#41;
    	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean&#40;AbstractAutowireCapableBeanFactory.java&#58;275&#41;
    	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean&#40;AbstractAutowireCapableBeanFactory.java&#58;193&#41;
    	at org.springframework.beans.factory.support.AbstractBeanFactory.getBean&#40;AbstractBeanFactory.java&#58;240&#41;
    	at org.springframework.beans.factory.support.AbstractBeanFactory.getBean&#40;AbstractBeanFactory.java&#58;163&#41;
    	at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons&#40;DefaultListableBeanFactory.java&#58;230&#41;
    	at org.springframework.context.support.AbstractApplicationContext.refresh&#40;AbstractApplicationContext.java&#58;304&#41;
    	at org.springframework.web.context.support.XmlWebApplicationContext.refresh&#40;XmlWebApplicationContext.java&#58;131&#41;
    	at org.springframework.web.context.ContextLoader.createWebApplicationContext&#40;ContextLoader.java&#58;167&#41;
    	at org.springframework.web.context.ContextLoader.initWebApplicationContext&#40;ContextLoader.java&#58;101&#41;
    	at org.springframework.web.context.ContextLoaderListener.contextInitialized&#40;ContextLoaderListener.java&#58;48&#41;
    	at org.apache.catalina.core.StandardContext.listenerStart&#40;StandardContext.java&#58;3276&#41;
    	at org.apache.catalina.core.StandardContext.start&#40;StandardContext.java&#58;3618&#41;
    	at org.apache.catalina.core.ContainerBase.addChildInternal&#40;ContainerBase.java&#58;821&#41;
    	at org.apache.catalina.core.ContainerBase.addChild&#40;ContainerBase.java&#58;807&#41;
    	at org.apache.catalina.core.StandardHost.addChild&#40;StandardHost.java&#58;595&#41;
    	at org.apache.catalina.core.StandardHostDeployer.addChild&#40;StandardHostDeployer.java&#58;700&#41;
    	at sun.reflect.NativeMethodAccessorImpl.invoke0&#40;Native Method&#41;
    	at sun.reflect.NativeMethodAccessorImpl.invoke&#40;NativeMethodAccessorImpl.java&#58;39&#41;
    	at sun.reflect.DelegatingMethodAccessorImpl.invoke&#40;DelegatingMethodAccessorImpl.java&#58;25&#41;
    	at java.lang.reflect.Method.invoke&#40;Method.java&#58;324&#41;
    	at org.apache.commons.beanutils.MethodUtils.invokeMethod&#40;MethodUtils.java&#58;252&#41;
    	at org.apache.commons.digester.SetNextRule.end&#40;SetNextRule.java&#58;256&#41;
    	at org.apache.commons.digester.Rule.end&#40;Rule.java&#58;276&#41;
    	at org.apache.commons.digester.Digester.endElement&#40;Digester.java&#58;1058&#41;
    	at org.apache.xerces.parsers.AbstractSAXParser.endElement&#40;Unknown Source&#41;
    	at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl.scanEndElement&#40;Unknown Source&#41;
    	at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl$FragmentContentDispatcher.dispatch&#40;Unknown Source&#41;
    	at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl.scanDocument&#40;Unknown Source&#41;
    	at org.apache.xerces.parsers.XML11Configuration.parse&#40;Unknown Source&#41;
    	at org.apache.xerces.parsers.DTDConfiguration.parse&#40;Unknown Source&#41;
    	at org.apache.xerces.parsers.XMLParser.parse&#40;Unknown Source&#41;
    	at org.apache.xerces.parsers.AbstractSAXParser.parse&#40;Unknown Source&#41;
    	at org.apache.commons.digester.Digester.parse&#40;Digester.java&#58;1567&#41;
    	at org.apache.catalina.core.StandardHostDeployer.install&#40;StandardHostDeployer.java&#58;385&#41;
    	at org.apache.catalina.core.StandardHost.install&#40;StandardHost.java&#58;819&#41;
    	at org.apache.catalina.servlets.ManagerServlet.deploy&#40;ManagerServlet.java&#58;562&#41;
    	at org.apache.catalina.servlets.ManagerServlet.doPut&#40;ManagerServlet.java&#58;413&#41;
    	at javax.servlet.http.HttpServlet.service&#40;HttpServlet.java&#58;763&#41;
    	at javax.servlet.http.HttpServlet.service&#40;HttpServlet.java&#58;853&#41;
    	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter&#40;ApplicationFilterChain.java&#58;247&#41;
    	at org.apache.catalina.core.ApplicationFilterChain.doFilter&#40;ApplicationFilterChain.java&#58;193&#41;
    	at org.apache.catalina.core.StandardWrapperValve.invoke&#40;StandardWrapperValve.java&#58;256&#41;
    	at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext&#40;StandardPipeline.java&#58;643&#41;
    	at org.apache.catalina.core.StandardPipeline.invoke&#40;StandardPipeline.java&#58;480&#41;
    	at org.apache.catalina.core.ContainerBase.invoke&#40;ContainerBase.java&#58;995&#41;
    	at org.apache.catalina.core.StandardContextValve.invoke&#40;StandardContextValve.java&#58;191&#41;
    	at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext&#40;StandardPipeline.java&#58;643&#41;
    	at org.apache.catalina.authenticator.AuthenticatorBase.invoke&#40;AuthenticatorBase.java&#58;551&#41;
    	at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext&#40;StandardPipeline.java&#58;641&#41;
    	at org.apache.catalina.valves.CertificatesValve.invoke&#40;CertificatesValve.java&#58;246&#41;
    	at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext&#40;StandardPipeline.java&#58;641&#41;
    	at org.apache.catalina.core.StandardPipeline.invoke&#40;StandardPipeline.java&#58;480&#41;
    	at org.apache.catalina.core.ContainerBase.invoke&#40;ContainerBase.java&#58;995&#41;
    	at org.apache.catalina.core.StandardContext.invoke&#40;StandardContext.java&#58;2422&#41;
    	at org.apache.catalina.core.StandardHostValve.invoke&#40;StandardHostValve.java&#58;180&#41;
    	at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext&#40;StandardPipeline.java&#58;643&#41;
    	at org.apache.catalina.valves.ErrorDispatcherValve.invoke&#40;ErrorDispatcherValve.java&#58;171&#41;
    	at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext&#40;StandardPipeline.java&#58;641&#41;
    	at org.apache.catalina.valves.ErrorReportValve.invoke&#40;ErrorReportValve.java&#58;163&#41;
    	at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext&#40;StandardPipeline.java&#58;641&#41;
    	at org.apache.catalina.core.StandardPipeline.invoke&#40;StandardPipeline.java&#58;480&#41;
    	at org.apache.catalina.core.ContainerBase.invoke&#40;ContainerBase.java&#58;995&#41;
    	at org.apache.catalina.core.StandardEngineValve.invoke&#40;StandardEngineValve.java&#58;174&#41;
    	at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext&#40;StandardPipeline.java&#58;643&#41;
    	at org.apache.catalina.valves.AccessLogValve.invoke&#40;AccessLogValve.java&#58;577&#41;
    	at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext&#40;StandardPipeline.java&#58;641&#41;
    	at org.apache.catalina.core.StandardPipeline.invoke&#40;StandardPipeline.java&#58;480&#41;
    	at org.apache.catalina.core.ContainerBase.invoke&#40;ContainerBase.java&#58;995&#41;
    	at org.apache.coyote.tomcat4.CoyoteAdapter.service&#40;CoyoteAdapter.java&#58;199&#41;
    	at org.apache.coyote.http11.Http11Processor.process&#40;Http11Processor.java&#58;828&#41;
    	at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.processConnection&#40;Http11Protocol.java&#58;700&#41;
    	at org.apache.tomcat.util.net.TcpWorkerThread.runIt&#40;PoolTcpEndpoint.java&#58;584&#41;
    	at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run&#40;ThreadPool.java&#58;683&#41;
    	at java.lang.Thread.run&#40;Thread.java&#58;536&#41;
    
    2004-12-06 17&#58;57&#58;37 StandardContext&#91;/webservices&#93;&#58; Context startup failed due to previous errors
    2004-12-06 17&#58;57&#58;37 Closing root WebApplicationContext
    Now, I am aware that at least in Tomcat 4.1.x (which I am using) that the getRealPath stuff in the ServletContextResource object won't work in a WAR file, but I noticed this JIRA issue:

    http://opensource.atlassian.com/proj...browse/SPR-409

    And i updated to 1.1.2 to ensure that I received the change that supposively repaired this problem - but obviously I am still having the same problem. Is there any RIGHT way to do this when the mappings are packaged in a JAR?

    Let me know what other information would help you help me.

    Ryan

  2. #2
    Join Date
    Aug 2004
    Location
    Southampton, UK
    Posts
    826

    Default

    Ryan,

    The fix you are describing was for a separate problem. When using programmatic configuration in Hibernate, Hibernate requires that you pass in File instance when attempting to add a JAR to the configuration. In order to do this Spring needs for JAR locations to be specified as real paths.

    You should trying using expanded deployment in Tomcat to get your code to work.

    Rob

  3. #3
    Join Date
    Aug 2004
    Posts
    14

    Default

    Rob -

    Thanks for your response. I noticed upon further evaluation of the JIRA entry that indeed it was for a different issue, sorry about that.

    I was under the impression though that expanded deployment was the default method in tomcat. A requirement of my project is the ability to remotely deploy thie war file (using ant). Probably shouldn't be aksing this here, and I'll understand if you ask me to take this question elsewhere - but if it is not possible to do this in coordination with using mappingJarLocations for my spring/hibernate configuration, do I have any better options besides using classpath:/path/to/mapping/file?

    Thanks again,

    Ryan

  4. #4
    Join Date
    Aug 2004
    Location
    Southampton, UK
    Posts
    826

    Default

    Ryan,

    To use the mappingJarLocations you need to specify a real file path, that can be resolved to an actual instance of File. This means a path that is either absolute, relative to the Tomcat working directory or is classpath relative.

    I find that for web applications the best option is to store mapping files in the classes directory and then use mappingResources to specify the list.

    Rob

Similar Threads

  1. Spring + Quartz + Tomcat = no shutdown
    By ahumphr in forum Container
    Replies: 7
    Last Post: Jul 5th, 2011, 11:45 AM
  2. Replies: 4
    Last Post: Jun 15th, 2005, 04:47 PM
  3. Tomcat [ERROR] SchemaExecute update
    By scraly in forum Web
    Replies: 0
    Last Post: Apr 26th, 2005, 02:59 AM
  4. Replies: 1
    Last Post: Mar 9th, 2005, 04:51 PM
  5. Replies: 2
    Last Post: Jan 1st, 2005, 01:15 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •