stephenconnolly wrote:
>
> I'll see if I can share a bit more specific code...
>
With pleasure !
I've in fact a "standard" web application, done through eclipse with
m2eclipse.
I've a launcher done this way (which I put in the src/main/java for
packaging purposes) :
package boot;
import org.mortbay.jetty.Connector;
import org.mortbay.jetty.Server;
import org.mortbay.jetty.bio.SocketConnector;
import org.mortbay.jetty.webapp.WebAppContext;
public class JettyMain
{
public static void main(final String[] args) throws Exception
{
Server server = new Server();
SocketConnector connector = new SocketConnector();
// Set some timeout options to make debugging easier.
connector.setMaxIdleTime(1000 * 60 * 60);
connector.setSoLingerTime(-1);
connector.setPort(8080);
server.setConnectors(new Connector[]
{ connector });
WebAppContext bb = new WebAppContext();
bb.setServer(server);
bb.setContextPath("/");
// TODO : update once picked up
bb.setWar("");
// START JMX SERVER
// MBeanServer mBeanServer =
ManagementFactory.getPlatformMBeanServer();
// MBeanContainer mBeanContainer = new MBeanContainer(mBeanServer);
// server.getContainer().addEventListener(mBeanContainer);
// mBeanContainer.start();
server.addHandler(bb);
try
{
System.out.println(">>> STARTING EMBEDDED JETTY SERVER, PRESS
ANY KEY TO STOP");
server.start();
System.in.read();
System.out.println(">>> STOPPING EMBEDDED JETTY SERVER");
while (System.in.available() == 0)
{
Thread.sleep(5000);
}
server.stop();
server.join();
}
catch (Exception e)
{
e.printStackTrace();
}
}
}
>From eclipse, running this class as a Java application nicely starts my
application. I would like to able to package this application in a
standalone jar using jetty to run. Something which would be started through
java -jar file.war (file.jar would be fine as well lol). And that's where I
struggle.
Having found this thread, I used the sample maven config given above this
way :
<?xml version="1.0" encoding="UTF-8"?>
<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
http://maven.apache.org/xsd/maven-4.0.0.xsd"
xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<modelVersion>4.0.0</modelVersion>
<groupId>____</groupId>
<artifactId>____</artifactId>
<packaging>war</packaging>
<dependencies>
<!-- your dependencies... don't forget jetty -->
</dependencies>
<build>
<plugins>
<plugin>
<artifactId>maven-war-plugin</artifactId>
<configuration>
<archive>
<manifest>
<mainClass>boot.JettyMain</mainClass>
</manifest>
</archive>
</configuration>
</plugin>
<plugin>
<artifactId>maven-dependency-plugin</artifactId>
<executions>
<execution>
<phase>generate-resources</phase>
<goals>
<goal>unpack-dependencies</goal>
</goals>
<configuration>
<includeTypes>jar</includeTypes>
<outputDirectory>${project.build.directory}/${project.build.finalName}</outputDirectory>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
I then do mvn clean install, then cd target then java -jar mywar.war
Since I've tried to put the boot package in a separate project but it
doesn't help
++
--
View this message in context:
http://n2.nabble.com/Using-custom-assembly-descriptor-tp3189204p3699602.html
Sent from the maven users mailing list archive at Nabble.com.
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]