Discussion:
[jetty-user] Jetty Maven Plugin, run-war, and JNDI/jetty-env.xml. (UNCLASSIFIED)
Hendricks, Brad K Mr CTR USA HRC
2008-09-03 17:34:20 UTC
Permalink
Classification: UNCLASSIFIED
Caveats: NONE

Hello,

I've been developing an application using the Jetty Maven plugin and the
run goal. My application is using a JNDI reference for a datasource,
which I have configured using a jetty-env.xml file like:

<plugin>
<groupId>org.mortbay.jetty</groupId>
<artifactId>maven-jetty-plugin</artifactId>
<version>6.1.11</version>
<configuration>

<jettyEnvXml>target/test-classes/jetty-env.xml</jettyEnvXml>
</configuration>
...
</plugin>

This works fine for the run goal, but I now need to use the run-war
goal, and it seems to ignore the jettyEnvXml setting. A quick googling
turned up that this issue seems to have come up before, and was fixed a
while ago - http://jira.codehaus.org/browse/JETTY-285. However, I can't
seem to get a JNDI datasource defined so that it is recognized by
run-war. I've basically come down to two different approaches:

1. Configure jetty.xml to define the datasource. I can't seem to get
this to work. I think that the problem here is that jetty.xml defines a
server context, and I need to turn on JNDI for a webapp context. I
think that by defining a specific webapp context inside jetty.xml it
might work, but I wanted to avoid that so that the whole setup is a
little bit more dynamic.

2. Get the <webAppConfig> element of the plugin to recognize
jetty-env.xml. This seems like it should be possible, as the
webAppConfig is an instance of Jetty6PluginWebAppContext, which has a
property for the env file:

<plugin>
<groupId>org.mortbay.jetty</groupId>
<artifactId>maven-jetty-plugin</artifactId>
<version>6.1.11</version>
<configuration>
<webAppConfig>

<jettyEnvXmlFile>target/test-classes/jetty-env.xml</jettyEnvXmlFile>
</webAppConfig>
</configuration>
...
</plugin>

This doesn't seem to work either.

So, does anyone know the proper incantation to bind a JNDI datasource
that works with the run-war goal? I'd also like to ask the Jetty
developers if there is some reason why the run goal supports the env
file while the other goals do not? It seems like it would be possible
to move this support from AbstractJettyRunMojo to AbstractJettyMojo so
that all the goals could use it. Any thoughts on that?

Thanks.

Brad Hendricks



Classification: UNCLASSIFIED
Caveats: NONE
Jan Bartel
2008-09-04 00:05:28 UTC
Permalink
Hi Brad,

The idea with the jetty:run goal is that it works on an unassembled
webapp, so you can have the bits and pieces of your webapp scattered
in different places.

The jetty:run-war goal assembles and runs the whole webapp. So therefore,
it doesn't need to look at anything except the built webapp.

In the case of the jetty-env.xml file, it normally lives in the WEB-INF/
directory. So when you build your war file, it should get built into
that location and picked up by the normal jetty deployment mechanisms.

Having said that, as the run-war goal does support the webAppConfig
element, I think it should be possible for the jetty-env.xml file
to be set on it as you say. I guess it should override any WEB-INF/jetty-env.xml
file found inside the webapp.

I'll take a look at the code and get back to you.

In the meantime, can you confirm that you can use the jetty:run goal
with this config:
<configuration>
<webAppConfig>
<jettyEnvXmlFile>target/test-classes/jetty-env.xml</jettyEnvXmlFile>
</webAppConfig>
</configuration>

Jan
Classification: _* UNCLASSIFIED*_**
Caveats: NONE
Hello,
I've been developing an application using the Jetty Maven plugin and the
run goal. My application is using a JNDI reference for a datasource,
<plugin>
<groupId>org.mortbay.jetty</groupId>
<artifactId>maven-jetty-plugin</artifactId>
<version>6.1.11</version>
<configuration>
<jettyEnvXml>target/test-classes/jetty-env.xml</jettyEnvXml>
</configuration>

