Not able to create custom error for Spring jersey application - java

We have a web based application with Front end in Angular JS 1 and REST service with Spring jersey frame work.We are using Spring 3.We have deployed our project in Tomcat 9.We have deployed angular js part as a separate project and REST service is build as a war file and deployed separately.
Suppose our application url is https://10.100.200.300:8443/DEMO.When we are trying to access the URL with a wrong value say https://10.100.200.300:8443/DEMO_TEST we are getting the error 404 i.e. resource not found by the tomcat server.We want to show some customized error page for 404 or any other tomcat error. Please suggest how to do it?

You can have a look here - Configure spring boot to redirect 404 to a single page app
Make spring configuration as mentioned in above answer and reroute it to your desired page.

Related

Difference in URLs to access the Controller Mappings

I am trying to learn Spring Framework and while going through the Spring MVC and Spring Boot REST to create a dummy project, I noticed below difference in the way the Tomcat responds to your URL in the browser
Spring Boot
http://localhost:8080/
Redirects to the Controller that is mapped to "/"
http://localhost:8080/springbootrestapp
where "springbootrestapp" is the project name, it gives HTTP 404 resource not found error
Spring MVC
http://localhost:8080/
Opens the Tomcat Home page
http://localhost:8080/springmvc
where "springmvc" is the project name, it redirects to the Controller that is mapped to "/"
My doubt is why in case of Spring Boot just entering the localhost:8080 redirects to the controller mapped to "/" whereas in case of Spring MVC(without Spring Boot configurations) it needs http://localhost:8080/<projectname>/ to redirect to controller mapped to "/" ?
I got the same issue In my case before running my Spring-MVC application I started the tomcat server I didn't stop so whenever I access localhost:8080/ it redirect me to Tomcat Client.
The first option is very basic: we just have to delete the /ROOT/ folder in $CATALINA_HOME\webapps, rename our springbootrestapp.war (or springmvc.war) to ROOT.war, and deploy it.
Our app will now be available at http://localhost:8080/.
There are different solutions not to change the filename. You can review the recommendations here.

Can a JBOSS 7+ servlet listen/take over another subdeployment's requests?

Currently working an application that is moving from JBOSS 4 (java 6) to JBOSS 7.1 (Java 8). It had no REST WS - only SOAP and worked with Servlets.
I added my WAR containing a basic REST Service (ApplicationPath class with 1 resource class and a web.xml (empty since I'm using RESTEasy implementation which should scan my classes)) to the main EAR.
During deployment, I see no errors in my logs and it says my .war has been deployed and my web context registered.
However, whenever I call one of my resource's endpoint I get the default JBOSS response for Error 404 Not Found (the url is correct though) and when I try to call the same URL but by using PUT or POST I get the message "Http Method POST is not supported by this URL" which is typically an error from Custom Servlets.
Is it possible that another Servlet is listening to my path or taking over things? Even if outside of my web context? How could I investigate/debug this?
The problem came from the old RESTeasy Version - 3.0.7-Final that was being used, which has some known bugs with the #ApplicationPath annotation and web.xml configuration. After using the provided version of RESTeasy from the JBOSS 7 (version 3.6.1-SP2), everything worked like a charm.

Camunda Spring Boot starter with embedded forms

I am trying to use embedded forms with a start event with the Camunda spring boot starter.
My startEvent is described like this:
<bpmn:startEvent id="StartEvent_1" name="Rechnungseingang" camunda:formKey="embedded:app:forms/rechnungseingang.html">
<bpmn:outgoing>SequenceFlow_0dtfc1a</bpmn:outgoing>
</bpmn:startEvent>
The form itself is located under "src/main/webapp/forms/rechnungseingang.html", from my understanding this should be the correct path.
If I try to start the process after starting the spring boot app, I am receiving the error: "Form failure: The context path is either empty or not defined."
In the browser console, I can see a request to http://localhost:8080/test/api/engine/engine/default/process-definition/Rechnungseingang:1:927f0aa4-e590-11e7-973d-e2cbd8678b9f/startForm with the response:
{"key":"embedded:app:forms/rechnungseingang.html","contextPath":null}
Obviously the application can't handle the null value in the contextPath. How am I able to set the contextPath for Camunda in Spring Boot? In the application.properties I already tried to set server.context-path with no effect.
1.) there is no src/main/webapp with spring boot applications, use src/main/resources/static
2.) for camunda to link the resource to the engine, you will need a process application. This is done easily by adding "#EnableProcessApplication" to your spring boot app.
3.) Autodeployment requires a src/main/resources/META-INF/processes.xml file, but you can leave it empty
4.) there is a full example for embedded forms with camunda spring boot here: https://github.com/camunda/camunda-bpm-examples/tree/master/spring-boot-starter/example-twitter

Spring Boot sample Rest web service getting 403 error on Weblogic

I'm deploying a .war file built from one of the Spring Boot Getting Started projects, built with Spring Tool Suite. It's a simple RESTful webservice that works on the Tomcat server provided in the Spring Tool Suite running on my PC. The service responds with a string property on a get operation, so it's simple.
I added the Web Fragment Module facet in order to generate a war file. I'm deploying this war to a Weblogic 10.3.5 managed server instance on a test host. The deployment is successful. However, when I use the test URL provided from the Weblogic admin console, I get a 403 forbidden error.
This basic war does not have a web.xml. Should I have one? Should it contain a welcome file reference?
Is there additional configuration that I should do on Weblogic? I am reading the Weblogic documentation.

Spring Web Service SOAP is not working after integration with struts 2.3?

Till now in my project the spring 3.0.1 and struts 2.0 was getting integrated and SOAP web service was working perfectly fine. But for some security reason I have migrated to struts 2.3 and for SOAP, I am using jars like spring-ws-all-1.5.9 and wsld4j-1.6.2.jar.
Still when I am calling my web service method I am getting exception like this:
HTTP Status 404 - There is no Action mapped for namespace [/] and action name [someServices] associated with context path [/someproject].
I tried to search the solution for this problem but I didn't get any. I finally migrated my jar to spring-ws-2.0.2.RELEASE-all.jar . Still I am getting the same problem. Please help me if anyone have any idea.

Categories

Resources