compilation problems after setting classpath in tomcat 5.5 - servlets

I have installed Tomcat 5.5 in windows vista home basic. I have set classpath to
"C:\program files\apache software foundation\tomcat 5.5\common\lib\servlet-api.jar".
now there are two problems.
1. I could not compile my servlets. It says package javax.servlet.* dosenot exist.
2. I could not connect with local host in chrome nor in explorer.
these errors are appearing inspite of server instance running.
Classpath to java sdk and tomcat are different. is it the matter of concern.
Please help.
I have invested considerable amount of time figuring out the problem.
thanx in advance.

I could not compile my servlets. It says package javax.servlet.* dosenot exist.
It means that the classpath for javac is not been correctly specified. It should go like so:
javac -cp .;"/path with spaces/to/servlet-api.jar" com/example/YourServlet.class
Note that you need to surround a path with spaces by doublequotes.
I could not connect with local host in chrome nor in explorer. These errors are appearing inspite of server instance running.
Then you used the wrong domain/port. When running Tomcat at the local machine, the domain should at least be localhost. The actual port can be determined in Tomcat/conf/server.xml file. It defaults to 8080, but can be changed during the Windows setup wizard. The final URL should look like http://localhost:8080. If you use port 80 which is the default HTTP port, then the :80 part can be omitted from the URL.
Classpath to java sdk and tomcat are different.
The %CLASSPATH% environment variable is worthless. Use -cp argument. If you want to avoid long typing/remembering everytime, consider using a .bat file with the command, or a build tool like Ant, or an IDE like Eclipse.
The %JAVA_HOME% environment variable is however important. Tomcat needs to know it in order to have access to the toolset to compile JSP files. The %JAVA_HOME% should point to the installation directory of the JDK.

I have set classpath to "C:\program
files\apache software
foundation\tomcat
5.5\common\lib\servlet-api.jar"
If this means CLASSPATH environment variable, you're learning a valuable lesson: it's worthless. javac.exe and java.exe ignore it; so do all Java EE app servers like Tomcat; so do all IDEs like IntelliJ.
You'll have to add servlet-api.jar to your CLASSPATH using javac.exe -cp every time you compile in a command shell, or add it to your IDE project CLASSPATH, or set it up in Ant.
If you can't connect to localhost using Chrome or Explorer, it probably means that you haven't packaged or deployed your app properly. Make sure you create a valid WAR file and put it in the Tomcat 5.x /webapps directory to deploy.

Related

Nexus OSS does not start

I'm trying to install nexus 3.38 on a debian 10 system. I use aodoptopenjdk-8... as Java runtime.
When I try running it as a systemd sevrice nexus does not start. There are no usable logs.
Whe I try running nexus directly with command nexus start-launchd (virtually the same as nexus start) I get the following out put
bin/nexus start-launchd
Starting nexus
Could not resolve mvn:org.apache.felix/org.apache.felix.framework/6.0.5
I look for this library/dependency and find it in {nexus-home}/system/org/apache/felix/org.apache.felix.framework/6.0.5/. But the filename looks crippled org.apache.felix.framework- that's it. No *.jar. The same can be seen with some other dependencies, like other felix stuff or karaf.
Other dependecies in {nexus-home}/system look fine.
If I change the name from org.apache.felix.framework- to org.apache.felix.framework-6.0.5.jar then it looks like this dependency loaded and next stop is karaf.
Do I have to fix all the names of the jar files? Why do I not find other complains about that, is it an error in front of my monitor?
I've seen the same problem with current release of apache karaf. The names of the jar files are crippled.
The content of the folder system of the unix package (*.tar.gz) of nexus 3.38.0-01 is damaged.
I've downloaded the windows package (*.zip) and replaced the system with this version.
Everything looks fine now.

Check Glassfish version on domain folder

