Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Getting WriteBeyondContentLengthException #6

Open
johnsmitherpn5 opened this issue May 14, 2015 · 16 comments
Open

Getting WriteBeyondContentLengthException #6

johnsmitherpn5 opened this issue May 14, 2015 · 16 comments

Comments

@johnsmitherpn5
Copy link

Hi,

We have an internal Spring framework mvc web application. Which is running on WebSphere 8.5.

I am trying to setup stagemonitor to see the "In Browser Widget". Followed your wiki "Set up stagemonitor with your own Application".

But getting WriteBeyondContentLengthException when I try to access the login page itself. Please see the console log below...

[ERROR   ] SRVE8109W: Uncaught exception thrown by filter org.stagemonitor.web.monitor.filter.HttpRequestMonitorFilter: com.ibm.wsspi.http.channel.exception.WriteBeyondContentLengthException
    at com.ibm.wsspi.http.HttpOutputStream.writeToBuffers(HttpOutputStream.java:268)
    at [internal classes]
    at org.stagemonitor.web.monitor.filter.HttpRequestMonitorFilter.injectHtmlToOutputStream(HttpRequestMonitorFilter.java:197)
    at org.stagemonitor.web.monitor.filter.HttpRequestMonitorFilter.injectHtml(HttpRequestMonitorFilter.java:181)
    at org.stagemonitor.web.monitor.filter.HttpRequestMonitorFilter.doMonitor(HttpRequestMonitorFilter.java:128)
    at org.stagemonitor.web.monitor.filter.HttpRequestMonitorFilter.doFilterInternal(HttpRequestMonitorFilter.java:100)
    at org.stagemonitor.web.monitor.filter.AbstractExclusionFilter.doFilter(AbstractExclusionFilter.java:75)
    at com.ibm.ws.webcontainer.filter.FilterInstanceWrapper.doFilter(FilterInstanceWrapper.java:206)
    at [internal classes]
    at org.apache.shiro.web.servlet.ProxiedFilterChain.doFilter(ProxiedFilterChain.java:61)
    at org.apache.shiro.web.servlet.AdviceFilter.executeChain(AdviceFilter.java:108)
    at org.apache.shiro.web.servlet.AdviceFilter.doFilterInternal(AdviceFilter.java:137)
    at org.apache.shiro.web.servlet.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:125)
    at org.apache.shiro.web.servlet.ProxiedFilterChain.doFilter(ProxiedFilterChain.java:66)
    at org.apache.shiro.web.servlet.AbstractShiroFilter.executeChain(AbstractShiroFilter.java:449)
    at org.apache.shiro.web.servlet.AbstractShiroFilter$1.call(AbstractShiroFilter.java:365)
    at org.apache.shiro.subject.support.SubjectCallable.doCall(SubjectCallable.java:90)
    at org.apache.shiro.subject.support.SubjectCallable.call(SubjectCallable.java:83)
    at org.apache.shiro.subject.support.DelegatingSubject.execute(DelegatingSubject.java:383)
    at org.apache.shiro.web.servlet.AbstractShiroFilter.doFilterInternal(AbstractShiroFilter.java:362)
    at org.apache.shiro.web.servlet.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:125)
    at org.springframework.web.filter.DelegatingFilterProxy.invokeDelegate(DelegatingFilterProxy.java:344)
    at org.springframework.web.filter.DelegatingFilterProxy.doFilter(DelegatingFilterProxy.java:261)
    at com.ibm.ws.webcontainer.filter.FilterInstanceWrapper.doFilter(FilterInstanceWrapper.java:206)
    at [internal classes]

