OpenSAML bootstrap() nets me "InputStream cannot be null" - java

Deployment environment: Windows Server 2008, Tomcat 7.0.5, Oracle JRE 1.6. Development environment same plus Eclipse Helios.
When I try to deploy my Java application which uses OpenSAML 2.3.1 and test it live, it doesn't want to run. Looking through the source code and stack trace, it seems that DefaultBootstrap.bootstrap() ends up causing java.lang.IllegalArgumentException: InputStream cannot be null. I'm including the full stack trace below.
The software versions on the target deployment system are, or at least are supposed to be, exactly the same as on my development box, where everything runs just fine, but of course there I don't deploy using the .war. I am getting the distinct feeling that I'm missing some XML or DTD file in the deployment archive, but that feeling alone doesn't help me much in fixing it. Googling for parts of the stacktrace also didn't really help me much.
Where do I start tracking down the actual root cause of this error, so I can fix it?
2011-feb-10 10:56:08 org.apache.catalina.core.StandardWrapperValve invoke
ALLVARLIG: Servlet.service() for servlet [se.novasoftware.gabriel.SAMLParser] in context with path [/ServiceTier] threw exception [java.lang.IllegalArgumentException: InputStream cannot be null] with root cause
java.lang.IllegalArgumentException: InputStream cannot be null
at javax.xml.parsers.DocumentBuilder.parse(DocumentBuilder.java:120)
at org.opensaml.xml.parse.BasicParserPool$DocumentBuilderProxy.parse(BasicParserPool.java:643)
at org.opensaml.xml.parse.BasicParserPool.parse(BasicParserPool.java:216)
at org.opensaml.xml.XMLConfigurator.load(XMLConfigurator.java:141)
at org.opensaml.DefaultBootstrap.initializeXMLTooling(DefaultBootstrap.java:148)
at org.opensaml.DefaultBootstrap.bootstrap(DefaultBootstrap.java:88)
at _mynamespace_.saml.ParsedResponse.<init>(ParsedResponse.java:56)
at _mynamespace_.saml.ParsedResponse.<init>(ParsedResponse.java:104)
at _mynamespace_.SAMLParser.doPost(SAMLParser.java:29) // servlet entry point
at javax.servlet.http.HttpServlet.service(HttpServlet.java:641)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:722)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:306)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:240)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:161)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:164)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:108)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:118)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:379)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:243)
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:259)
at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:281)
at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
at java.lang.Thread.run(Thread.java:662)
ParsedResponse.java line 56 is the bootstrap() call in its constructor:
private PersedResponse() throws ConfigurationException {
DefaultBootstrap.bootstrap(); // line 56
...
whereas line 104 in that same file is the constructor that gets called from the outside calling this private default constructor:
public ParsedResponse(final String samlXML)
throws UnmarshallingException, ConfigurationException {
this(); // line 104
...

Adding openws-1.3.0.jar to the deployment assembly did the trick.

Related

BeanLocator is null for servlet context

Continually get this error on one server but not the other.
Both servers have the same code deployed to it and in comparing the context.xml and the applicationevn.xml they are both insync. where else do I even look to start solving this bean error
11:40:04,180 ERROR [tomcat-http--24][PortletBeanLocatorUtil:42]
BeanLocator is null for servlet context message-manager-portlet
11:40:04,183 ERROR [tomcat-http--24][render_portlet_jsp:132] null
com.liferay.portal.kernel.bean.BeanLocatorException: BeanLocator has
not been set for servlet context message-manager-portlet
at com.liferay.portal.kernel.bean.PortletBeanLocatorUtil.locate(PortletBeanLocatorUtil.java:46)
at com.fm.fmconnect.mm.service.MessageManagerReportTypeLocalServiceUtil.getService(MessageManagerReportTypeLocalServiceUtil.java:349)
at com.fm.fmconnect.mm.service.MessageManagerReportTypeLocalServiceUtil.findSellerServicerCounts(MessageManagerReportTypeLocalServiceUtil.java:331)
at com.fm.fmconnect.mm.action.CommonAction.updateSellerServicerIds(CommonAction.java:234)
at com.fm.fmconnect.mm.action.CommonAction.setSellerServicerValues(CommonAction.java:159)
at com.fm.fmconnect.mm.portlet.controller.MessageManagerController.doView(MessageManagerController.java:148)
at com.liferay.portal.kernel.portlet.LiferayPortlet.doDispatch(LiferayPortlet.java:235)
at com.liferay.util.bridges.mvc.MVCPortlet.doDispatch(MVCPortlet.java:314)
at javax.portlet.GenericPortlet.render(GenericPortlet.java:262)
at com.liferay.portlet.FilterChainImpl.doFilter(FilterChainImpl.java:103)
at com.liferay.portlet.ScriptDataPortletFilter.doFilter(ScriptDataPortletFilter.java:55)
at com.liferay.portlet.FilterChainImpl.doFilter(FilterChainImpl.java:100)
at com.liferay.portal.kernel.portlet.PortletFilterUtil.doFilter(PortletFilterUtil.java:64)
at com.liferay.portal.kernel.servlet.PortletServlet.service(PortletServlet.java:112)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:731)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:303)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.doFilter(InvokerFilterChain.java:116)
at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilter.doFilter(InvokerFilter.java:117)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241)
What portal version are you running?
Have you tried deleting all of the files generated by service builder (except the three modifiable impl files), running your ant clean target, and building/deploying?
To be more explicit I would delete the following files.
/WEB-INF/lib/message-manager-portlet-service.jar
/WEB-INF/service (entire folder)
/WEB-INF/sql/indexes.sql
/WEB-INF/sql/tables.sql
/WEB-INF/sql/sequences.sql
/WEB-INF/src/META-INF (everything in this folder assuming no XML modifications were made)
Then run the following ant targets
1. clean
2. build-services
3. compile
4. deploy
Then start the server.

