Return-Path: Delivered-To: apmail-geronimo-user-archive@www.apache.org Received: (qmail 51555 invoked from network); 13 Sep 2006 17:02:48 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (209.237.227.199) by minotaur.apache.org with SMTP; 13 Sep 2006 17:02:48 -0000 Received: (qmail 41453 invoked by uid 500); 13 Sep 2006 17:02:43 -0000 Delivered-To: apmail-geronimo-user-archive@geronimo.apache.org Received: (qmail 40906 invoked by uid 500); 13 Sep 2006 17:02:41 -0000 Mailing-List: contact user-help@geronimo.apache.org; run by ezmlm Precedence: bulk list-help: list-unsubscribe: List-Post: Reply-To: user@geronimo.apache.org List-Id: Delivered-To: mailing list user@geronimo.apache.org Received: (qmail 40880 invoked by uid 99); 13 Sep 2006 17:02:41 -0000 Received: from asf.osuosl.org (HELO asf.osuosl.org) (140.211.166.49) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 13 Sep 2006 10:02:41 -0700 X-ASF-Spam-Status: No, hits=0.0 required=10.0 tests=UNPARSEABLE_RELAY X-Spam-Check-By: apache.org Received-SPF: neutral (asf.osuosl.org: local policy) Received: from [80.252.160.176] (HELO silver.areteinternet.se) (80.252.160.176) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 13 Sep 2006 10:02:29 -0700 Received: from p2p.nu (ns2.areteinternet.se [80.252.160.164]) by silver.areteinternet.se (8.12.8/8.12.5) with ESMTP id k8DH1uUt031140 for ; Wed, 13 Sep 2006 19:01:56 +0200 Received: from rep.freefarm.se by mailer.p2p.nu (MDaemon.PRO.v8.1.3.R) with ESMTP id md50003094052.msg for ; Wed, 13 Sep 2006 19:01:54 +0200 Message-Id: <6.2.1.2.0.20060913185912.03f679e0@pop03.crystone.se> X-Mailer: QUALCOMM Windows Eudora Version 6.2.1.2 Date: Wed, 13 Sep 2006 19:01:47 +0200 To: user@geronimo.apache.org From: Mattias Malmgren Subject: Re: Minimalistic example In-Reply-To: <4507ADF5.1010503@opensource.lk> References: <6.2.1.2.0.20060912140517.024e7730@pop03.crystone.se> <4506AF9E.8080603@opensource.lk> <6.2.1.2.0.20060912152823.0416c3e0@pop03.crystone.se> <4507ADF5.1010503@opensource.lk> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii"; format=flowed X-Authenticated-Sender: mattiasfreefarm@mailer.p2p.nu X-Spam-Processed: mailer.p2p.nu, Wed, 13 Sep 2006 19:01:54 +0200 (not processed: spam filter disabled) X-MDRemoteIP: 81.170.229.226 X-Return-Path: mattias@freefarm.se X-MDaemon-Deliver-To: user@geronimo.apache.org X-Virus-Checked: Checked by ClamAV on apache.org X-Spam-Rating: minotaur.apache.org 1.6.2 0/1000/N Thanks for all help so far Lasantha! However, I have not been able to get my test case work yet. More questions: OK, I understand the concept of writing EJBs and then tell the EJB container about how to run the EJBs by providing that kind of information in XML-files specifying names, URL-access-paths and other stuff. In that way one single application can run in many different EJB containers (or applications servers) just by modifying the XML-files not the program code. In your example here you have changed the servlet code to include imports of the home and remote interface: import com.test.ejb.MyTest; import com.test.ejb.MyTestHome; They appears as part of the com.test.ejb package. Note, I never put my EJB nor the interfaces in a package. Is the package necessary? You never wrote the content of the application.xml file. What should the contents of the applications.xml file be? What is correct, to have one web.xml or one geronimo-web.xml or both? What's the difference between web.xml and geronimo-web.xml? What is correct about application.xml and geronimo-application.xml In the servlet I use Object objref = initial.lookup("java:comp/env/ejb/MyTest"); I guess that "java:comp/env/ejb/MyTest" is some sort of URL that the container will use to return the right object (in this case an interface). Now, what are the rules of the lookup-string? In a normal web-url eg. http://www.freefarm.se/foo/bar/test.html the http:// part is the protocol, www.freefarm.se is the domain, foo/bar corresponds to directories and test.html is the file to ret rive and show in the users browser. But what is "java:" in java:comp/env/ejb/MyTest?? What is env/ejb?? Is that supposed to correspond to something we have put in one of the different xml files? Or is it part of the package com.test.ejb ? MyTest is probably the name of the remote interface. But why the name of the remote interface, why not the name of the home interface? Or is MyTest refering to somwthing in the XML-files? Now I am going to have a look at http://cwiki.apache.org/GMOxDOC11/deployment-plans-level-1.html and see if that can put me on the right track. But I am looking forward to your response Lasantha! Best regards // Mattias At 09:06 2006-09-13, you wrote: >Hi Mattias, > >Following are my comments regarding this sample. I think step 1 to 3 you >might have already done. Anyway I am going to put it to clarity. > >1. web.xml >You need to add ejb-ref element to the given web.xml as given in below. >Missing geronimo-web.xml in will give a warning. But anyway it will work. :) > > >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"> > > >MyTestServlet >MyTestServlet >MyTestServlet > > > >MyTestServlet >/test > > > >ejb/MyTest >Session >MyTestHome >MyTest >MyTestBean > > > > >2. Can't find openejb-jar.xml and ejb-jar.xml in your document. >I can't find the openejb-jar.xml and ejb-jar.xml for the ejb.jar file. It >would be some thing like this given in the below. > >openejb-jar.xml > > > > >samples >my-test-ejb >1.0 >car > > > > > > > >MyTestBean >MyTestBean > > > > >ejb-jar.xml > > >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/ejb-jar_2_1.xsd" version="2.1"> > >Generated by XDoclet > > > > > >Test EJB >MyTestBean >MyTestHome >MyTest >MyTestBean >Stateless >Container > > > > > > >3. Create JAR files. >Hope EJB jar file would have a package structure something similar here. >my-test-ejb.jar >|-META-INF/ openejb-jar.xml >|-META-INF/ ejb-jar.xml >|- > >4. Create an EAR with following structure. Note I have changed WAR archive >as my-test-web.war. ;) >my-test.ear >|- META-INF/ application.xml >my-test-web.war >my-test-ejb.jar > >application.xml > >5. Refer EJB from Servlet as given below. (Casting to PortableRemoteObject >is unnecessary. Anyway I am leaving it as you given) > >MyTestServlet.java > >import java.io.IOException; >import java.io.PrintWriter; > >import javax.naming.Context; >import javax.naming.InitialContext; >import javax.rmi.PortableRemoteObject; >import javax.servlet.ServletException; >import javax.servlet.http.HttpServlet; >import javax.servlet.http.HttpServletRequest; >import javax.servlet.http.HttpServletResponse; > >import com.test.ejb.MyTest; >import com.test.ejb.MyTestHome; > > >public class MyTestServlet extends HttpServlet { > > >public void doGet(HttpServletRequest request, HttpServletResponse >response) throws ServletException, IOException { > >PrintWriter out = response.getWriter(); >out.println("This is a test, time in servlet =" + new >java.util.Date().toString() + "

