maven


Error in running a spring batch war file


I have created a spring batch project and created a war file for the same using maven
<modelVersion>4.0.0</modelVersion>
<groupId>com.batch</groupId>
<artifactId>dms-batch-app</artifactId>
<packaging>war</packaging>
<version>0.0.1-SNAPSHOT</version>
<name>dms-batch-app Maven Webapp</name>
<url>http://maven.apache.org</url>
<properties>
<jdk.version>1.8</jdk.version>
<spring.version>4.0.6.RELEASE</spring.version>
<spring.batch.version>3.0.7.RELEASE</spring.batch.version>
<quartz.version>1.8.5</quartz.version>
<build>
<finalName>dms-batch-app</finalName>
</build>
I am able to generate a war file but when i deploy on the tomcat server and start the tomcat application it throws the below error
SEVERE: Exception sending context initialized event to listener instance of class org.springframework.web.context.ContextLoaderListener
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.jdbc.datasource.init.DataSourceInitializer#0': Invocation of init method failed; nested exception is org.springframework.jdbc.datasource.init.CannotReadScriptException: Cannot read SQL script from ServletContext resource [/jar:file:org/springframework/batch/core/schema-drop-mysql.sql]; nested exception is java.io.FileNotFoundException: Could not open ServletContext resource [/jar:file:org/springframework/batch/core/schema-drop-mysql.sql]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1553)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:539)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:475)
at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:302)
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:228)
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:298)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:193)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:703)
at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:760)
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:482)
at org.springframework.web.context.ContextLoader.configureAndRefreshWebApplicationContext(ContextLoader.java:446)
at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:328)
at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:107)
at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:5068)
at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5584)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:147)
at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:899)
at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:875)
at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:652)
at org.apache.catalina.startup.HostConfig.deployDirectory(HostConfig.java:1260)
at org.apache.catalina.startup.HostConfig$DeployDirectory.run(HostConfig.java:2002)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at java.lang.Thread.run(Thread.java:745)
Caused by: org.springframework.jdbc.datasource.init.CannotReadScriptException: Cannot read SQL script from ServletContext resource [/jar:file:org/springframework/batch/core/schema-drop-mysql.sql]; nested exception is java.io.FileNotFoundException: Could not open ServletContext resource [/jar:file:org/springframework/batch/core/schema-drop-mysql.sql]
at org.springframework.jdbc.datasource.init.ScriptUtils.executeSqlScript(ScriptUtils.java:441)
at org.springframework.jdbc.datasource.init.ResourceDatabasePopulator.populate(ResourceDatabasePopulator.java:208)
at org.springframework.jdbc.datasource.init.CompositeDatabasePopulator.populate(CompositeDatabasePopulator.java:61)
at org.springframework.jdbc.datasource.init.DatabasePopulatorUtils.execute(DatabasePopulatorUtils.java:49)
at org.springframework.jdbc.datasource.init.DataSourceInitializer.execute(DataSourceInitializer.java:108)
at org.springframework.jdbc.datasource.init.DataSourceInitializer.afterPropertiesSet(DataSourceInitializer.java:93)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1612)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1549)
... 25 more
Caused by: java.io.FileNotFoundException: Could not open ServletContext resource [/jar:file:org/springframework/batch/core/schema-drop-mysql.sql]
at org.springframework.web.context.support.ServletContextResource.getInputStream(ServletContextResource.java:141)
at org.springframework.core.io.support.EncodedResource.getReader(EncodedResource.java:132)
at org.springframework.jdbc.datasource.init.ScriptUtils.readScript(ScriptUtils.java:278)
at org.springframework.jdbc.datasource.init.ScriptUtils.executeSqlScript(ScriptUtils.java:438)
... 32 more
I am connection to a database in the context xml as shown below
<jdbc:initialize-database data-source="dataSource">
<jdbc:script location="org/springframework/batch/core/schema-drop-mysql.sql" />
<jdbc:script location="org/springframework/batch/core/schema-mysql.sql" />
</jdbc:initialize-database>
But as per the error the war is not able to read from the jar file. Also i modified the same and kept the ddl scripts under resources folder , yet the war again goes to pick the ddl scripts from the jar file itself.
Kindly provide a solution to this.
And , what will be a better option , deploying spring batch project as a jar file or as a war file ?
Kindly help.
Try this versions:
<jdbc:script location="/org/springframework/batch/core/schema-drop-mysql.sql" />
<jdbc:script location="/org/springframework/batch/core/schema-mysql.sql" />
<jdbc:script location="classpath:/org/springframework/batch/core/schema-drop-mysql.sql" />
<jdbc:script location="classpath:/org/springframework/batch/core/schema-mysql.sql" />
<jdbc:script location="jar:file:org/springframework/batch/core/schema-drop-mysql.sql" />
<jdbc:script location="jar:file:org/springframework/batch/core/schema-mysql.sql" />

Related Links

mvn error--while building the project
Maven: Reporting warnings during regular compile, but not for generated sources
Is it possible to push a build directly to nexus instance running downstream as a proxy repository?
Maven war plugin copy arbitrary files
Is it possible to specify a dependency on a particular maven phase?
How fix all check style issues with Intellij Idea?
Add font to FOP through maven
How to handle Maven dependencies that are not yet added to mvnrepository?
Ensuring that a maven build is self-contained
Ignore maven plugin during a build
Running single integration test through terminal [duplicate]
Jenkins maven project failed ot build
How do you fix the missing 'javadoc' command issue when calling maven from IntelliJ?
Bamboo problems with maven release plugin
Tomcat 7 maven plugin complete configuration reference
Should all 3rd-party jar dependencies be introduced to Maven via 'import' scope?

Categories

HOME
cloud
vbscript
openstack
c#-4.0
server
heroku
single-sign-on
homebrew
bookshelf.js
malloc
rubygems
enterprise-library-5
node-pdfkit
static-libraries
windows-server-2012
interop
django-cms
lucene.net
introduction
dbext
wkwebview
cultureinfo
claims-based-identity
crystal-reports-2010
chromebook
librato
instant-messaging
key-value-observing
scorm2004
noraui
mpmediaquery
nssegmentedcontrol
wpf-controls
serve
retina-display
occlusion
squib
gzipstream
ncalc
dynamic-reports
janrain
eclipse-gef
menuitem
alphabet
rdfs
mu
mcafee
django-scheduler
android-textview
slicknav
database-optimization
nsviewcontroller
nessus
associative-array
google-places
feedback
wireshark-dissector
citrus-pay
operation
formatjs
offloading
c3
eol
comexception
braille
undefined-reference
page-layout
ms-project-server-2010
google-cloud-save
soundtouch
ora-00911
type-equivalence
cassini-dev
venn-diagram
objective-c-2.0
removeclass
asyncfileupload
eclipse-templates
boost-filesystem
php-parser
nsobject
tomcat-valve
locationlistener
imac
zend-translate
web-architecture
audio-capture
genealogy
wsdl.exe
lzh

Resources

Mobile Apps Dev
Database Users
javascript
java
csharp
php
android
MS Developer
developer works
python
ios
c
html
jquery
RDBMS discuss
Cloud Virtualization
Database Dev&Adm
javascript
java
csharp
php
python
android
jquery
ruby
ios
html
Mobile App
Mobile App
Mobile App