h:outputStylesheet and h:graphicImage not working? - jsf

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

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.

Defining relative path for an application in IBM WebSphere

I have a couple of XSD's in my application. Something like the below,
XSD
common
common.xsd
request
request.xsd
response
response.xsd
I have to use the common.xsd in the request and response xsd's. So I have used import statement. The config is as below,
<xsd:import namespace="www.some.namespace.com" schemaLocation="../common/common.xsd"/>
The problem here is, this works absolutely fine in Tomcat. But when I deploy the same application in WebSphere, it is throwing error as file not found. In the logs, I could see WebSpher is looking for the xsd in the IBM installation folder. The path it is looking is, "C:/IBM installation folder/common/common.xsd".
Can anyone help ?
Thanks in advance.
Just remove the schemaLocation attribute of the import element. Just keep the namespace attribute alone and be sure that you are importing the correct namespace.

Struts2 simple app throwing HTTP 404 Exception

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.

Deploy to azure then get 403 - Access Forbidden

I'm trying to deploy to Azure (Silverlight application); I've migrated my DB, updated connection strings and published my application to Azure but when I click the service URL I get this:
403 - Forbidden: Access is denied.
You do not have permission to view this directory or page using the credentials that you supplied.
Any idea what I need to change?
Many thanks
If the name of your bundle matches the path in the file system then IIS on Azure will throw the 403 Forbidden error.
So if you have a path in your solution called /Content/css and you have a bundle name called bundles.Add(new StyleBundle("~/Content/css").Include( ... in BundleConfig.cs which is displayed like this #Styles.Render("~/Content/css") in your _Layout.cshtml file. Then you get that error.
I solved this by changing the name of my bundle from /Content/css to /Style/css
bundles.Add(new StyleBundle("~/Content/css").Include( ... in BundleConfig.cs becomes bundles.Add(new StyleBundle("~/Style/css").Include( ...
#Styles.Render("~/Content/css") in your _Layout.cshtml becomes #Styles.Render("~/Style/css") in your _Layout.cshtml
You can use any names you like there is no specific limitations. I imagine you can go ahead and rename the folders in your solution too and that should work.
NB: The name of the bundle turns into a virtual directory that the browser can request from. If it resembles a physical folder structure then it will throw back the 403.
I needed to use the full path to a page within the application as I hadn't set a default document in my web config e.g
<add value="Pages/Home.aspx"/>
I got the same error in my MVC project.
After some debugging I found that it was because I have removed all "default pages" in the Azure Portal.
I added a dummy "index.html"-record in the portal and then everything worked nicely again :)

Resources