Error while initializing metro webservice client

Since few weeks we have some trouble with our external test environment (which is not operated by us). Our webapplication is connected to a soap webservice.
We are using:
metro 2.1.1 for the webservice client
java-1.5.0-ibm-1.5.0.12.4 is installed on the test environment.
tomcat version: 5.5.27
The first time trying to initialize the client on this environment, we are getting the following exception (only on this environment):
java.lang.ExceptionInInitializerError
at java.lang.J9VMInternals.initialize(J9VMInternals.java:218)
at javax.xml.ws.Service.<init>(Service.java:57)
at com.xxx.xxx.xxx.xxxy.client.MyServiceRequestProvider_Service.<init>(MyServiceRequestProvider_Service.java:50)
at com.xxx.xxx.client.MyServiceRequester.<init>(MyServiceRequester.java:63)
at com.xxx.xxx.action.CheckAction.execute(CheckAction.java:120)
at com.xxx.xxx.webservice.validators.ApplicationValidatorImpl.validateCheck(ApplicationValidatorImpl.java:403)
at com.xxx.xxx.webservice.validators.ApplicationValidatorImpl$$EnhancerByGuice$$55e5e7ad.CGLIB$validateCheck$6(<generated>)
at com.xxx.xxx.webservice.validators.ApplicationValidatorImpl$$EnhancerByGuice$$55e5e7ad$$FastClassByGuice$$380e5720.invoke(<generated>)
at com.google.inject.cglib.proxy.MethodProxy.invokeSuper(MethodProxy.java:187)
at com.google.inject.InterceptorStackCallback$InterceptedMethodInvocation.proceed(InterceptorStackCallback.java:66)
at com.xxx.xxx.webservice.guice.interceptor.ValidationErrorInterceptor.invoke(ValidationErrorInterceptor.java:21)
at com.google.inject.InterceptorStackCallback$InterceptedMethodInvocation.proceed(InterceptorStackCallback.java:66)
at com.xxx.xxx.webservice.guice.interceptor.PersistenzInterceptor.invoke(PersistenzInterceptor.java:35)
at com.google.inject.InterceptorStackCallback$InterceptedMethodInvocation.proceed(InterceptorStackCallback.java:66)
at com.google.inject.InterceptorStackCallback.intercept(InterceptorStackCallback.java:45)
at com.xxx.xxx.webservice.validators.ApplicationValidatorImpl$$EnhancerByGuice$$55e5e7ad.validateCheck(<generated>)
at com.xxx.xxx.webservice.endpoint.xxxWS.order(xxxWS.java:99)
at com.xxx.xxx.webservice.endpoint.xxxWS$$EnhancerByGuice$$3bd5ffaf.CGLIB$order$1(<generated>)
at com.xxx.xxx.webservice.endpoint.xxxWS$$EnhancerByGuice$$3bd5ffaf$$FastClassByGuice$$806bc0a0.invoke(<generated>)
at com.google.inject.cglib.proxy.MethodProxy.invokeSuper(MethodProxy.java:187)
at com.google.inject.InterceptorStackCallback$InterceptedMethodInvocation.proceed(InterceptorStackCallback.java:66)
at com.xxx.xxx.webservice.guice.interceptor.RsvAgeManipulatorInterceptor.invoke(RsvAgeManipulatorInterceptor.java:95)
at com.google.inject.InterceptorStackCallback$InterceptedMethodInvocation.proceed(InterceptorStackCallback.java:66)
at com.xxx.xxx.webservice.guice.interceptor.ValueConverterInterceptor.invoke(ValueConverterInterceptor.java:101)
at com.google.inject.InterceptorStackCallback$InterceptedMethodInvocation.proceed(InterceptorStackCallback.java:66)
at com.xxx.xxx.webservice.guice.interceptor.DataValidationInterceptor.invoke(DataValidationInterceptor.java:31)
at com.google.inject.InterceptorStackCallback$InterceptedMethodInvocation.proceed(InterceptorStackCallback.java:66)
at com.xxx.xxx.webservice.guice.interceptor.UserValidationInterceptor.invoke(UserValidationInterceptor.java:36)
at com.google.inject.InterceptorStackCallback$InterceptedMethodInvocation.proceed(InterceptorStackCallback.java:66)
at com.xxx.xxx.webservice.guice.interceptor.SessionInitializerInterceptor.invoke(SessionInitializerInterceptor.java:65)
at com.google.inject.InterceptorStackCallback$InterceptedMethodInvocation.proceed(InterceptorStackCallback.java:66)
at com.google.inject.InterceptorStackCallback.intercept(InterceptorStackCallback.java:45)
at com.xxx.xxx.webservice.endpoint.xxxWS$$EnhancerByGuice$$3bd5ffaf.order(<generated>)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:79)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:618)
at com.sun.xml.ws.api.server.InstanceResolver$1.invoke(InstanceResolver.java:250)
at com.sun.xml.ws.server.InvokerTube$2.invoke(InvokerTube.java:150)
at com.sun.xml.ws.server.sei.EndpointMethodHandler.invoke(EndpointMethodHandler.java:261)
at com.sun.xml.ws.server.sei.SEIInvokerTube.processRequest(SEIInvokerTube.java:100)
at com.sun.xml.ws.api.pipe.Fiber.__doRun(Fiber.java:641)
at com.sun.xml.ws.api.pipe.Fiber._doRun(Fiber.java:600)
at com.sun.xml.ws.api.pipe.Fiber.doRun(Fiber.java:585)
at com.sun.xml.ws.api.pipe.Fiber.runSync(Fiber.java:482)
at com.sun.xml.ws.server.WSEndpointImpl$2.process(WSEndpointImpl.java:314)
at com.sun.xml.ws.transport.http.HttpAdapter$HttpToolkit.handle(HttpAdapter.java:608)
at com.sun.xml.ws.transport.http.HttpAdapter.handle(HttpAdapter.java:259)
at com.sun.xml.ws.transport.http.servlet.ServletAdapter.invokeAsync(ServletAdapter.java:207)
at com.sun.xml.ws.transport.http.servlet.WSServletDelegate.doGet(WSServletDelegate.java:159)
at com.sun.xml.ws.transport.http.servlet.WSServletDelegate.doPost(WSServletDelegate.java:194)
at com.sun.xml.ws.transport.http.servlet.WSServlet.doPost(WSServlet.java:80)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:710)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:269)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:188)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:210)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:172)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:117)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:108)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:151)
at org.apache.jk.server.JkCoyoteHandler.invoke(JkCoyoteHandler.java:200)
at org.apache.jk.common.HandlerRequest.invoke(HandlerRequest.java:291)
at org.apache.jk.common.ChannelSocket.invoke(ChannelSocket.java:775)
at org.apache.jk.common.ChannelSocket.processConnection(ChannelSocket.java:704)
at org.apache.jk.common.ChannelSocket$SocketConnection.runIt(ChannelSocket.java:897)
at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:685)
at java.lang.Thread.run(Thread.java:811)
Caused by: java.lang.SecurityException: java.util.ServiceLoader - protected system package 'java.util'
at java.lang.ClassLoader.checkClassName(ClassLoader.java:213)
at java.lang.ClassLoader.defineClass(ClassLoader.java:255)
at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:151)
at java.net.URLClassLoader.defineClass(URLClassLoader.java:600)
at java.net.URLClassLoader.access$400(URLClassLoader.java:124)
at java.net.URLClassLoader$ClassFinder.run(URLClassLoader.java:1055)
at java.security.AccessController.doPrivileged(AccessController.java:274)
at java.net.URLClassLoader.findClass(URLClassLoader.java:492)
at java.lang.ClassLoader.loadClass(ClassLoader.java:640)
at java.lang.ClassLoader.loadClass(ClassLoader.java:632)
at java.lang.ClassLoader.loadClass(ClassLoader.java:606)
at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1346)
at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1205)
at java.lang.Class.forNameImpl(Native Method)
at java.lang.Class.forName(Class.java:130)
at javax.xml.ws.spi.Provider.<clinit>(Provider.java:55)
at java.lang.J9VMInternals.initializeImpl(Native Method)
at java.lang.J9VMInternals.initialize(J9VMInternals.java:196)
... 68 more
Further attempts to initialize this client results in:
2012-09-26 11:34:56,016 ERROR [TP-Processor7] com.xxx.xxx.client.MyServiceRequester#<init>(65): Error initialising MyServiceRequestProvider_Service
java.lang.NoClassDefFoundError: javax.xml.ws.spi.Provider (initialization failure)
at java.lang.J9VMInternals.initialize(J9VMInternals.java:134)
at javax.xml.ws.Service.<init>(Service.java:57)
...
It seems that there are some security issues within the metro Provider class.
I think the following snipped of the class javax.xml.ws.spi.Provider of metro is the source of the failure:
static {
Method tLoadMethod = null;
Method tIteratorMethod = null;
try {
Class<?> clazz = Class.forName("java.util.ServiceLoader");
tLoadMethod = clazz.getMethod("load", Class.class);
tIteratorMethod = clazz.getMethod("iterator");
} catch(ClassNotFoundException ce) {
// Running on Java SE 5
} catch(NoSuchMethodException ne) {
// Shouldn't happen
}
loadMethod = tLoadMethod;
iteratorMethod = tIteratorMethod;
}
It seems that instead of throwing an ClassNotFoundException the Classloader throws an SecurityException, which is not catched by the
static initializer.
What can be the cause of this behaviour (some policy settings?) and how can we prevent this. The application is running on our local test environment, and was running on the external environment too. The external provider denies any changes of the environment.
Is this behaviour IBM-JDK specific ?
EDIT:
I found the following in the JDK 5.0 API class java.security.SecureClassLoader :
SecurityException - if an attempt is made to add this class to a
package that contains classes that were signed by a different set of
certificates than this class, or if the class name begins with
"java.".
But souldn't this happen to all Metro clients running on tomcat ?
EDIT:
Thanks a lot for the advice! There is actually the path of a JDK 1.6 rt.jar in the classpath. And therefore the ServiceLoader class is found but not allowed to load within the Provider.
Thanks to Sean,
There actually was the path of a JDK 1.6 rt.jar in the classpath. And therefore the ServiceLoader class is found but not allowed to load within the Provider.

