geronimo-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Lasantha Ranaweera <lasan...@opensource.lk>
Subject Re: Locally Reffered EJB by Servlet Problem
Date Tue, 18 Jul 2006 06:02:36 GMT
Hi All,

Finally I found the answer by myself. ;-)

Thanks,
Lasantha

Lasantha Ranaweera wrote:
> Hi Derk,
>
> I added the ejb-local-ref element in to the web.xml. But still it 
> gives the same error. Don't know whether problem due to a 
> configuration files I have attached here or not. Please help.
>
> Thanks,
> Lasantha
>
>
>
> D. Strauss wrote:
>> Hello, Lasantha
>>
>> can you post your web.xml please? Check, if there is an element called
>> ejb-local-ref in it ^^
>>
>> Best regards
>>
>> Dirk
>>
>> lasantha@opensource.lk schrieb:
>>   
>>> Hi All,
>>>
>>> I have been writing a sample EAR application to the Geronimo 1.1. This
>>> sample application is basically HelloWorld application, which contains a
>>> stateless session bean reffered by a servlet as in the follows.
>>>
>>> 	System.out.println("### Request Recieved ###");
>>>
>>> 	Context context = new InitialContext();
>>> 	HelloHome home = (HelloHome)context.lookup("java:comp/env/ejb/HelloLocal");
>>> 	Hello hello = home.create();
>>> 	hello.sayHello();
>>>
>>> It gives following error in the console.
>>> ### Request Recieved ###
>>> javax.naming.NameNotFoundException: env/ejb/HelloLocal
>>>         at
>>> org.apache.geronimo.naming.enc.AbstractReadOnlyContext.lookup(AbstractReadOnlyContext.java:81)
>>>         at
>>> org.apache.geronimo.naming.java.RootContext.lookup(RootContext.java:51)
>>>         at javax.naming.InitialContext.lookup(InitialContext.java:351)
>>>         at com.test.web.HelloServlet.sayHello(Unknown Source)
>>>         at com.test.web.HelloServlet.doGet(Unknown Source)
>>>         at javax.servlet.http.HttpServlet.service(HttpServlet.java:595)
>>>         at javax.servlet.http.HttpServlet.service(HttpServlet.java:688)
>>>         at
>>> org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:252)
>>>         at
>>> org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
>>>         at
>>> org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:213)
>>>         at
>>> org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:178)
>>>         at
>>> org.apache.geronimo.tomcat.valve.DefaultSubjectValve.invoke(DefaultSubjectValve.java:46)
>>>         at
>>> org.apache.geronimo.tomcat.GeronimoStandardContext$SystemMethodValve.invoke(GeronimoStandardContext.java:342)
>>>         at
>>> org.apache.geronimo.tomcat.valve.GeronimoBeforeAfterValve.invoke(GeronimoBeforeAfterValve.java:31)
>>>         at
>>> org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:126)
>>>         at
>>> org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:105)
>>>         at
>>> org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:107)
>>>         at
>>> org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:541)
>>>         at
>>> org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:148)
>>>         at
>>> org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:869)
>>>         at
>>> org.apache.coyote.http11.Http11BaseProtocol$Http11ConnectionHandler.processConnection(Http11BaseProtocol.java:667)
>>>         at
>>> org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:527)
>>>         at
>>> org.apache.tomcat.util.net.LeaderFollowerWorkerThread.runIt(LeaderFollowerWorkerThread.java:80)
>>>         at
>>> org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:684)
>>>         at java.lang.Thread.run(Thread.java:595)
>>>
>>>
>>> It looks EJB is not visible to the Servlet. How can I overcome this
>>> problem? Herewith I have attached the configuration files used to create
>>> the EAR.
>>>
>>> Thanks,
>>>
>>> Lasantha Ranaweera
>>> Senior Software Engineer,
>>> Lanka Software Foundation,
>>> Sri Lanka.
>>>
>>>
>>> ------------------------------------------------------------------------
>>>
>>> <?xml version="1.0" encoding="UTF-8"?>
>>> <application 
>>>        xmlns="http://java.sun.com/xml/ns/j2ee"
>>>        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
>>>        xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee
>>>        http://java.sun.com/xml/ns/j2ee/application_1_4.xsd"
>>>        version="1.4">
>>>     <module>
>>>         <ejb>Hello.jar</ejb>
>>>     </module>
>>>     <module>
>>>         <web>
>>>             <web-uri>Hello.war</web-uri>
>>>             <context-root>/Hello</context-root>
>>>         </web>
>>>     </module>
>>> </application>
>>>
>>>
>>> ------------------------------------------------------------------------
>>>
>>> <?xml version="1.0" encoding="UTF-8"?>
>>>
>>> <!DOCTYPE ejb-jar PUBLIC "-//Sun Microsystems, Inc.//DTD Enterprise JavaBeans
2.0//EN" "http://java.sun.com/dtd/ejb-jar_2_0.dtd">
>>>
>>> <ejb-jar >
>>>
>>>    <display-name>Generated by XDoclet</display-name>
>>>
>>>    <enterprise-beans>
>>>
>>>       <!-- Session Beans -->
>>>       <session >
>>>          <description><![CDATA[]]></description>
>>>
>>>          <ejb-name>HelloBean</ejb-name>
>>>
>>>          <local-home>com.test.ejb.HelloHome</local-home>
>>>          <local>com.test.ejb.Hello</local>
>>>          <ejb-class>com.test.ejb.HelloBean</ejb-class>
>>>          <session-type>Stateless</session-type>
>>>          <transaction-type>Container</transaction-type>
>>>
>>>       </session>
>>>
>>>      <!--
>>>        To add session beans that you have deployment descriptor info for, add
>>>        a file to your XDoclet merge directory called session-beans.xml that contains
>>>        the <session></session> markup for those beans.
>>>      -->
>>>
>>>       <!-- Entity Beans -->
>>>      <!--
>>>        To add entity beans that you have deployment descriptor info for, add
>>>        a file to your XDoclet merge directory called entity-beans.xml that contains
>>>        the <entity></entity> markup for those beans.
>>>      -->
>>>
>>>       <!-- Message Driven Beans -->
>>>      <!--
>>>        To add message driven beans that you have deployment descriptor info for,
add
>>>        a file to your XDoclet merge directory called message-driven-beans.xml
that contains
>>>        the <message-driven></message-driven> markup for those beans.
>>>      -->
>>>
>>>    </enterprise-beans>
>>>
>>>    <!-- Relationships -->
>>>
>>>    <!-- Assembly Descriptor -->
>>>      <!--
>>>        To specify your own assembly descriptor info here, add a file to your
>>>        XDoclet merge directory called assembly-descriptor.xml that contains
>>>        the <assembly-descriptor></assembly-descriptor> markup.
>>>      -->
>>>
>>>    <assembly-descriptor >
>>>      <!--
>>>        To specify additional security-role elements, add a file in the merge
>>>        directory called ejb-security-roles.xml that contains them.
>>>      -->
>>>
>>>    <!-- method permissions -->
>>>      <!--
>>>        To specify additional method-permission elements, add a file in the merge
>>>        directory called ejb-method-permissions.ent that contains them.
>>>      -->
>>>    <method-permission >
>>>       <description><![CDATA[description not supported yet by ejbdoclet]]></description>
>>>       <unchecked/>
>>>       <method >
>>>          <description><![CDATA[description not supported yet by ejbdoclet]]></description>
>>>          <ejb-name>HelloBean</ejb-name>
>>>          <method-name>*</method-name>
>>>       </method>
>>>    </method-permission>
>>>
>>>    <!-- transactions -->
>>>      <!--
>>>        To specify additional container-transaction elements, add a file in the
merge
>>>        directory called ejb-container-transactions.ent that contains them.
>>>      -->
>>>
>>>    <!-- finder transactions -->
>>>
>>>    <!-- message destinations -->
>>>      <!--
>>>        To specify additional message-destination elements, add a file in the
merge
>>>        directory called ejb-message-destinations.ent that contains them.
>>>      -->
>>>
>>>    <!-- exclude list -->
>>>      <!--
>>>        To specify an exclude-list element, add a file in the merge directory
>>>        called ejb-exclude-list.xml that contains it.
>>>      -->
>>>    </assembly-descriptor>
>>>
>>> </ejb-jar>
>>>
>>>
>>> ------------------------------------------------------------------------
>>>
>>> <application xmlns="http://geronimo.apache.org/xml/ns/j2ee/application-1.1">
>>>   <dep:environment xmlns:dep="http://geronimo.apache.org/xml/ns/deployment-1.1">
>>>     <dep:moduleId>
>>>       <dep:groupId>default</dep:groupId>
>>>       <dep:artifactId>HelloEAR</dep:artifactId>
>>>       <dep:version>1.0</dep:version>
>>>       <dep:type>car</dep:type>
>>>     </dep:moduleId>
>>>     <dep:dependencies/>
>>>     <dep:hidden-classes/>
>>>     <dep:non-overridable-classes/>
>>>   </dep:environment>  
>>> </application>
>>>
>>>
>>> ------------------------------------------------------------------------
>>>
>>> <?xml version="1.0" encoding="UTF-8"?>
>>> <openejb-jar xmlns="http://www.openejb.org/xml/ns/openejb-jar-2.1">
>>>   <dep:environment xmlns:dep="http://geronimo.apache.org/xml/ns/deployment-1.1">
>>>     <dep:moduleId>
>>>       <dep:groupId>default</dep:groupId>
>>>       <dep:artifactId>HelloEJB</dep:artifactId>
>>>       <dep:version>1.0</dep:version>
>>>       <dep:type>car</dep:type>
>>>     </dep:moduleId>
>>>     <dep:dependencies/>
>>>     <dep:hidden-classes/>
>>>     <dep:non-overridable-classes/>
>>>   </dep:environment>
>>>   <enterprise-beans>
>>> 		<session>	
>>> 			<ejb-name>HelloBean</ejb-name>	
>>> 			<local-jndi-name>java:comp/env/ejb/HelloLocal</local-jndi-name>
>>> 		</session>
>>>    </enterprise-beans>
>>> </openejb-jar>
>>>     
>>
>>   
>
> ------------------------------------------------------------------------
>
> <?xml version="1.0" encoding="UTF-8"?>
> <web-app xmlns="http://java.sun.com/xml/ns/j2ee"
> 	 xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
> 	 xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee
> 	 http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd"
> 	 version="2.4">	
> 	 
>     <servlet>
> 	    <display-name>HelloServlet</display-name>
> 	    <servlet-name>HelloServlet</servlet-name>
> 	    <servlet-class>com.test.web.HelloServlet</servlet-class>
>   	</servlet>
> 	  
>   	<servlet-mapping>
> 	    <servlet-name>HelloServlet</servlet-name>
> 	    <url-pattern>/hello</url-pattern>
>     </servlet-mapping>	
> 	
> 	<!-- To refer local EJB's -->
> 	<ejb-local-ref>
> 		<ejb-ref-name>java:comp/env/ejb/HelloLocal</ejb-ref-name>
> 		<ejb-ref-type>Session</ejb-ref-type>
> 		<local-home>com.test.ejb.HelloHomeLocal</local-home>
> 		<local>com.test.ejb.HelloLocal</local>
> 		<ejb-link>HelloBean</ejb-link>				
> 	</ejb-local-ref>	
> 	
> 	
> </web-app>
> ------------------------------------------------------------------------
>
> <?xml version="1.0" encoding="UTF-8"?>
> <application 
>        xmlns="http://java.sun.com/xml/ns/j2ee"
>        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
>        xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee
>        http://java.sun.com/xml/ns/j2ee/application_1_4.xsd"
>        version="1.4">
>     <module>
>         <ejb>HelloEJB.jar</ejb>
>     </module>
>     <module>
>         <web>
>             <web-uri>HelloWeb.war</web-uri>
>             <context-root>/Hello</context-root>
>         </web>
>     </module>
> </application>
> ------------------------------------------------------------------------
>
> <application xmlns="http://geronimo.apache.org/xml/ns/j2ee/application-1.1">
>   <dep:environment xmlns:dep="http://geronimo.apache.org/xml/ns/deployment-1.1">
>     <dep:moduleId>
>       <dep:groupId>default</dep:groupId>
>       <dep:artifactId>Hello</dep:artifactId>
>       <dep:version>1.0</dep:version>
>       <dep:type>car</dep:type>
>     </dep:moduleId>
>     <dep:dependencies/>	
>     <dep:hidden-classes/>
>     <dep:non-overridable-classes/>
>   </dep:environment>  
> </application>
>
>   
> ------------------------------------------------------------------------
>
> <web-app xmlns="http://geronimo.apache.org/xml/ns/j2ee/web-1.1" xmlns:naming="http://geronimo.apache.org/xml/ns/naming-1.1">
>   <dep:environment xmlns:dep="http://geronimo.apache.org/xml/ns/deployment-1.1">
>     <dep:moduleId>
>       <dep:groupId>default</dep:groupId>
>       <dep:artifactId>HelloWeb</dep:artifactId>
>       <dep:version>1.0</dep:version>
>       <dep:type>car</dep:type>
>     </dep:moduleId>
>     <dep:dependencies/>	
>     <dep:hidden-classes/>
>     <dep:non-overridable-classes/>
>   </dep:environment>
>   <context-root>/Hello</context-root>
> </web-app>
> ------------------------------------------------------------------------
>
> <?xml version="1.0" encoding="UTF-8"?>
> <openejb-jar xmlns="http://www.openejb.org/xml/ns/openejb-jar-2.1">
>   <dep:environment xmlns:dep="http://geronimo.apache.org/xml/ns/deployment-1.1">
>     <dep:moduleId>
>       <dep:groupId>default</dep:groupId>
>       <dep:artifactId>HelloEJB</dep:artifactId>
>       <dep:version>1.0</dep:version>
>       <dep:type>car</dep:type>
>     </dep:moduleId>
>     <dep:dependencies/>
>     <dep:hidden-classes/>
>     <dep:non-overridable-classes/>
>   </dep:environment>
>   <enterprise-beans>
> 		<session>	
> 			<ejb-name>HelloBean</ejb-name>	
> 			<jndi-name>com.test.ejb.HelloBean</jndi-name>
> 			<local-jndi-name>java:comp/ejb/HelloLocal</local-jndi-name>
> 		</session>	  
>    </enterprise-beans>
> </openejb-jar>
>   


Mime
View raw message