Hi,

Is it possible that the database connection credentials are not right? Have you 
tried connecting to the database from the standard client with the same 
username and password?

Regards
Carlos

-----Original Message-----
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Oege de Moor
Sent: terça-feira, 18 de Janeiro de 2005 16:27
To: tomcat-user@jakarta.apache.org
Subject: tomcat4 + postgresql jdbc

I'm attempting to install tomcat4 + postgresql jdbc under Debian linux.
I've put the jdbc jar at /usr/share/tomcat4/common/lib/pg74.215.jdbc3.jar

When I attempt to connect to a database via jsp, I get
java.security.AccessControlException: access denied
(java.net.SocketPermission localhost resolve)

I've put a file "test2.jsp" at /var/lib/tomcat4/webapps/ROOT,
with the following contents:

-------------------------

<[EMAIL PROTECTED] import="java.sql.*"%>
<%
   // Define the connection
   Connection con = null;
   // Check that the DB2Driver class is available
   Class.forName("org.postgresql.Driver");
   try {
       // Attempt to connect to the Database
       con =
DriverManager.getConnection("jdbc:postgresql:demodb","oege","xxx");
       out.println("The test is complete, your Database has been
contacted");
   }
   // Make sure to catch any exceptions
   catch (SQLException e) {
             out.println(e.getMessage());
   }
%>
---------------------------

When I point my web browser at http://localhost:8180/test2.jsp,
the above exception occurs. The full stack trace is appended below.

I've attempted adding this line to the security policy file
in /etc/tomcat4/policy.d/99examples.policy:

grant codeBase "file:/usr/share/tomcat4/common/lib/pg74.215.jdbc3.jar!/-"
{
        permission java.security.AllPermission;
};


Any help would be much appreciated!

-Oege


Something unusual has occured to cause the driver to fail. Please report
this exception: Exception: java.security.AccessControlException: access
denied (java.net.SocketPermission localhost resolve) Stack Trace:
java.security.AccessControlException: access denied
(java.net.SocketPermission localhost resolve) 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.checkConnect(SecurityManager.java:1023) at
java.net.InetAddress.getAllByName0(InetAddress.java:1000) at
java.net.InetAddress.getAllByName0(InetAddress.java:981) at
java.net.InetAddress.getAllByName(InetAddress.java:975) at
java.net.InetAddress.getByName(InetAddress.java:889) at
java.net.InetSocketAddress.(InetSocketAddress.java:114) at
java.net.Socket.(Socket.java:124) at
org.postgresql.core.PGStream.(PGStream.java:47) at
org.postgresql.jdbc1.AbstractJdbc1Connection.openConnection(AbstractJdbc1Connection.java:197)
at org.postgresql.Driver.connect(Driver.java:139) at
java.sql.DriverManager.getConnection(DriverManager.java:512) at
java.sql.DriverManager.getConnection(DriverManager.java:171) at
org.apache.jsp.test2_jsp._jspService(test2_jsp.java:51) at
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:92) at
javax.servlet.http.HttpServlet.service(HttpServlet.java:853) at
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:162)
at
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:240)
at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:187) at
javax.servlet.http.HttpServlet.service(HttpServlet.java:853) at
org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:200)
at
org.apache.catalina.core.ApplicationFilterChain.access$000(ApplicationFilterChain.java:51)
at
org.apache.catalina.core.ApplicationFilterChain$1.run(ApplicationFilterChain.java:129)
at java.security.AccessController.doPrivileged(Native Method) at
org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:125)
at
org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:209)
at
org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:596)
at
org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:433)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:948)
at
org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:144)
at
org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:596)
at
org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:433)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:948)
at
org.apache.catalina.core.StandardContext.invoke(StandardContext.java:2358)
at
org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:133)
at
org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:596)
at
org.apache.catalina.valves.ErrorDispatcherValve.invoke(ErrorDispatcherValve.java:118)
at
org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:594)
at
org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:116)
at
org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:594)
at
org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:433)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:948)
at
org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:127)
at
org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:596)
at
org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:433)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:948)
at org.apache.coyote.tomcat4.CoyoteAdapter.service(CoyoteAdapter.java:152)
at
org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:799)
at
org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.processConnection(Http11Protocol.java:705)
at
org.apache.tomcat.util.net.TcpWorkerThread.runIt(PoolTcpEndpoint.java:577)
at
org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:683)
at java.lang.Thread.run(Thread.java:534) End of Stack Trace



---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



----------
Esta mensagem e quaisquer anexos são confidenciais, podendo conter
informação sujeita a sigilo profissional ou qualquer outro dever de
confidencialidade ou de segredo. Caso não seja o destinatário deste e-mail,
não deverá usar, copiar ou revelar o seu conteúdo, solicitando-se que
contacte o emissor com a brevidade possível e apague esta mensagem.
Obrigado pela colaboração.
----------
The information transmitted is intended for the person or entity to
which it is addressed only and may contain confidential and/or privileged
material. Any review, retransmission, dissemination or other use of, or
taking of any action in reliance upon, this information by persons or
entities other than the intended recipient is prohibited. If you received
this in error, please contact the sender and delete the material from any
computer.
Thank you for your cooperation.


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to