Running servlet program - java

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.

Related

Apache Tomcat returns 404 error for Web Application

I have a Spring MVC application WAR file deployed in ${catalina_home}/webapps. Let's say the name of the WAR is abc.war and suppose, after tomcat unpacks the WAR and creates a folder abc in webapps folder, there is file named inside abc, in path app/abc.js.After running the tomcat server, I typed 'http://localhost:8090/abc/app/abc.js` on the browser. This returns an 404 error on the browser.
Operating System: Windows 7
Apache Tomcat: version 7, running on PORT 8090.
Java version: 8
This setup is the same on all other systems with the team of developers I work with and it works for them on their system. But it does not work on my system.
Please can anybody help me with an insight why this could happen and possibly a fix will be great respite. thanks.
Please find below point will effected on application
Database use access
Set proper Environment variable (like. JDK,MAVEN)
check CPU and memory usages of other process
check thread dumps
Hope so its will help you :)

Tomcat deployment of grails war having classpath issues

I am deploying a WAR into a Tomcat 6 or Tomcat 7 server on a Windows 2003 Server box. The error looks something like
java.lang.Exception: Error initializing iSec web service proxy: Unable to create JAXBContext for generated packages: "com.integrity_apps" doesnt contain ObjectFactory.class or jaxb.index.
which I was getting previously when tools.jar was not in the classpath of my application. I was running the grails app from STS with the default web container, and I was able to fix this by re-installing JUST the JDK with tools.jar in the lib dir, and making sure JAVA_HOME was set correctly.
I have tried the same steps on the server - only installing the JDK, making sure JAVA_HOME is pointing to it, and dropping my WAR in the Tomcat container. I am still getting the error. Can anyone suggest why this may be happening?
As a further datapoint, I have noticed that if, on the server, I run the Tomcat7.exe from the command prompt directly (JAVA_HOME is set as a system variable), the error goes away. If I run it from the service manager, the error comes back.
Thanks
Looks like "com.integrity_apps" is your package containing your JAXB bean classes? I think it's missing ObjectFactory class within the package.
Check if there is a package called "com.integrity_apps" and if there is a class named ObjectFactory in that package. If not you may want to add it or use other ways to let JAXBContext know how to create your JAXB beans. This question on SO may be helpful:
Do you always need an ObjectFactory class when using JAXB?

Strange file name character encoding problem with Ubuntu / Java / Glassfish

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>

java system.getenv(HOME) returns tomcat6 directory

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.

guacamole vnc viewer - how to?

i have my tomcat server running, i downloaded the guacamole vnc viewer, and i followed the instructions on : http://guacamole.sourceforge.net/
however when i type :http://localhost:8080/guacamole/ i get error message : http status 404 The requested resource () is not available.
anyone using guacamole, plz can you explain the steps to follow? i moved the xml files and the war file as instructed, but there is this folder: "guacamole-src.tar" where do i unzip it to?
what are the steps to follow to make it work?
thx a lot:)
Once you've copied guacamole.war, start the server and check if a folder /guacamole is created at the same place (that means the server has found your web application and is trying to deploy it).
Also, please check your Tomcat logs.
You don't need to use guacamole-src.tar, that file only contains the project sources, but it is not needed.

Categories

Resources