[ERROR   ] SRVE0315E: An exception occurred: com.ibm.ws.webcontainer.webapp.WebAppErrorReport: javax.servlet.ServletException: com.ibm.wsspi.http.channel.exception.WriteBeyondContentLengthException
    at com.ibm.ws.webcontainer.filter.FilterInstanceWrapper.doFilter(FilterInstanceWrapper.java:262)
    at [internal classes]
    at org.apache.shiro.web.servlet.ProxiedFilterChain.doFilter(ProxiedFilterChain.java:61)
    at org.apache.shiro.web.servlet.AdviceFilter.executeChain(AdviceFilter.java:108)
    at org.apache.shiro.web.servlet.AdviceFilter.doFilterInternal(AdviceFilter.java:137)
    at org.apache.shiro.web.servlet.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:125)
    at org.apache.shiro.web.servlet.ProxiedFilterChain.doFilter(ProxiedFilterChain.java:66)
    at org.apache.shiro.web.servlet.AbstractShiroFilter.executeChain(AbstractShiroFilter.java:449)
    at org.apache.shiro.web.servlet.AbstractShiroFilter$1.call(AbstractShiroFilter.java:365)
    at org.apache.shiro.subject.support.SubjectCallable.doCall(SubjectCallable.java:90)
    at org.apache.shiro.subject.support.SubjectCallable.call(SubjectCallable.java:83)
    at org.apache.shiro.subject.support.DelegatingSubject.execute(DelegatingSubject.java:383)
    at org.apache.shiro.web.servlet.AbstractShiroFilter.doFilterInternal(AbstractShiroFilter.java:362)
    at org.apache.shiro.web.servlet.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:125)
    at org.springframework.web.filter.DelegatingFilterProxy.invokeDelegate(DelegatingFilterProxy.java:344)
    at org.springframework.web.filter.DelegatingFilterProxy.doFilter(DelegatingFilterProxy.java:261)
    at com.ibm.ws.webcontainer.filter.FilterInstanceWrapper.doFilter(FilterInstanceWrapper.java:206)
    at [internal classes]
Caused by: javax.servlet.ServletException: com.ibm.wsspi.http.channel.exception.WriteBeyondContentLengthException
    ... 19 more
Caused by: com.ibm.wsspi.http.channel.exception.WriteBeyondContentLengthException
    at com.ibm.wsspi.http.HttpOutputStream.writeToBuffers(HttpOutputStream.java:268)
    at [internal classes]
    at org.stagemonitor.web.monitor.filter.HttpRequestMonitorFilter.injectHtmlToOutputStream(HttpRequestMonitorFilter.java:197)
    at org.stagemonitor.web.monitor.filter.HttpRequestMonitorFilter.injectHtml(HttpRequestMonitorFilter.java:181)
    at org.stagemonitor.web.monitor.filter.HttpRequestMonitorFilter.doMonitor(HttpRequestMonitorFilter.java:128)
    at org.stagemonitor.web.monitor.filter.HttpRequestMonitorFilter.doFilterInternal(HttpRequestMonitorFilter.java:100)
    at org.stagemonitor.web.monitor.filter.AbstractExclusionFilter.doFilter(AbstractExclusionFilter.java:75)
    at com.ibm.ws.webcontainer.filter.FilterInstanceWrapper.doFilter(FilterInstanceWrapper.java:206)
    ... 17 more

Please let me know if I need to use any specific settings....Thanks.

@trampi
Copy link
Member

trampi commented May 15, 2015

@johnsmitherpn5: I think i know the cause of this issue.

@felixbarny: The reason is probably that the Content-Length HTTP-Header is not recalculated after injecting the stagemonitor html snippet.
I've created an issue in the corresponding project: stagemonitor/stagemonitor#74

I'll have a further look at this on sunday.

@johnsmitherpn5
Copy link
Author

@trampi : Thank you for the quick response. Will look forward for the fix.

@trampi
Copy link
Member

trampi commented May 18, 2015

@johnsmitherpn5: sorry for the late answer but i haven't found time on sunday or today. However, tomorrow should a pull request be ready.

@felixbarny
Copy link
Member

@johnsmitherpn5 could you try out the fix?
This is how to install the latest version into your local maven repository (~/.m2/repository)

git clone git@github.com:trampi/stagemonitor.git
cd stagemonitor
git checkout recalculate-content-length-header

Then build the project as described here: https://github.com/stagemonitor/stagemonitor#build-locally

If you're using maven, all you have to do is to update the version in pom.xml to 0.15.0-SNAPSHOT.

@johnsmitherpn5
Copy link
Author