</plugin>
This works fine for the run goal, but I now need to use the run-war
goal, and it seems to ignore the jettyEnvXml setting. A quick googling
turned up that this issue seems to have come up before, and was fixed a
while ago - ___http://jira.codehaus.org/browse/JETTY-285_. However, I
can't seem to get a JNDI datasource defined so that it is recognized by
1. Configure jetty.xml to define the datasource. I can't seem to get
this to work. I think that the problem here is that jetty.xml defines a
server context, and I need to turn on JNDI for a webapp context. I
think that by defining a specific webapp context inside jetty.xml it
might work, but I wanted to avoid that so that the whole setup is a
little bit more dynamic.
2. Get the <webAppConfig> element of the plugin to recognize
jetty-env.xml. This seems like it should be possible, as the
webAppConfig is an instance of Jetty6PluginWebAppContext, which has a
<plugin>
<groupId>org.mortbay.jetty</groupId>
<artifactId>maven-jetty-plugin</artifactId>
<version>6.1.11</version>
<configuration>
<webAppConfig>
<jettyEnvXmlFile>target/test-classes/jetty-env.xml</jettyEnvXmlFile>
</webAppConfig>
</configuration>

</plugin>
This doesn't seem to work either.
So, does anyone know the proper incantation to bind a JNDI datasource
that works with the run-war goal? I'd also like to ask the Jetty
developers if there is some reason why the run goal supports the env
file while the other goals do not? It seems like it would be possible
to move this support from AbstractJettyRunMojo to AbstractJettyMojo so
that all the goals could use it. Any thoughts on that?
Thanks.
Brad Hendricks
Classification: ___* UNCLASSIFIED*_**
Caveats: NONE
--
Jan Bartel, Webtide LLC | ***@webtide.com | http://www.webtide.com

---------------------------------------------------------------------
To unsubscribe from this list, please visit:

http://xircles.codehaus.org/manage_email
David Yu
2008-09-04 10:12:11 UTC
Permalink
Brad,

Below actually works with jetty:run-war:

<build>
<defaultGoal>install</defaultGoal>
<plugins>
<plugin>
<groupId>org.mortbay.jetty</groupId>
<artifactId>maven-jetty-plugin</artifactId>
<version>6.1.11</version>
<configuration>
<webAppConfig>
<jettyEnvXmlFile>src/main/etc/jetty-env.xml</jettyEnvXmlFile>
</webAppConfig>
</configuration>
</plugin>
</plugins>
</build>

Btw, if with jetty:run, it will be not work because of this bug.
http://jira.codehaus.org/browse/JETTY-709 which is fixed in trunk(jetty6
and 7)

Cheers,
dyu
Post by Jan Bartel
Hi Brad,
The idea with the jetty:run goal is that it works on an unassembled
webapp, so you can have the bits and pieces of your webapp scattered
in different places.
The jetty:run-war goal assembles and runs the whole webapp. So therefore,
it doesn't need to look at anything except the built webapp.
In the case of the jetty-env.xml file, it normally lives in the WEB-INF/
directory. So when you build your war file, it should get built into
that location and picked up by the normal jetty deployment mechanisms.
Having said that, as the run-war goal does support the webAppConfig
element, I think it should be possible for the jetty-env.xml file
to be set on it as you say. I guess it should override any WEB-INF/jetty-env.xml
file found inside the webapp.
I'll take a look at the code and get back to you.
In the meantime, can you confirm that you can use the jetty:run goal
<configuration>
<webAppConfig>
<jettyEnvXmlFile>target/test-classes/jetty-env.xml</jettyEnvXmlFile>
</webAppConfig>
</configuration>
Jan
Classification: _* UNCLASSIFIED*_**
Caveats: NONE
Hello,
I've been developing an application using the Jetty Maven plugin and the
run goal. My application is using a JNDI reference for a datasource,
<plugin>
<groupId>org.mortbay.jetty</groupId>
<artifactId>maven-jetty-plugin</artifactId>
<version>6.1.11</version>
<configuration>
<jettyEnvXml>target/test-classes/jetty-env.xml</jettyEnvXml>
</configuration>

