jaysensharma / MiddlewareMagicDemos

Middleware Technology Related Demos
http://middlewaremagic.com/
31 stars 54 forks source link

Simply does not work... #3

Open gmarshall56 opened 8 years ago

gmarshall56 commented 8 years ago

I have implemented the sample provided here on a Weblogic 12c server. I have this directory established: C:\nrdImagesDir\slideshow, and \slideshow is populated with, among others, a file named USDA.jpg and a file named V4W_5.jpg. Here is my weblogic.xml:

<weblogic-web-app xmlns="http://xmlns.oracle.com/weblogic/weblogic-web-app" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://xmlns.oracle.com/weblogic/weblogic-web-app http://xmlns.oracle.com/weblogic/weblogic-web-app/1.6/weblogic-web-app.xsd">

<virtual-directory-mapping>
    <local-path>C:/nrdImagesDir</local-path>
    <url-pattern>/slideshow/*</url-pattern>
    <url-pattern>*.jpg</url-pattern>
</virtual-directory-mapping>

On my index.jsp page I have two img tags:

and:

When the page renders I get: http://localhost:7001/NRDAlphaSpringAngular/slideshow/USDA.jpg 404 (Not Found) http://localhost/NRDAlphaSpringAngular/V4W_v5.JPG 404 (Not Found)

I've been wrestling with this for the last three hours with no success. I have tried using forward slashes and back slashes in the local-patha nd url-pattern nodes. It appears that WLS is simply ignoring the virtual-directory-mapping tag in the weblogic.xml file. Any ideas? Thank you. Gary

jaysensharma commented 8 years ago

Hello Gary, Can you please share your sample project with us so that we can have a look on it to findout why it is not working with your Spring Project. Also please let us know what is your Spring & WLS Version?

gmarshall56 commented 8 years ago

Hello: Due to security issues I cannot share the projects that I have where this feature does not work. I can tell you that I am developing using Spring 4.2.5.RELEASE, and I am using WebLogic Server Version: 12.1.3.0.0.
I can share with you a couple of items. Here is the weblogic.xml file: weblogicXML.txt

Here is my web.xml file: webXML.txt

Here is my POM file: POM.txt

If you need to see any of the application context files please let me know. However I think I have identified the problem. I have two projects wherein I have installed the virtual-directory-mapping node in the weblogic.xml file. Both of these virtual-directory-mapping entries that were made in these two seperate projects point to the same local directory to find images. You can see the virtual-directory-mapping entry in the attached weblogicXML file. Now on a jsp page in the xxxcms project I have the following html:

img src="http://localhost/xxximagemapper/slideshow/scroll image 2.jpg" and: mg src="http://localhost/xxxcms/slideshow/scroll image 2.jpg"

The result of this html is that the jpg image being pulled from xxximagemapper - which is one of the projects mentioned earlier, works just fine, while the same jpg image being pulled from xxxcms - the other poject mentioned earlier - does not. BTW - the files provided earlier belong to the xxxcms project.

Also: In a new browser window I can place the above img src URL that points to the xxximagemapper project and the image returns successfully. However when I enter the img src URL that points to the xxxcms project it returns a 404 - Not Found, even though both projects have the same virtual-directory-mapping entry pointing to the same local directory where the jpg image is stored.

This is what I see that could be the problem: In the Chrome inspector, in the Network tab, I see that the image being pulled from the xxxcms project - the one that doesn't work - shows a type of "text/html", which is wrong, while the image being pulled from the xxximagemapper project shows a type of jpeg, which, of course, is correct. So it appears that in the xxxcms project where I am pulling jpeg files from using via the virtual-directory-mapping the jpeg file being returned to the client html page is of type text/html, instead of what it should be - jpeg. At this point I don't know why this is happening. I thought I may need to set some WLS properties to make this work, but that can't be the solution to this problem because the jpg image is being rendered with the correct type when pulled from the xxximagemapper project, which is deployed to the same server as the xxxcms project. So something probably needs to be changed in my xxxcms project but I do not know what since this virtual-directory-mapping is just redirecting a URI search for a particluar file to a specific directory outside of the webapp deployment folder. What do you think? Sorry for the lengthy text. I wanted to make sure you understand the issue. Thank you for your time. Gary