Eclipse RCP + Jetty 9.4.8 + Websocket - eclipse

I'm writing an Eclipse RCP application. I use the embedded Jetty server to handle Rest Services. It works fine.
Now I want to add a WebSocket Connection. I didn't find any Jetty Websocket bundle in the Eclipse repository. So I've created my own plugin with the differents Jetty WebSocket jars.
I've created a WebSocketServlet and a wetsocket client to test it.
When I try to initiate de Websocket, I get the following error :
java.lang.IllegalStateException: Unable to find required ServletContext attribute: org.eclipse.jetty.util.DecoratedObjectFactory
at org.eclipse.jetty.websocket.server.WebSocketServerFactory.doStart(WebSocketServerFactory.java:311)
Does someone have a solution ?
Thanks.
Cedric.

Don't mix versions of Jetty jars, make sure you are using the same version for all Jetty jars.
Bundles for Jetty can be found at the listed location.
https://download.eclipse.org/jetty/updates/jetty-bundles-9.x/

Thank you for your answers.
The Jetty version bundled with my Eclipse version is the 9.4.8. I known, I have to migrate to a newer version but I didn't do it yet (and I get some troubles with Java 9+ and the Jersey layer embedded in eclipse (the rsconnector).
The ServletContextLauncher present into the Jetty eclipse bundle set up correctly the DecoratedObjectFactory but It doesn't seem to be used to initialise the websocket server layer.
I've already did some tests a few years ago with an oldest Jetty release (also bundled in an eclipse plugin) and I was able to open a websocket without error. But, not with the 9.4.8 one...

Related

Apache Wicket Quick Start

I was trying to start learning about Apache Wicket (as it looked like an easy to use UI for Java) and as I like to work with Eclipse and Maven. I also like to work with Tomcat, however, Wicket seems to prefer Jetty at least in its tutorials. I do not know nothing about Jetty, however should not take ages to learn.
I tried the Wicket Quick Start and successfully imported the generated Maven project to Eclipse workspace.
But errors appear: e.g.
import org.eclipse.jetty.server.HttpConfiguration;
It seems Eclipse cannot find the jetty server classes. How to add these to the Eclipse project?
Does the creater of the Wicket Quick Start assumed that Jetty is already installed on the machine?
I installed it. However: what is the recommended way to make what jar file available to a maven project to have jetty server classes available? I would assume via the pom.xml but I doubt that is the case here - the given pom.xml would contain it.
Or is there some special plugin for Eclipse (Photon)?Run-Jetty-Run?. I wasn't brave enough to try that.
I would love to get the Wicket Quick Start running.
I also tried Eclipse + Tomcat + Apache Wicket Maven Setup with Hello World Example but it seems that it is outdated. I was not able to install qwickie to Eclipse as described.
I am using Eclipse Proton with Java 10.0.2 on Debian Stretch.
If you are using https://wicket.apache.org/start/quickstart.html then you can start the application these ways:
mvn jetty:run - this will use jetty-maven-plugin
Open in Eclipse src/test/java/com/example/Start.java and run it as a normal Java class with a main(String[]) method. This will use Jetty Maven dependencies to start an embedded Jetty server.
Wicket's Quickstart prefers Jetty because Jetty developers made it easy to use it in non production way, i.e. in development mode, for faster dev cycles. No need to build a .war file and deploy it.
On the other side Tomcat devs (disclaimer: I am a member of both Wicket and Tomcat teams) never spent time in this direction. Tomcat's Maven plugin has been abandoned long time ago. The best integration for starting embedded Tomcat is provided by Spring Boot project (I recommend it if you use Spring!).
So, just remove the Jetty related dependencies and plugin in pom.xml and the Start.java in src/test/java/.... Then you can continue developing with Eclipse and Tomcat the way you like to do it.

Using DCEVM with weblogic 12 and eclipse

I have dynamic web project which is deployed as part of EAR on weblogic server. I am using eclipse IDE. I have used jar available on http://dcevm.github.io/ to configure DCEVM as alternated JVM for JDk1.7.0_45. After starting my server and publishing my application, if I make changes to java files(add new methods, rename methods) I don't see the change. I still see the error in eclipse as "Hot code replace failed.
Am I missing any step/setting? Please help
You should have some agent that supports weblogic. https://github.com/HotswapProjects/HotswapAgent

Configuring Mojarra 2.1.X on Eclipse Indigo

