You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by Martin Gainty <mg...@hotmail.com> on 2006/04/04 13:34:12 UTC

Re: Servlet action is not available

Red--
I am re-posting the question to tomcat-users with request to display contents of jndi.properties..
Thanks,
Martin--
----- Original Message ----- 
From: "Craig McClanahan" <cr...@apache.org>
To: "Struts Users Mailing List" <us...@struts.apache.org>
Sent: Monday, April 03, 2006 9:40 PM
Subject: Re: Servlet action is not available


On 4/3/06, red phoenix <ro...@gmail.com> wrote:
>
> Mr Craig,
>    I  configure a JNDI in Tomcat5.5.12 like you tell me,like follows:
>
> <Context path="" docBase="/jsp-examples" debug="5" reloadable="true"
> crossContext="true">
>     <Resource name="jdbc/bb1" auth="Container" type=" javax.sql.DataSource
> "
> maxActive="100" maxIdle="30" maxWait="10000" username="administrator"
> password="123" driverClassName="sun.jdbc.odbc.JdbcOdbcDriver"
> url="jdbc:odbc:SMS"/>
>     </Context>
>
> Then I call this JNDI in a JSP file,the JSP file is follows:
>
> <%@page <%2...@page> <%2...@page> import="java.sql.*"%>
> <%@page <%2...@page> import="javax.sql.DataSource"%>
> < %@page <%2...@page> import="javax.naming.*"%>
> <html>
> <body>
> <%
> try{
>   Context initCtx=new InitialContext();
>   System.out.println("ok");
>   DataSource db = (DataSource)initCtx.lookup("java:comp/env/jdbc/bb1");
>   System.out.println("db="+db);
>   Connection conn = db.getConnection();
>   System.out.println("conn="+conn);
>   Statement stmt = conn.createStatement();
>   ResultSet rs = stmt.executeQuery ("SELECT * FROM abc");
>   out.println("User-list"+"<br>");
>   while(rs.next()){
>    out.print(rs.getString(1)+"<br>");
>   }
>   rs.close();
>   stmt.close();
>   conn.close();
> }catch(Exception e){
>   out.print(e);
> }
> %>
> </body>
> </html>
>
>
>
> javax.naming.NameNotFoundException: Name jdbc is not bound in this Context
>
> Why?
> Any idea will be appreciated!


This error implies there is something wrong with your configuration, and
that the registration of the resource did not get completed successfully.
In my experience, there's usually a stack trace in the Tomcat logs that says
why it didn't get processed.   You might also want to add a call to:

    e.printStackTrace();

inside your exception handler to see where the error is actually coming
from.

I don't use Tomcat 5.5 much myself (primarily 5.0) so I can't help you much
more than that ... best bet would be to ask questions on the Tomcat user
mailing list.

Craig

