I have a Java application deployed on Glassfish web server on Ubuntu Server Edition PC.
One of the services this application has to provide is to mount an ISO image in a specific folder and copy all the contents of this folder to another destination.
Since once my Java method found a Cyrillic file name, it has crashed. This file name appears as "???????????????.txt" in server application logs.
First I thought this was a linux problem, because this file appeared incorrectly in terminal as well. After I added CP1251 locale the problem in linux terminal has solved but still my application was throwing an error.
One guy at UbuntuForums (http://ubuntuforums.org/showthread.php?t=1813920) suggested me to convert this bad file with "convmv" utility, but this utility's output said that this file was already a UTF-8.
After that I've created a test application with the same methods and run it on the same PC but just like "java Test $arguments$".
And it did worked!
Simple System.out.println method displayed the file name correctly and successfully copied the problem file to another folder.
This fact left me no choice but to claim Glassfish for being the gap between my class, java and linux (though I'm not sure how it's possible).
Is there any character encoding specific settings in Glassfish I could correct to fix this error or maybe I'm missing something and the problem isn't really there?
Thanks in advance!
Andrew
Try to change Charset.defaultCharset(). See Setting the default Java character encoding? for more details.
Also, see Glassfish configuration such as
In sun-web.xml You have to see something like this:
<locale-charset-info default-locale="">
<parameter-encoding default-charset="UTF-8"/>
</locale-charset-info>
Related
This is the weirdest thing ever. I'm working on an app that I run using Tomcat though IntelliJ IDE. Part of this app creates a folder in the configured %CATALINA_TMPDIR%. For some reason no matter where I point %CATALINA_TMPDIR% to java can't create a folder there, but it can create a folder everywhere else.
For example, If
CATALINA_TMPDIR=C:\Users\dallend\.IntelliJIdea14\system\tomcat\Unnamed_datasite_7\temp then my app can't create a folder there, but can create it in C:\Temp, a folder I created.
Then if I change to CATALINA_TMPDIR=C:\Temp, the app won't be able to create a directory there but will be able to create one at C:\SomewhereElse.
From debugging through things it appears that java.io.File tries to create the directory but that the WinNTFileSystem.public native boolean createDirectory() method can't successfully create it.
Why might this happen? Could there be something I need to tweak with IntelliJ, or Java, or my OS? Has anyone encountered this before?
EDIT: I've tried running Tomcat stand-alone, and the problem persists.
Try to use forward slashes in your directory names. I've pulled out a lot of hair with backslashes actually escaping a path, e.g. C:\temp pointing to C:<tab>emp. I've completely given up on using backslashes even on Windows: Java will translate forward slashes just fine: C:/temp/
I have developed a liferay 6.2 application using jsf and primefaces 4. I have unicode characters both in xhtml files and java source files. There a strange behaviour of breaking my characters after tomcat restart or redeploy of application and the problem is only with characters coming from the source files. The rest unicode characters on the page are displayed correctly. And the behaviour is not always reproducible.
I have read posts referring to setting the jvm's or tomcat default encoding and main suggested action was setting -Dfile.encoding=UTF-8 but didn't have any luck.
I am using tomcat 7.0.42
If you are using Eclipse, try setting the text encoding in your project Properties>Resource
The problem has to do with the encoding of the class files. The solution was to set the correct encoding for javac. I finally discovered that in eclipse I had to edit the build.user.properties file to set javac.encoding = UTF-8
I am trying to use 'Bouncy castle' library in JAVA and want to add that jar file(bouncy castle's) to the providers list in the 'java.security file', I'm using windows7 and I have changed the permissions too for the files and folders but yet I'm getting an error "Access to 'complete-path' was denied". Kindly help me in how to deal with this error.
You can only save edits made to a java.security file if the editor you are using is running as an administrator.
Notepad is sadly not good enough for this job, as Notepad only supports files with CR+LF line-endings and java.security uses LF line endings. I normally use Notepad++ for this task, although Notepad2 and various other programmer's editors can be used instead if that's your preference.
Note that you must quit Notepad++ if it is currently running. If Notepad++ is running and you attempt to start another copy of it (as administrator or otherwise), Notepad++ will figure out that it is already running and instead give focus to the already-running copy of Notepad++.
The solution for me was to copy the file somewhere else, update it and paste it back in. There is a security warning that I had to say 'continue' to.
Hi as the subject reads
System.getenv("HOME")
in my action class (struts2) and deploy that as a war in
/var/lib/tomcat6/webapps/
When i run my class, getenv HOME returns
/var/lib/tomcat6
Can anyone tell me whats going on? I even tested it out on a standalone java class.Returns the proper value of home. Tried it on shell also echo $HOME and it gives a proper output.
Running on Ubuntu 10.04.
i THINK ive got what the problem is.. My project got deployed with permissions for "tomcat6 tomcat6" so when i getenv HOME, it gives me tomcat home. Am I right?
No.
The problem is that your tomcat6 service is configured to run as the "tomcat" user. (There is typically a variable in the init.d/tomcatd script that does this ...) THIS IS DONE FOR SECURITY REASONS. Don't change it unless you've done a proper risk assessment.
What you really need to do is change your web application so that it doesn't expect $HOME to be >>your<< home directory. Instead, create a webapp specific properties file that gives the location of this external (to tomcat) directory. Or better still (and best practice!) change your application so that it doesn't need to refer to an external directory at all.
I have recently installed Tomcat 6.0.29 on my Ubuntu 10.04 system. Process till the localhost connectivity is fine but when I tried to run a simple hello program, it giving me the following error:
type Status report
message
/opt/apache-tomcat-6.0.29/webapps/examples/WEB-INF/classes/HelloWorldExample
description The requested resource
(/opt/apache-tomcat-6.0.29/webapps/examples/WEB-INF/classes/HelloWorldExample)
is not available.
I have tried to reinstall tomcat by the different methods give on other sites but the result is same. I am not yet sure where I am going wrong. Please can anyone describe me the correct method of running a servlet program ie, where to store the actual Java and class files.
Have you got a correct web.xml file? It needs servlet and servlet-mapping tags.
Check that WAR file from which you deployed your web-app is not corrupted.
always put you class in package, eg, not HelloWorldExample, but foo.HelloWorldExample.
Tomcat (and other containers as well) doesn't like default packages.