</plugin>
This works fine for the run goal, but I now need to use the run-war
goal, and it seems to ignore the jettyEnvXml setting. A quick googling
turned up that this issue seems to have come up before, and was fixed a
while ago - ___http://jira.codehaus.org/browse/JETTY-285_. However, I
can't seem to get a JNDI datasource defined so that it is recognized by
1. Configure jetty.xml to define the datasource. I can't seem to get
this to work. I think that the problem here is that jetty.xml defines a
server context, and I need to turn on JNDI for a webapp context. I
think that by defining a specific webapp context inside jetty.xml it
might work, but I wanted to avoid that so that the whole setup is a
little bit more dynamic.
2. Get the <webAppConfig> element of the plugin to recognize
jetty-env.xml. This seems like it should be possible, as the
webAppConfig is an instance of Jetty6PluginWebAppContext, which has a
<plugin>
<groupId>org.mortbay.jetty</groupId>
<artifactId>maven-jetty-plugin</artifactId>
<version>6.1.11</version>
<configuration>
<webAppConfig>
<jettyEnvXmlFile>target/test-classes/jetty-env.xml</jettyEnvXmlFile>
</webAppConfig>
</configuration>

</plugin>
This doesn't seem to work either.
So, does anyone know the proper incantation to bind a JNDI datasource
that works with the run-war goal? I'd also like to ask the Jetty
developers if there is some reason why the run goal supports the env
file while the other goals do not? It seems like it would be possible
to move this support from AbstractJettyRunMojo to AbstractJettyMojo so
that all the goals could use it. Any thoughts on that?
Thanks.
Brad Hendricks
Classification: ___* UNCLASSIFIED*_**
Caveats: NONE
---------------------------------------------------------------------
To unsubscribe from this list, please visit:

http://xircles.codehaus.org/manage_email
Hendricks, Brad K Mr CTR USA HRC
2008-09-04 15:06:28 UTC
Permalink
Classification: UNCLASSIFIED
Caveats: NONE

Jan,

Thanks for your reply.

I've run some tests, using the config you suggested

<configuration>
<webAppConfig>

<jettyEnvXmlFile>target/test-classes/jetty-env.xml</jettyEnvXmlFile>
</webAppConfig>
</configuration>

It seems that you are correct and I was mistaken - this does work for
the run-war goal. I must have just had it misconfigured earlier. I did
try several versions of the plug-in and it works with 1.6.9 and .11, but
not with .3. This seems consistent with your fix for
http://jira.codehaus.org/browse/JETTY-285.

This does not work for me with the run goal however. Again, I tried
versions 1.6.3, .9, and .11, and it failed every time. However, with
the run goal you can use <jettyEvnXml> outside of the <webAppConfig>.
This would seem to be consistent with David's mention of
http://jira.codehaus.org/browse/JETTY-709. I didn't check out his fix
to trunk to verify that works.

Of course, you guys are the developers, but I would vote for having
jettyEnvXmlFile inside of webAppConfig work consistently for all goals.

Cheers.

Brad

-----Original Message-----
From: Jan Bartel [mailto:***@webtide.com]
Sent: Wednesday, September 03, 2008 8:05 PM
To: ***@jetty.codehaus.org
Subject: Re: [jetty-user] Jetty Maven Plugin, run-war, and
JNDI/jetty-env.xml. (UNCLASSIFIED)

Hi Brad,

The idea with the jetty:run goal is that it works on an unassembled
webapp, so you can have the bits and pieces of your webapp scattered in
different places.

The jetty:run-war goal assembles and runs the whole webapp. So
therefore, it doesn't need to look at anything except the built webapp.

In the case of the jetty-env.xml file, it normally lives in the WEB-INF/
directory. So when you build your war file, it should get built into
that location and picked up by the normal jetty deployment mechanisms.

Having said that, as the run-war goal does support the webAppConfig
element, I think it should be possible for the jetty-env.xml file to be
set on it as you say. I guess it should override any
WEB-INF/jetty-env.xml file found inside the webapp.

