I have created a spring project. I need to create a jar file of this project. I can able to create a jar file but applicationcontext.xml is placed outside when i open the jar. but where i need to exactly place the applicationcontext.xml in the jar, so that it gets loaded and I can use the spring bean inside the jar.
How to specify in pom.xml, that applicationcontext.xml should be placed inside the META-INF folder?
You need to place your applicationcontext.xml file under the src/main/resources/META-INF folder in your maven project.
I put it here -
src/main/resources/
and it worked
Related
I would like to deploy a mock service developed with SoapUI. I have SoapUI project, web.xml and now I would like to add them to WAR archive. I'm using Gradle to prepare this WAR file.
My code below:
war {
archiveName 'mock.war'
webXml file ('src/main/webapp/web.xml')
}
Default filesystem of produced archive is:
META-INF
WEB-INF
lib
some libs...
classes (this folder I would like to rename to 'soapui')
some files...
web.xml
Is there any possibility, to change the name of 'classes' folder?
Thanks in advance,
Patryk
We've got many beans.xml and struts.xml files located in src/main/java folder. When mvn package is finished, I couldn't find those files in WEB-INF/classes folder.
Is it wrong to put xml files in src/main/java? Should I put them in src/main/resources instead? Or should I modify the pom.xml?
The standard is to place them into src/main/resources They will end up going into WEB-INF/classes when the war is packaged by maven.
I am building a webapp through Gradle's war plugin. In order to disable Tomcat's session persistence, I need to place the file context.xml in the META-INF directory of the war's root.
I attempted the following:
Create the file src/main/webapp/META-INF/context.xml of the main project
Create the file src/main/resources/META-INF/context.xml of the main project
However, when I build the project using gradle clean war, the produced war file contains a META-INF with only a MANIFEST.MF in it. It is as if my directory gets overridden.
How do I place context.xml in the war?
src/main/webapp/META-INF/context.xml is correct and works fine for me. Chances are that you went wrong somewhere, or that there is a problem with your build script.
I have a jar file (kept in jboss-home/server/default/lib) and a war file (kept in jboss-home/server/default/deploy). The jar file contains a servlet which initializes the spring context. The servlet is initialized from the war file.
The problem is that the #Component (and #Service, etc) annotations in the jar file are not scanned. It gives NoSuchBeanDefinitionException error. I have declared the following in context xml.
<context:component-scan base-package="com.abc.mypack" />
I have also selected "Add directory entries" when building the jar using eclipse.
If I change to xml based configuration, it works. Or, if I move the jar file to WEB-INF/lib of the war file, it works.
Is there a way to scan the jboss server lib directory for components?
I am using spring 3.1 and Jboss AS 6.
Those annotations don't scan libraries. They scan packages, which means that the libraries containing those packages need to be on the classpath.
Most-likely the libraries you're referring to are on different classloaders.
I would suggest packaging the jar within the war's WEB-INF/lib directory.
I am using Maven for creating my project structure. The following is the way I am doing
Generate Archetype
Have the following modules - Ear, War and WarSource (I am deleting the src, ejb and jar folders)
So my EAR will have 2 modules - War and WarSource which inturn have src/main/java and src/main/resource folders
Question is - where should my application context reside so that I avoid the File Not Found error during runtime.
Thanks
If you're using spring mvc it will be in the war src/main/webapp/WEB-INF/ directory. Also if you're using spring you may not even need an ear file, you should read up on that to be sure you're not adding unnecessary complexity.