"); >// Put the code here that can get the time from the EJB >// That code might look somthing like this? > >try { >Context initial = new InitialContext(); >Object objref = initial.lookup("java:comp/env/ejb/MyTest"); >MyTestHome home = (MyTestHome)PortableRemoteObject.narrow(objref, >MyTestHome.class); > >MyTest test = home.create(); >String newtime = test.getTime(); >out.println("This is a new test, time from EJB =" + newtime + "

"); >} catch (Exception e) { >e.printStackTrace(); >out.println("Faild to get time from EJB

"); >} >} >} > >Hope this will help. > >BR, >Lasantha Ranaweera > >Mattias Malmgren wrote: >>Hi! >> >>I have prepared something for you here: >> >>http://www.freefarm.se/geronimohelp.htm >> >>Best regards / Mattias >> >> >>At 15:01 2006-09-12, you wrote: >>>Hi Mattias, >>> >>>I would like to help you on this matter. Post your files to the community. >>> >>>Regards, >>>Lasantha Ranaweera >>> >>>Mattias Malmgren wrote: >>>>Hello! >>>> >>>>I have coded Java for 10 years, I know who to write Servlets and so on. >>>>Now I would like to write som EJBs and depoy them on geronimo. I can >>>>compile my EJBs, but the hard task is to make a ear-file and deploy. I >>>>have looked at the Bank-exemaple in the documentation, but it is to >>>>compex. Is there a more minimalistic example? >>>> >>>>Best regards / Mattias >>>> >> >>