RestEasy running on WebSphere 8.5 - resteasy

I am new to RestFul API and came across this https://www.journaldev.com/9189/resteasy-tutorial-eclipse-tomcat. The tutorial is working fine on Tomcat but encounters 404 on WebSphere 8.5.
I could see the below printed in SystemOut.log during startup.
[6/9/20 18:15:54:460 SGT] 0000004a ServletWrappe I com.ibm.ws.webcontainer.servlet.ServletWrapper init SRVE0242I: [backoffice] [/secure/backoffice] [ResteasyServlet]: Initialization successful.
Classloader at server level
Classloader at application level
No error code found in the J2EE logs but found below error in the web error log.
[Thu Jun 11 10:34:57 2020] [error] [client 10.128.1.22] File does not exist: /sldev/scb/dev/ist/web_bkoff/secure/backoffice/rest
I tried below tutorial in IBM website yet I still encounter same issue https://www.ibm.com/support/knowledgecenter/SSAW57_8.5.5/com.ibm.websphere.nd.multiplatform.doc/ae/twbs_jaxrs_getstarted.html
SystemOut.log
<servlet>
<servlet-name>HelloWorldApp</servlet-name>
<servlet-class>com.ibm.websphere.jaxrs.server.IBMRestServlet</servlet-class>
<init-param>
<param-name>javax.ws.rs.Application</param-name>
<param-value>com.ibm.jaxrs.sample.HelloWorldAppConfig</param-value>
</init-param>
<load-on-startup>9</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>HelloWorldApp</servlet-name>
<url-pattern>/rest/*</url-pattern>
</servlet-mapping>

If I had to guess, the problem is most likely that WebSphere 8.5 ships the JAX-RS 1.1 APIs, but the article you referenced uses JAX-RS 2.0. The current version of RESTEasy uses the JAX-RS 2.1 APIs.
RESTEasy implements the JAX-RS APIs. This allows users to code to the JAX-RS APIs, and then run on any compatible implementation - like CXF, Jersey, RESTEasy, etc. But if the implementation is mis-matched with the API version, you can run into problems.
Tomcat does not package any JAX-RS APIs, so it will use the APIs packaged with the application - which should match with what RESTEasy expects. But since WebSphere ships it's own version of the API (and it's own implementation, based on Apache Wink) you are probably running into those problems.
WebSphere v9.0 has the ability to switch API versions to use 2.0, and WebSphere Liberty (or Open Liberty) has the ability to enable/disable different versions of JAX-RS entirely. Unfortunately, WebSphere v8.5 does not have the ability to disable the JAX-RS APIs.
If you can upgrade to v9.0 or switch over to Liberty, that would most likely solve this problem. If upgrading is not an option, you may still be able to make it work in WebSphere v8.5, but it's not a pretty solution: you could use a parent-last classloading delegation so that your application loads the RESTEasy and JAX-RS 2.X API classes from your application's classloader before loading the JAX-RS 1.1/Wink classes from WebSphere's classloader. More information on parent-last here:
https://www.ibm.com/support/knowledgecenter/SS7K4U_8.5.5/com.ibm.websphere.zseries.doc/ae/urun_rclassloader_inst.html
Alternatively, you could package the JAX-RS 2.X API JARs and RESTEasy in an isolated shared library and associate that library with the application. Isolated shared libraries are parent-last, but leaves the application classloader at parent-first. More information on isolated shared libraries here:
https://www.ibm.com/support/knowledgecenter/SSEQTP_8.5.5/com.ibm.websphere.base.iseries.doc/ae/tcws_sharedlib.html
Hope this helps!

Related

Developping an angularJS app using a tomcat server

Hi stackoverflow community,
I'm on a project that imposes developping a web app with these technologies:
AngularJs app calling the back-end (the back-end API already existing)
this app will be hosted on Tomcat, with maven as a build tool.
Now I installed eclipse, configured maven and tomcat on it, and i want to start with my first html page. The problem is that I can't find how to deploy an html page (as a start) with these technologies without using a servlet.
I want to generate a war file using maven that would be deployed in tomcat server without defining servlets in web.xml.
All i can find on the internet is how to manually deploy angularJs apps on tomcat.
I found this github project that might be very useful, I'll try to follow the same project structure.

Google Endpoints V2 and Maven plugin version?

We have a multi-module (war-packaged) project that uses com.google.appengine - appengine-maven-plugin target being ear file.
We have migrated succesfully to Java8 and EndpointsV2. It builds and runs fine in Cloud. However the following requirement is still a bit questionmark in the migration instructions. What is the reason behind this incompatibility and requirement? Or is it just related to for example "discovery docs" that we are not using anyway?
The old App Engine Maven plugin, with group com.google.appengine, is incompatible with the Endpoints Framework plugin. You must use the new version shown above
https://cloud.google.com/endpoints/docs/frameworks/java/migrating
If you aren't using discovery docs or generated client libraries and are only using Endpoints as a library dependency, you can remove the Endpoints plugin and the error should go away.

Deploying camel spring application in Apache Karaf 4.2.0

I am trying to deploy camel spring application in apache karaf. I am using maven to resolve the dependencies. The application runs fine in Intellij but when I deploy the application (along with all the project dependencies) in karaf the application won't start.
Can anyone tell me what is the correct way to deploy camel spring application in karaf?
And also the best approach in resolving the project dependencies?
Camel-version: 2.16.5
Karaf: 4.2.0
If the application is not starting, then it might be waiting for some resolvable dependency. Check the log and install the dependency manually using feature:install. Also ensure all libraries are properly mentioned in pom.xml

Is it possible to use camel-2.16.2 with servicemix 5.6.0 and karaf -2.4.4?

In our application we have encountered impotency issue which is fixed by https://issues.apache.org/jira/browse/CAMEL-9480. we are currently using service mix 5.5.0 with following dependencies.
Activiti 5.17.0
Apache ActiveMQ 5.11.1
Apache Camel 2.15.2
Apache CXF 3.0.4
Apache Karaf 2.4.3 .
So in-order to get fix for CAMEL-9480, i tried to upgrade camel to 2.16.2 by doing service mix upgrade to 5.6.0 which supports following dependencies
Activiti 5.19.0.2
Apache ActiveMQ 5.12.3
Apache Camel 2.16.2
Apache CXF 3.1.4
Apache Karaf 2.4.4
after upgrade i am getting following error during deployment
[caused by: Unable to resolve 295.0: missing requirement [295.0] osgi.wiring.package; (&(osgi.wiring.package=org.eclipse.jetty.util.log)(version>=9.2.0)(!(version>=10.0.0)))]
when i checked camel-jetty-2.16.2.pom,it uses camel-jetty9 and in karaf features its mentioned as below.
<details>camel-jetty9 intend to work with jetty9, so this feature only works in the karaf container which support jetty9, e.g. karaf 4.x</details>
so is it possible to use camel-2.16.2 with karaf 2.4.4 or we need upgrade to karaf 4.x?
There are two bundles and two features:
camel-jetty which support jetty8 (and Karaf 2/3)
camel-jetty9 which support jetty9 and Karaf 4
However, It depends too on the other camel features you use. Some feature uses a feature jetty without versions, other use directly camel-jetty9 or camel-jetty, etc. Sometimes, It necessary to rewrite some feature to fix a version range, but in most case, it works out of the box.

How do I install and use Apache Velocity?

I have installed Apache server 2.4, and Ant 1.8.3, I have downloaded Velocity 1.7, and Velocity tools 2.0. I have read the installation documentation for Apache Velocity about ten times, and Googled it for two days, I still have no idea what to do with these files. Can anyone provide a detailed description on how to install Velocity please?
I was hoping to develop using Eclipse, so I have also installed this.
I would appreciate any assistance as I am stuck.
Thank you.
Update:
I have configured Eclipse to use Tomcat and have worked my way through a tutorial and managed to get this all working, but I do not know how exactly to start a velocity project in Eclipse, if anyone has used Eclipse to build a Velocity project, I would appreciate some advice on how to set that up.
Thanks.
You will also need a Java EE container (aka servlet container) like Apache Tomcat. The Apache HTTP server doesn't know anything about Java. Please note that Tomcat can itself be used directly as an HTTP server - you would typically choose to keep Apache HTTP server in front of Tomcat on production servers to speed up static files requests among other reasons (Apache HTTP can forward requests to Tomcat with the mod_proxy_ajp module). But for the beginning, it's easier to directly use the HTTP service provided by Tomcat.
Then, you need to get familiar with the concept of a Web Application. It's nothing more than a specific hierarchy of files (that can be compressed into a jar file with the .war extension). For a web application using Velocity, that would typically be:
./ ← root of your web application
./index.vhtml ← your welcome page template
./foo/bar.vhtml ← any other file or subdirectory containing your web resources
./WEB-INF/ ← the WEB-INF directory contains all web application configuration
./WEB-INF/web.xml ← maps HTTP requests towards filters and servlets
./WEB-INF/tools.xml ← optional configuration file for your Velocity custom tools
./WEB-INF/velocity.properties ← optional file to tune Velocity configuration
./WEB-INF/lib/ ← contains all the libraries needed by your web application
./WEB-INF/src/ ← contains your custom Java classes source code
./WEB-INF/classes/ ← contains your custom Java classes
Your web.xml file has to map adequate requests towards the VelocityViewServlet. It will look like this:
<?xml version="1.0" encoding="ISO-8859-1" ?>
<web-app version="2.4" xmlns="http://java.sun.com/xml/ns/j2ee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee
http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd">
<servlet>
<servlet-name>view</servlet-name>
<servlet-class>org.apache.velocity.tools.view.VelocityViewServlet</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>view</servlet-name>
<url-pattern>*.vhtml</url-pattern>
</servlet-mapping>
</web-app>
I cannot help you much with Eclipse as I don't use it, but there seems to be several tutorials online if you search for tomcat + eclipse. Here's one that looks interesting: http://www.coreservlets.com/Apache-Tomcat-Tutorial/tomcat-7-with-eclipse.html

Resources