Tim Driven Development | Test until the fear goes away
Tim Cooke wrote:Doing a "mvn clean install" will build your application artefact and deploy it into your local .m2 repository. If you want to share it with other people in your organisation then you can use a product called Nexus which acts as your own Maven Repository. Otherwise if you want to make it available to the world then you can use SonaType to deploy it to Maven Central.
The secret of how to be miserable is to constantly expect things are going to happen the way that they are "supposed" to happen.
You can have faith, which carries the understanding that you may be disappointed. Then there's being a willfully-blind idiot, which virtually guarantees it.
Tim Holloway wrote:Please be kind enough not to repeat long quotes when posting. The longer I have to scroll past them, the less it is likely I'll bother to do so.
Webapps are not placed in "executable jars". In Java parlance, an "executable jar" is something that you can run by typing a console command such as "java -jar my.jar". A webapp must be in the form of a WAR or EAR. The exception to this would be if you were creating a Spring Boot jar, which contains an executable webserver as well as the webapp in it, but I don't think that this is what you're asking about, because that's a fairly advanced topic and people who do that usually already have experience in creating WARs.
To get Maven to produce a WAR, you must configure the maven WAR plugin into your Maven POM and have your source directories located in the places that Maven expects them to be. Maven will then compile code, copy resources, and build an exploded WAR under the project's "target" directory. Following that, it will ZIP up the exploded WAR into an actual WAR file (assuming you're using standard build options). The Maven install command then proceeds to copy this WAR file, along with Maven metadata to the .m2/repository directory.
Thus, the first thing you need to do is ensure that a proper WAR is being built in your target directory. You also need to be sure that the .m2 repository has enough free disk space and that it's writable by you (since you own it, it normally is).
It's possible to create a WAR and post it to a public directory where other users can access it, but that's an entirely different level of complexity.
The secret of how to be miserable is to constantly expect things are going to happen the way that they are "supposed" to happen.
You can have faith, which carries the understanding that you may be disappointed. Then there's being a willfully-blind idiot, which virtually guarantees it.
Tim Holloway wrote:A POM is a custom file that contains specifics about your project. Even if we were into doing other people's homework here, my POMs would be useless to you.
As I said earlier, however, a webapp is not a JAR, it's a WAR. You should be using the following goals instead of the jar:jar goal:
Or, more simply:
The secret of how to be miserable is to constantly expect things are going to happen the way that they are "supposed" to happen.
You can have faith, which carries the understanding that you may be disappointed. Then there's being a willfully-blind idiot, which virtually guarantees it.
Tim Holloway wrote:All Maven projects must have a POM file. Maven is a declarative-based build system where the declarations are elements of the POM. A POM can produce one and only one final artefact. Depending on the declarations contained within the POM, this artefact may be a JAR, a WAR, an EAR or in some cases, even a non-Java product such as a Red Hat RPM package.
Maven operates to achieve one or more goals. For example, the goal named "clean" deletes the project's "target" directory and its subsidiaries. The goal named "compile" compiles source code. Some goals implicitly trigger pre-requisite goals. For example, the "package" goal when run against a POM defining a WAR product will run the "compile" and "war:war" goals. You can also create plugin enhancements to Maven that can be triggered to act when certain goals are invoked. These plugins are called "mojos".
There are a number of public archetypes that can build prototoype POMs for web applications, including enhancements such as Hibernate. But a very basic WAR POM can be constructed using the sample command on this webpage:
https://maven.apache.org/plugins-archives/maven-archetype-plugin-1.0-alpha-7/examples/webapp.html
For detailed information on Maven, there are the documentation on maven.apache.org, although there are also several books on Maven.
I will repeat for third time: A webapp is a WAR not a JAR. There is nothing to do with JARs in this process.
The secret of how to be miserable is to constantly expect things are going to happen the way that they are "supposed" to happen.
You can have faith, which carries the understanding that you may be disappointed. Then there's being a willfully-blind idiot, which virtually guarantees it.
Tim Holloway wrote:NO, you are not building a [b]JAR, you're building a WAR .[/b]
The top of your POM (before the <build>) should resemble this:
Comal Rajagopalaratnam Muthukumar wrote:
Tim Holloway wrote:NO, you are not building a [b]JAR, you're building a WAR .[/b]
The top of your POM (before the <build>) should resemble this:
Hi
my sincere thanks for your valuable suggestion.that resulted ok but
for the tantalizing behaviour on use of war and jar,ie.if I put the word war
and compile ,I get a failure report while usge of jar was successfull as under .However jar so
produced is as usual non executable,inspite of the fact three special additional properties were included for the project by me
as webxml attribute but still invain in its enablence. But on the whole as you said already, i feel that war is rather
very combursome and hard .you may please have a glimpse especially for the pom of the follwing and
if possible do needfull correction.(as for example you may include the relevent webapp attributes to make it activate the war/jar
I also tried the same by writing lke the folowing but not so ok hence resulted in failure.)
<web-app>
url-pattern='servlet',servlet name ='invoker'
</web-app>
.
Atleast I am sure you would now be able to say authenticaly as to why is the jar always kept empty.What and where I should should add to
make it otherwise filledwith classes.
Thanks
As
CRMK
The secret of how to be miserable is to constantly expect things are going to happen the way that they are "supposed" to happen.
You can have faith, which carries the understanding that you may be disappointed. Then there's being a willfully-blind idiot, which virtually guarantees it.
Tim Holloway wrote:I'm sorry, but what you want and what J2EE demands are two different things. Software isn't something where you can just throw anything you desire in and it gets done and no amount of copying and pasting entire messages will make it otherwise.
J2EE web applications require a WAR. Building a JAR will not work. At all. Ever. As long as you insist that you must build a JAR, no one can help you.
Stephan van Hulst wrote:Comal, I suggest you reread all Tim's replies in this topic, read the Maven POM reference, and read online about how to build Java web applications.
You're repeating questions, and we're repeating answers.
Stephan van Hulst wrote:I'm glad you figured it out