MoinMoin Logo
  • Comments
  • Immutable Page
  • Menu
    • Navigation
    • RecentChanges
    • FindPage
    • Local Site Map
    • Help
    • HelpContents
    • HelpOnMoinWikiSyntax
    • Display
    • Attachments
    • Info
    • Raw Text
    • Print View
    • Edit
    • Load
    • Save
  • Login

Navigation

  • Start
  • Sitemap

Upload page content

You can upload content for the page named below. If you change the page name, you can also upload content for another page. If the page name is empty, we derive the page name from the file name.

File to load page content from
Page name
Comment

Revision 8 as of 2013-12-25 20:14:05
  • Java
  • ApacheMaven

Apache Maven

Maven is a software project management and comprehension tool. Based on the concept of a Project Object Model (POM), Maven can manage a project's build, reporting and documentation from a central piece of information.

Requires Java.

Slackbuild

  • su
  • cd /tmp
  • wget http://slackbuilds.org/slackbuilds/14.0/development/apache-maven.tar.gz

  • tar xvzf apache-maven.tar.gz
  • cd apache-maven
  • wget http://archive.apache.org/dist/maven/binaries/apache-maven-3.0.4-bin.tar.gz

  • ./apache-maven.SlackBuild

  • installpkg /tmp/apache-maven-3.0.4-noarch-1_SBo.tgz

Package: apache-maven-3.0.4-noarch-1_SBo.tgz

User settings

You can specify your user configuration in ${user.home}/.m2/settings.xml. The default location of your local repository is ${user.home}/.m2/repository/.

Maven sample web app for JBoss AS 7.1.1

Web application creation

  • cd ~
  • mvn archetype:generate -DgroupId=org.allowed.bitarus -DartifactId=WebApp -DarchetypeArtifactId=maven-archetype-webapp -DinteractiveMode=false

  • cd WebApp

  • mvn clean
  • mvn compile
  • mvn package

Deploy web application on jboss AS 7.1.1

  • /opt/jboss-as-7.1.1.Final/bin/standalone.sh
  • http://localhost:9990

  • admin 12345678
  • Manage deployments
  • Add content
  • Choose file ~/WebApp/target/WebApp.war
  • next, save
  • enable , confirm
  • http://localhost:8080/WebApp/

Add REST and servlet support

  • url http://localhost:8080/WebApp/rest/testSvc/paramx

Add dependencies to pom.xml, jboss AS 7.1.1 JAX-RS

   1 <dependency>
   2     <groupId>org.jboss.resteasy</groupId>
   3     <artifactId>resteasy-jaxrs</artifactId>
   4     <version>2.2.1.GA</version>
   5     <scope>provided</scope>
   6 </dependency>
   7 <dependency>
   8     <groupId>javax</groupId>
   9     <artifactId>javaee-web-api</artifactId>
  10     <version>6.0</version>
  11     <scope>provided</scope>
  12 </dependency>

In JBoss 5.1.0 comment the scope provided for resteasy, to add to WEB-INF folder the required libraries for resteasy.

Create source code for REST service and servlet

File src/main/java/org/allowed/bitarus/TestService.java

URL http://localhost:8080/WebApp/rest/testSvc/asddddd

   1 package org.allowed.bitarus;
   2 
   3 import javax.ws.rs.GET;
   4 import javax.ws.rs.Path;
   5 import javax.ws.rs.PathParam;
   6 import javax.ws.rs.core.Response;
   7 
   8 @Path("/testSvc")
   9 public class TestService {
  10 
  11     @GET
  12     @Path("/{param}")
  13     public Response getMsg(@PathParam("param") String msg) {
  14         String out = String.format("testSvc returns %s", msg);
  15         return Response.status(200).entity(out).build();
  16     }
  17 
  18 }

File src/main/java/org/allowed/bitarus/Servletx.java

http://localhost:8080/WebApp/servletxxx

   1 package org.allowed.bitarus;
   2 
   3 import javax.servlet.*;
   4 import javax.servlet.http.*;
   5 import java.io.*;
   6 
   7 public class Servletx extends HttpServlet{
   8     public void service(HttpServletRequest req, HttpServletResponse res) throws IOException
   9     {
  10         res.setContentType("text/html");
  11         PrintWriter out = res.getWriter();
  12         out.println("<html><head><title>Hello World!</title></head>");
  13         out.println("<body><h1>Hello World!</h1></body></html>");
  14     }
  15 }

Configure web app

File src/main/webapp/WEB-INF/web.xml

   1 <web-app>
   2   <display-name>Archetype Created Web Application</display-name>
   3   <context-param>
   4     <param-name>resteasy.scan</param-name>
   5     <param-value>true</param-value>
   6   </context-param>
   7  
   8   <context-param>
   9     <param-name>resteasy.servlet.mapping.prefix</param-name>
  10     <param-value>/rest</param-value>
  11   </context-param>
  12 
  13   <servlet>
  14     <servlet-name>resteasy-servlet</servlet-name>
  15     <servlet-class>org.jboss.resteasy.plugins.server.servlet.HttpServletDispatcher</servlet-class>
  16   </servlet>
  17   <servlet-mapping>
  18     <servlet-name>resteasy-servlet</servlet-name>
  19     <url-pattern>/rest/*</url-pattern>
  20   </servlet-mapping>
  21 
  22   <servlet>
  23     <servlet-name>Servletx</servlet-name>
  24     <servlet-class>org.allowed.bitarus.Servletx</servlet-class>
  25   </servlet>
  26   <servlet-mapping>
  27     <servlet-name>Servletx</servlet-name>
  28     <url-pattern>/servletxxx</url-pattern> 
  29   </servlet-mapping>
  30 </web-app>
  • MoinMoin Powered
  • Python Powered
  • GPL licensed
  • Valid HTML 4.01