Re: “java.lang.NullPointerException” with JDBC connection from InitialContext

2009-01-03 Thread Robert Blackburn
 Just some suggestions that come to mind:

 Have you considered googling for StringUtils indexOfIgnoreCaseRespectQuotes?
 E.g. it may be Connector/J bug #25047 fixed in v. 5.0.5
 Check, what version of MySQL Connector/J you are using.


OK, problem solved.
For the record I did search on that, and looked into it originally.
But stupidly, I verified that my test Connector/J was version v5.0.5
or later,... but must not have check the server. Sure enough the host
had v5.0.2. Upgrading the driver resolved this. Thank you Konstantin.

Thank you everyone who responded to my issue.

-
To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org
For additional commands, e-mail: users-h...@tomcat.apache.org



Jar wars - Conflicting classes

2009-01-03 Thread David.Meldrum

Windows XP SP 3  Tomcat 6.0.1  JVM 1.6.0

Must all conflicting classes be sorted out on one instance of Tomcat?
I have learned not to put application jars (classes) in the jre lib, 
since they then become common to all applications and if there is a 
duplicate, but not exact duplicate, then things crash.  What I am 
wondering is, are all the classes loaded into the _same_ JVM?  Here is 
the problem I ran into.  Application #1 uses some Quartz scheduling 
classes.  Application #2 also uses Quartz, but apparently a different 
version.  Can these applications live on the same Tomcat instance?  In 
other words if each of the applications has it's own  lib, can the 
classes overlap?  I get the feeling the applications will have to be 
sorted out to use the same Quart library.  I read the  documentation 
regarding Class Loader and understand the order in which libraries are 
searched, but do the classes end up in one single aggregated JVM memory?


- Dave



Re: Jar wars - Conflicting classes

2009-01-03 Thread Konstantin Kolinko
2009/1/3 David.Meldrum david.meld...@verizon.net:
 Windows XP SP 3  Tomcat 6.0.1  JVM 1.6.0

 Must all conflicting classes be sorted out on one instance of Tomcat?
 I have learned not to put application jars (classes) in the jre lib, since
 they then become common to all applications and if there is a duplicate, but
 not exact duplicate, then things crash.  What I am wondering is, are all the
 classes loaded into the _same_ JVM?  Here is the problem I ran into.
  Application #1 uses some Quartz scheduling classes.  Application #2 also
 uses Quartz, but apparently a different version.  Can these applications
 live on the same Tomcat instance?  In other words if each of the
 applications has it's own  lib, can the classes overlap?  I get the feeling
 the applications will have to be sorted out to use the same Quart library.
  I read the  documentation regarding Class Loader and understand the order
 in which libraries are searched, but do the classes end up in one single
 aggregated JVM memory?


You can put them in WEB-INF/lib folders of your applications and they
will happily coexist separately.

The problem will occur is some of them are put into the common lib folder
of Tomcat, or, even worse, into JRE lib folder, as you mentioned.

Well, the problem do not occur always.
It depends. It depends on how the library is used, what are its dependencies,
but when it occurs, the easiest answer is to remove the library either from
the application or from commons.

I may add that a) classloader delegation rules in web applications are
different from those of core Java. You may read [1] and try to figure what
implications that impose. b) web applications may be unloaded, reloaded
and thus the classes may have gone away. Thus classloader issues are
more observable here than in a standalone application.


For reference,
[1] http://tomcat.apache.org/tomcat-6.0-doc/class-loader-howto.html

Best regards,
Konstantin Kolinko

-
To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org
For additional commands, e-mail: users-h...@tomcat.apache.org



RE: Redeploy leaks

2009-01-03 Thread Cosio, Raul
Memory leak is an advanced task. But once understood is very easy to fix
them, just follow some simple rules, most common situations are: 1) Not
de-registering jdbc driver, 2) shutdown log4j after use.

To de-register jdbc driver just put this code in the contextDestroyed()
method inside a ServletContextListener in your application:

System.out.println(unloading drivers for classLoader: [ +
Integer.toHexString(getClass().getClassLoader().hashCode()) + ]);
try {
for (java.util.Enumeration e = java.sql.DriverManager.getDrivers();
e.hasMoreElements();) 
{
java.sql.Driver driver = (java.sql.Driver) e.nextElement();
if (driver.getClass().getClassLoader() ==
getClass().getClassLoader()) 
{
java.sql.DriverManager.deregisterDriver(driver);
System.out.println(driver.getClass().getName() + 
unloaded.);
}
else
System.out.println(driver.getClass().getName() +  not
unloaded.);
}
} catch (Throwable e) { 
System.err.println(Failed to cleanup ClassLoader for webapp); 
e.printStackTrace();
}

For the log4j issue you can include also this code:

org.apache.commons.logging.LogFactory.release(Thread.currentThread().get
ContextClassLoader());
org.apache.log4j.LogManager.shutdown();

Of course there are lots of issues to handle with... you can also read:
http://tomcat.apache.org/faq/memory.html



-Original Message-
From: Adriano dos Santos Fernandes [mailto:adrian...@uol.com.br] 
Sent: Viernes, 19 de Diciembre de 2008 09:20 p.m.
To: users@tomcat.apache.org
Subject: Redeploy leaks