I'll take a look at the code and get back to you.

In the meantime, can you confirm that you can use the jetty:run goal
with this config:
<configuration>
<webAppConfig>

<jettyEnvXmlFile>target/test-classes/jetty-env.xml</jettyEnvXmlFile>
</webAppConfig>
</configuration>

Jan
Classification: _* UNCLASSIFIED*_**
Caveats: NONE
Hello,
I've been developing an application using the Jetty Maven plugin and
the run goal. My application is using a JNDI reference for a
<plugin>
<groupId>org.mortbay.jetty</groupId>
<artifactId>maven-jetty-plugin</artifactId>
<version>6.1.11</version>
<configuration>
<jettyEnvXml>target/test-classes/jetty-env.xml</jettyEnvXml>
</configuration>
...
</plugin>
This works fine for the run goal, but I now need to use the run-war
goal, and it seems to ignore the jettyEnvXml setting. A quick
googling turned up that this issue seems to have come up before, and
was fixed a while ago - ___http://jira.codehaus.org/browse/JETTY-285_.
However, I can't seem to get a JNDI datasource defined so that it is
recognized by run-war. I've basically come down to two different
1. Configure jetty.xml to define the datasource. I can't seem to get
this to work. I think that the problem here is that jetty.xml defines
a server context, and I need to turn on JNDI for a webapp context. I
think that by defining a specific webapp context inside jetty.xml it
might work, but I wanted to avoid that so that the whole setup is a
little bit more dynamic.
2. Get the <webAppConfig> element of the plugin to recognize
jetty-env.xml. This seems like it should be possible, as the
webAppConfig is an instance of Jetty6PluginWebAppContext, which has a
<plugin>
<groupId>org.mortbay.jetty</groupId>
<artifactId>maven-jetty-plugin</artifactId>
<version>6.1.11</version>
<configuration>
<webAppConfig>
<jettyEnvXmlFile>target/test-classes/jetty-env.xml</jettyEnvXmlFile>
</webAppConfig>
</configuration>
...
</plugin>
This doesn't seem to work either.
So, does anyone know the proper incantation to bind a JNDI datasource
that works with the run-war goal? I'd also like to ask the Jetty
developers if there is some reason why the run goal supports the env
file while the other goals do not? It seems like it would be possible
to move this support from AbstractJettyRunMojo to AbstractJettyMojo so
that all the goals could use it. Any thoughts on that?
Thanks.
Brad Hendricks
Classification: ___* UNCLASSIFIED*_**
Caveats: NONE
--
Jan Bartel, Webtide LLC | ***@webtide.com | http://www.webtide.com

---------------------------------------------------------------------
To unsubscribe from this list, please visit:

http://xircles.codehaus.org/manage_email


Classification: UNCLASSIFIED
Caveats: NONE


---------------------------------------------------------------------
To unsubscribe from this list, please visit:

