Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » e(fx)clipse » Embedded jetty in efxclipse application
Embedded jetty in efxclipse application [message #1720407] Mon, 18 January 2016 13:53 Go to next message
Ali Karimi is currently offline Ali KarimiFriend
Messages: 36
Registered: October 2015
Member
Hey there,

i am trying to embed a jetty server into my efxclipse application and export a standalone runnable executable with the provided
tycho stubs generated by the efxclipse tooling in eclipse.

In short: Everything works fine, when running my application from eclipse. I have configured a servlet in the embedded jetty and i am
able to get a response when calling the servlet from a browser. The problem is, i am not able to reach the servlet when starting my
application from the generated executable file.

As far as a can see, the jetty server isn't running at all, but i am clueless why. I have created a small demo app demonstrating my
problem. Basically it consists of the usual 4 projects generated by the efxlipse tooling. I have added the dependencies to the embedded
jetty server and configured a servlet (e.g. HelloServlet.java).

Steps to get the demo running:

  1. Make sure you have jdk configured in your eclipse installation (i am using eclipse mars and jdk1.8_60)
  2. Download attached zip file
  3. In Eclipse choose -> Import -> General - > Exisiting Projects into workspace
  4. Select the downloaded zip file
  5. Import all 4 projects
  6. Open de.jetty.test.app/targetplatfrom/efxclipse_2.2.0_release.target in eclipse
  7. Select Set as target platfrom in the upper right corner
  8. Run .product file in de.jetty.test.app.product


After that a window should open showing a circle and you should be able to point a browser to the url http://127.0.0.1:8888/hello

Now when creating a runnable executable by running a mvn clean install on the de.jetty.test.app.releng/pom.xml file and executing the de.jetty.test.app.releng/build.xml ant script, an executable should be created. However when running this executable the servlet is not running. Unfortunately i have no idea why? As far as i can see i have included all required plugins in my .product file and set the start level and auto-start accordingly. However the server is not starting.

Anyone an idea what could be problem? I guess its only a tiny configuration problem, however i can not get it.

Thanks in advance...

[Updated on: Tue, 19 January 2016 07:39]

Report message to a moderator

Re: Embedded jetty in efxclipse application [message #1720408 is a reply to message #1720407] Mon, 18 January 2016 13:59 Go to previous messageGo to next message
Ali Karimi is currently offline Ali KarimiFriend
Messages: 36
Registered: October 2015
Member
Please note, starting the osgi console for both configuration more or less revealed the same output. Same number of plugins, same state. The only major difference in the output is the following:

This one is shown when starting from eclipse
0	ACTIVE      org.eclipse.osgi_3.10.101.v20150820-1432
				Fragments=85


This is the same line when starting from the executable.
0	ACTIVE      org.eclipse.osgi_3.10.101.v20150820-1432
				Fragments=1

Goolging about it, unfortunately i had no luck so far.
Re: Embedded jetty in efxclipse application [message #1720409 is a reply to message #1720407] Mon, 18 January 2016 14:00 Go to previous messageGo to next message
Thomas Schindl is currently offline Thomas SchindlFriend
Messages: 6651
Registered: July 2009
Senior Member
Launch the exported app with -console -consoleLog then you should be
able to interactively work with the OSGi-Shell

Tom

On 18.01.16 14:53, Ali Karimi wrote:
> Hey there,
>
> i am trying to embed a jetty server into my efxclipse application and export a standalone runnable executable with the provided
> tycho stubs generated by the efxclipse tooling in eclipse.
>
> In short: Everything works fine, when running my application from eclipse. I have configured a servlet in the embedded jetty and i am
> able to get a response when calling the servlet from a browser. The problem is, i am not able to reach the servlet when starting my
> application from the generated executable file.
>
> As far as a can see, the jetty server isn't running at all, but i am clueless why. I have created a small demo app demonstrating my
> problem. Basically it consists of the usual 4 projects generated by the efxlipse tooling. I have added the dependencies to the embedded
> jetty server and configured a servlet (e.g. HelloServlet.java).
>
> Steps to get the demo running:
>
> Make sure you have jdk configured in your eclipse installation (i am using eclipse mars and jdk1.8_60)
> Download attached zip file
> In Eclipse choose -> Import -> General - > Exisiting Projects into workspace
> Select the downloaded zip file
> Import all 4 projects
> Open de.jetty.test.app/targetplatfrom/efxclipse_2.2.0_release.target in eclipse
> Select Set as target platfrom in the upper right corner
> Run .product file in de.jetty.test.app.product
>
>
> After that a window should open showing a circle and you should be able to point a browser to the url http://127.0.0.1/hello
>
> Now when creating a runnable executable by running a mvn clean install on the de.jetty.test.app.releng/pom.xml file and executing the de.jetty.test.app.releng/build.xml ant script, an executable should be created. However when running this executable the servlet is not running. Unfortunately i have no idea why? As far as i can see i have included all required plugins in my .product file and set the start level and auto-start accordingly. However the server is not starting.
>
> Anyone an idea what could be problem? I guess its only a tiny configuration problem, however i can not get it.
>
> Thanks in advance...
>
Re: Embedded jetty in efxclipse application [message #1720415 is a reply to message #1720409] Mon, 18 January 2016 14:14 Go to previous messageGo to next message
Ali Karimi is currently offline Ali KarimiFriend
Messages: 36
Registered: October 2015
Member
Hello Tom,

thanks for your help. I guess we were writing our last posts in parallel. I already tried you advice and started the application with the -console parameter. Unfortunately i can not see any major difference except the one mentioned in my previous post and that the numbering of the bundles in the eclipse output is not continuous increment. Some numbers are missing. The number of bundles is the same.

Any further ideas?

For reference, here is the output of the ss cmd in the osgi consoles:

From Eclipse
id	State       Bundle
0	ACTIVE      org.eclipse.osgi_3.10.101.v20150820-1432
	            Fragments=85
1	ACTIVE      org.eclipse.equinox.simpleconfigurator_1.1.100.v20150423-1455
2	RESOLVED    com.google.guava_15.0.0.v201403281430
3	ACTIVE      com.ibm.icu.base_52.1.0.v201404171520
5	RESOLVED    javax.annotation.jre_1.2.0.201512110704
6	RESOLVED    javax.inject_1.0.0.v20091030
8	RESOLVED    javax.xml.jre_1.3.4.201512110704
9	RESOLVED    org.apache.commons.jxpath_1.3.0.v200911051830
10	RESOLVED    org.apache.commons.lang_2.6.0.v201404270220
11	RESOLVED    org.apache.commons.logging_1.1.1.v201101211721
12	ACTIVE      org.apache.felix.gogo.command_0.10.0.v201209301215
13	ACTIVE      org.apache.felix.gogo.runtime_0.10.0.v201209301036
14	ACTIVE      org.apache.felix.gogo.shell_0.10.0.v201212101605
15	RESOLVED    org.eclipse.core.commands_3.7.0.v20150422-0725
16	ACTIVE      org.eclipse.core.contenttype_3.5.0.v20150421-2214
17	STARTING    org.eclipse.core.databinding_1.5.0.v20150422-0725
18	ACTIVE      org.eclipse.core.databinding.observable_1.5.0.v20150422-0725
19	STARTING    org.eclipse.core.databinding.property_1.5.0.v20150422-0725
20	STARTING    org.eclipse.core.expressions_3.5.0.v20150421-2214
21	ACTIVE      org.eclipse.core.filesystem_1.5.0.v20150725-1910
22	ACTIVE      org.eclipse.core.jobs_3.7.0.v20150330-2103
23	ACTIVE      org.eclipse.core.resources_3.10.1.v20150725-1910
24	ACTIVE      org.eclipse.core.runtime_3.11.1.v20150903-1804
25	ACTIVE      org.eclipse.e4.core.commands_0.11.0.v20150422-0725
26	ACTIVE      org.eclipse.e4.core.contexts_1.4.0.v20150828-0818
27	ACTIVE      org.eclipse.e4.core.di_1.5.0.v20150421-2214
28	RESOLVED    org.eclipse.e4.core.di.annotations_1.4.0.v20150528-1451
29	ACTIVE      org.eclipse.e4.core.di.extensions_0.13.0.v20150421-2214
30	ACTIVE      org.eclipse.e4.core.services_2.0.0.v20150403-1912
31	RESOLVED    org.eclipse.e4.emf.xpath_0.1.100.v20150513-0856
32	ACTIVE      org.eclipse.e4.ui.di_1.1.0.v20150422-0725
33	ACTIVE      org.eclipse.e4.ui.model.workbench_1.1.100.v20150407-1430
34	ACTIVE      org.eclipse.e4.ui.services_1.2.0.v20150422-0725
35	ACTIVE      org.eclipse.e4.ui.workbench_1.3.0.v20150531-1948
36	ACTIVE      org.eclipse.emf.common_2.11.0.v20150805-0538
37	STARTING    org.eclipse.emf.databinding_1.3.0.v20150123-0452
38	ACTIVE      org.eclipse.emf.ecore_2.11.1.v20150805-0538
39	STARTING    org.eclipse.emf.ecore.change_2.11.0.v20150805-0538
40	ACTIVE      org.eclipse.emf.ecore.xmi_2.11.1.v20150805-0538
41	ACTIVE      org.eclipse.equinox.app_1.3.300.v20150423-1356
42	ACTIVE      org.eclipse.equinox.common_3.7.0.v20150402-1709
43	STARTING    org.eclipse.equinox.concurrent_1.1.0.v20130327-1442
44	ACTIVE      org.eclipse.equinox.console_1.1.100.v20141023-1406
45	ACTIVE      org.eclipse.equinox.ds_1.4.300.v20150423-1356
46	ACTIVE      org.eclipse.equinox.event_1.3.100.v20140115-1647
50	RESOLVED    org.eclipse.equinox.launcher_1.3.100.v20150511-1540
52	ACTIVE      org.eclipse.equinox.preferences_3.5.300.v20150408-1437
53	ACTIVE      org.eclipse.equinox.registry_3.6.0.v20150318-1503
54	ACTIVE      org.eclipse.equinox.util_1.0.500.v20130404-1337
55	ACTIVE      org.eclipse.fx.core_2.2.0.201512110704
56	RESOLVED    org.eclipse.fx.core.databinding_2.2.0.201512110704
57	RESOLVED    org.eclipse.fx.core.di_2.2.0.201512110704
58	ACTIVE      org.eclipse.fx.core.di.context_2.2.0.201512110704
59	RESOLVED    org.eclipse.fx.core.fxml_2.2.0.201512110704
61	ACTIVE      org.eclipse.fx.osgi.util_2.2.0.201512110704
62	RESOLVED    org.eclipse.fx.ui.animation_2.2.0.201512110704
63	ACTIVE      org.eclipse.fx.ui.controls_2.2.0.201512110704
64	RESOLVED    org.eclipse.fx.ui.databinding_2.2.0.201512110704
65	ACTIVE      org.eclipse.fx.ui.di_2.2.0.201512110704
66	RESOLVED    org.eclipse.fx.ui.dialogs_2.2.0.201512110704
67	ACTIVE      org.eclipse.fx.ui.keybindings_2.2.0.201512110704
68	RESOLVED    org.eclipse.fx.ui.keybindings.e4_2.2.0.201512110704
69	ACTIVE      org.eclipse.fx.ui.keybindings.generic_2.2.0.201512110704
70	RESOLVED    org.eclipse.fx.ui.panes_2.2.0.201512110704
71	ACTIVE      org.eclipse.fx.ui.services_2.2.0.201512110704
72	ACTIVE      org.eclipse.fx.ui.theme_2.2.0.201512110704
73	ACTIVE      org.eclipse.fx.ui.workbench.base_2.2.0.201512110704
74	ACTIVE      org.eclipse.fx.ui.workbench.fx_2.2.0.201512110704
75	ACTIVE      org.eclipse.fx.ui.workbench.renderers.base_2.2.0.201512110704
76	ACTIVE      org.eclipse.fx.ui.workbench.renderers.fx_2.2.0.201512110704
77	ACTIVE      org.eclipse.fx.ui.workbench.services_2.2.0.201512110704
85	RESOLVED    org.eclipse.osgi.compatibility.state_1.0.100.v20150402-1551
	            Master=0
86	RESOLVED    org.eclipse.osgi.services_3.5.0.v20150519-2006
87	ACTIVE      de.jetty.test.app_1.0.0.qualifier
88	ACTIVE      org.eclipse.equinox.http.jetty_3.1.1.v20150818-2108
89	ACTIVE      org.eclipse.equinox.http.registry_1.1.300.v20130402-1529
90	ACTIVE      org.eclipse.equinox.http.servlet_1.2.1.v20150828-1818
91	ACTIVE      javax.servlet_3.1.0.v201410161800
92	RESOLVED    org.eclipse.jetty.continuation_9.2.13.v20150730
93	RESOLVED    org.eclipse.jetty.http_9.2.13.v20150730
94	RESOLVED    org.eclipse.jetty.io_9.2.13.v20150730
95	RESOLVED    org.eclipse.jetty.security_9.2.13.v20150730
96	RESOLVED    org.eclipse.jetty.server_9.2.13.v20150730
97	RESOLVED    org.eclipse.jetty.servlet_9.2.13.v20150730
98	RESOLVED    org.eclipse.jetty.util_9.2.13.v20150730



Standalone executable
 
id      State       Bundle
0       ACTIVE      org.eclipse.osgi_3.10.101.v20150820-1432
                    Fragments=1
1       RESOLVED    org.eclipse.osgi.compatibility.state_1.0.100.v20150402-1551
                    Master=0
2       ACTIVE      org.eclipse.equinox.simpleconfigurator_1.1.100.v20150423-1455
3       RESOLVED    com.google.guava_15.0.0.v201403281430
4       ACTIVE      com.ibm.icu.base_52.1.0.v201404171520
5       ACTIVE      de.jetty.test.app_1.0.0.201601181407
6       RESOLVED    javax.annotation.jre_1.2.0.201601180703
7       RESOLVED    javax.inject_1.0.0.v20091030
8       ACTIVE      javax.servlet_3.1.0.v201410161800
9       RESOLVED    javax.xml.jre_1.3.4.201601180703
10      RESOLVED    org.apache.commons.jxpath_1.3.0.v200911051830
11      RESOLVED    org.apache.commons.lang_2.6.0.v201404270220
12      RESOLVED    org.apache.commons.logging_1.1.1.v201101211721
13      ACTIVE      org.apache.felix.gogo.command_0.10.0.v201209301215
14      ACTIVE      org.apache.felix.gogo.runtime_0.10.0.v201209301036
15      ACTIVE      org.apache.felix.gogo.shell_0.10.0.v201212101605
16      RESOLVED    org.eclipse.core.commands_3.7.0.v20150422-0725
17      ACTIVE      org.eclipse.core.contenttype_3.5.0.v20150421-2214
18      STARTING    org.eclipse.core.databinding_1.5.0.v20150422-0725
19      ACTIVE      org.eclipse.core.databinding.observable_1.5.0.v20150422-0725
20      STARTING    org.eclipse.core.databinding.property_1.5.0.v20150422-0725
21      STARTING    org.eclipse.core.expressions_3.5.0.v20150421-2214
22      ACTIVE      org.eclipse.core.filesystem_1.5.0.v20150725-1910
23      ACTIVE      org.eclipse.core.jobs_3.7.0.v20150330-2103
24      ACTIVE      org.eclipse.core.resources_3.10.1.v20150725-1910
25      ACTIVE      org.eclipse.core.runtime_3.11.1.v20150903-1804
26      ACTIVE      org.eclipse.e4.core.commands_0.11.0.v20150422-0725
27      ACTIVE      org.eclipse.e4.core.contexts_1.4.0.v20150828-0818
28      ACTIVE      org.eclipse.e4.core.di_1.5.0.v20150421-2214
29      RESOLVED    org.eclipse.e4.core.di.annotations_1.4.0.v20150528-1451
30      ACTIVE      org.eclipse.e4.core.di.extensions_0.13.0.v20150421-2214
31      ACTIVE      org.eclipse.e4.core.services_2.0.0.v20150403-1912
32      RESOLVED    org.eclipse.e4.emf.xpath_0.1.100.v20150513-0856
33      ACTIVE      org.eclipse.e4.ui.di_1.1.0.v20150422-0725
34      ACTIVE      org.eclipse.e4.ui.model.workbench_1.1.100.v20150407-1430
35      ACTIVE      org.eclipse.e4.ui.services_1.2.0.v20150422-0725
36      ACTIVE      org.eclipse.e4.ui.workbench_1.3.0.v20150531-1948
37      ACTIVE      org.eclipse.emf.common_2.11.0.v20150805-0538
38      STARTING    org.eclipse.emf.databinding_1.3.0.v20150123-0452
39      ACTIVE      org.eclipse.emf.ecore_2.11.1.v20150805-0538
40      STARTING    org.eclipse.emf.ecore.change_2.11.0.v20150805-0538
41      ACTIVE      org.eclipse.emf.ecore.xmi_2.11.1.v20150805-0538
42      ACTIVE      org.eclipse.equinox.app_1.3.300.v20150423-1356
43      ACTIVE      org.eclipse.equinox.common_3.7.0.v20150402-1709
44      STARTING    org.eclipse.equinox.concurrent_1.1.0.v20130327-1442
45      ACTIVE      org.eclipse.equinox.console_1.1.100.v20141023-1406
46      ACTIVE      org.eclipse.equinox.ds_1.4.300.v20150423-1356
47      ACTIVE      org.eclipse.equinox.event_1.3.100.v20140115-1647
48      ACTIVE      org.eclipse.equinox.http.jetty_3.1.1.v20150818-2108
49      ACTIVE      org.eclipse.equinox.http.registry_1.1.300.v20130402-1529
50      ACTIVE      org.eclipse.equinox.http.servlet_1.2.1.v20150828-1818
51      RESOLVED    org.eclipse.equinox.launcher_1.3.100.v20150511-1540
52      ACTIVE      org.eclipse.equinox.preferences_3.5.300.v20150408-1437
53      ACTIVE      org.eclipse.equinox.registry_3.6.0.v20150318-1503
54      ACTIVE      org.eclipse.equinox.util_1.0.500.v20130404-1337
55      ACTIVE      org.eclipse.fx.core_2.2.0.201601180703
56      RESOLVED    org.eclipse.fx.core.databinding_2.2.0.201601180703
57      RESOLVED    org.eclipse.fx.core.di_2.2.0.201601180703
58      ACTIVE      org.eclipse.fx.core.di.context_2.2.0.201601180703
59      RESOLVED    org.eclipse.fx.core.fxml_2.2.0.201601180703
60      ACTIVE      org.eclipse.fx.osgi.util_2.2.0.201601180703
61      RESOLVED    org.eclipse.fx.ui.animation_2.2.0.201601180703
62      ACTIVE      org.eclipse.fx.ui.controls_2.2.0.201601180703
63      RESOLVED    org.eclipse.fx.ui.databinding_2.2.0.201601180703
64      ACTIVE      org.eclipse.fx.ui.di_2.2.0.201601180703
65      RESOLVED    org.eclipse.fx.ui.dialogs_2.2.0.201601180703
66      ACTIVE      org.eclipse.fx.ui.keybindings_2.2.0.201601180703
67      RESOLVED    org.eclipse.fx.ui.keybindings.e4_2.2.0.201601180703
68      ACTIVE      org.eclipse.fx.ui.keybindings.generic_2.2.0.201601180703
69      RESOLVED    org.eclipse.fx.ui.panes_2.2.0.201601180703
70      ACTIVE      org.eclipse.fx.ui.services_2.2.0.201601180703
71      ACTIVE      org.eclipse.fx.ui.theme_2.2.0.201601180703
72      ACTIVE      org.eclipse.fx.ui.workbench.base_2.2.0.201601180703
73      ACTIVE      org.eclipse.fx.ui.workbench.fx_2.2.0.201601180703
74      ACTIVE      org.eclipse.fx.ui.workbench.renderers.base_2.2.0.201601180703
75      ACTIVE      org.eclipse.fx.ui.workbench.renderers.fx_2.2.0.201601180703
76      ACTIVE      org.eclipse.fx.ui.workbench.services_2.2.0.201601180703
77      RESOLVED    org.eclipse.jetty.continuation_9.2.13.v20150730
78      RESOLVED    org.eclipse.jetty.http_9.2.13.v20150730
79      RESOLVED    org.eclipse.jetty.io_9.2.13.v20150730
80      RESOLVED    org.eclipse.jetty.security_9.2.13.v20150730
81      RESOLVED    org.eclipse.jetty.server_9.2.13.v20150730
82      RESOLVED    org.eclipse.jetty.servlet_9.2.13.v20150730
83      RESOLVED    org.eclipse.jetty.util_9.2.13.v20150730
84      RESOLVED    org.eclipse.osgi.services_3.5.0.v20150519-2006
Re: Embedded jetty in efxclipse application [message #1720518 is a reply to message #1720415] Tue, 19 January 2016 07:34 Go to previous messageGo to next message
Ali Karimi is currently offline Ali KarimiFriend
Messages: 36
Registered: October 2015
Member
For anyone comming to this thread, it turns out that the jetty server is running but using a different port then the one i specified when running from eclipse.
From within eclipse one can specify the port by using a command line argument in the vm arguments section of the launching tab of the product file.
The following two, which i was using also in older versions of jetty are working when the application is started from eclipse. You only need one of those:
VM Arguments
-Dorg.osgi.service.http.port=8888
-Dorg.eclipse.equinox.http.jetty.http.port=8888

However, the resulting executable ignores those parameters although they exist in the eclipse.ini file. Also note the default port in jetty is 80.
This is also the reason why i did not recognize that the server is already running. I thought it was 8080.

[Updated on: Tue, 19 January 2016 07:35]

Report message to a moderator

Re: Embedded jetty in efxclipse application [message #1720521 is a reply to message #1720518] Tue, 19 January 2016 07:43 Go to previous messageGo to next message
Thomas Schindl is currently offline Thomas SchindlFriend
Messages: 6651
Registered: July 2009
Senior Member
The eclipse.ini is ONLY read by the native eclipse launcher! If you run
from the command line with java -jar you need to add them to the call!
If you use the java-packager you need to add them to the build.xml.

Tom

On 19.01.16 08:34, Ali Karimi wrote:
> For anyone comming to this thread, it turns out that the jetty server is
> running but using a different port then the one i specified when running
> from eclipse. From within eclipse one can specify the port by using a
> command line argument in the vm arguments section of the launching tab
> of the product file. The following two, which i was using also in older
> versions of jetty are working when the application is started from eclipse:
> VM Arguments
>
> -Dorg.osgi.service.http.port=8888
> -Dorg.eclipse.equinox.http.jetty.http.port=8888
>
> However, the resulting executable ignores those parameters although they
> exist in the eclipse.ini file. Also note the default port in jetty is
> 80. This is also the reason why i did not recognize that the server is
> already running. I thought it was 8080.
Re: Embedded jetty in efxclipse application [message #1720529 is a reply to message #1720521] Tue, 19 January 2016 08:21 Go to previous message
Ali Karimi is currently offline Ali KarimiFriend
Messages: 36
Registered: October 2015
Member
Oh yes, indeed. That works. This information would have saved a lot of my time Very Happy
However, thanks for the clarification. Now, things are making sense.
Previous Topic:tycho build failing due to missing efxclipse dependencies
Next Topic:Native launcher artifacts for efxclipse application
Goto Forum:
  


Current Time: Thu Apr 18 14:06:26 GMT 2024

Powered by FUDForum. Page generated in 0.02237 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top