Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [jetty-users] GWT+Jersey+Embedded Jetty+war files query

Hi Jan,

Yes, the 'correct ordering' worked for all embedded tests, especially for the GWT starter project. Not sure if it is possible to do, but would it be good to have two webapp.setConfigurations/1?; at the moment setConfigurations requires that the Configuration[] list be ordered, so may I suggest an additional or replacement setConfigurations called something like setOrderedConfigurations/1, where a knowledgeable programmer determines the config order. By contrast the current setConfigurations could be renamed to setUnorderedConfigurations/1 with Jetty in this case providing some underlying code to check and apply elements of the Configuration[] list in a sane order. My error was to treat the Configuration[] list as effectively unordered, but I was not aware of any feedback/warning that my ordering was incorrect. I think it is generally a good idea to explicitly indicate whether operations apply to ordered or unordered sets (think of sorting a set). Anyway, just a thought.

Thanks for help!
Goffredo


Quoting Jan Bartel <janb@xxxxxxxxxxx>:

The correct ordering of the Configurations is:

        "org.eclipse.jetty.webapp.WebInfConfiguration",
        "org.eclipse.jetty.webapp.WebXmlConfiguration",
        "org.eclipse.jetty.webapp.MetaInfConfiguration",
        "org.eclipse.jetty.webapp.FragmentConfiguration",
       "org.eclipse.jetty.plus.webapp.EnvConfiguration",
       "org.eclipse.jetty.plus.webapp.PlusConfiguration",
       "org.eclipse.jetty.annotations.AnnotationConfiguration",
       "org.eclipse.jetty.webapp.JettyWebXmlConfiguration"

Trying fixing up that order and re-running your tests.

If there is still a failure, please attach one of the failing wars, your
embedded setup code and classpath and we'll take a look.

Jan

On 19 September 2017 at 17:42, <goffredo@xxxxxxxxxxx> wrote:

Hi

Thanks for responses, but no joy. Trying to be experimental, I set up a
single file with configuration as below, to try a number of variants. Seems
that anything (so to speak) without GWT will work on the embedded Jetty, so
plain Jersey app works OK embedded (so Annotation scanning is ok), but app
with GWT and Jersey fails; A plain GWT app without backend server code
works OK also; however the GWT 'Web Application Starter Project' fails in
embedded but runs in Jetty stand alone. The GWT starter project uses
RMI/RPC to manage backend connection, which differs from Jersey REST. All
the .war files were created the same way, project cleaned, GWT compiled,
etc.

Nothing in the embedded examples seems useful. But since all GWT examples
obviously run fine in SuperDevMode which uses an older version of Jetty
Embedded the matter seems to be some kind of configuration problem.

Regards
Goffredo

        /*
         * Correctly order your configurations! This is the default list.
         */
        webapp.setConfigurations(new Configuration[] {
            new WebXmlConfiguration(),   // Processes a WEB-INF/web.xml
file
            new WebInfConfiguration(),   // Extracts war, orders jars and
defines classpath
            new MetaInfConfiguration(),  // Looks in container and webapp
jars for META-INF/resources and META-INF/web-fragment.xml
            new FragmentConfiguration(), //Processes all discovered
META-INF/web-fragment.xml files
            // -- supporting JNDI
            new EnvConfiguration(),     // Creates java:comp/env for the
webapp, applies a WEB-INF/jetty-env.xml file
            new PlusConfiguration(),    // Processes JNDI related aspects
of WEB-INF/web.xml and hooks up naming entries
            // -- supporting ANNOTATIONS
            new AnnotationConfiguration(), // Scan container and web app
jars looking for @WebServlet, @WebFilter, @WebListener etc
            new JettyWebXmlConfiguration() });

        /*
         * Set app .war file as needed
         *
         */
        webapp.setContextPath("/");
        File warFile = new File(
                // Plain Jersey Application
                // "src/webapps/jersey-getting-started.war"); // OK
embedded OK stand alone

                // GWT + GWTResty + Jersey
                // "src/webapps/gwt_jersey_gwtresty.war");    // FAILS
embedded OK stand alone

                // GWT + Jersey (Plain GWT Interface no RMI/RPC calls,
backend Jersey server only)
                // "src/webapps/gwt_jersey_test.war");        // FAILS
embedded OK stand alone

                // Plain GWT Application without Server code
                // "src/webapps/architecture2.war");          // OK
embedded OK stand alone

                // actual GWT: 'Web Application Starter Project' (which
contains (RMI/RPC) Server code)
                "src/webapps/gwt_helloworld.war");            // FAILS
embedded OK stand alone

                // Plain Jersey Application
                //"src/webapps/adages2_1.war");               // OK
Embedded

                // Plain Jersey Application
                //"src/webapps/predictions3.war");            // OK
Embedded

          webapp.setWar(warFile.getAbsolutePath());


