Struts2 simple app throwing HTTP 404 Exception - web

I am running a "Hello World " struts 2 example.I have put all the required dependencies in the "/WEB-INF/lib" location. I have the following jars in my lib location :
commons.io_2.0.1.jar
commons-collections-3.2.1.jar
commons-fileupload-1.2.2.jar
commons-logging-1.1.1.jar
freemarker-2.3.16.jar
ognl-2.6.11.jar
struts2-core-2.2.3.jar
xwork-2.0.4.jar
Do I need any other jar file to run simple Struts2 app?
I am getting "HTTP Status 404 - requested resource is not available" exception when I am running my app.

Check the web.xml as well as the deployment descriptor created by Eclipse to know if it points to the correct JSP. i.e. if the jsp is under JSP folder, the welcome file should be /JSP/welcome.jsp

FYI: Filter dispatcher has been deprecated in struts2 i must suggest you to use
org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter
its always better to start with updated one
And try adding commons-lang3-3.x file. It might work.

Related

Broadleaf - running locally - problem getting started the API project

I'm trying to run Heat Clinic 6.0.1 locally following getting started tutorial: https://www.broadleafcommerce.com/docs/core/current/getting-started/running-locally
I managed to run admin and site but not the API project. The application starts without problems but when I go to http://localhost:8082/api/v1/swagger-ui.html I get a 404. In the log I see this exception:
javax.servlet.ServletException: Circular view path [error]: would dispatch back to the current handler URL [/error] again. Check your ViewResolver setup! (Hint: This may be the result of an unspecified view, due to default view name generation.)
Also trying to log in directly in the API with user broadleafapi and password gives 404.
My environment: Windows 10, jdk 8, maven 3.6
What's wrong? Can you help me? Thank you
Thanks for the report. I reproduced this and it looks like that with the update to Spring Boot 2.0, we did not appropriately override the updated property that specifies the servlet location to embedded Tomcat. Thus, when you went to /api/v1/swagger-ui.html, the application treats it exactly like that URL which is what gave the 404.
Setting the server.servlet.contextPath=/api/v1 property appropriately stripped off this path as part of the servlet context and resolved the 404.
I tested around a bit and was able to 'Authorize' the app (button at the top right of the Swagger page) with the credentials information that get spit out in the logs:
Basic auth configured with user broadleafapi and password: <<generated>>
then I was able to hit the API endpoints.
The changes you will need to make locally in your project to consume the fix are at https://github.com/BroadleafCommerce/DemoSite/commit/422d1cdc37f847afd8bec0be477ab784cbad2e9d#diff-991c59b6dbb0f619b8570d8f8779eaddR11. You will notice that I moved the original definition in default.properties over to common.properties and I recommend that you do the same. To be clear, follow these steps:
Delete the server.servlet.contextPath entry in `api/src/main/resources/runtime-properties/default.properties
Change server.servletPath in api/src/main/resources/runtime-properties/common.properties to server.servlet.contextPath
Thanks for trying out Broadleaf and the report, sorry for the rough early start!

Request for (gzipped) 'jsf.js' from Mojarra 2.3.3 results in empty response

I used the <f:websocket/> tag in my project with mojarra 2.3.3 and in project stage 'Development' everything was working fine. But when the project was deployed on our QA system with project stage 'Staging', the client produced the JS error "'mojarra' not defined".
This is due to the jsf.js being loaded as a blank file. When I debugged, I found that in com.sun.faces.application.resource.ResourceHelper#getInputStreamFromClientInfo the content of the js file is copied to a GZIPOutputStream which is never finished and thus nothing is written to the wrapped ByteArrayOutputStream (ll. 234-237), resulting in the empty response to my client.
In stage Development the file is delivered uncompressed.
Is this a bug or am I missing something? Is there a configuration for this? Is there a workaround?
I tried setting com.sun.faces.compressJavaScript to false with no luck.
When I call GZIPOutputStream#finish() on the stream before it's written to the ByteArrayInputStream in the debugger, the content of the input stream is correct and sent to the client. I also checked mojarra 2.3.8 but the code seems to be unchanged.
I expect the client to receive the correct js code. It doesn't necessarily have to be compressed.
Addition:
The project is running on a Tomcat 8.5.14 with JDK1.8.0_161 and I'm using Primefaces (6.2).
I created a miminal working example here which doesn't use Primefaces. It doesn't actually push anything into the websocket channel but the relevant thing here is the JS error when the index.xhtml is loaded.
It's also tested with Java 1.8_202, Tomcat 8.5.37, Mojarra 2.3.8. It's working (loading the jsf.js that is) with Mojarra 2.2.14.

JavaLite ActiveWeb rootPackage

I'm developing a web application with ActiveWeb. I wanted to change the package from app.controller to be.coudron.graphplanner.controller
I created a file activewebproperties and placed it in src/main/resources
the contents of the file are:
freeMarkerConfig=be.coudron.graphplanner.config.FreeMarkerConfig
bootstrap=be.coudron.graphplanner.config.AppBootstrap
dbconfig=be.coudron.graphplanner.config.DbConfig
route_config=be.coudron.graphplanner.config.RouteConfig
controllerConfig=be.coudron.graphplanner.config.AppControllerConfig
rootPackage=be.coudron.graphplanner
When I start the app with mvn jetty:run
I get the error:
org.javalite.activeweb.ControllerException: controller must be
in the 'app.controllers' package
What am i doing wrong?
There are no typos in the code nor the package names.
the exception message is self-explanatory: "controller must be in the 'app.controllers' package"
The file activeweb.properties is part of the framework and not editable. With time, you will appreciate simplicity and consistency of the framework. It requires that controllers are placed into app.controllers package. Please, refer to http://javalite.io/structure_of_activeweb_project#location-of-controllers

JSF1029 warning during deploying on a server

I use JSF 2.1.21 and Tomahawk 1.1.14. And when I try to deploy my project on a server(it can be Tomcat or Weblogic) I see the Warnings:
WARNING: JSF1029: Application is versioned at 2.0 (either explicitly by the version
of /WEB-INF/faces-config.xml or the lack of a /WEB-INF/faces-confg.xml), however class
'org.apache.myfaces.custom.aliasbean.AliasBeanTagHandler' depends on legacy facelet class.
The facelet artifact represented by this class will not be registered.
And many other warnings about diferent handlers (like a AliasBeansScopeTagHandler, HtmlInputCalendarTagHandler and so on). How can I avoid this warnings?
I tried to change the artifactId of tomahawk on tomahawk21 or tomahawk20, but it didn't help + it threw this:
java.util.MissingResourceException: Can't find bundle for base name resources.application, locale en
UPDATE:
I considered to add the stacktrace, which was displayed in the case where I tried to use tomahawk20:
java.util.MissingResourceException: Can't find bundle for base name resources.application, locale en
at java.util.ResourceBundle.throwMissingResourceException(ResourceBundle.java:1499)
at java.util.ResourceBundle.getBundleImpl(ResourceBundle.java:1322)
at java.util.ResourceBundle.getBundle(ResourceBundle.java:1028)
at org.apache.myfaces.tomahawk.resource.UncompressedResourceHandlerWrapper.getLocalePrefixForLocateResource(UncompressedResourceHandlerWrapper.java:242)
at org.apache.myfaces.tomahawk.resource.UncompressedResourceHandlerWrapper.createResource(UncompressedResourceHandlerWrapper.java:78)
at org.apache.myfaces.tomahawk.resource.UncompressedResourceHandlerWrapper.createResource(UncompressedResourceHandlerWrapper.java:61)
at com.sun.faces.facelets.tag.jsf.CompositeComponentTagLibrary.getCompositeComponentResource(CompositeComponentTagLibrary.java:155)
Before deploy your application on weblogic, the first deploy in under apache tomcat, and try to solve warnings.
" Can't find bundle for base name resources.application, locale en ", if your application wit maven, put
i18n.properties file to src\main\resources
I uploaded fully configured JSF2.2 project tamplate to github
JSF frontend

h:outputStylesheet and h:graphicImage not working?

I am using h:outputStylesheet and h:graphicImage in my .xhtml files. It works completely fine on my localhost.
Now I tried to upload my .war it on Hosting space provider which uses NGASI AppServer Manager.
Here, h:outputStylesheet and h:graphicImage tags have stopped functioning. What I noticed is that everything with pattern /ctx/faces/javax.faces.resource/....?ln=.... is giving 404: (Not found) error.
For ex:
http://www.edarena.com/EdArena/faces/javax.faces.resource/theme_edarena.css?ln=css
http://www.edarena.com/EdArena/faces/javax.faces.resource/jsf.js?ln=javax.faces&stage=Development
http://www.edarena.com/EdArena/faces/javax.faces.resource/THEME_EDARENA/logo.png?ln=images
All the .xhtml files in app root are getting accessed properly, which means the mapping /faces/* to Faces Servlet is correct in web.xml.
My first impression was that the image or resource path is somehow not getting determined.
But I just tried renaming my file resources/images/THEME_EDARENA/logo.png to logo1.png.
After this when I refresh my pages using this image, I get message 'Unable to find resource THEME_EDARENA/logo.png' in my tag. If I make it logo.png, the error messages goes away, which means the file is found but something goes wrong while rendering it.
Thanks for any help.
Please suggest something.
BR
Anand

Resources