http://xircles.codehaus.org/manage_email
David Yu
2008-09-05 02:10:43 UTC
Permalink
Post by Hendricks, Brad K Mr CTR USA HRC
Classification: UNCLASSIFIED
Caveats: NONE
Jan,
Thanks for your reply.
I've run some tests, using the config you suggested
<configuration>
<webAppConfig>
<jettyEnvXmlFile>target/test-classes/jetty-env.xml</jettyEnvXmlFile>
</webAppConfig>
</configuration>
It seems that you are correct and I was mistaken - this does work for
the run-war goal. I must have just had it misconfigured earlier. I did
try several versions of the plug-in and it works with 1.6.9 and .11, but
not with .3. This seems consistent with your fix for
http://jira.codehaus.org/browse/JETTY-285.
This does not work for me with the run goal however. Again, I tried
versions 1.6.3, .9, and .11, and it failed every time. However, with
the run goal you can use <jettyEvnXml> outside of the <webAppConfig>.
This would seem to be consistent with David's mention of
http://jira.codehaus.org/browse/JETTY-709. I didn't check out his fix
to trunk to verify that works.
Of course, you guys are the developers, but I would vote for having
jettyEnvXmlFile inside of webAppConfig work consistently for all goals.
JETTY-709 makes it consistent.
Post by Hendricks, Brad K Mr CTR USA HRC
Cheers.
Brad
-----Original Message-----
Sent: Wednesday, September 03, 2008 8:05 PM
Subject: Re: [jetty-user] Jetty Maven Plugin, run-war, and
JNDI/jetty-env.xml. (UNCLASSIFIED)
Hi Brad,
The idea with the jetty:run goal is that it works on an unassembled
webapp, so you can have the bits and pieces of your webapp scattered in
different places.
The jetty:run-war goal assembles and runs the whole webapp. So
therefore, it doesn't need to look at anything except the built webapp.
In the case of the jetty-env.xml file, it normally lives in the WEB-INF/
directory. So when you build your war file, it should get built into
that location and picked up by the normal jetty deployment mechanisms.
Having said that, as the run-war goal does support the webAppConfig
element, I think it should be possible for the jetty-env.xml file to be
set on it as you say. I guess it should override any
WEB-INF/jetty-env.xml file found inside the webapp.
I'll take a look at the code and get back to you.
In the meantime, can you confirm that you can use the jetty:run goal
<configuration>
<webAppConfig>
<jettyEnvXmlFile>target/test-classes/jetty-env.xml</jettyEnvXmlFile>
</webAppConfig>
</configuration>
Jan
Classification: _* UNCLASSIFIED*_**
Caveats: NONE
Hello,
I've been developing an application using the Jetty Maven plugin and
the run goal. My application is using a JNDI reference for a
<plugin>
<groupId>org.mortbay.jetty</groupId>
<artifactId>maven-jetty-plugin</artifactId>
<version>6.1.11</version>
<configuration>
<jettyEnvXml>target/test-classes/jetty-env.xml</jettyEnvXml>
</configuration>
...
</plugin>
This works fine for the run goal, but I now need to use the run-war
goal, and it seems to ignore the jettyEnvXml setting. A quick
googling turned up that this issue seems to have come up before, and
was fixed a while ago - ___http://jira.codehaus.org/browse/JETTY-285_.
However, I can't seem to get a JNDI datasource defined so that it is
recognized by run-war. I've basically come down to two different
1. Configure jetty.xml to define the datasource. I can't seem to get
this to work. I think that the problem here is that jetty.xml defines
a server context, and I need to turn on JNDI for a webapp context. I
think that by defining a specific webapp context inside jetty.xml it
might work, but I wanted to avoid that so that the whole setup is a
little bit more dynamic.
2. Get the <webAppConfig> element of the plugin to recognize
jetty-env.xml. This seems like it should be possible, as the
webAppConfig is an instance of Jetty6PluginWebAppContext, which has a
<plugin>
<groupId>org.mortbay.jetty</groupId>
<artifactId>maven-jetty-plugin</artifactId>
<version>6.1.11</version>
<configuration>
<webAppConfig>
<jettyEnvXmlFile>target/test-classes/jetty-env.xml</jettyEnvXmlFile>
</webAppConfig>
</configuration>
...
</plugin>
This doesn't seem to work either.
So, does anyone know the proper incantation to bind a JNDI datasource
that works with the run-war goal? I'd also like to ask the Jetty
developers if there is some reason why the run goal supports the env
file while the other goals do not? It seems like it would be possible
to move this support from AbstractJettyRunMojo to AbstractJettyMojo so
that all the goals could use it. Any thoughts on that?
Thanks.
Brad Hendricks
Classification: ___* UNCLASSIFIED*_**
Caveats: NONE
--
---------------------------------------------------------------------
http://xircles.codehaus.org/manage_email
Classification: UNCLASSIFIED
Caveats: NONE
---------------------------------------------------------------------
http://xircles.codehaus.org/manage_email
---------------------------------------------------------------------
To unsubscribe from this list, please visit:

http://xircles.codehaus.org/manage_email

Loading...