I am having a peculiar issue. I am running grails (2.3.5). I think I started developping my app with (2.1.x). The issue I am having is with German character encoding (especially Umlaute).
The issue is that in production (ubuntu Linux) the german special characters are not shown correctly in my browser. They are shown by "?". This thing is not happening in my dev (windows maschine). Additionally earlier scaffolded Domain Object (lets say with grails 2.2) are shown correctly even in production. That is what I am not getting. I was comapring the two "show.gsp" checking the encoding (both are utf-8).
Does anybody have a recommendation where to look at?
Add the java propertie -Dfile.encoding=UTF-8 to your java web-server (tomcat?).
Related
Please see my post on the Grails user mailing list. Essentially, I get the error "Cannot forward after response has been committed" with Grails 2.x after every few requests. This happens for all types of URLs, controllers, GSPs, CSS files, JS files and even image files. I have tried Grails 2.0.0 and Grails 2.0.1 with Tomcat 6.0.35 and Tomcat 7.0.25 on Windows XP 32-bit, Windows 7 32-bit and Centos 64-bit. The error comes up on all these combinations.
As I have mentioned in my post, there are no response.redirect or response.forward statements in our code. This is causing severe problem on our production application so need help in determining what else can be looked at to get to the bottom of the problem.
This has been solved. In one of the controllers in the application, response output stream was being directly written to but not closed explicitly after the operation was over. It seems Tomcat and Jetty recycle response objects. When a response object that did not have their output stream closed earlier was recycled for a future request and redirect was performed on it, the redirect would fail.
The code has been changed and the error has disappeared now. The lesson learned is that any time such an error occurs, scan the entire code base for direct access to response output stream and close output stream responsibly before existing controller methods.
You should create a new grails application and move the controllers, domains and etc yourself rather than grails update.
When you do that also make sure you look into the configuration files of grails.
Also take a look at what plugins you have.
Also, when moving the files, try out the application once in a while when it is possible, and perhaps you can detect when the error arises. Start out by trying it in your most basic controller and see if the error is there then as well.
Good luck.
For web development on localhost I'm using domains with .loc extension at the end of a domain name.
For example: if I work on a site roses.com, the local development domain would be roses.loc
(defined in hosts file and IIS as a host-header in binding)
My preferred browser (the main browser I use for development is Chrome) but unfortunately
it does not recognize a domain name with .loc extension as http://rose.loc - it throws me onto a google search page each time I would type in rose.loc (without http://) in the beginning..
Have you experienced this in a similar way ? Is there some solution to that ?
Because during intensive development testing with clearing browser cache and restarting the browser for various reasons, it's getting pretty annoying to be thrown at a google search page instead of the development page where I expect to notice some changes, each time I forget to type in http:// before the url (and Chrome is the one who hides it by default, anyway..)
Google Chrome is pretty "smart" with this. It uses a list of known-good TLDs and assumes everything else is just a search term that happens to end in a dot followed with some characters.
99% of the time that's perfectly fine. It's "only" us developers and a few people with strange network setups that have to suffer for the good of the majority ;-)
You can try using .local as your TLD, as that's a defined domain for referencing local domain names (at least it's used in some mDNS systems).
The issue has been entered as #30636 in the Chromium bug tracker. One workaround that often (but not always) seems to work is to append / to your hostname. So try roses.loc/.
I've created a search engine with a keyword of 'l' (my local TLD is .l). The URL for the search engine is http://%s.l. Then, I simply type "l mysite" in the address bar and it takes me to mysite.l.
Here is a workaround I came up with for this bug: http://code.google.com/p/chromium/issues/detail?id=30636#c38
I have Chromium installed on Linux Mint, and have a few localhost websites here. (I use Firefox for all of my work, so I have just discovered something here with Chromium.) My local sites are called morse and a.z. I had to enter http://morse/ and a.z/ respectively to get these sites to load the first time. They produced quick links on the new tab's otherwise blank page.
After closing Chromium, I reopened it and I could enter just morse/ and a.z to visit these sites. Since I've never seriously used this browser, I have not tailored any settings in it. (I did not use the quick link icons, but instead typed in the address bar.)
My findings confirm the localhost example.TLD/ entry does work when entered for the first time.
About Chromium: I am using Version 106.0.5249.119 (Official Build) for Linux Mint (64-bit).
I have a webapp developed with struts2 deployed in tomcat 5.5. The server has other applications deployed in it. But the app created with struts2 is very slow. Any ideas? How does Struts 2 handle object creation? And is there anything I can do on the tomecat server..
How slow is it? What are you doing? are you sure it is Struts 2 that is slow and not your application code? Did you do any profiling? What were the results?
Check this out: http://struts.apache.org/2.2.1/docs/performance-tuning.html
I found serving the static content from a folder increased the speed.
Well few details are really required for some one to answer your question in more good way
Which Struts2 version you are using
At which place/part do you think application is slow
as per my experience there are certain areas where Struts2 have known problems, OGNL in itself sometime creates problem since this is the part of the framework which took most of the time, this has been known to fixed in 3.x version of OGNL so you can get new jar of OGNL and than can test your application.
Second use some profiler and it will help you to catch the culprit like any thread blocking etc.
What OS is Tomcat running on?
If it's Linux, you may have run into a lack of entropy issue.
If this command returns something less than 200, it could explain your issue:
cat /proc/sys/kernel/random/entropy_avail
If it is low (or watch during startup/making requests), try pointing /dev/random to /dev/urandom. (Not for secure Production, but to test in Dev should be fine):
mv /dev/random /dev/random.orig
ln -s /dev/urandom /dev/random
And try starting Tomcat again.
In a rails app when sending out emails on my development machine the html emails look as expected when viewed, in that both the html and plain text can been seen nested in the proper mimetype when the raw version of the email is viewed, while the html renders properly when viewed normally.
The live server behaves differently. Only the html is sent and the mime type is not defined, which results in the email displaying a lot of html.
I am running up to date versions of archlinux on both the server and my dev machine, with postfix also running on each machine as the mail server.
Any ideas of what could be causing this difference?
You should probably be running vagrant and puppet/chef. Then you can find out.
I had tried restarting the postfix daemon, but that didn't seem to help. Once traffic died down I restarted the server and things worked. There were never any changes made to any of the configuration settings and doing a diff between my local settings and the remote showed no differences.
So I don't have the slightest clue to why things were behaving the way they were.
I am facing a problem with jetty character encoding. When installed the jetty server on Mac (OSX), it works fine. But, when it is installed on Ubuntu (10.10), the character encoding is not proper.
The word in the page (not URL) having problem is: The New York Times® Bestsellers
It is shown as "The New York Times� Bestsellers" on the page served by the server on Linux
and it is shown as "The New York Times® Bestsellers" on the page served by the server on Mac (This is correct)
The jetty server version is: hightide-7.0.2.v20100331
The character encoding of file served is: UTF-8
Can you please let me know if any settings need to be changed to overcome this problem?
Thanks in advance!
I had a similar problem with jetty 8 and solved it by adding this line to bin/jetty.sh:
JAVA_OPTIONS+=("-Dfile.encoding=UTF-8")
I also had a problem like this and I want to thank aditsu for his answer.
I am using restlet on top of a Jetty server on ubuntu 12.04 (and 14.04). The restlet application is behind an Apache server that functions as a proxyPass.
All files are UTF-8.
All HTTP-responses have Content-Type text/html; charset=UTF-8.
All files contain <meta content="text/html; charset=UTF-8" http-equiv="content-type"/>
The strange thing was that when the server boots and I visit the site, the character encoding was not UTF-8 so I got all those funny characters. Even when all signals were telling the server and agents and everything in between that UTF-8 is de encoding used.
When I restart the service manually after the server boot all characters are fine. Because I could not find an answer easily and I did not know who was causing this wrong encoding I kept restarting the service manually.
My candidates at that time were: Apache, Ubuntu service boot order, Restlet framework, File encoding actually used, HTTP headers, HTML meta tags. But all were as it was supposed to be.
So in the end it was Jetty which I only considered just now after having revisited this issue several times.
I still do not have a clue why starting at boot time makes the character encoding all wrong and after a manual restart of the service the encoding is correct. Adding the extra JAVA argument '-Dfile.encoding=UTF-8' made it all go away. Thanks to aditsu again for sharing his solution!!
Cheers
Edit:
Settting the LANG environment variable in the start up script also solve the problem. I.e.
export LANG=en_US.UTF-8
Actually this is the difference between starting the Jetty server at boot time (LANG is not defined out of the box) and starting it from a shell. So two solutions for the same problem.
Got it; for me, it was missing encoding header of the JSP:
<%# page contentType="text/html;charset=UTF-8" language="java" %>
You are probably reading directly raw http encoding and you need to decode it to utf8 using Decoder.
use java.net.URLDecoder
line = URLDecoder.decode(line, "UTF-8");
For encoding text to html charset, use URLEncoder, like when java String directly to post:
line = URLEncoder.encode(line, "UTF-8");