Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [jetty-users] various problems with embedded jetty (in web app)

A couple of points on your pom.xml

Don't shade anything in the javax.* space, or glassfish, or anything to do with logging (slf4j and log4j).
Don't use version ranges in your dependencies.
Specify the specific servlet-api, jsp, el, and glassfish jsp versions appropriate to the version of jetty that you are using.

--
Joakim Erdfelt
joakim@xxxxxxxxxxx



On Mon, Jan 9, 2012 at 2:24 PM, Eugen Cepoi <cepoi.eugen@xxxxxxxxx> wrote:
I'm running jetty from inside my "executable war".
I've extracted the server dependencies (all content of jetty jars,jsp,servlet,etc) at the root of the war and removed them from WEB-INF/lib.
So in this way they are in the containers classpath no? For jstl I'm using javax.servlet:jstl artifact.

I'm doing surely something wrong as it works when I run it from eclipse, but I can't find what...

Here are the relevant parts of the pom I use. Thank's!

<dependencies>
....
<dependency>
            <groupId>org.eclipse.jetty</groupId>
            <artifactId>jetty-server</artifactId>
            <version>${jetty.version}</version>
        </dependency>
        <dependency>
            <groupId>org.eclipse.jetty</groupId>
            <artifactId>jetty-webapp</artifactId>
            <version>${jetty.version}</version>
        </dependency>
        <dependency>
            <groupId>org.eclipse.jetty</groupId>
            <artifactId>jetty-deploy</artifactId>
            <version>${jetty.version}</version>
        </dependency>

         <dependency>
            <groupId>javax.servlet</groupId>
            <artifactId>jstl</artifactId>
            <version>1.2</version>
        </dependency>


        <dependency>
            <groupId>org.glassfish.web</groupId>
            <artifactId>jsp-impl</artifactId>
            <version>[2.2.1,)</version>
        </dependency>

        <dependency>
            <groupId>javax.servlet.jsp</groupId>
            <artifactId>jsp-api</artifactId>
            <version>[2.2,)</version>
        </dependency>

        <dependency>
            <groupId>javax.el</groupId>
            <artifactId>el-api</artifactId>
            <version>[2.2,)</version>
        </dependency>

        <dependency>
            <groupId>org.glassfish.web</groupId>
            <artifactId>el-impl</artifactId>
            <version>[2.2,)</version>
        </dependency>
....
</dependencies>


