S
Snyke
I'm currently developing a large application which has two main
components. They communicate each other with RMI. As a logging API I'm
using Log4J which is really nice for its ease of use, but I recently
came across a real Problem: when starting tomcat it crashes when trying
to register a Listener I wrote that should connect to the RMI-Registry:
----- PersistenceListener -----
/**
* PersistenceListener.java created on Dec 14, 2005
*
* This program is free software; you can redistribute it and/or
modify
* it under the terms of the GNU General Public License as published
by
* the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
02111-1307 USA
*/
package net.sf.ww2.persister;
import java.net.MalformedURLException;
import java.rmi.Naming;
import java.rmi.NotBoundException;
import java.rmi.RMISecurityManager;
import java.rmi.RemoteException;
import javax.servlet.*;
import org.apache.log4j.Logger;
/**
* @author Christian 'Snyke' Decker
*/
public class PersistenceListener implements ServletContextListener {
PersistenceSession session = null;
public PersistenceListener() {
super();
// TODO Auto-generated constructor stub
}
public void contextInitialized(ServletContextEvent arg0){
try {
if (System.getSecurityManager() == null) {
System.setSecurityManager(new RMISecurityManager());
}
try{System.getSecurityManager().checkConnect("localhost",1099);}catch(SecurityException
se){
Logger.getLogger("Frontend").fatal("Cannot connect to RMI
Server!");
}
String name = "//127.0.0.1/Persister";
session = (PersistenceSession)Naming.lookup(name);
arg0.getServletContext().setAttribute("Persister",session);
} catch (MalformedURLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (RemoteException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (NotBoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
public void contextDestroyed(ServletContextEvent arg0) {
// TODO Auto-generated method stub
}
}
------ eof -----
There is also another issue with the RMI startup but I'll post that to
another Post...
catalina.sh run gives me the following output:
----- # -----
nex:/home/cxd/dev/apache-tomcat-5.5.12/bin ./catalina.sh run
Using CATALINA_BASE: /home/cxd/dev/apache-tomcat-5.5.12
Using CATALINA_HOME: /home/cxd/dev/apache-tomcat-5.5.12
Using CATALINA_TMPDIR: /home/cxd/dev/apache-tomcat-5.5.12/temp
Using JRE_HOME: /usr/lib/jvm/java/jre
Created MBeanServer with ID: 4413ee:10872d205cd:-8000:nex:1
Dec 28, 2005 8:22:13 PM org.apache.catalina.core.AprLifecycleListener
lifecycleEvent
INFO: The Apache Portable Runtime which allows optimal performance in
production environments was not found on the java.library.path:
/usr/lib/jvm/java-1.4.2-sun-1.4.2.06/jre/lib/i386/client:/usr/lib/jvm/java-1.4.2-sun-1.4.2.06/jre/lib/i386:/usr/lib/jvm/java-1.4.2-sun-1.4.2.06/jre/../lib/i386
Dec 28, 2005 8:22:13 PM org.apache.coyote.http11.Http11BaseProtocol
init
INFO: Initializing Coyote HTTP/1.1 on http-8080
Dec 28, 2005 8:22:13 PM org.apache.catalina.startup.Catalina load
INFO: Initialization processed in 817 ms
Dec 28, 2005 8:22:14 PM org.apache.catalina.core.StandardService start
INFO: Starting service Catalina
Dec 28, 2005 8:22:14 PM org.apache.catalina.core.StandardEngine start
INFO: Starting Servlet Engine: Apache Tomcat/5.5.12
Dec 28, 2005 8:22:14 PM org.apache.catalina.core.StandardHost start
INFO: XML validation disabled
Dec 28, 2005 8:22:14 PM org.apache.catalina.startup.HostConfig
deployWAR
INFO: Deploying web application archive frontend-1.0-SNAPSHOT.war
Dec 28, 2005 8:22:14 PM org.apache.catalina.loader.WebappClassLoader
validateJarFile
INFO:
validateJarFile(/home/cxd/dev/apache-tomcat-5.5.12/webapps/frontend-1.0-SNAPSHOT/WEB-INF/lib/servlet-api-2.4.jar)
- jar not loaded. See Servlet Spec 2.3, section 9.7.2. Offending class:
javax/servlet/Servlet.class
DEBUG [main] (ManagerBase.java:516) - Opening /dev/urandom
DEBUG [main] (ManagerBase.java:724) - Registering
Catalina:type=Manager,path=/frontend-1.0-SNAPSHOT,host=localhost
DEBUG [main] (StandardManager.java:629) - Force random number
initialization starting
DEBUG [main] (ManagerBase.java:304) - Getting message digest component
for algorithm MD5
DEBUG [main] (ManagerBase.java:318) - Completed getting message digest
component
DEBUG [main] (ManagerBase.java:321) - getDigest() 1
DEBUG [main] (StandardManager.java:632) - Force random number
initialization completed
DEBUG [main] (StandardManager.java:336) - Start: Loading persisted
sessions
DEBUG [main] (StandardManager.java:346) - Loading persisted sessions
from SESSIONS.ser
DEBUG [main] (StandardManager.java:369) - No persisted data file found
DEBUG [main] (StandardContext.java:3637) - Configuring event listener
class 'net.sf.ww2.persister.PersistenceListener'
DEBUG [main] (StandardContext.java:3676) - Sending application start
events
FATAL [main] (PersistenceListener.java:50) - Cannot connect to RMI
Server!
Dec 28, 2005 8:22:14 PM org.apache.catalina.startup.HostConfig
deployWAR
SEVERE: Error deploying web application archive
frontend-1.0-SNAPSHOT.war
java.lang.NoClassDefFoundError:
org/apache/log4j/spi/ThrowableInformation
at
org.apache.log4j.spi.LoggingEvent.<init>(LoggingEvent.java:145)
at org.apache.log4j.Category.forcedLog(Category.java:372)
at org.apache.log4j.Category.log(Category.java:864)
at
org.apache.commons.logging.impl.Log4JLogger.error(Log4JLogger.java:193)
at
org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:3696)
at
org.apache.catalina.core.StandardContext.start(StandardContext.java:4127)
at
org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:759)
at
org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:739)
at
org.apache.catalina.core.StandardHost.addChild(StandardHost.java:524)
at
org.apache.catalina.startup.HostConfig.deployWAR(HostConfig.java:804)
at
org.apache.catalina.startup.HostConfig.deployWARs(HostConfig.java:693)
at
org.apache.catalina.startup.HostConfig.deployApps(HostConfig.java:472)
at
org.apache.catalina.startup.HostConfig.start(HostConfig.java:1118)
at
org.apache.catalina.startup.HostConfig.lifecycleEvent(HostConfig.java:310)
at
org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:119)
at
org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1020)
at
org.apache.catalina.core.StandardHost.start(StandardHost.java:718)
at
org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1012)
at
org.apache.catalina.core.StandardEngine.start(StandardEngine.java:442)
at
org.apache.catalina.core.StandardService.start(StandardService.java:450)
at
org.apache.catalina.core.StandardServer.start(StandardServer.java:680)
at
org.apache.catalina.startup.Catalina.start(Catalina.java:536)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:324)
at
org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:275)
at
org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:413)
java.lang.reflect.InvocationTargetException
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:324)
at
org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:275)
at
org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:413)
Caused by: java.security.AccessControlException: access denied
(java.io.FilePermission /home/cxd/dev/apache-tomcat-5.5.12/webapps
read)
at
java.security.AccessControlContext.checkPermission(AccessControlContext.java:269)
at
java.security.AccessController.checkPermission(AccessController.java:401)
at
java.lang.SecurityManager.checkPermission(SecurityManager.java:524)
at
java.lang.SecurityManager.checkRead(SecurityManager.java:863)
at java.io.File.list(File.java:913)
at
org.apache.catalina.startup.HostConfig.deployApps(HostConfig.java:474)
at
org.apache.catalina.startup.HostConfig.start(HostConfig.java:1118)
at
org.apache.catalina.startup.HostConfig.lifecycleEvent(HostConfig.java:310)
at
org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:119)
at
org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1020)
at
org.apache.catalina.core.StandardHost.start(StandardHost.java:718)
at
org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1012)
at
org.apache.catalina.core.StandardEngine.start(StandardEngine.java:442)
at
org.apache.catalina.core.StandardService.start(StandardService.java:450)
at
org.apache.catalina.core.StandardServer.start(StandardServer.java:680)
at
org.apache.catalina.startup.Catalina.start(Catalina.java:536)
... 6 more
java.security.AccessControlException: access denied
(java.util.logging.LoggingPermission control)
at
java.security.AccessControlContext.checkPermission(AccessControlContext.java:269)
at
java.security.AccessController.checkPermission(AccessController.java:401)
at
java.lang.SecurityManager.checkPermission(SecurityManager.java:524)
at
java.util.logging.LogManager.checkAccess(LogManager.java:825)
at java.util.logging.LogManager.reset(LogManager.java:532)
at
java.util.logging.LogManager$Cleaner.run(LogManager.java:195)
nex:/home/cxd/dev/apache-tomcat-5.5.12/bin
----- eof-----
Sorry for the lenghty output but I need this to work really quickly
Any idea on how to fix this?
Thanks for your time,
Snyke
components. They communicate each other with RMI. As a logging API I'm
using Log4J which is really nice for its ease of use, but I recently
came across a real Problem: when starting tomcat it crashes when trying
to register a Listener I wrote that should connect to the RMI-Registry:
----- PersistenceListener -----
/**
* PersistenceListener.java created on Dec 14, 2005
*
* This program is free software; you can redistribute it and/or
modify
* it under the terms of the GNU General Public License as published
by
* the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
02111-1307 USA
*/
package net.sf.ww2.persister;
import java.net.MalformedURLException;
import java.rmi.Naming;
import java.rmi.NotBoundException;
import java.rmi.RMISecurityManager;
import java.rmi.RemoteException;
import javax.servlet.*;
import org.apache.log4j.Logger;
/**
* @author Christian 'Snyke' Decker
*/
public class PersistenceListener implements ServletContextListener {
PersistenceSession session = null;
public PersistenceListener() {
super();
// TODO Auto-generated constructor stub
}
public void contextInitialized(ServletContextEvent arg0){
try {
if (System.getSecurityManager() == null) {
System.setSecurityManager(new RMISecurityManager());
}
try{System.getSecurityManager().checkConnect("localhost",1099);}catch(SecurityException
se){
Logger.getLogger("Frontend").fatal("Cannot connect to RMI
Server!");
}
String name = "//127.0.0.1/Persister";
session = (PersistenceSession)Naming.lookup(name);
arg0.getServletContext().setAttribute("Persister",session);
} catch (MalformedURLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (RemoteException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (NotBoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
public void contextDestroyed(ServletContextEvent arg0) {
// TODO Auto-generated method stub
}
}
------ eof -----
There is also another issue with the RMI startup but I'll post that to
another Post...
catalina.sh run gives me the following output:
----- # -----
nex:/home/cxd/dev/apache-tomcat-5.5.12/bin ./catalina.sh run
Using CATALINA_BASE: /home/cxd/dev/apache-tomcat-5.5.12
Using CATALINA_HOME: /home/cxd/dev/apache-tomcat-5.5.12
Using CATALINA_TMPDIR: /home/cxd/dev/apache-tomcat-5.5.12/temp
Using JRE_HOME: /usr/lib/jvm/java/jre
Created MBeanServer with ID: 4413ee:10872d205cd:-8000:nex:1
Dec 28, 2005 8:22:13 PM org.apache.catalina.core.AprLifecycleListener
lifecycleEvent
INFO: The Apache Portable Runtime which allows optimal performance in
production environments was not found on the java.library.path:
/usr/lib/jvm/java-1.4.2-sun-1.4.2.06/jre/lib/i386/client:/usr/lib/jvm/java-1.4.2-sun-1.4.2.06/jre/lib/i386:/usr/lib/jvm/java-1.4.2-sun-1.4.2.06/jre/../lib/i386
Dec 28, 2005 8:22:13 PM org.apache.coyote.http11.Http11BaseProtocol
init
INFO: Initializing Coyote HTTP/1.1 on http-8080
Dec 28, 2005 8:22:13 PM org.apache.catalina.startup.Catalina load
INFO: Initialization processed in 817 ms
Dec 28, 2005 8:22:14 PM org.apache.catalina.core.StandardService start
INFO: Starting service Catalina
Dec 28, 2005 8:22:14 PM org.apache.catalina.core.StandardEngine start
INFO: Starting Servlet Engine: Apache Tomcat/5.5.12
Dec 28, 2005 8:22:14 PM org.apache.catalina.core.StandardHost start
INFO: XML validation disabled
Dec 28, 2005 8:22:14 PM org.apache.catalina.startup.HostConfig
deployWAR
INFO: Deploying web application archive frontend-1.0-SNAPSHOT.war
Dec 28, 2005 8:22:14 PM org.apache.catalina.loader.WebappClassLoader
validateJarFile
INFO:
validateJarFile(/home/cxd/dev/apache-tomcat-5.5.12/webapps/frontend-1.0-SNAPSHOT/WEB-INF/lib/servlet-api-2.4.jar)
- jar not loaded. See Servlet Spec 2.3, section 9.7.2. Offending class:
javax/servlet/Servlet.class
DEBUG [main] (ManagerBase.java:516) - Opening /dev/urandom
DEBUG [main] (ManagerBase.java:724) - Registering
Catalina:type=Manager,path=/frontend-1.0-SNAPSHOT,host=localhost
DEBUG [main] (StandardManager.java:629) - Force random number
initialization starting
DEBUG [main] (ManagerBase.java:304) - Getting message digest component
for algorithm MD5
DEBUG [main] (ManagerBase.java:318) - Completed getting message digest
component
DEBUG [main] (ManagerBase.java:321) - getDigest() 1
DEBUG [main] (StandardManager.java:632) - Force random number
initialization completed
DEBUG [main] (StandardManager.java:336) - Start: Loading persisted
sessions
DEBUG [main] (StandardManager.java:346) - Loading persisted sessions
from SESSIONS.ser
DEBUG [main] (StandardManager.java:369) - No persisted data file found
DEBUG [main] (StandardContext.java:3637) - Configuring event listener
class 'net.sf.ww2.persister.PersistenceListener'
DEBUG [main] (StandardContext.java:3676) - Sending application start
events
FATAL [main] (PersistenceListener.java:50) - Cannot connect to RMI
Server!
Dec 28, 2005 8:22:14 PM org.apache.catalina.startup.HostConfig
deployWAR
SEVERE: Error deploying web application archive
frontend-1.0-SNAPSHOT.war
java.lang.NoClassDefFoundError:
org/apache/log4j/spi/ThrowableInformation
at
org.apache.log4j.spi.LoggingEvent.<init>(LoggingEvent.java:145)
at org.apache.log4j.Category.forcedLog(Category.java:372)
at org.apache.log4j.Category.log(Category.java:864)
at
org.apache.commons.logging.impl.Log4JLogger.error(Log4JLogger.java:193)
at
org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:3696)
at
org.apache.catalina.core.StandardContext.start(StandardContext.java:4127)
at
org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:759)
at
org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:739)
at
org.apache.catalina.core.StandardHost.addChild(StandardHost.java:524)
at
org.apache.catalina.startup.HostConfig.deployWAR(HostConfig.java:804)
at
org.apache.catalina.startup.HostConfig.deployWARs(HostConfig.java:693)
at
org.apache.catalina.startup.HostConfig.deployApps(HostConfig.java:472)
at
org.apache.catalina.startup.HostConfig.start(HostConfig.java:1118)
at
org.apache.catalina.startup.HostConfig.lifecycleEvent(HostConfig.java:310)
at
org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:119)
at
org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1020)
at
org.apache.catalina.core.StandardHost.start(StandardHost.java:718)
at
org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1012)
at
org.apache.catalina.core.StandardEngine.start(StandardEngine.java:442)
at
org.apache.catalina.core.StandardService.start(StandardService.java:450)
at
org.apache.catalina.core.StandardServer.start(StandardServer.java:680)
at
org.apache.catalina.startup.Catalina.start(Catalina.java:536)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:324)
at
org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:275)
at
org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:413)
java.lang.reflect.InvocationTargetException
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:324)
at
org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:275)
at
org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:413)
Caused by: java.security.AccessControlException: access denied
(java.io.FilePermission /home/cxd/dev/apache-tomcat-5.5.12/webapps
read)
at
java.security.AccessControlContext.checkPermission(AccessControlContext.java:269)
at
java.security.AccessController.checkPermission(AccessController.java:401)
at
java.lang.SecurityManager.checkPermission(SecurityManager.java:524)
at
java.lang.SecurityManager.checkRead(SecurityManager.java:863)
at java.io.File.list(File.java:913)
at
org.apache.catalina.startup.HostConfig.deployApps(HostConfig.java:474)
at
org.apache.catalina.startup.HostConfig.start(HostConfig.java:1118)
at
org.apache.catalina.startup.HostConfig.lifecycleEvent(HostConfig.java:310)
at
org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:119)
at
org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1020)
at
org.apache.catalina.core.StandardHost.start(StandardHost.java:718)
at
org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1012)
at
org.apache.catalina.core.StandardEngine.start(StandardEngine.java:442)
at
org.apache.catalina.core.StandardService.start(StandardService.java:450)
at
org.apache.catalina.core.StandardServer.start(StandardServer.java:680)
at
org.apache.catalina.startup.Catalina.start(Catalina.java:536)
... 6 more
java.security.AccessControlException: access denied
(java.util.logging.LoggingPermission control)
at
java.security.AccessControlContext.checkPermission(AccessControlContext.java:269)
at
java.security.AccessController.checkPermission(AccessController.java:401)
at
java.lang.SecurityManager.checkPermission(SecurityManager.java:524)
at
java.util.logging.LogManager.checkAccess(LogManager.java:825)
at java.util.logging.LogManager.reset(LogManager.java:532)
at
java.util.logging.LogManager$Cleaner.run(LogManager.java:195)
nex:/home/cxd/dev/apache-tomcat-5.5.12/bin
----- eof-----
Sorry for the lenghty output but I need this to work really quickly
Any idea on how to fix this?
Thanks for your time,
Snyke