I've tried to check one way to discover the version of the glassfish server checking the domain folder but I didn't find it. I didn't find the version in domain.xml or another file. I know we can use "asadmin version" command to check the version, but I need to find it on the domain folder because the structure of my project and some limitations that there is. Do you know some way to check the version? One difference maybe, like one file that not exists in glassfish 3.0 domain folder but there is in glasshfish 4 domain folder...
Thank you so much!
You could check the index.html in the docroot of your domain folder. It contains the Glassfish Version.
The file is located in GLASSFISH_INSTALL/glassfish/domains/domain1/docroot
It should contain a line like
<title>GlassFish Server 3.1.1 - Server Running</title>
For Glassfish 4 it only contains a line like:
<title>GlassFish Server - Server Running</title>
So this is one option to distinguish.
If this is not specific enough, you can just parse the server.log file for the version. In the file GLASSFISH_INSTALL/glassfish/domains/domain1/logs/server.log you should find a string like:
GlassFish Server Open Source Edition 3.1.1 (12) startup time : Felix (6.971ms), startup services(2.353ms), total(9.324ms)|]
or
GlassFish Server Open Source Edition 4.1.1 (1) startup time : Felix (6.175ms), startup services(5.352ms), total(11.527ms)]]

Changing the nexus repository directory

when i install Nexus war into my tomcat server Nexus creating its folder etc at Win home directory. I want to redirect this to my different directory.
Meaning.. I want nexus to store its repository in user defined folder
How to do this ?
You should set the environment variable PLEXUS_NEXUS_WORK to your user defined folder in your the /bin/setenv.cmd file and restart Tomcat before deploying the Nexus web application.
I don't have a Windows example handy but here is the /usr/share/tomcat7/bin/setenv.sh on my Linux deployment:
#! /bin/sh
export PLEXUS_NEXUS_WORK=/var/nexus
I assume that the Windows equivalent might be:
SET PLEXUS_NEXUS_WORK=C:\NEXUS
Setting the PLEXUS_NEXUS_WORK environment variable didn't work for me using Tomcat 7 and Nexus 2.8. Perhaps this no longer works with newer versions of Nexus.
What did work was to change the nexus-work setting in nexus.properties file, which is in the WEB-INF/classes folder of the Nexus web app
Here is what my setting now looks like:
nexus-work=D:/sonatype-work/nexus
I would suggest to use the Nexus bundle installer with the embedded jetty server instead of running the Jetty war in Tomcat. While you can do that, you will not be able to upgrade to Nexus Professional easily since it is only supported with the embedded Jetty.
If you use the bundle installer the storage will be in a sibling folder to the nexus folder called sonatype-work/nexus.
Check out the free book Repository Management with Nexus for more info.
Since Nexus 2.8, you could set the nexus-work as an environment parameter for the tomcat JVM, like this :
JAVA_OPTS="-d64 -server -Xms128M -Xmx1024M -XX:MaxPermSize=512M -Dcom.sun.security.enableCRLDP=true -Djava.net.preferIPv4Stack=true -Djava.io.tmpdir=/tmp -Dnexus-work=/var/lib/nexus/work "
It works for me as I have the Nexus OSS as a war file into a RHEL6 tomcat6 installation.

cannot seem to run my jar file in command promtp

I have created a project within NetBeans with includes a form and a class that serves as a database connection layer. When i try to run this project through the IDE everything launches just fine. The problem occurs when i try to launch the jar file created by the ide on the commmand prompt terminal. nothing happens? it just moves to the next line. i have a manifest file with a class path and main class specified and it looks like so
Manifest-Version: 1.0
Ant-Version: Apache Ant 1.8.3
Created-By: 1.6.0_22-b04 (Sun Microsystems Inc.)
Class-Path: lib/mysql-connector-java-5.1.13-bin.jar lib/mylib.jar
X-COMMENT: Main-Class will be added automatically by build
Main-Class: eopprototype.EOPPrototype
when i look at what the compiler says is says To run this application from the command line without Ant, try:
java -jar "/h/USERS/local/pagola/NetBeansProjects/EOPPrototype/dist/EOPPrototype.jar"
when i try to type that command it just goes to the second line without anything happening. Not evena ny errors. I am supposed to distribute this jar file to a shared folder and have it run but i cant do it and i dont know whats wrong. I have NOT added any JAVA_HOME path as my jdk 1,6 is isntalled in usr/bin so it should find it there but i have NOT added any classpath (ide shows two runtime and bootable classpaths) somebody please assist me as i am new to the whole java virtual machine environment
I guess you meant the standard outputs, or other things you printed to the command prompt from your java program. To get that printed on the command propmt, you need to run java in debug mode.
Use
java -Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=n,address=5005 -jar myJar.jar
to run java in debug mode and get all standard outputs, exceptions etc. on the command prompt.

