WebLogic Virtual Directory Mapping Not Working - weblogic

I am having a frustrating problem with virtual directory mapping in my very simple WebLogic 11g application. I installed WebLogic 11g OEPE, which installs WebLogic Server 10.35. I believe that this is installed correctly, because I am able to deploy a much more complicated application that is working fine...except for my issue with virtual directory mapping.
I want to access files from a directory outside of the web application, H:\Backup.
Here is my entire application, and these are my exact files.
wl_test/index.html
<html>
<head><title>WebLogic Test</title></head>
<body>
<h1>This is another new test<br>
</body>
</html>
wl_test/WEB-INF/web.xml
<web-app>
<welcome-file-list>
<welcome-file>index.html</welcome-file>
</welcome-file-list>
</web-app>
wl_test/WEB-INF/weblogic.xml
<weblogic-web-app>
<virtual-directory-mapping>
<local-path>H:/Backup/</local-path>
<url-pattern>/files/*</url-pattern>
<url-pattern>*.txt</url-pattern>
</virtual-directory-mapping>
</weblogic-web-app>
When I access the HTML file, 'http://localhost:7002/wl_test/index.html', it loads perfectly fine.
However when I attempt to load either of the following two URLs, they both fail with a HTTP 404 error. And yes, both of those files, one.ini and asdf.txt exist in the H:\Backup directory.
'http://localhost:7002/wl_test/files/one.ini'
'http://localhost:7002/wl_test/asdf.txt'
What could be wrong with this trivial setup?
I'm beginning to think I don't understand how this is supposed to work.

I think I understand what has changed and how to fix everything.
There were two problems with the virtual directory mapping.
First, the local-path cannot be a MS-DOS SUBSTed drive. I don't understand why, but WebLogic doesn't like it.
Second, when the url-pattern contains a folder, like /files/*, that folder must exist in the local-path directory.
Both of these are allowed in the JRun server that this is being ported from.
Sigh,
Randy Stegbauer

I think there is something a little goofy about the combination of multiple url-pattern elements. Here's a sample showing the shared 404 file from my archives.
Part of the NotFoundWeb.war/WEB-INF/web.xml looks like this:
<error-page>
<error-code>404</error-code>
<location>/error/404.html</location>
</error-page>
Part of the NotFoundWeb.war/WEB-INF/weblogic.xml looks like this:
<wls:virtual-directory-mapping>
<wls:local-path>d:\temp\notfound</wls:local-path>
<wls:url-pattern>*.html</wls:url-pattern>
</wls:virtual-directory-mapping>
I have a file on the file system:
d:\temp\notfound\error\404.html
So at runtime when I type something like:
http://localhost:7001/NotFoundWeb/somebadurl
I get the error page from the file system.

The generatedReports and /app/reports are local folders in the file system. This way, you can put any type of files inside the generated Reports folder:
<!DOCTYPE weblogic-web-app PUBLIC "-//BEA Systems, Inc.//DTD Web Application 8.1//EN" "http://www.bea.com/servers/wls810/dtd/weblogic810-web-jar.dtd">
<weblogic-web-app>
<container-descriptor>
<index-directory-enabled>true</index-directory-enabled>
</container-descriptor>
<virtual-directory-mapping>
<local-path>/app/reports</local-path>
<url-pattern>/generatedReports/*</url-pattern>
</virtual-directory-mapping>
</weblogic-web-app>

Related

Weblogic 12.2.1 RegistrationService_V10 in web application war is mapped to multiple Servlets

I am using Weblogic 12.2.1 and I added a JAX-WS client. It runs perfectly when run in eclipse but if I try to deploy the war file through the admin console I get:
The url-pattern RegistrationService_V10 in web application webApp.war is mapped to multiple Servlets. The only place I could find a reference to that is the the com.oracle.webservices.wls.wls-soap-stack-impl package in a class called RegistrationServiceV10 which is annotaited as a webservice to RegistrationService_V10 but that is the only place I could find a reference to it, not mapped in my web.xml so where is the multiple servlet mapping coming from.
I know this question was asked some time ago, but I had the same problem, and reading the question lead me to the answer, so here's what worked for me:
I had the same problem, did I text search on every single file in the repository for the text 'RegistrationService_V10' (and 'RegistrationService_V11', as I got that as an issue too), but it wasn't present.
The problem was the presence of multiple weblogic jar files. I was using maven to copy my dependencies into the weblogic domain lib folder, but because the code was depending on weblogic it was also copying a whole host of weblogic jar files as well. This resulted in multiple copies of the same files in my weblogic application classpath (the server's own weblogic files and my imported files). Thus there was an issue with code trying to register the same service with the same name more than once.
The solution is to make sure there is only one copy of the weblogic jar files available to weblogic (which is a part of weblogic; you shouldn't be copying any in).
Hope this helps you or somebody else with the same problem.
I've been facing similar issue when uploading my war files to WebLogic server.
After scouring the internet for answers, I've stumbled this question mapped to multiple servlet which led me to OpenAM weblogic bugtracker
Workaround is to disable annotation processing by either:
starting WebLogic with -Dweblogic.servlet.DIDisabled=true parameter
or
setting metadata-complete attribute to true in web.xml
<web-app metadata-complete="true" id="WebApp_ID" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd"
version="3.0">
By putting metadata-complete on my web.xml, fixes the problem for me.

GWT GUI Application not getting loaded on Apache Tomcat 7.0.39

I have a GWT GUI (getmap) application and i have placed it at \Apache Software Foundation\Tomcat 7.0\webapps directory.
Now when i am trying to open it using http://:8080/getmap/GetMap.html>, i am getting an error " Requested Resource is not available"
But when i copy same GWT GUI Application under \Apache Software Foundation\Tomcat 7.0\examples directory and load it using http://:8080/examples/getmap/GetMap.html>, everything works perfectly !!!
This problem is faced on Windows Vista.
I wold appreciate if anybody could provide some pointers to get rid of this issue ?
webapps contains WAR files or their exploded equivalent (i.e. a folder with a WEB-INF subfolder containing a web.xml file). The root of the server (served at the URL /) is a special webapp named ROOT.
So either create a ROOT webapp, or make getmap a webapp by adding the necessary WEB-INF/web.xml.
DISCLAIMER: the above is overly simplified and might not be accurate; plase check the Servlets spec and/or the Tomcat docs about deployment.

How can I get aspnet compiler to handle a page that contains an include file

I have a web application that lands on a shared hosting platform for my company. That platform has global header/footer code that all applications on the platform consume using include files. I can't change how the header files are structured and how they are to be cosumed--that is dictated to me by another group. I have a build server that does not has IIS installed by design. I am attempting to use the aspnet_compiler.exe during the build process to generate the precompiled website files for deployment.
However, when the build runs I get errors like this:
/Company/Controls/Header.ascx(7): error ASPPARSE: Failed to map the path '/sites/header.inc'.
The Header.ascx control has this server-side include in the HTML:
<!-- #include virtual="/sites/header.inc" -->
On my local machine, I have created a virtual directory in IIS named "sites" that points to the global header code (which I have also copied to my local machine). This same "sites" virtual exists in IIS on the hosting environment. I would really like to avoid having to install IIS on the build machine because it is a shared build machine and I don't anyone to mistakenly work IIS dependencies into their code. The build machine shouldn't need to have IIS.
What is the best way to get the precompiled site files that aspnet_compiler.exe produces during my build without installing IIS?
Microsoft has a very simple example of how to replace an include statement...
http://support.microsoft.com/kb/306575
Looking at the path of your error it seems you are already using some sort of global user control and I'm guessing this is a file which is reused by other applications or languages so I would suggest coming up with a more custom version with error handling and such since it is working over a mapped drive but the basic answer is you need to read the file and output it to the stream during the Render event.
Don't use server-side includes. They are ancient technology and are disabled on most modern sites.
I recommend you instead create .ascx files to replace each of the .inc files, and use those instead.
Try this:
<!-- #include virtual="~/sites/header.inc" -->
The ~ is a shortcut for "root of the web application."

tomcat 5.5 setting up context path with virtual hosts (non webapps directory)

I have been a web developer for a couple of years (some ASP, mostly PHP) and have recently taken on Java/JSP in the last two years.
The one thing I have tried repeatedly but continue to fail to wrap my head around is the way to setup a working JSP application in another location that is NOT the webapps folder. Rocking my application out of webapps does not seem to be a problem for me.
Could anyone help break this down, or point me to post somewhere which outlines it?
I have Googled repeatedly and read and re-read the documentation on the apache.org website, but I still cant seem to get it :(
I am trying to setup an "exploded" site (folders and files separated - not part of a WAR).
I know that I CAN edit the server.xml file, but am not supposed to (not that it matters... even when I attempt to edit that I fail).
I know I am missing something with the way the paths work. I THOUGHT I understand but I dont thinks so.
Any help is mucho appreciated!!
Love this site.
-- I have decided to re-phrase my question with more detail --
Let's say I have a directory structure as follows (**NOTE: webproject is NOT in the tomcat/webapps directory)
/webproject
/webproject/htdocs
/webproject/htdocs/images
/webproject/htdocs/images/logo.gif
/webproject/java
/webproject/java/page1.jsp
/webproject/java/page2.jsp
I would like to setup a virtual host so that I can view my project via a URL: http://webproject
I THINK all I need is two things (I am using apache):
a 'VirtualHost' entry in my httpd.conf file.
some type of 'context' file or fragment somewhere.
Am I right? If so, could someone help me define these two elements?
Also, if I want to use a domain-relative URL for referencing my logo.gif file from either of my jsp pages what would my path look like?
What if I want to use a domain-relative URL for referencing page2.jsp from page1.jsp?
HOWEVER, if there are paths within my application that reference resources (images, scripts, etc) using a path which starts at the root (ie. img src="/htdocs/images/foo.gif") it is not found.
Are you aware that those paths are supposed to be URL's relative to the current request URL (the one of the JSP page) and thus not local disk file system paths relative to their location at the local disk file system? As you're using /htdocs, it namely look like that you thought the latter.
Thus, if the JSP page is for example to be requested by http://example.com/context/page.jsp and the foo.gif is actually available by http://example.com/context/images/foo.gif, then you need to use either page-relative URL:
<img src="images/foo.gif">
or domain-relative URL:
<img src="/context/images/foo.gif">
or protocol-relative URL:
<img src="//example.com/context/images/foo.gif">
or absolute URL:
<img src="http://example.com/context/images/foo.gif">
OK, after struggling with this I finally got it to work. I aint saying this is the best (or even correct!) way of doing it, but this is what ultimately worked for me locally on my Windows machine (running WAMP) and on a remote server running Linux.
The paths listed are where they were for my environments. Obviously this could be different for your situation.
BEFORE-FIRST (Windows only)
With Windows, you need to setup an entry in your hosts file for the new "domain".
WIN - C:\Windows\System32\drivers\etc\hosts
127.0.0.1 webproject.local
FIRST
Need to edit httpd.conf and add a virtual host
WIN - C:\wamp\bin\apache\Apache2.2.11\conf\extra\httpd-vhosts.conf
LINUX - /etc/httpd/conf/httpd.conf
<VirtualHost *:80>
DocumentRoot "C:\wamp\www\webproject"
ServerName webproject.local
</VirtualHost>
SECOND
Setup a host and context in server.xml. From what I read online, editing server.xml is discouraged but this was the only way I could figure it out.
WIN - C:\Program Files (x86)\Apache Software Foundation\Tomcat 5.5\conf\server.xml
LINUX - etc/tomcat5/server.xml
<Host name="webproject" debug="0" appBase="webapps" unpackWARs="true">
<Context path="" docBase="C:/wamp/www/webproject"/>
<Logger className="org.apache.catalina.logger.FileLogger" directory="logs" prefix="webproject.local_error-log." suffix=".txt" timestamp="true"/>
</Host>
The thing I don't think is right, but worked for me was using "webapps" as the appBase even though my files are not in the "webapps" folder. Not sure why this is working... I fear that it is one of those situations where it works even though it shouldnt. I hope someone a lot smarter than me can offer some insight.

How can I install one Web Application in two context roots in Weblogic 10g?

How can I install one Web Application in two context roots in Weblogic 10g?
This is a packaging issue. Package the WAR twice, each with a specific WEB-INF/weblogic.xml, to solve it.
For the first WAR:
<?xml version='1.0' encoding='UTF-8'?>
<weblogic-web-app>
<context-root>my-context-1</context-root>
</weblogic-web-app>
For the second WAR:
<?xml version='1.0' encoding='UTF-8'?>
<weblogic-web-app>
<context-root>my-context-2</context-root>
</weblogic-web-app>
This will allow you to use standard deployment tools. I don't recommend installing your application as a shared library.
If you really need this, I recommend making your application a shared library and creating just a new web.xml file to change the context root for the two deployments.
This way you won't duplicate the entire war file and you still can configure them individually.
Assuming you have an Apache reverse proxy in front of the app server, you could use mod_rewrite to change the context root on-the-fly on the server side (transparent for the client).
For example: adding the iinstructions below to httpd.conf will return the content of 2.html when the client calls 1.html:
RewriteEngine on
RewriteRule ^/1.html$ /2.html
Respectivly, you could make the obvious translation to translate the second context root to the other single context root.