News



Tomcat behind a Proxy

"Connection refused..". This seems to be a stupid problem, but I hope by writing this, I can help some beginners which have the same problem.
This happens, when you are trying to access some page from Tomcat and that page is behind the company's proxy.
I found one article which says that you have to add to catalina.properties in %CATALINA_HOME%/conf/catalina.properties values http.proxyHost=... http.proxyPort=, .. etc.

in fact, it did not work, because I am running Tomcat from Exadel Studio Pro..

The final solution is more than simple:
in JRE configuration of Exadel, I specified these additional JVM paramters:
-DproxyHost=my.company.host -DproxyPort=8080 -DproxyUser=matto -DproxyPassword=mypassword

Shame on me, it was so simple ;)
 
Some notes about JBoss and JNDI
I was confused while using the JNDI calls and could not figure out when to use the java: , java:comp, etc.. so, here are some notes that come from http://www.informit.com/articles/article.asp?p=384904
java:comp - available only to the application component associated with that particular context

java: - only visible to JBoss AS

other - remote clients (or when you are using EJBs.. there is a convention to map ejbs to ejb/NameOfEJB) Name of ejb-jar.xml usually maps to java:comp/env/Name
 
Extracting a value with Regular expressions in Java
 
Exception in thread "main" java.lang.NoClassDefFoundError

 

>> Register as FREELANCE DEVELOPER for FREE!


A friend of mine wanted to start to learn java, and I wanted to help him, so we created a simple Hello World example.

public class Hello {

public static void main(String argv[]) {

System.out.println("Hello world !");

}

}

then, when you compile it:

> javac Hello.java

and want to execute it:

> java Hello

Exception in thread "main" java.lang.NoClassDefFoundError: Hello

We set the CLASSPATH and JAVA_HOME enviroment variable correctly, and the problem was still the same..

When we copied the Hello.class into a lib directory of JAVA_HOME, it worked, but not from the current directory !

We tried different versions of java.. and do you know where this stupid problem is?

in the CLASSPATH there should be:
CLASSPATH=.;c:\programme\jboss\lib;c:\programme\
j2sdk1.4.2_08\lib;c:\programme\j2sdk1.4.2_08\jre\lib; ...

yes.. a dot .. it means, that it will search for classes bytecode in the current directory !

you can also tell java to search the current directory with the -classpath parameter

> java -classpath . Hello

Problems like this can really discourage java newbies, and that moment was very embarassing :)




 

Problem:
Basically, the Exception in thread "main" java.lang.NoClassDefFoundError:

means, that the class which you are trying to run was not found in the classpath.

Solution: you need to add the class or .jar file which contains this class into the java classpath. When you are running a java class from the command line, you need to add the dot (.)

java YourSingleClass -cp . 

into the classpath which tells the JVM to search for classes in actual directory.


If you are running a class from a .jar file, you need to add this jar file into the classpath:

java org.somepackage.SomeClass -cp myJarWithSomeClass.jar



 
Tomcat behind a proxy
Dear God...
"Connection refused..". This seems to be a stupid problem, but I hope by writing this, I can help some beginners which have the same problem.

This happens, when you are trying to access some page from Tomcat and that page is behind the company's proxy.
I found one article which says that you have to add to catalina.properties in %CATALINA_HOME%/conf/catalina.properties values http.proxyHost=... http.proxyPort=, .. etc.

in fact, it did not work, because I am running Tomcat from Exadel Studio Pro..

The final solution is more than simple:
in JRE configuration of Exadel, I specified these additional JVM paramters:
-DproxyHost=my.company.host -DproxyPort=8080 -DproxyUser=matto -DproxyPassword=mypassword

Shame on me, it was so simple ;)
 
<< Start < Prev 1 2 Next > End >>

Page 2 of 2

This website uses cookies to ensure you get the best experience on our website. Learn More.

Got It!