Processing Java servlet 'javax.servlet' package not found

Not a very common implementation, but using Processing as a Java Servlet has been discussed in previous posts before (1, 2). I have been developing a program in Processing to use as a Java servlet. However, when I have code (such as like the first linked example) in a Processing sketch, I get the error message
The package 'javax.servlet' does not exist. You might be missing a library.
I have Tomcat 5.5 service running on XP, and my environment variables are as follows
CLASSPATH = C:\tomcat\common\lib\servlet-api.jar
CATALINA_HOME = C:\tomcat
JAVA_HOME = C:\Program Files\Java\jdk1.6.0_21
JRE_HOME = C:\Program Files\Java\jre6
I have been trying to diagnose why the javax.servlet packages are not recognized by Processing for many hours and there is nothing online that seems to yield an explanation other than fixing the environment variables to recognize the tomcat libraries. I have also tried to put the servlet-api.jar and jsp-api.jar files in Processing as a kind of custom Processing library but they are not recognized there either, nor when I try to run the program within the tomcat/webapps folder.
I also have tried
javap -classpath my;class;path javax.servlet.Servlet
on the cmd and it gave me the same error.
I'm not that good with Tomcat yet so please forgive me if this is a result of my unfamiliarity. If anyone more knowledgeable than I can shed some light as to why Processing cannot recognize this package would be tremendous. Thanks so much~
CLASSPATH = C:\tomcat\common\lib\servlet-api.jar
This is the problem . Your classpath should be one level up i.e
CLASSPATH = C:\tomcat\common\lib\
This should work fine.
Right Click on MyComputer->Properties->Advanced->Environment Variables->
Set a new user variable name as classpath and give the variable value where your servlet-api.jar file is located (applicable for tomcat webserver), for example:->
variablename: classpath
variablevalue: D:\Tomcat\lib\servlet-api.jar
Now you can run your disassembler to find out the servlet class and interface information
If you are not able to load the servlet package, try setting the environment variable CLASSPATH to .;C:\tomcat\common\lib\servlet-api.jar. That should help.
Ok!.. i bought a new laptop and was faced the same problem, well i hope this would fix the issue on your windows 10 device as well.
First of all know that the error is just due to incorrect or incomplete path or classpath. After Installing Tomcat and JDK set the environment variable as follows(Location may vary as per your installation):
JAVA_HOME = C:\Program Files (x86)\Java\jdk1.7.0_80
JRE_HOME = C:\Program Files (x86)\Java\jre7
CATALINA_HOME = C:\Program Files (x86)\Apache Software Foundation\Tomcat 7.0
PATH = C:\Program Files (x86)\Java\jdk1.7.0_80\bin; C:\Program Files (x86)\Apache Software Foundation\Tomcat 7.0\bin;
CLASSPATH = C:\Program Files (x86)\Apache Software Foundation\Tomcat 7.0\lib\servlet-api.jar; C:\Program Files (x86)\Java\jdk1.7.0_80\lib\tools.jar; JAVA_HOME\lib
make sure that your classpath directs the mentioned jar files, as javax is included in it(try using winrar for checking the inner contents).
After saving the setting, Test using javap javax.servlet.Servlet
Well if you still face any issue please share the error message and screenshot.
Probably because Tomcat is not in the Java Build Path. Try add Tomcat to your library
1) Right-click on your project folder > Build Path > Configure Build Path
2) Click on Library tab > click Add Library button
3) Select Server Runtime > click Next button
4) Select your server > click Finish button

Resources