S
Snyke
As I said before,
http://groups.google.com/group/comp...baf1c5eca75/6f16b023abc2100e#6f16b023abc2100e
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 -----
This fails upon TomCat startup, with a Permission Error (resolve and
connect 127.0.0.1) which is solved usually by setting the right policy
but I have no idea at all where to place the policy and what
Permissions to aply. The class name is
net.sf.ww2.persister.PersistenceListener while the two Classes (remote
and local) are net.sf.ww2.persister.PersistenceSession and
net.sf.ww2.persister.PersistenceSessionImpl.
What would the policy file look like and where do I have to put it?
http://groups.google.com/group/comp...baf1c5eca75/6f16b023abc2100e#6f16b023abc2100e
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 -----
This fails upon TomCat startup, with a Permission Error (resolve and
connect 127.0.0.1) which is solved usually by setting the right policy
but I have no idea at all where to place the policy and what
Permissions to aply. The class name is
net.sf.ww2.persister.PersistenceListener while the two Classes (remote
and local) are net.sf.ww2.persister.PersistenceSession and
net.sf.ww2.persister.PersistenceSessionImpl.
What would the policy file look like and where do I have to put it?