<plugins>
....
<plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-war-plugin</artifactId>
                <version>2.1.1</version>
                <configuration>
                    <packagingExcludes>WEB-INF/lib/*jetty*.jar,WEB-INF/lib/*slf4j*.jar,WEB-INF/lib/*log4j*.jar,WEB-INF/lib/*servlet-api*.jar,WEB-INF/lib/*jstl*.jar,WEB-INF/lib/*el-api*.jar,WEB-INF/lib/*el-impl*.jar,WEB-INF/lib/*jsp-api*.jar,WEB-INF/lib/*jsp-impl*.jar</packagingExcludes>
                </configuration>
            </plugin>

            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-shade-plugin</artifactId>
                <version>1.4</version>
                <executions>
                    <execution>
                        <phase>package</phase>
                        <goals>
                            <goal>shade</goal>
                        </goals>
                        <configuration>
                            <createDependencyReducedPom>true</createDependencyReducedPom>
                            <artifactSet>
                                <includes>
                                    <include>*jetty:*</include>
                                    <include>org.slf4j:*</include>
                                    <include>log4j:*</include>
                                    <include>javax.servlet:servlet-api:*</include>
                                    <include>javax.servlet:jstl:*</include>
                                    <include>javax.servlet.jsp:*:*</include>
                                    <include>javax.el:*:*</include>
                                    <include>org.glassfish.web:*:*</include>
                                </includes>
                            </artifactSet>
                            <transformers>
                                <transformer
                                    implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
                                    <mainClass>xxx.web.server.EmbeddedJettyServer</mainClass>
                                    <manifestEntries>
                                        <Class-Path>./etc/</Class-Path>
                                    </manifestEntries>
                                </transformer>
                            </transformers>
                        </configuration>
                    </execution>
                </executions>
            </plugin>

            <plugin>
                <artifactId>maven-antrun-plugin</artifactId>
                <executions>
                    <execution>
                        <id>move-main-class</id>
                        <phase>compile</phase>
                        <configuration>
                            <tasks>
                                <copy
                                    todir="${project.build.directory}/${project.artifactId}-${project.version}">
                                    <fileset dir="src/main/webapp/WEB-INF/classes/">
                                        <include name="xxx/web/server/*.class" />
                                    </fileset>
                                </copy>
                            </tasks>
                        </configuration>
                        <goals>
                            <goal>run</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
....
</plugins>



2012/1/9 Jan Bartel <janb@xxxxxxxxxxx>
Eugen,

The jstl jars need to be on the container's classpath, not inside your
webapp. Can you see the $JETTY_HOME/lib/jsp directory contains the
jstl jars org.apache.taglibs.standard.glassfish_1.2.0.v201004190952.jar
and javax.servlet.jsp.jstl_1.2.0.v201004190952.jar

regards
Jan

On 28 December 2011 09:54, Eugen Cepoi <cepoi.eugen@xxxxxxxxx> wrote:
> Hi,
>
> I maybe said that everything was fine a bit fast...
> When I run the assembled war by maven (if it's from inside eclipse its ok)
> I've got this exception when I try to display a jsp with jstl inside
>
> The absolute uri: http://java.sun.com/jsp/jstl/core cannot be resolved in
> either web.xml or the jar files deployed with this application
>
> If I replace jetty versions by RC1 it works again (but of course it's not ok
> as I need the correction provided by RC2).
>
> Are you able to reproduce this bug? If no I can provide an example.
>
> Happy christmas ! =)
>
> Eugen
>
>
> 2011/12/23 Eugen Cepoi <cepoi.eugen@xxxxxxxxx>
>>
>> Yep its included in rc2.
>> Thanks,
>> Eugen
>>
>> Le 22 déc. 2011 23:58, "Jesse McConnell" <jesse.mcconnell@xxxxxxxxx> a
>> écrit :
>>
>>> I just released 8.1.0.RC2 a few minutes ago, I suspect this change
>>> would be in that..
>>>
>>> cheers,
>>> jesse
>>>
>>> --
>>> jesse mcconnell
>>> jesse.mcconnell@xxxxxxxxx
>>>
>>>
>>>
>>> On Thu, Dec 22, 2011 at 16:22, Jan Bartel <janb@xxxxxxxxxxx> wrote:
>>> > Eugen,
>>> >
>>> > Glad to hear this is working. This change will be released with
>>> > 8.1.0.RC1, which should be happening within the next few weeks.
>>> > No idea on the windows/linux difference, sorry. Not something I've
>>> > come across before with jetty.
>>> >
>>> > Jan
>>> >
>>> > On 23 December 2011 09:12, Eugen Cepoi <cepoi.eugen@xxxxxxxxx> wrote:
>>> >> Hi Jan,
>>> >> Nice, it corrects the problem of hot deployment of jsps and the
>>> >> jsp-config
>>> >> from the web.xml
>>> >> Could it be integrated in the RC1 (or an RC2) so people using range
>>> >> version
>>> >> of jetty can get it? Actually the latest version seems to be RC1 in
>>> >> the
>>> >> maven-metadata file, so if I don't explicit that I want the
>>> >> 8.1.0-SNAPSHOT I
>>> >> can't get it.
>>> >>
>>> >> Also do you have some clue on the difference of the memory load in RAM
>>> >> between windows and linux?
>>> >> However, it has maybe nothing do with jetty...
>>> >>
>>> >> Kind regards,
>>> >> Eugen
>>> >>
>>> >>
>>> >> 2011/12/22 Jan Bartel <janb@xxxxxxxxxxx>
>>> >>>
>>> >>> Fix checked in to trunk. I've also pushed a new snapshot distribution
>>> >>> here:
>>> >>>
>>> >>>
>>> >>> https://oss.sonatype.org/content/groups/jetty/org/eclipse/jetty/jetty-distribution/8.1.0-SNAPSHOT/
>>> >>>
>>> >>> Please select and download the snapshot with the most recent date on
>>> >>> it and try it out - the jsp config should now be working.
>>> >>>
>>> >>> Jan
>>> >>>
>>> >>> On 22 December 2011 16:08, Jan Bartel <janb@xxxxxxxxxxx> wrote:
>>> >>> > Ooops. The jsp problem is a bug in jetty-8's handling of the
>>> >>> > jsp-config element. Specifically, we're not returning it for the
>>> >>> > new
>>> >>> > ServletContext.getJspConfigDescriptor() method, which jasper in
>>> >>> > jetty-8 relies on.
>>> >>> >
>>> >>> > I've opened this bug:
>>> >>> > https://bugs.eclipse.org/bugs/show_bug.cgi?id=367383
>>> >>> >
>>> >>> > Should have a fix for you shortly.
>>> >>> >
>>> >>> > Jan
>>> >>> >
>>> >>> > On 22 December 2011 08:50, Eugen Cepoi <cepoi.eugen@xxxxxxxxx>
>>> >>> > wrote:
>>> >>> >> Hi all,
>>> >>> >>
>>> >>> >> I have a couple of problems and need your help and some
>>> >>> >> recommendations
>>> >>> >> on
>>> >>> >> embedding jetty in a web app.
>>> >>> >> I don't want to use maven to run it (no jetty:run) and I also
>>> >>> >> don't
>>> >>> >> want to
>>> >>> >> use the start jar provided. As I want the war to be self
>>> >>> >> sufficient.
>>> >>> >> To do so I have, implemented 2 classes for embedding jetty:
>>> >>> >>                     - one is the "production" server main class,
>>> >>> >> that
>>> >>> >> will
>>> >>> >> be moved to the root of the war,
>>> >>> >>                     - the other is an implementation with hot
>>> >>> >> deploy
>>> >>> >> enabled
>>> >>> >> to run during development (from eclipse for example).
>>> >>> >> And configured a pom for maven to produce the executable war (I
>>> >>> >> use
>>> >>> >> shade
>>> >>> >> plugin to build it and choose only the needed artifacts to be
>>> >>> >> copied at
>>> >>> >> the
>>> >>> >> root and deleted them from the WEB-INF/lib).
>>> >>> >>
>>> >>> >> Most of the things work fine except :
>>> >>> >>                     - If I use jetty 8 the jsp-config in web.xml
>>> >>> >> doesn't
>>> >>> >> seem to be recognised, if I go back to jetty 7 and servlet 2.5
>>> >>> >> it's ok.
>>> >>> >> However I would like to use jetty 8... am I missing something? I
>>> >>> >> am
>>> >>> >> using
>>> >>> >> glassfishs implementations.
>>> >>> >>
>>> >>> >>                     - Second problem. When I am using my
>>> >>> >> development
>>> >>> >> implementation of the server I have nullpointerexception in
>>> >>> >> JstlBaseTLV.validate after a hot deploy of a jsp. If I look at the
>>> >>> >> code, I
>>> >>> >> can see that the initParameters map is null. Do you have any clue
>>> >>> >> on
>>> >>> >> how I
>>> >>> >> could solve this problem? This one is pretty annoying...
>>> >>> >>
>>> >>> >>                     - Last problem, when I am running the server
>>> >>> >> on
>>> >>> >> debian
>>> >>> >> linux the app takes twice as much memory as in windows xp... does
>>> >>> >> someone
>>> >>> >> already had this kind of problem?
>>> >>> >>
>>> >>> >> I am joining to the mail an extract of the pom and the two
>>> >>> >> simplified
>>> >>> >> server
>>> >>> >> classes.
>>> >>> >> Thank you for your help.
>>> >>> >>
>>> >>> >> Kind regards,
>>> >>> >> Eugen
>>> >>> >>
>>> >>> >> _______________________________________________
>>> >>> >> 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
>>> >>
>>> >>
>>> >>
>>> >> _______________________________________________
>>> >> 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
>>> _______________________________________________
>>> 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
>
_______________________________________________
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



Back to the top