History | Log In     View a printable version of the current page.  
Issue Details (XML | Word | Printable)

Key: LPP-3457
Type: Bug Bug
Status: Open Open
Priority: P1 P1
Assignee: P T Withington
Reporter: Rick Robinson
Votes: 1
Watchers: 3
Operations

If you were logged in you would be able to see more operations.
OpenLaszlo

NullPointerException when deploying core as .war archive

Created: 22/Jan/07 01:11 PM   Updated: Tuesday 06:20 AM
Component/s: Server - General
Affects Version/s: OL4B1
Fix Version/s: HoneyDew (4.2b2)

Time Tracking:
Not Specified

Environment: All

Severity: Major
Runtime: N/A
Flags: Support, Products
Release Note Text:
Do not deploy to WebLogic with the OpenLaszlo war file. The OpenLaszlo Compiler requires an expanded web application directory for logging and the
creation of cache files. Make sure you deploy with the expanded web application directory instead of pointing to a .war file.
Fix in hand: False


 Description  « Hide
Class org.openlaszlo.utils.LZHttpUtils has a method "public static String getRealPath(ServletContext ctxt, String path)" that does not account for openlaszlo being deployed as a war archive...in that case, the call to ctxt.getRealPath(path) returns null - but this isn't accounted for in the return statement - throws a NullPointerException all the time and doesn't work !!


 All   Comments   Work Log   Change History      Sort Order: Ascending order - Click to sort in descending order
Rick Robinson - 24/Jan/07 09:02 AM
For a better approach on obtaining a path, please refer to:
http://www.servlets.com/archive/servlet/ReadMsg?msgId=261978&listName=tomcat-user

This little article has a nice code snippet that provides a better standard approach that works regardless of whether app is deployed in an unexploded .war file or not...

Hope this helps,
Best regards,
R

Phill Apley - 09/Mar/07 08:09 AM
On Mar 1, 2007, at 9:22 AM, Phillip George Apley wrote:

LPP-3457 refers to http://www.servlets.com/archive/servlet/ReadMsg?msgId=261978&listName=tomcat-user, which indicates a solution using a temporary file, but warns:

> Yes, but now you are constrained by the fact that the app is running
> directly from myapp.war which means that you have no filesystem access to
> your webapp.

On Mar 1, 2007, at 2:09 PM, P T Withington wrote:

I'm unsure of the context here and whether this warning can be safely ignored.

I think the answer being referred to by the Jira comment is the _unquoted_ part of the message.

The question for you to answer is, how is getRealPath used in the LPS? If it is just to construct paths to log files, or the server temp directory, etc. then it would seem the referenced message is a good solution. If it is being used to get to files in the servlet, then we're SOL, since then the quote you refer to is very applicable.

I suspect there is probably a mixture of uses and the fix to the bug is to examine each one and decide on a case-by-case basis.

P T Withington - 12/Mar/07 08:38 AM
Rick,

Do you have a specific test case that is failing because of this?


P T Withington - 12/Mar/07 11:08 AM
I was able to reproduce this bug with the following steps:

1) Set my environment to use tomcat 5.5

[For me that means: export TOMCAT_HOME=/usr/local/tomcat/apache-tomcat-5.5.20]

2) Edit $TOMCAT_HOME/conf/server.xml and set unpackWARs="false"

3) Build a core distribution: `ant dist-core`

4) Use the tomcat manager interface to deploy the dev war: http://127.0.0.1:8080/manager and upload openlaszlo-4.0.x.war

5) Browse to the OpenLaszlo Explorer in that war: http://127.0.0.1:8080/openlaszlo-4.0.x/laszlo-explorer/index.jsp?lzr=swf7

The nav pane gets the following error:

HTTP Status 500 -

type Exception report

message

description The server encountered an internal error () that prevented it from fulfilling this request.

exception

java.lang.NullPointerException
java.io.File.<init>(File.java:194)
org.openlaszlo.utils.LZHttpUtils.getRealPath(LZHttpUtils.java:349)
org.openlaszlo.servlets.LZServlet.getServletContextName(LZServlet.java:590)
org.openlaszlo.servlets.LZServlet.initLPS(LZServlet.java:70)
org.openlaszlo.servlets.LZServlet.doGet(LZServlet.java:345)
javax.servlet.http.HttpServlet.service(HttpServlet.java:689)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
note The full stack trace of the root cause is available in the Apache Tomcat/5.5.20 logs.

P T Withington - 12/Mar/07 11:10 AM
(I still think the correct fix here is "don't _do_ that". I.e., simply to document that the OpenLaszlo Servlet must be unpacked if it is deployed as a .war)

P T Withington - 12/Mar/07 11:24 AM
Well, maybe not. The full backtrace reveals more. Perhaps there is a way around this error?

2007-03-12 15:02:06,296 [http-8080-Processor22] ERROR org.apache.catalina.core.ContainerBase.[Catalina].[localhost].[/openlaszlo-4.0.x].[LPS] - Servlet.service() for servlet LPS threw exception
java.lang.NullPointerException
at java.io.File.<init>(File.java:194)
at org.openlaszlo.utils.LZHttpUtils.getRealPath(LZHttpUtils.java:349)
at org.openlaszlo.servlets.LZServlet.getServletContextName(LZServlet.java:590)
at org.openlaszlo.servlets.LZServlet.initLPS(LZServlet.java:70)
at org.openlaszlo.servlets.LZServlet.doGet(LZServlet.java:345)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:689)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:252)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:213)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:178)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:126)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:105)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:107)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:148)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:869)
at org.apache.coyote.http11.Http11BaseProtocol$Http11ConnectionHandler.processConnection(Http11BaseProtocol.java:664)
at org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:527)
at org.apache.tomcat.util.net.LeaderFollowerWorkerThread.runIt(LeaderFollowerWorkerThread.java:80)
at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:684)
at java.lang.Thread.run(Thread.java:613)

