users@glassfish.java.net

Re: Enabling asserts and seeing it in the log

From: Tom Mueller <tom.mueller_at_oracle.com>
Date: Tue, 01 Mar 2011 10:08:23 -0600

Can you please provide more details about what type of program this is in?

I inserted the following into a JSP:

<%
             assert 3 == 4 : "3 doesn't equal 4";
             %>

To enable assertions, I used:

asadmin create-jvm-options -ea
asadmin restart-domain

Then, after accessing the page, I found the following log message in the
server.log file:

[#|2011-03-01T10:01:43.904-0600|WARNING|glassfish3.2|javax.enterprise.system.container.web.com.sun.enterprise.web|_ThreadID=115;_ThreadName=Thread-1;|StandardWrapperValve[jsp]:
PWC1406: Servlet.service() for servlet jsp threw exception
java.lang.AssertionError: 3 doesn't equal 4
     at org.apache.jsp.index_jsp._jspService(index_jsp.java from :64)
     at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:111)
     at javax.servlet.http.HttpServlet.service(HttpServlet.java:848)
     at
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:403)
     at
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:492)
     at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:378)
     at javax.servlet.http.HttpServlet.service(HttpServlet.java:848)
     at
org.apache.catalina.core.StandardWrapper.service(StandardWrapper.java:1534)
     at
org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:281)
     at
org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:175)
     at
org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:655)
     at
org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:595)
     at com.sun.enterprise.web.WebPipeline.invoke(WebPipeline.java:98)
     at
com.sun.enterprise.web.PESessionLockingStandardPipeline.invoke(PESessionLockingStandardPipeline.java:91)
     at
org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:162)
     at
org.apache.catalina.connector.CoyoteAdapter.doService(CoyoteAdapter.java:326)
     at
org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:227)
     at
com.sun.enterprise.v3.services.impl.ContainerMapper.service(ContainerMapper.java:228)
     at
com.sun.grizzly.http.ProcessorTask.invokeAdapter(ProcessorTask.java:822)
     at com.sun.grizzly.http.ProcessorTask.doProcess(ProcessorTask.java:719)
     at com.sun.grizzly.http.ProcessorTask.process(ProcessorTask.java:1013)
     at
com.sun.grizzly.http.DefaultProtocolFilter.execute(DefaultProtocolFilter.java:225)
     at
com.sun.grizzly.DefaultProtocolChain.executeProtocolFilter(DefaultProtocolChain.java:137)
     at
com.sun.grizzly.DefaultProtocolChain.execute(DefaultProtocolChain.java:104)
     at
com.sun.grizzly.DefaultProtocolChain.execute(DefaultProtocolChain.java:90)
     at
com.sun.grizzly.http.HttpProtocolChain.execute(HttpProtocolChain.java:79)
     at
com.sun.grizzly.ProtocolChainContextTask.doCall(ProtocolChainContextTask.java:54)
     at
com.sun.grizzly.SelectionKeyContextTask.call(SelectionKeyContextTask.java:59)
     at com.sun.grizzly.ContextTask.run(ContextTask.java:71)
     at
com.sun.grizzly.util.AbstractThreadPool$Worker.doWork(AbstractThreadPool.java:532)
     at
com.sun.grizzly.util.AbstractThreadPool$Worker.run(AbstractThreadPool.java:513)
     at java.lang.Thread.run(Thread.java:619)
|#]

Tom

On 2/28/2011 9:20 PM, Arthur Yeo wrote:
> All,
>
> I have enabled "asserts" for my JVM in GF and my test shows that the
> program is stopping with a Assertsion exception.
> But, I cannot get the assert message to go into the GF Server log.
>
> So, here's a sample line of code I am using:
>
> assert SomeObj != null : "Obj Blah is null --- irrecoverable";
>
> The message "Obj Blah is null --- irrecoverable" is not showing up in
> the GF server log.
>
> --
> Arthur Y.