The User Library download from Properties/Project Facets/Java Server Faces only lists Apache and Mojarra 2.0.X options. And setting up a user library manually, if I add javax.faces-2.1.11.jar, it doesn't error, puts the jar in the entry, then says \jarfiles\jaf (missing). So I see no way to use Mojarra 2.1.X.
I am unable to understand completely that what are you saying? But as much as I can I understood that "you want you use Mojarra 2.1.X" in your project. Now here is the thing You should mention the server that you are using.
If you are using glassfish 3.1.x then you have to replace your javax.faces.jar present in /glassfish/modules folder with javax.faces-2.1.11.jar as the glassfish built in jar javax.faces.jar enforce glassfish to use Mojarra 2.1.6.Now if it is Tomcat then it is up to you that you have to add all jsf compulsory jars in your lib folder :) One last thing that if you are using anyother server which has built in support for JSF and you are unable to find How to replace your jar from that server or you have issue with admin access over that server then you can also upgrade JSF by placing the newer javax.faces.jar file in webapp's own /WEB-INF/lib folder and editing the /WEB-INF/glassfish-web.xml file to add the following two new entries: <class-loader delegate="false" /><property name="useBundledJsf" value="true" />.Keep in mind that you are only enforce Web servers to use your desired jars not the application servers because many applications servers are giving built in support for JSF. So Configuring Mojarra 2.1.X on Eclipse Indigo is somehow wrong to ask.You have to ask that how should I use Mojarra 2.1.x with my XXX server because eclipse is only IDE and these things are SOMEHOW managed by IDE but only in case of Webservers.Thanks :)

How to set up eclipse with GWT and (regular servlet) Jetty backend

Does anybody know how to set up a project in Eclipse with GWT and a jetty backend (regular web app, not app engine)? Or know of a good link (tried googling it, but no dice)
I've been trying to set up this all evening, but just ran into a number of strange problems, some seems to be bugs in WST/Jetty and the other is that the host page just doesn't work :-(
There are three ways to run your own jetty server together with GWT.
If you run your own jetty server you have to invoke dev-mode in GWT with the -noserverparameter or for solution one you can use -server JettyLauncher
Use your own JettyLauncher.class or use gwt-jetty.
Use Jetty maven plugin to launch the jetty server (see here and here for infos)
Use Jetty WTP plugin for eclipse to start a jetty server.
I personally used solution 3 (Jetty WTP plugin) to start a custom Jetty 7 server for my GWT project and it works fine.

Eclipse doesn't import all Axis2 jars but project still runs on Tomcat?

When I develop an Axis2 web service on Eclipse, I noticed that Eclipse is automatically copying the classes from the lib folder of Axis2 to the lib folder of the new project. However, not all classes from the lib folder of Axis2 are being copied. Interestingly, the web service runs without any problem when deployed to Tomcat via Eclipse even if some the jars from Axis2 were not copied. Also, when I viewed the temp file of Tomcat, Tomcat seems to generate the jars for the listed modules on modules.list of the web service.
Can someone enlighten me regarding what is happening on this? Why Eclipse doesn't copy all the jars from Axis2? Why can the web service run on Tomcat even without the other jars from Axis2? What are those temp files for? When and why is it being generated?
I tried to run the same project on WebSphere and I am encountering a ClassDefNotFound exception because of the missing jars. My problem was solved when I copied all the Axis2 jars that was not copied by Eclipse to my project. But I'm not comfortable with my solution because Tomcat can run my project even without those jars. Is my solution really the right solution? Or am I missing a configuration setting?
This is just for clarification:
My web service is already running in Axis2. My class loading policy is set to PARENT_LAST. I know that since WebSphere has its own Axis2 configuration, the class loading policy must be set to PARENT_LAST so that WebSphere will use the Axis2 from the project itself. Aside from setting the class loading policy, I did something to make my web service run on WebSphere. I describe what I did above. My question is why such method must be taken?
WebSphere has it's own axis2 configuration as part of its Java EE server spec for JAX-WS. Change your class loading policy to PARENT_LAST and check if that solves your problem.
Edit:
As the original post already states: WebSphere is a Java EE server depending on version it supports its the standard Java JAX-WS web services. Actually web services became part of the standard jdk.
If you use JAX-WS like mentioned in Introduction to JAX-WS or building web services then you don't have to add any 3rd party library for getting your web services running. As soon as you use the non JDK implementation like axis2 you have to package it with your application.
IBM didn't just pack the axis2 into their WAS/JDK, they modified it. I'm not sure what Tomcat delivers, however as long as you use JAX-WS it shouldn't matter. With JAX-WS you don't have any direct import of the org.apache.axis packages. If you use these imports you have to supply the libraries and make sure that yours are loaded.