Best regards,
>
>
> On 4/4/06, Craig McClanahan <cr...@apache.org> wrote:
> >
> > On 4/3/06, red phoenix <ro...@gmail.com> wrote:
> > >
> > > My Struts is 1.2.9,and tomcat is 5.5.15,and JDK is 1.5,I want to use
> > > Struts
> > > Datasource,my database is Microsoft Access 2000,and I have configured
> > ODBC
> > > datasource in windows,when I run it, it raise follows error:
> > > type Status report
> > > message Servlet action is not available
> > > description The requested resource (Servlet action is not available)
> is
> > > not
> > > available.
> >
> >
> > "Servlet action is not available" almost always means that some
> exception
> > was thrown as the Struts action servlet was first initialized.  The
> > exception will be logged in one of the Tomcat log files
> > ($CATALINA_HOME/logs/*).
> >
> > In your particular case, the most likely problem is trying to use the
> > Struts
> > data source.  This functionality was deprecated in Struts 1.1, and was
> > removed in Struts 1.2.  You should use the JNDI data sources provided by
> > your container (Tomcat) instead.  There is pretty reasonable
> documentation
> > on the Tomcat web site for how to set this stuff up, which applies to
> all
> > webapps, not just Struts based ones.
> >
> >
> >
> >
> http://tomcat.apache.org/tomcat-5.5-doc/jndi-datasource-examples-howto.html
> >
> > Historical note -- the only reason Struts 1.0 supplied a data source
> > implementation in the first place was that, six years ago, most servlet
> > containers did not support JNDI based resource access.  Now that they
> > (essentially) all do support JNDI, that is the recommended mechanism for
> > managing data sources.
> >
> > Craig
> >
> >
>
>

Re: Servlet action is not available

Posted by Richard Schilling <sc...@cognitiongroup.biz>.
Do you want to display the contents of the file jndi.properties?  Why 
not just read the file contents using a File object and and output each 
line?


Richard Schilling
Cognition Group, Inc
Seattle, WA

Martin Gainty wrote:
> Red--
> I am re-posting the question to tomcat-users with request to display contents of jndi.properties..
> Thanks,
> Martin--
> ----- Original Message ----- 
> From: "Craig McClanahan" <cr...@apache.org>
> To: "Struts Users Mailing List" <us...@struts.apache.org>
> Sent: Monday, April 03, 2006 9:40 PM
> Subject: Re: Servlet action is not available
> 
> 
> On 4/3/06, red phoenix <ro...@gmail.com> wrote:
> 
>>Mr Craig,
>>   I  configure a JNDI in Tomcat5.5.12 like you tell me,like follows:
>>
>><Context path="" docBase="/jsp-examples" debug="5" reloadable="true"
>>crossContext="true">
>>    <Resource name="jdbc/bb1" auth="Container" type=" javax.sql.DataSource
>>"
>>maxActive="100" maxIdle="30" maxWait="10000" username="administrator"
>>password="123" driverClassName="sun.jdbc.odbc.JdbcOdbcDriver"
>>url="jdbc:odbc:SMS"/>
>>    </Context>
>>
>>Then I call this JNDI in a JSP file,the JSP file is follows:
>>
>><%@page <%2...@page> <%2...@page> import="java.sql.*"%>
>><%@page <%2...@page> import="javax.sql.DataSource"%>
>>< %@page <%2...@page> import="javax.naming.*"%>
>><html>
>><body>
>><%
>>try{
>>  Context initCtx=new InitialContext();
>>  System.out.println("ok");
>>  DataSource db = (DataSource)initCtx.lookup("java:comp/env/jdbc/bb1");
>>  System.out.println("db="+db);
>>  Connection conn = db.getConnection();
>>  System.out.println("conn="+conn);
>>  Statement stmt = conn.createStatement();
>>  ResultSet rs = stmt.executeQuery ("SELECT * FROM abc");
>>  out.println("User-list"+"<br>");
>>  while(rs.next()){
>>   out.print(rs.getString(1)+"<br>");
>>  }
>>  rs.close();
>>  stmt.close();
>>  conn.close();
>>}catch(Exception e){
>>  out.print(e);
>>}
>>%>
>></body>
>></html>
>>
>>
>>
>>javax.naming.NameNotFoundException: Name jdbc is not bound in this Context
>>
>>Why?
>>Any idea will be appreciated!
> 
> 
> 
> This error implies there is something wrong with your configuration, and
> that the registration of the resource did not get completed successfully.
> In my experience, there's usually a stack trace in the Tomcat logs that says
> why it didn't get processed.   You might also want to add a call to:
> 
>     e.printStackTrace();
> 
> inside your exception handler to see where the error is actually coming
> from.
> 
> I don't use Tomcat 5.5 much myself (primarily 5.0) so I can't help you much
> more than that ... best bet would be to ask questions on the Tomcat user
> mailing list.
> 
> Craig
> 
> Best regards,
> 
>>
>>On 4/4/06, Craig McClanahan <cr...@apache.org> wrote:
>>
>>>On 4/3/06, red phoenix <ro...@gmail.com> wrote:
>>>
>>>>My Struts is 1.2.9,and tomcat is 5.5.15,and JDK is 1.5,I want to use
>>>>Struts
>>>>Datasource,my database is Microsoft Access 2000,and I have configured
>>>
>>>ODBC
>>>
>>>>datasource in windows,when I run it, it raise follows error:
>>>>type Status report
>>>>message Servlet action is not available
>>>>description The requested resource (Servlet action is not available)
>>
>>is
>>
>>>>not
>>>>available.
>>>
>>>
>>>"Servlet action is not available" almost always means that some
>>
>>exception
>>
>>>was thrown as the Struts action servlet was first initialized.  The
>>>exception will be logged in one of the Tomcat log files
>>>($CATALINA_HOME/logs/*).
>>>
>>>In your particular case, the most likely problem is trying to use the
>>>Struts
>>>data source.  This functionality was deprecated in Struts 1.1, and was
>>>removed in Struts 1.2.  You should use the JNDI data sources provided by
>>>your container (Tomcat) instead.  There is pretty reasonable
>>
>>documentation
>>
>>>on the Tomcat web site for how to set this stuff up, which applies to
>>
>>all
>>
>>>webapps, not just Struts based ones.
>>>
>>>
>>>
>>>
>>
>>http://tomcat.apache.org/tomcat-5.5-doc/jndi-datasource-examples-howto.html
>>
>>>Historical note -- the only reason Struts 1.0 supplied a data source
>>>implementation in the first place was that, six years ago, most servlet
>>>containers did not support JNDI based resource access.  Now that they
>>>(essentially) all do support JNDI, that is the recommended mechanism for
>>>managing data sources.
>>>
>>>Craig
>>>
>>>
>>
>>
> 
> 


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