Java assertion malformed with Weblogic and Struts 2

I started using assertions in my Java EE 5 application and while the assert command is running there are no stack trace and no messages. Here is my code:

  assert 4 == outputList.size() : "outputList is not size 4: " + outputList.size();

      

When I make the list size 3, it throws this:

<Error> <HTTP> <BEA-101020> <[weblogic.servlet.internal.WebAppServletContext@6ea53502 - appName: 'MyPortal', name: 'myportal', context-path: '/myportal'] Servlet failed with Exception
java.lang.NullPointerException
at weblogic.servlet.internal.ServletResponseImpl.sendError(ServletResponseImpl.java:610)
at org.apache.struts2.dispatcher.Dispatcher.sendError(Dispatcher.java:770)
at org.apache.struts2.dispatcher.Dispatcher.serviceAction(Dispatcher.java:505)
at org.apache.struts2.dispatcher.ng.ExecuteOperations.executeAction(ExecuteOperations.java:77)
at org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter.doFilter(StrutsPrepareAndExecuteFilter.java:91)
at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:42)
at weblogic.servlet.internal.WebAppServletContext$ServletInvocationAction.run(WebAppServletContext.java:3242)
at weblogic.security.acl.internal.AuthenticatedSubject.doAs(AuthenticatedSubject.java:321)
at weblogic.security.service.SecurityManager.runAs(SecurityManager.java:121)
at weblogic.servlet.internal.WebAppServletContext.securedExecute(WebAppServletContext.java:2010)
at weblogic.servlet.internal.WebAppServletContext.execute(WebAppServletContext.java:1916)
at weblogic.servlet.internal.ServletRequestImpl.run(ServletRequestImpl.java:1366)
at weblogic.work.ExecuteThread.execute(ExecuteThread.java:209)
at weblogic.work.ExecuteThread.run(ExecuteThread.java:181)
>

      

It does not perform a clean stack trace and does not have an assert message.

Any ideas?

+3


source to share


1 answer


It is not the statement that this exception throws. You can use the keyword assert

, but the JVM usually ignores it, if you want the JVM not to ignore it you should use java -enableassertions

or java -ea

.



So, you have to add this java parameter to JAVA_OPTS.

+1


source







All Articles