Plain Jersey Application (No GWT)
Embedded: This works OK:
=====================================================================
When starting: "src/webapps/jersey-getting-started.war");
This is some printout:
 |   |   |   += org.eclipse.jetty.servlet.ServletHandler@1fd91c9 - STARTED
  <stuff snipped>
 |   |   |   |   +- [/]=>default
 |   |   |   |   +- [*.jsp, *.jspf, *.jspx, *.xsp, *.JSP, *.JSPF, *.JSPX,
*.XSP]=>jsp
 |   |   |   |   += Jetty_WebSocketUpgradeFilter - STARTED
 |   |   |   |   |   +- contextAttributeKey=org.eclips
e.jetty.websocket.server.WebSocketUpgradeFilter
 |   |   |   |   |   +- configuration=org.eclipse.jett
y.websocket.server.NativeWebSocketConfiguration@14658f7
 |   |   |   |   +- [/*]/[]==1=>Jetty_WebSocketUpgradeFilter
 |   |   |   |   += org.eclipse.jetty.servlet.ListenerHolder@8eee0f -
STARTED
 |   |   |   |   += com.armida.jersey.jersey_getti
ng_started.MyResourceConfig@647d15ac==org.glassfish.
jersey.servlet.ServletContainer,jsp=null,order=1,inst=true - STARTED
 |   |   |   |   +- [/webapi/*]=>com.armida.jersey
.jersey_getting_started.MyResourceConfig
                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^  OK


Plain GWT Interface no RMI/RPC calls, backend Jersey server only
Embedded: This FAILS:
=====================================================================
When starting: "src/webapps/gwt_jersey_test.war");
This is some printout:
 |   |   |   += org.eclipse.jetty.servlet.ServletHandler@15c6049 - STARTED
 <stuff snipped>
 |   |   |   |   +- [/]=>default
 |   |   |   |   +- [*.jsp, *.jspf, *.jspx, *.xsp, *.JSP, *.JSPF, *.JSPX,
*.XSP]=>jsp
 |   |   |   |   += Jetty_WebSocketUpgradeFilter - STARTED
 |   |   |   |   |   +- contextAttributeKey=org.eclips
e.jetty.websocket.server.WebSocketUpgradeFilter
 |   |   |   |   |   +- configuration=org.eclipse.jett
y.websocket.server.NativeWebSocketConfiguration@3118b0
 |   |   |   |   +- [/*]/[]==1=>Jetty_WebSocketUpgradeFilter
 |   |   |   |   += org.eclipse.jetty.servlet.ListenerHolder@5d7657 -
STARTED
                 <jersey stuff not here> ????????????????????? FAIL




in reply to:
------------


Quoting Joakim Erdfelt <joakim@xxxxxxxxxxx>:

Did you configure your embedded-jetty to use the appropriate webapp
configurations?
Of particular interest is the AnnotationConfiguration (which scans
bytecode
and looks for annotated classes).

Joakim Erdfelt / joakim@xxxxxxxxxxx

On Mon, Sep 18, 2017 at 7:08 AM, <goffredo@xxxxxxxxxxx> wrote:

Hi,

Hoping someone can help with a problem I have not been able to solve.
I have a simple GWT application, with a simple Jersey REST server. I am
able to compile and succesfully run it on Eclipse IDE using SuperDev
Mode.
I am able to created a .war file from my project, and drop this .war file
into an unmodified stand-alone Jetty (9.4.6) webapps folder, and again it
runs as expected. The .war File Size is 95981747 bytes containing the
appropriate GWT and Jersey jars (if that is relevant).

But when I try to load the .war file into an Embedded Jetty (9.4.2), the
server-side programs will not work at all, as if the server side programs
did not exist. The welcome page is however available, just that it
appears
there is no backend. (I am able as well to write and run simple Jersey
REST
applications with no dependency on GWT; also able to run simple GWT apps
in
embedded mode.) GWT's JettyLauncher.java (which starts embedded Jetty in
Dev Mode) provides no clue. From my reading of the documentation a .war
file should just work with embedded Jetty. I can't understand why one
.war
file works in embedded Jetty and another fails, or why a .war file works
in
Jetty stand-alone mode, but seriously fails in Jetty embedded mode. Maybe
it's a configuration problem? If so is there a document that shows how to
configure embedded Jetty to work like the stand-alone Jetty?

Regards
Goffredo


_______________________________________________
jetty-users mailing list
jetty-users@xxxxxxxxxxx
To change your delivery options, retrieve your password, or unsubscribe
from this list, visit
https://dev.eclipse.org/mailman/listinfo/jetty-users



_______________________________________________
jetty-users mailing list
jetty-users@xxxxxxxxxxx
To change your delivery options, retrieve your password, or unsubscribe
from this list, visit
https://dev.eclipse.org/mailman/listinfo/jetty-users




--
Jan Bartel <janb@xxxxxxxxxxx>
www.webtide.com
*Expert assistance from the creators of Jetty and CometD*




Back to the top