@felixbarny : Sorry for the delay. Completely tied up in meetings. I am not able to install the fix. We are using maven but when I update the version in pom.xml to 0.15.0-SNAPSHOT getting maven dependency error. I tried git clone also but getting below error...

git clone git@github.com:trampi/stagemonitor.git
Cloning into 'stagemonitor'...
Warning: Permanently added the RSA host key for IP address '192.30.252.131' to the list of known hosts.
Permission denied (publickey).
fatal: Could not read from remote repository.
Please make sure you have the correct access rights and the repository exists.

@johnsmitherpn5
Copy link
Author

@felixbarny : With http URL https://github.com/trampi/stagemonitor.git I am able to clone. When I do gradlew.bat compileJava install getting below error...

\.m2\repository\stagemonitor\stagemonitor-core\src\main\java\o
rg\stagemonitor\core\instrument\StagemonitorRuntimeAgentAttacherDriver.java:67:
method does not override or implement a method from a supertype
        @Override
        ^
Note: Some input files use unchecked or unsafe operations.
Note: Recompile with -Xlint:unchecked for details.
1 error
:stagemonitor-core:compileJava FAILED

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':stagemonitor-core:compileJava'.
> Compilation failed; see the compiler error output for details.

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug
option to get more log output.

BUILD FAILED

Total time: 2 mins 31.407 secs

@trampi
Copy link
Member

trampi commented May 22, 2015

I could reproduce the mentioned WriteBeyondContentLengthException. I am working on a solution.

@trampi
Copy link
Member

trampi commented Jun 1, 2015

Further investigations showed that this exception happens in spring petclinic even without stagemonitor. The stagemonitor part however seems to work even with that exception. Unfortunately i can not find any information regarding the WriteBeyondContentLengthException in IBM WebSphere.

One last idea: Remove all calls to setContentLength in your application. It is not required. It is just nice to know in large file downloads to indicate the progress and to display the complete file size.

@johnsmitherpn5
Copy link
Author

@trampi : I am able to run petclinic example with stagemonitor on WebSphere. I am getting this issue in our application (spring based web application) and we don't have any setContentLength calls. I found something related to this in the below link.
http://www-01.ibm.com/support/docview.wss?uid=swg1PI12194

But we are using latest version WebSphere than what they mentioned in the link. Below is the link to download the WebSphere Liberty Profile which is free for development and we are using same.

https://developer.ibm.com/wasdev/downloads/liberty-profile-using-non-eclipse-environments/

Also I am not able to download 0.15.0-SNAPSHOT using maven which @felixbarny mentioned.

@felixbarny
Copy link
Member

I have finally found some time to look at this. The petclinic example runs fine for me on websphere. Do you have any example application that I can use to reproduce your problem? I have just released 0.15.2 in which I set the Content-Length header to -1 if it has already been set and if the widget is injected. That may fix your problem. Would you try out again?

@janakarajp
Copy link

did any one used / tested the option as mention the above post to fix issue, I am not sure which file we need specify " set the Content-Length header to -1" , Please do share the feedback.

@felixbarny
Copy link
Member

You don't have to do this manually. Do you encounter simmilar problems?

@janakarajp
Copy link

Hi,

Yes, I do have slimier issue

On 27 August 2015 at 13:12, Felix notifications@github.com wrote:

You don't have to do this manually. Do you encounter simmilar problems?


Reply to this email directly or view it on GitHub
#6 (comment)
.

@felixbarny
Copy link
Member

Which version of stagemonitor and WebSphere are you using?

@janakarajp
Copy link

Web sphere Liberty 8.5.5.6 ( App. WAR will drop on dropins path)

Thanks & RegardsJanakJanakaraj PALANISAMY | @mail : janakarajp@gmail.com
janakarajp@gmail.com *
| Cell : +65 -8315 2346* |
http://lnkd.in/b8tN4ye

On 27 August 2015 at 14:34, Felix notifications@github.com wrote:

Which version of stagemonitor and WebSphere are you using?


Reply to this email directly or view it on GitHub
#6 (comment)
.

@felixbarny
Copy link
Member

This commit should fix the issue: stagemonitor/stagemonitor@96fef8e

Releasing 0.17.3 now...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants