Glassfish increase maxParameterCount - java

We have a page on an application deployed in Glassfish 3.1.2.2 that has over 10,000 fields (both hidden and displayed) that get submitted to the server. When the page is submitted, the server logs spit out:
WARNING: More than the maximum number of request parameters (GET plus POST) for a single request([10,000]) were detected. Any parameters beyond this limit have been ignored. To change this limit, set the maxParameterCount attribute on the Connector.
I've seen other posts on increasing it for JBoss using a system property on startup, but that doesn't work here. I've also tried setting that property on various connector XML attributes in domain.xml without any success, nor have I been able to find any UI control in the admin where that would be set.

I'm going to put the answer here for public knowledge, but it was someone else who I know who figured it out:
I changed web-core.jar to be web-core.zip and then opened the zip and went into the org/apache/catalina/connector folder. I extracted the Connector.class file and opened it in a hex editor, searched for 0x2710 (10,000) and changed it to 0xFFFF (-1) Then I copied the Connector.class back into the zip file and renamed back to .jar
I also opened the jar with java-decompiler to verify that the java code did actually look correct after manually editing the class file.

Related

Wicket 6.3 FileUpload uploaded file is distored when downloaded or viewed randomly

My application uses wicket 6.3 and my file upload is working as expected, except for some cases of corrupted or distorted files when viewed or downloaded.
In most cases, file upload is working, but there are cases when the uploaded files are saved (no error), but cannot be viewed or downloaded correctly since it is corrupted.
The file size of these files are just less than 100KB.
When I say corrupted, when you try to open the uploaded file it will look like this:
Below is the part of my code that saves the uploaded file:
BE code
FileUploadField fileUploadField = new FileUploadField("fileUploadField");
...
// File types can be images (jpg/png/bmp), documents (docx/pdf)
// File types with random distorted/corrupted (png and docx)
// Reuploading the file will fix the issue
for (FileUpload fu : m_fileUpload.getFileUploads()) {
byte[] fileByes = fu.getBytes();
String fileId = myService.persistFile(new MyFile().setContent(fileByes));
supportingDoc.addAttachment(fileId, fu.getClientFileName(), fileByes.length);
}
...
HTML
<input wicket:id="fileUploadField" type="file" class="form-control">
When I try to replicate it again, it usually works, and I can download or view the file.
I am unsure why it gets corrupted/distorted and how I can avoid getting a such an error though it rarely happens.
Update:
I thought the initial case was a PNG upload but it was not, it was docx. When I tried to replicate the issue using PNG file. It works.
I have 2 tomcat servers (test and live). I uploaded the same docx file on both tomcat servers (both on ubuntu). Test server was able to view/download the uploaded docx file, while Live server did not.
I am converting the file into byte array and save it to DB. When I compare both file contents in DB, they have exactly the same content. So the problem is not really on uploads.
I think the problem is on the download decoding, both servers does not have the same decoder. On my local environment (tomcat + windows) it works, same with my Test environment (tomcat + ubuntu). My Live environment running tomcat + ubuntu seems to have a different default decoder that is why it cannot view/download docx properly.
My problem now is where and how I can check that default decoder? Will I check it in ubuntu side? or it should be in tomcat side? When I checked the tomcat server config on both Test and Live tomcats, both seems to have the same config. They only differ on SSL certs.
Solution that works on my case:
The problem was really on how my Live server handles unknown mime-types. It is handling it like text file. This is the reason why it is showing the unknown mime-type file as garbled text.
I checked my Live tomcat server configuration and compared it with my test server's config and both are almost the same and I cannot find any configuration relating to mime-type or encoder/decoder.
In my file download code, when mime-type is unknown it is setting it as force-download only so I changed it to application/force-download.
For unknown mime-type, I changed the content-disposition from inline; filename="<filename>" to attachment; filename="<filename>".
I think content disposition attachment alone works, I haven't tested it though since application/force-download seems to be a hack, while setting the correct content disposition as attachment will download the unknown mime-type for my case.
I will not delete this question though, since I might have the same issue in the future and I forgot how I solved it :)

JSP c:import giving java.net.SocketException when using short name alias

I have a Java web app which has a JSP page which has a couple c:import lines in it. The content referenced is on the same web server as the Java app, but is not bundled in the war file. My site has dns entries to allow for access to this app from a browser with a full name https://abc.123.def.com/app or a short name of just https://abc/app for users on our network.
If I access the jsp page via the alias https://abc/app I can get to the jsp page in the browser, but I get a server exception Problem accessing the absolute URL "https://abc//webfiles/included_file.html". java.net.SocketException: Connection reset on the page. But, when I access the jsp page via the fqdn like https://abc.123.def.com/app the include works perfectly, the jsp compiles, and all is well.
If I put the address of the file to be included in my browser it works with either short name or fqdn. So even though the error is saying the JSP can't find the file https://abc//webfiles/included_file.html I can plug that address in my browser and get to it fine. That's true from my separate user machine, or from a browser on the server itself. (Yes I see that double // there, it seems to not be a problem, it loads in the browser and loads fine as an include when using the fqdn).
I have good reason to believe the code is fine, this code worked fine on my old server which had JBoss 5. We've moved it to JBoss 6.4 on a new server and are now encountering this alias/short name include problem. I'm thinking it's some JBoss or IIS configuration issue. Of course we have lots of external links to this application utilizing the short name so simply using the fqdn will not work.
So IIS can serve up both the jsp via a fqdn or short name, it can also serve up the included_file path using the fqdn or short name. But Java for some reason can't see that included_file when using the short name, only the fqdn.
I've confirmed that the DNS suffix search list in the server's ipconfig includes the domain the site is in.
I'm not a JBoss config admin, and have no experience with IIS really, just a developer of the app, but I've been thrust into JBoss config/debugging out of desperation. Any help much appreciated.

Oauth identity toolkit

I am at last step to configure the identity tool kit login authentication , so they talk about configure server side " There are two code snippets at the bottom of the page. The first snippet helps make the JavaScript configuration easy for your website. The second snippet should be saved in your server side code directory as gitkit-server-config.json.
The server side configuration file needs to be further configured before use. Open the file for editing and change serviceAccountPrivateKeyFile setting to be equal to the path of the *.p12 or *.json file you downloaded earlier. You should use the full path, beginning with / and ending with the full name of the *.p12 or *.json file" can any one help me

Apache jMeter is not generating ApacheJMeterTemporaryRootCA.crt certificate for http request recording

I'm following step by step this tutorial to create the certificate ApacheJMeterTemporaryRootCA.crt.
http://jmeter.apache.org/usermanual/jmeter_proxy_step_by_step.pdf
However after I hit run nothing related to certificate is showing up, as if I was just running a simple test without recording. It's not even displaying error messages. I have read these threads but they are not helpful for my case:
Does any
- Apache jMeter not generating ApacheJMeterTemporaryRootCA.crt for https recording
- ApacheJMeterTemporaryRootCA.crt not generated
I am using Java 1.7.0,67, Jmeter 2.13 (both are newest versions). I have also followed this page to set up my environment variables
https://wiki.apache.org/jmeter/TestRecording210
Does anyone has an idea about what is missing here?
Thanks a million!!
I had a problem where I'd deleted the certificate and struggled to get it to regenerate.
In the bin folder there is a keystore file called proxyserver.jks, when I deleted that the certificate regenerated on the next start of the test script recorder
In the absolute majority of cases jmeter.log file contains all the answers or at least can help to figure out the cause of the problem.
If below checklist doesn't help - update your question with relevant bit of the JMeter log file.
Use JDK, not JRE
Make sure that you have the following environment variables set:
JAVA_HOME - pointing to JDK installation root
PATH - contains /bin folder of JAVA_HOME
If you using web browser for recording make sure that
"HTTP Proxy" is set to correct JMeter host and port
"Use proxy for all protocols" box is checked
"No proxy for" input doesn't filter out JMeter host (you can clean it)
Refer below image for example proxy settings for Firefox browser:
The easiest way to set up JMeter for recording is using Recording Template (File -> Templates -> Recording), this way you can get JMeter configured for recording in a single click
If above checklist didn't resolve your problem check out Recording HTTPS Traffic with JMeter's Proxy Server guide for troubleshooting tips.
Navigate to HTTP(S) Test Script Recorder, and click the Start button at the bottom.
http://jmeter.apache.org/usermanual/jmeter_proxy_step_by_step.pdf
This will start the JMeter proxy server which is used to intercept the browser requests.
A file called ApacheJMeterTemporaryRootCA.crt will be generated in jmeter/bin folder.
Possibly you run test instead of starting proxy server.

java tomcat links generated don't work

I'm just doing a java tomcat project, that does some query in a database then return the file path of some web pages.
Now I have mapped my only class in web.xml and the webapp does return a list of urls which correspond to some html pages in my local disk. I set up a side frame in the webapp, my idea is that I output the results in the output page like "file:///file_path_of_html_page" and when this link is clicked, the side frame will show the html page.
But actually I got the right links but when I click on them, nothing happens, chrome tells me "Not allowed to load local resource". Even I set the target="_blank", the link doesn't work. But the "file:///filepath" are all ok when I type them in the address bar. I've moved all the html pages in the eclipse project folder but that didn't help.
Any suggestions to do this simple task?
The average browser disallows due to security reasons opening file:// resources when the parent resource is by itself served over http://. If you make them fullworthy http:// links, then it will work properly.
Even if the browser allowed it, this approach would not going to work when you publish the webapp on a different server. A file:// resource refers to the local disk file system, which is the one the client (the user with the webbrowser) is using. This is normally in a physically different machine. The client should have a copy of exactly those resources on its own local disk file system beforehand in order to get the file:// links to work.
Just put the HTML pages in public web root of your web project (there where you normally put your JSP files and so on) and use (relative) http:// links to refer the HTML pages. For example, the following link in a http://localhost:8080/contextname/some.jsp
link to some html file
would open the http://localhost:8080/contextname/some.html file.

Categories