[
Date Prev][
Date Next][
Thread Prev][
Thread Next][
Date Index][
Thread Index]
[
List Home]
[jetty-users] Jetty Maven Plugin: How can I add Jars to "lib/ext"?
|
I need to have additional libraries/jars available to the Jetty Maven
Plugin when starting it with "mvn jetty:run".
With the Jetty "start.jar" mechanism, I simply have to put the
required libraries into Jetty's directory "lib/ext" and they will be
added to Jetty automatically (as pointed out in
http://wiki.eclipse.org/Jetty/Reference/Jetty_Classloading#Adding_Extra_Classpaths_to_Jetty
).
For an example, I need "MySQL Connector/J" at Jetty startup time. With
the "start.jar" mechanism, I've put
"mysql-connector-java-5.1.22-bin.jar" into "lib/ext". Then my setup
looks like the following and works smoothly.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
~~~~~~~~~~~~~~~~~ begin smoothly working start.jar example ~~~~~~~~~~~~~~~~~
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
================= begin startup command =================
java -jar start.jar
================= end startup command =================
================= begin start.ini =================
OPTIONS=All
etc/jetty.xml
etc/jetty-plus.xml
etc/jetty-deploy.xml
etc/jetty-webapps.xml
etc/jetty-contexts.xml
etc/jetty-myBlaDatabase.xml
================= end start.ini =================
================= begin etc/jetty-myBlaDatabase.xml =================
<?xml version="1.0"?>
<!DOCTYPE Configure PUBLIC "-//Jetty//Configure//EN"
"http://www.eclipse.org/jetty/configure.dtd">
<Configure id="Server" class="org.eclipse.jetty.server.Server">
..........
<New id="jdbc-bla" class="org.eclipse.jetty.plus.jndi.Resource">
<Arg></Arg>
<Arg>jdbc/bla</Arg>
<Arg>
<New class="com.mysql.jdbc.jdbc2.optional.MysqlConnectionPoolDataSource">
<Set name="Url">jdbc:mysql://localhost:3306/bla</Set>
<Set name="User">root</Set>
<Set name="Password">oooops</Set>
</New>
</Arg>
</New>
..........
</Configure>
================= end etc/jetty-myBlaDatabase.xml=================
================= begin web.xml =================
<?xml version="1.0" encoding="UTF-8"?>
<web-app version="3.0" xmlns="http://java.sun.com/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee
http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd">
..........
<resource-ref>
<description>Primary database</description>
<res-ref-name>jdbc/bla</res-ref-name>
<res-type>javax.sql.DataSource</res-type>
<res-auth>Container</res-auth>
</resource-ref>
..........
</web-app>
================= end web.xml =================
================= begin SomeJavaFile.java =================
..........
DataSource dataSource = null;
InitialContext ic;
try {
ic = new InitialContext();
geeshenkDs =
(DataSource)ic.lookup("java:comp/env/jdbc/bla");
} catch (NamingException e) {
e.printStackTrace();
}
..........
================= end SomeJavaFile.java =================
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
~~~~~~~~~~~~~~~~~ end smoothly working start.jar example ~~~~~~~~~~~~~~~~~
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
How can I make "mysql-connector-java-5.1.22-bin.jar" available to
Jetty when using the Jetty Maven Plugin?
Thanks!