Feeling ashamed, it was my fault, I deployed it inside a ear and the
dpeloymaet plan had a <web/> section in it, probably overiding the
geronimo-web.xml file...it is working now (removed the web section and mode
setting to geronimo-web.xml.

Thanks for your help


Janko Heilgeist-3 wrote:
> 
> Hi Marco,
> 
> hmm, it should work with these changes. I've tried it with the 
> mini-servlet attached to this mail. It deploys in Geronimo 2.1 without 
> errors and works as it should. If this is still not working for you, 
> then I don't know what else it could be.
> 
> Janko
> 
> MarcoLaponder wrote:
>> Hi Janko,
>> 
>> Thanks for your quick response. I changed the lookup as you suggested in
>> option 1, but I still have the exception (except it now tells it cannot
>> find
>> system-info). Any more ideas or things to check ?
>> 
>> Kind regards,
>> Marco
>> 
>> 
>> Janko Heilgeist-3 wrote:
>>> Hi Marco,
>>>
>>> the line "<ref-name>system-info</ref-name>" defines the local name of 
>>> the ServerInfo object in the context of your WAR. Therefore, you can
>>> either
>>>
>>> 1) keep the ref-name and try to lookup "java:comp/env/system-info", or
>>>
>>> 2) keep the lookup and change the line in geronimo-web.xml to 
>>> <ref-name>ServerInfo</ref-name>.
>>>
>>> I hope I could help you!
>>>
>>> Regards, Janko
>>>
>>>
>>> MarcoLaponder wrote:
>>>> I am trying to get some information for the ServerInfo object, i have
>>>> added
>>>> the gbean to my geronimo-web.xml:
>>>>
>>>> <web-app xmlns="http://geronimo.apache.org/xml/ns/j2ee/web-1.1";>
>>>>    <context-root>/navi</context-root>
>>>>     <gbean-ref> 
>>>>        <ref-name>system-info</ref-name> 
>>>>       
>>>> <ref-type>org.apache.geronimo.system.serverinfo.ServerInfo</ref-type> 
>>>>        <pattern> 
>>>>          <name>ServerInfo</name> 
>>>>        </pattern> 
>>>>      </gbean-ref> 
>>>>  </web-app>
>>>>
>>>> and a try to get a handle of the serverinfo in my servlet by:
>>>>
>>>> serverInfo = (ServerInfo)(new
>>>> InitialContext().lookup("java:comp/env/ServerInfo"));
>>>>
>>>> but this throws a NameNotFoundException.
>>>>
>>>> What am I doing wrong in the situation above ? 
>>>>
>>>> Kind regards,
>>>> Marco Laponder
>>>
>>>
>> 
> 
> 
> package test.geronimo.gbean_in_war;
> 
> import java.io.IOException;
> import java.io.PrintWriter;
> 
> import javax.naming.InitialContext;
> import javax.naming.NamingException;
> import javax.servlet.ServletException;
> import javax.servlet.http.HttpServlet;
> import javax.servlet.http.HttpServletRequest;
> import javax.servlet.http.HttpServletResponse;
> 
> import org.apache.geronimo.system.serverinfo.ServerInfo;
> 
> public class TestServlet extends HttpServlet {
> 
>       @Override
>       protected void doGet(HttpServletRequest req, HttpServletResponse res)
>                       throws ServletException, IOException {
>               res.setContentType("text/plain");
>               PrintWriter out = res.getWriter();
> 
>               // lookup of ServerInfo object
>               ServerInfo info;
>               try {
>                       InitialContext ic = new InitialContext();
>                       info = (ServerInfo) 
> ic.lookup("java:comp/env/system-info");
>               } catch (NamingException ex) {
>                       throw new ServletException("lookup failed", ex);
>               }
> 
>               // just to check that info is indeed working as expected
>               out.println(info.getVersion());
>               out.println(info.getCopyright());
>               out.close();
>       }
> 
> }
> 
> <?xml version="1.0" encoding="UTF-8"?>
> <web-app xmlns="http://geronimo.apache.org/xml/ns/j2ee/web-2.0.1";
>       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";
>       xsi:schemaLocation="
>               http://geronimo.apache.org/xml/ns/j2ee/web-2.0.1
> http://geronimo.apache.org/xml/ns/j2ee/geronimo-web-2.0.1.xsd";>
> 
>       <context-root>/gbean-in-war</context-root>
> 
>       <gbean-ref>
>               <ref-name>system-info</ref-name>
>               
> <ref-type>org.apache.geronimo.system.serverinfo.ServerInfo</ref-type>
>               <pattern>
>                       <name>ServerInfo</name>
>               </pattern>
>       </gbean-ref>
> 
> </web-app>
> <?xml version="1.0" encoding="UTF-8"?>
> <web-app version="2.5"
>       xmlns="http://java.sun.com/xml/ns/javaee";
>       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";
>       xsi:schemaLocation="http://java.sun.com/xml/ns/javaee
> http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd";>
> 
>       <!-- servlets and mappings -->
>       <servlet>
>               <servlet-name>TestServlet</servlet-name>
>               
> <servlet-class>test.geronimo.gbean_in_war.TestServlet</servlet-class>
>               <load-on-startup>1</load-on-startup>
>       </servlet>
>       <servlet-mapping>
>               <servlet-name>TestServlet</servlet-name>
>               <url-pattern>/TestServlet/*</url-pattern>
>       </servlet-mapping>
> 
>       <!-- welcome file list -->
>       <welcome-file-list>
>               <welcome-file>TestServlet</welcome-file>
>       </welcome-file-list>
> 
> </web-app>
> 

-- 
View this message in context: 
http://www.nabble.com/cannot-find-serverinfo-jndi-lookup-tp16646510s134p16670522.html
Sent from the Apache Geronimo - Users mailing list archive at Nabble.com.

Reply via email to