Hi!

As I had having OutOfMemory exceptions (PermGen) when redeploying an 
application, I started to verify things using Eclipse Memory Analyzer.

I've discovered some real leaks, for example caused by the Java Disposer

thread being instantiated using the Webapp classloader. After fix this, 
when I redeploy the application, Memory Analyzer shows that there are no

non-weak/soft references to the undeployed classloader. But it (and the 
classes allocated by it) is never garbaged collected.

I've tried different VM switches (-XX:+CMS*) and none make the 
classloader be collected. Thinking about word Perm (permanent) and 
some sources, I've done non-web testing and there a custom classloader 
*is* garbaged collected.

So what could be the problem when running in Tomcat?

I'm using Tomcat 6.0.18, JDK 1.6.0-10 (Linux and Windows) and Apache 
Wicket. I've not put any libraries in tomcat/lib, they are all on the 
WEB-INF/lib. Wicket uses ThreadGlobals, but I don't think this may be a 
problem, because Eclipse Memory Analyzer seems to show references from 
them, but it didn't show any references in my case!

Increasing the permgen size is not something I'm looking for. I'd rather

prefer to see unused memory being deallocated.


Adriano

Notice:  This e-mail message, together with any attachments, contains
information of Merck  Co., Inc. (One Merck Drive, Whitehouse Station,
New Jersey, USA 08889), and/or its affiliates (which may be known
outside the United States as Merck Frosst, Merck Sharp  Dohme or
MSD and in Japan, as Banyu - direct contact information for affiliates is
available at http://www.merck.com/contact/contacts.html) that may be
confidential, proprietary copyrighted and/or legally privileged. It is
intended solely for the use of the individual or entity named on this
message. If you are not the intended recipient, and have received this
message in error, please notify us immediately by reply e-mail and
then delete it from your system.


-
To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org
For additional commands, e-mail: users-h...@tomcat.apache.org



Change JSP Environment.

2009-01-03 Thread Stefan Englhart
Hello,

I want to change the default user file-dir.  for instance: /users/user1/

System: java 1.5.0_14, tomcat  6.0.18, os debian.
Configuration:
system.xml:

   Host name=test2.domain.at debug=0 unpackWARs=true
 Logger className=org.apache.catalina.logger.FileLogger
  directory=logs  prefix=virtual_log. suffix=.txt
timestamp=true/
 Context path= docBase=/users/user1/public_html
debug=0 reloadable=true/
 Valve className=org.apache.catalina.valves.AccessLogValve
  directory=logs  prefix=virtual_log. suffix=.txt
  pattern=common/
/Host




I've test it with a command (new File(.) ) in a JSP and the result of
the getCanonicalPath  is  the tomcat -home and not /users/user1/.
I've tried without success the attributes appBase and |workDir|. 

Thanks.
Greedings Stefan
|*
*|*||***


Classpath problem

2009-01-03 Thread FHSerkland
Hello.  I am using Tomcat 6.0.18, my Java version is 1.6.0_11 and I  have a 
servlet called TestingServlet.java.  My classpath reads like  this:
 
.;C:\Sun\SDK\bin; C:\Sun\SDK\jdk\bin; C:\Tomcat\lib\servlet-api.jar
 
I cannot compile in DOS without typing:
 
javac -classpath C:\Tomcat\lib\servlet-api.jar TestingServlet.java
 
I cannot understand why I am being required to specify the servlet api when  
I have it in my classpath.  I have looked through the manual and Googled  for 
an answer to this problem without success.  Can anyone help me  out?  Thanks.
**New year...new news.  Be the first to know what is making 
headlines. (http://www.aol.com/?ncid=emlcntaolcom0026)


Re: Classpath problem

2009-01-03 Thread Konstantin Kolinko
2009/1/4  fhserkl...@aol.com:
 Hello.  I am using Tomcat 6.0.18, my Java version is 1.6.0_11 and I  have a
 servlet called TestingServlet.java.  My classpath reads like  this:

 .;C:\Sun\SDK\bin; C:\Sun\SDK\jdk\bin; C:\Tomcat\lib\servlet-api.jar

 I cannot compile in DOS without typing:

 javac -classpath C:\Tomcat\lib\servlet-api.jar TestingServlet.java

 I cannot understand why I am being required to specify the servlet api when
 I have it in my classpath.

I guess that is because spaces are not allowed in the value.

Try:
set CLASSPATH=.;C:\Sun\SDK\bin;C:\Sun\SDK\jdk\bin;C:\Tomcat\lib\servlet-api.jar

or better
set CLASSPATH=.;C:\Tomcat\lib\servlet-api.jar

I do not know why you are adding those bin folders to the classpath.
There are no class files there.

-
To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org
For additional commands, e-mail: users-h...@tomcat.apache.org



set tomcat max session allow

2009-01-03 Thread cw
may i know is there any guidelines/info on how to set maximum limit of sessions 
allow for each webapp and redirect user to a static html page is exceeded . I 
already did my google and people mentioned need to do it directly on java codes 
rather than tomcat configuration,but they didn't mentioned how.. can 
elaborate?  

2. i know maxThread in sever.xml can be use to increase more sessions. but i 
don't see this option able to redirect user to static html page is exceeded