SOAP services with Axis2 + Java but embedding Jython and binary exe

i have 2 important pieces of code :
- first one is in Python,
- the other is a binary dos exe (i can not rewrite this one at all, i have wrapped it in a Java class, and it is working)
i'm using Java as a glue-ing, and incorporate my Python code by using Jython, i also have functional code for all these parts. Everything working fine in Eclipse as a standalone.
actually i would like to avoid any rewriting (not possible for the binary) or embedding Python part it is own Soap Service etc.
and i am defintively stick to Java due to other future included libraries!
now i am in the process of using a Soap Service via Axis2 over Tomcat server, i have an error "Exception occurred while trying to invoke service method"
i think that i may have some missing in how to indicate the path to the "import"-ed python modules as readed by the "ImportError: No module named mypymodule" (this module exists, and it correctly work when used from Java class in Eclipse)
i have added
PythonInterpreter interpreter = new PythonInterpreter(null, new PySystemState());
PySystemState sys = Py.getSystemState();
sys.path.append(new PyString("C:/jython2.5.2/Lib"));
sys.path.append(new PyString("d:/path/to/mypymodule")); // of course this is actually a realpath in my code
but it do not do the trick,
and i am also wodering if there is not a kind of securiy issue with Tomcat/Axis2 or rigth management forbidding access for some others directories?
it should also be notice that this "mypymodule" is not the one that is wrapped in the Java Factory Jython pattern but another external pure python module that is imported by this first one actually wrapped in Java.
please do you have any advices ?
Best regards,
(and i am expected some other future disagreements on the binary calling)
the full stack trace after changing to True the sendStacktraceDetailsWithFaults
<parameter name="sendStacktraceDetailsWithFaults">true</parameter>
is below
<soapenv:Fault>
<soapenv:Code>
<soapenv:Value>soapenv:Receiver</soapenv:Value>
</soapenv:Code>
<soapenv:Reason>
<soapenv:Text xml:lang="en-US">Exception occurred while trying to invoke service method oWPL</soapenv:Text>
</soapenv:Reason>
<soapenv:Detail>
<Exception>org.apache.axis2.AxisFault: Exception occurred while trying to invoke service method oneWordPerLine1
at org.apache.axis2.rpc.receivers.RPCMessageReceiver.invokeBusinessLogic(RPCMessageReceiver.java:208)
at org.apache.axis2.receivers.AbstractInOutMessageReceiver.invokeBusinessLogic(AbstractInOutMessageReceiver.java:40)
at org.apache.axis2.receivers.AbstractMessageReceiver.receive(AbstractMessageReceiver.java:110)
at org.apache.axis2.engine.AxisEngine.receive(AxisEngine.java:181)
at org.apache.axis2.transport.http.HTTPTransportUtils.processHTTPPostRequest(HTTPTransportUtils.java:172)
at org.apache.axis2.transport.http.AxisServlet.doPost(AxisServlet.java:146)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:641)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:722)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:305)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:225)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:169)
at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:472)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:168)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:98)
at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:927)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:118)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:407)
at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:999)
at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:565)
at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:307)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1110)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:603)
at java.lang.Thread.run(Thread.java:722)
Caused by: java.lang.reflect.InvocationTargetException
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:601)
at org.apache.axis2.rpc.receivers.RPCUtil.invokeServiceClass(RPCUtil.java:212)
at org.apache.axis2.rpc.receivers.RPCMessageReceiver.invokeBusinessLogic(RPCMessageReceiver.java:117)
... 23 more
Caused by: Traceback (most recent call last):
File "<string>", line 1, in <module>
ImportError: No module named mypymodule
at org.python.core.Py.ImportError(Py.java:290)
at org.python.core.imp.import_first(imp.java:750)
at org.python.core.imp.import_name(imp.java:834)
at org.python.core.imp.importName(imp.java:884)
at org.python.core.ImportFunction.__call__(__builtin__.java:1220)
at org.python.core.PyObject.__call__(PyObject.java:357)
at org.python.core.__builtin__.__import__(__builtin__.java:1173)
at org.python.core.imp.importFromAs(imp.java:978)
at org.python.core.imp.importFrom(imp.java:954)
at org.python.pycode._pyx0.f$0(<string>:1)
at org.python.pycode._pyx0.call_function(<string>)
at org.python.core.PyTableCode.call(PyTableCode.java:165)
at org.python.core.PyCode.call(PyCode.java:18)
at org.python.core.Py.runCode(Py.java:1261)
at org.python.core.Py.exec(Py.java:1305)
at org.python.util.PythonInterpreter.exec(PythonInterpreter.java:206)
at pyinterface.MyUtils.oWPL(MyUtils.java:127)
at pyinterface.MyUtils.oWPL(MyUtils.java:152)
... 29 more</Exception>
</soapenv:Detail>
</soapenv:Fault>