P T Withington - 12/Mar/07 12:21 PM
LPP-2605 has a solution for the proximate problem, but there are several other references to getRealPath that also need fixing.

In LzServlet.initLPS there are several uses of this call 'for sanity checking' and a reference to bugzilla bug 540.

Mark: how can we get the contents of Bugzilla 540?

[Given there are three bugs relating to this issue, I retract my comment about "don't do that". It seems this is something users want to do and we should see if there is a way to get by without knowing the path of the app.

P T Withington - 12/Mar/07 12:41 PM
[From bugzilla-540, which indicates that this is a much deeper problem:]

Weblogic does not expand war file during installation. This is a problem
because ServletContext.getRealPath() returns null. From Java Servlet 2.2 API
docs:

  public java.lang.String getRealPath(java.lang.String path)

  ".... This method returns null if the servlet container cannot
   translate the virtual path to a real path for any reason (such
   as when the content is being made available from a .war archive)."

Will document that WebLogic administrators cannot point to the war file and
that they need to deploy with the expanded directory instead.

Fix this in R1.0?

------- Additional Comment #1 From Pablo Kang 2002-11-05 17:41 [reply] -------
Documenting in lps/README for Beta 1.0.

------- Additional Comment #2 From Pablo Kang 2002-11-05 19:03 [reply] -------
Added documentation on change 3727. Notes for B1.0:

* DO NOT DEPLOY WITH THE LPS WAR FILE

The LPS 1.0 Beta Release requires an expanded web application directory for
logging and the creation of cache files. Make sure you deploy with the expanded
web application directory instead of pointing to the war file.

------- Additional Comment #3 From Pablo Kang 2002-11-05 19:04 [reply] -------
Reassigning R1.0 fix to Eric.

------- Additional Comment #4 From Eric Bloch 2002-11-18 17:57 [reply] -------
This can get fixed by moving logs and cache directories.

-Eric

------- Additional Comment #5 From Eric Bloch 2002-11-20 14:30 [reply] -------
The cache directory has moved. Still determining what to do
with the log file.

-Eric

------- Additional Comment #6 From Eric Bloch 2002-11-20 15:18 [reply] -------
This is sort of a dup of one that Pablo already has.

E

------- Additional Comment #7 From Pablo Kang 2002-11-20 15:41 [reply] -------
Will default log directory to "javax.servlet.context.tempdir" directory.

------- Additional Comment #8 From Pablo Kang 2002-11-22 14:36 [reply] -------
Default log directory to "javax.servlet.context.tempdir".
For Tomcat: ${TOMCAT_HOME}/work/Standalone/localhost/lps/LPS
Fixed in changeset 4214.
reviewer: eric

------- Additional Comment #9 From Mark Davis 2002-12-09 16:30 [reply] -------
Not quite fixed: Attempted to run from war:
Error 500--Internal Server Error
From RFC 2068 Hypertext Transfer Protocol -- HTTP/1.1:
10.5.1 500 Internal Server Error

The server encountered an unexpected condition which prevented it from
fulfilling the request.

------- Additional Comment #10 From Pablo Kang 2002-12-18 12:11 [reply] -------
Damn, we're still using getRealPath() to compile files. I've been looking at
other alternatives but haven't been found one so far. There may have no other
choice but to expand the war file.

------- Additional Comment #11 From Pablo Kang 2002-12-19 14:53 [reply] -------
Instead of using the File object, we should use URLConnection like:

URLConnection conn = null;
String content = "";
try {
    ServletContext ctxt = getServletContext();
    String path = "/examples/hello.lzx";
    URL url = ctxt.getResource(path);

    if (url != null) {
       conn = url.openConnection();

       // Read in content
       InputStream in = (InputStream)conn.getContent();
       byte[] b = new byte[in.available()];
       while (in.read(b) != -1)
           content += new String(b);

        res.setContentType ("text/html");
        ServletOutputStream out = res.getOutputStream();
        String lastModifed = new Date(conn.getLastModified()).toString()
        out.println("last modified: " + lastModified + "<br>");
        out.println("content: " + content + "<br>");
    }
} catch (IOException e) {
}

------- Additional Comment #12 From Pablo Kang 2002-12-20 12:02 [reply] -------
*** Bug 790 has been marked as a duplicate of this bug. ***

------- Additional Comment #13 From Pablo Kang 2003-01-22 18:31 [reply] -------
Removing DOC keyword. Already in the release notes.

------- Additional Comment #14 From Eric Bloch 2003-04-28 00:10 [reply] -------
This is a compiler/compilation manager bug. Mostly a compiler bug.

-Eric

------- Additional Comment #15 From Oliver Steele 2003-04-28 08:51 [reply] -------
This requires a major architectural change which has been discussed but not
scheduled.

------- Additional Comment #16 From Oliver Steele 2003-06-02 11:50 [reply] -------
RELNOTE: Do not deploy to WebLogic with the LPS war file. The LPS 1.0 Beta
Release requires an expanded web application directory for logging and the
creation of cache files. Make sure you deploy with the expanded web application
directory instead of pointing to the war file.

------- Additional Comment #17 From Sarah Allen 2003-08-08 16:05 [reply] -------
RELNOTE: Do not deploy to WebLogic with the LPS war file. LPS requires an
expanded web application directory for logging and the
creation of cache files. Make sure you deploy with the expanded web application
directory instead of pointing to the war file.

------- Additional Comment #18 From Mark Davis 2003-09-12 13:47 [reply] -------
re-re- evaluating.

------- Additional Comment #19 From Eric Bloch 2004-10-14 15:01 [reply] -------
future for now.