You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomee.apache.org by sgjava <sg...@gmail.com> on 2015/08/10 18:29:45 UTC

Example of org.apache.tomee.embedded.Container and deployClasspathAsWebApp

I'm using Maven to build my project and the exploded WAR is in the target
directory. The few examples I ran across explode the war file, etc. Is there
a good example of using container.deployClasspathAsWebApp considering Maven
is used?



--
View this message in context: http://tomee-openejb.979440.n4.nabble.com/Example-of-org-apache-tomee-embedded-Container-and-deployClasspathAsWebApp-tp4675809.html
Sent from the TomEE Users mailing list archive at Nabble.com.

Re: Example of org.apache.tomee.embedded.Container and deployClasspathAsWebApp

Posted by Romain Manni-Bucau <rm...@gmail.com>.
If it can help:
https://github.com/apache/tomee/blob/master/tomee/tomee-embedded/src/test/java/org/apache/tomee/embedded/ClasspathAsWebappTest.java
and
https://github.com/apache/tomee/blob/8c0d055b1ff9741ca2d184107ea2bc95c91ad28f/tomee/tomee-embedded/src/main/java/org/apache/tomee/embedded/junit/TomEEEmbeddedRule.java
can help


Romain Manni-Bucau
@rmannibucau <https://twitter.com/rmannibucau> |  Blog
<http://rmannibucau.wordpress.com> | Github <https://github.com/rmannibucau> |
LinkedIn <https://www.linkedin.com/in/rmannibucau> | Tomitriber
<http://www.tomitribe.com>

2015-08-10 9:52 GMT-07:00 sgjava <sg...@gmail.com>:

> Here's what I came up with in case someone else needs it (I'll add users
> and
> roles next):
>
>     /**
>      * TomEE container.
>      */
>     private static Container container;
>     /**
>      * TomEE container configuration.
>      */
>     private static Configuration configuration;
>
>     /**
>      * Start TomEE container.
>      */
>     @BeforeClass
>     public static void setUpClass() {
>         try {
>             log.info("setUpClass()");
>             configuration = new Configuration().randomHttpPort();
>             container = new Container();
>             container.setup(configuration);
>             container.start();
>             container.deployClasspathAsWebApp("/", null);
>             log.debug(String.format("TomEE embedded started on %s:%s",
>                     configuration.getHost(), configuration.getHttpPort()));
>         } catch (Exception e) {
>             log.error(e.getMessage());
>         }
>     }
>
>     /**
>      * Close TomEE container.
>      */
>     @AfterClass
>     public static void tearDownClass() {
>         try {
>             log.info("tearDownClass()");
>             container.stop();
>         } catch (Exception e) {
>             log.error(e.getMessage());
>         }
>     }
>
>
>
>
>
> --
> View this message in context:
> http://tomee-openejb.979440.n4.nabble.com/Example-of-org-apache-tomee-embedded-Container-and-deployClasspathAsWebApp-tp4675809p4675811.html
> Sent from the TomEE Users mailing list archive at Nabble.com.
>

Re: Example of org.apache.tomee.embedded.Container and deployClasspathAsWebApp

Posted by sgjava <sg...@gmail.com>.
Here's what I came up with in case someone else needs it (I'll add users and
roles next):

    /**
     * TomEE container.
     */
    private static Container container;
    /**
     * TomEE container configuration.
     */
    private static Configuration configuration;

    /**
     * Start TomEE container.
     */
    @BeforeClass
    public static void setUpClass() {
        try {
            log.info("setUpClass()");
            configuration = new Configuration().randomHttpPort();
            container = new Container();
            container.setup(configuration);
            container.start();
            container.deployClasspathAsWebApp("/", null);
            log.debug(String.format("TomEE embedded started on %s:%s",
                    configuration.getHost(), configuration.getHttpPort()));
        } catch (Exception e) {
            log.error(e.getMessage());
        }
    }

    /**
     * Close TomEE container.
     */
    @AfterClass
    public static void tearDownClass() {
        try {
            log.info("tearDownClass()");
            container.stop();
        } catch (Exception e) {
            log.error(e.getMessage());
        }
    }





--
View this message in context: http://tomee-openejb.979440.n4.nabble.com/Example-of-org-apache-tomee-embedded-Container-and-deployClasspathAsWebApp-tp4675809p4675811.html
Sent from the TomEE Users mailing list archive at Nabble.com.

Re: Example of org.apache.tomee.embedded.Container and deployClasspathAsWebApp

Posted by Romain Manni-Bucau <rm...@gmail.com>.
Hi
No good afaik, happy to review a patch but
https://github.com/rmannibucau/canjs-tomee-sample/blob/master/pom.xml is
public at least.
Le 10 août 2015 09:33, "sgjava" <sg...@gmail.com> a écrit :

> I'm using Maven to build my project and the exploded WAR is in the target
> directory. The few examples I ran across explode the war file, etc. Is
> there
> a good example of using container.deployClasspathAsWebApp considering Maven
> is used?
>
>
>
> --
> View this message in context:
> http://tomee-openejb.979440.n4.nabble.com/Example-of-org-apache-tomee-embedded-Container-and-deployClasspathAsWebApp-tp4675809.html
> Sent from the TomEE Users mailing list archive at Nabble.com.
>