Java assertion getting mangled with Weblogic and Struts 2

I started using assertions in my Java EE 5 app and while the assert is working, the stack trace and messages are not. 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 do a clean stack trace and does not have the assert message.
Any ideas?
It is not the assert that throws that exception.
You can use assert key word, but JVM normally ignores it, if you want to make JVM not to ignore it you must use java -enableassertions or java -ea.
So you must add this java parameter to your JAVA_OPTS.

"Stream Closed" Error caused apparently by multiple submits

I am accessing an Oracle 9 database using Java, in a Tomcat 7 environment.
In context.xml I have
<Resource type="javax.sql.DataSource" auth="Container"
name="jdbc/myDB"
factory="org.apache.tomcat.jdbc.pool.DataSourceFactory"
driverClassName="oracle.jdbc.OracleDriver"
url="jdbc:oracle:thin:#localhost:1521:db" maxwait="10000"
username="temp" password="temp" maxActive="20" maxIdle="10"/>
My java code works most of the time, but sometimes randomly I get the Stream Closed exception. I suspect this may be if the user presses the buttons in the application too fast, thus starting one query before finishing another query.
This exception is caused by the doEndTag function in the following code.
public class SQLIteratorTag extends BodyTagSupport
{
public SQLIteratorTag()
{
query = "";
rs = null;
stmt = null;
rsmd = null;
dbConn = null;
con = null;
}
public int doStartTag()
throws JspTagException
{
String fieldName = "";
try
{
DBConnection d=DBConnection.getInstance();
con = d.getConnection();
...
public int doAfterBody()
throws JspException
{
try
{
....
public int doEndTag()
throws JspException
{
try
{
if(bodyContent != null)
{
bodyContent.writeOut(bodyContent.getEnclosingWriter());
}
}
catch(IOException ex)
{
Log.getIns
I do not want to post too much code, but I may have posted too little. I have no idea where the problem may lie, but I will update the question if necessary.
The exception itself is:
SEVERE: Servlet.service() for servlet [jsp] in context with path [/charm] threw exception [javax.servlet.ServletException: javax.servlet.jsp.JspTagException: Stream closed] with root cause
javax.servlet.jsp.JspTagException: Stream closed
at c.tags.sql.SQLIteratorTag.doEndTag(SQLIteratorTag.java:218)
at org.apache.jsp.comp_005fpara_jsp._jspService(comp_005fpara_jsp.java:708)
at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:722)
at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:432)
at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:390)
at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:334)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:722)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:305)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
at com.jspbook.GZIPFilter.doFilter(Unknown Source)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:243)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:224)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:169)
at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:472)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:168)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:98)
at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:927)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:118)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:407)
at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:987)
at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:579)
at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:309)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1110)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:603)
at java.lang.Thread.run(Thread.java:722)
From the stack trace, this doesn't appear to be anything to do with the database connection, but does look related to the user submitting two requests from the back end. I've changed the tags, but you might want to rephrase the question a bit and change the title to get more attention.
Essentially your application receives two requests, and processes them both. It's a while since I've seen this but as far as I can remember the first one gets this error because the browser has closed the TCP/IP connection in order to open a new one for the second request. (That's probably a bit simplistic with HTTP/1.1 as it reuses connections).
I think we worked around this by hiding a unique identifier on the page as it was generated, and then detecting if we got a second POST request on the same session with that UID - indicating they'd submitted twice. It was a while ago though so I'm rather hazy on exactly what we did, and how we stopped it being visible to the user; I do recall that we wrapped the HttpServletRequest for the second request in a HttpServletRequestWrapper that appeared to change the request from a POST to a GET, but I'd have to do some digging to figure what was going on.
Edit: This link is quite old but seems to have a better way to deal with it than anything ancient I can drag up (which seems to be essentially option 2 in that post). There are probably several common ways to deal with this.

Categories