[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [jetty-users] Jetty Maven Plugin: How can I add Jars to "lib/ext"?

Perfect! Thanks Jesse, this worked!

Below I provide my working pom.xml snippet. The relevant stuff is:
adding a <dependencies> section to the jetty-maven-plugin <plugin>
section.

======= begin pom.xml =======

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0";
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";
	xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
http://maven.apache.org/maven-v4_0_0.xsd";>
	<modelVersion>4.0.0</modelVersion>
......
	<packaging>war</packaging>
	<version>1.0.0</version>
	<properties>
		<jetty-maven-plugin-version>8.1.5.v20120716</jetty-maven-plugin-version>
		<mysql-connector-java-version>5.1.21</mysql-connector-java-version>
	</properties>
......
	<dependencies>
......
		<!-- MySQL Connector/J -->
		<dependency>
			<groupId>mysql</groupId>
			<artifactId>mysql-connector-java</artifactId>
			<version>${mysql-connector-java-version}</version>
			<scope>provided</scope>
		</dependency>
	</dependencies>

	<build>
......
		<plugins>
......
			<plugin>
				<groupId>org.mortbay.jetty</groupId>
				<artifactId>jetty-maven-plugin</artifactId>
				<version>${jetty-maven-plugin-version}</version>
				<dependencies>
					<dependency>
						<groupId>mysql</groupId>
						<artifactId>mysql-connector-java</artifactId>   <!-- needed for
providing "mvn jetty:run" Jetty Server with the MySQL Connector/J
implementation -->
						<version>${mysql-connector-java-version}</version>
					</dependency>
				</dependencies>
				<configuration>
					<jettyXml>pom-xml-relative/path/to/jetty-myBlaDatabase.xml</jettyXml>
				</configuration>
			</plugin>
		</plugins>
	</build>
......
</project>

========= end pom.xml =======

Have a great week!

On Mon, Sep 17, 2012 at 5:44 PM, Jesse McConnell
<jesse.mcconnell@xxxxxxxxx> wrote:
> declare them as dependencies of the jetty plugin itself, they will
> then be downloaded and added into the classpath of the plugin
> execution
>
> cheers,
> jesse
>
> --
> jesse mcconnell
> jesse.mcconnell@xxxxxxxxx
>
>
> On Mon, Sep 17, 2012 at 10:13 AM, Gerrit Hübbers
> <gerrit.huebbers@xxxxxxxxx> wrote:
>> 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!
>> _______________________________________________
>> jetty-users mailing list
>> jetty-users@xxxxxxxxxxx
>> https://dev.eclipse.org/mailman/listinfo/jetty-users
> _______________________________________________
> jetty-users mailing list
> jetty-users@xxxxxxxxxxx
> https://dev.eclipse.org/mailman/listinfo/jetty-users