Return-Path: X-Original-To: apmail-geronimo-user-archive@www.apache.org Delivered-To: apmail-geronimo-user-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 307349B3E for ; Mon, 23 Apr 2012 01:25:07 +0000 (UTC) Received: (qmail 30418 invoked by uid 500); 23 Apr 2012 01:25:06 -0000 Delivered-To: apmail-geronimo-user-archive@geronimo.apache.org Received: (qmail 30342 invoked by uid 500); 23 Apr 2012 01:25:06 -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 30329 invoked by uid 99); 23 Apr 2012 01:25:05 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 23 Apr 2012 01:25:05 +0000 X-ASF-Spam-Status: No, hits=-0.7 required=5.0 tests=RCVD_IN_DNSWL_LOW,SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (athena.apache.org: domain of liyanlyee@gmail.com designates 209.85.210.182 as permitted sender) Received: from [209.85.210.182] (HELO mail-iy0-f182.google.com) (209.85.210.182) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 23 Apr 2012 01:25:00 +0000 Received: by iahk25 with SMTP id k25so20719620iah.13 for ; Sun, 22 Apr 2012 18:24:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :content-type:content-transfer-encoding; bh=pDuOhJHprwCT6rOMXHLmEY7RfXdESmwI4cjiUW1MpNo=; b=xttBJzbRS6RqBZLB66Qcpn97JDwgVANp43WN7GCQvOssFOizFiM6JJlyLjyvh2LyzZ 7WwAGiP6SULUYDCwgqrlixVsSS1sNyJ88RCUo8C0LIhgGcChbn3XDrbcZbR0b0nbP9AJ rZuNDgiv1NpxPhsNNRdtfOjFWEj2LtlNTe12rVEtIpN3eR8x9F5arlqMG0/VGXvZIxMQ J+xR7VE+hoAOsOv4o5T7j45cOZmaSPpcHJzy2AMfNczOtE/bMymxTNZQQyEv6OM6Nird 3OIp1PLxqsrPAB11l1z1I6+GLL9OLgIYKqkLHBhMKiUD8zHqgjxQXcUSOGvBQD3UEwIj jGkQ== MIME-Version: 1.0 Received: by 10.50.154.132 with SMTP id vo4mr4980065igb.27.1335144279972; Sun, 22 Apr 2012 18:24:39 -0700 (PDT) Received: by 10.231.41.194 with HTTP; Sun, 22 Apr 2012 18:24:39 -0700 (PDT) In-Reply-To: References: <4B5C2DA7-FD7E-48D0-B93F-CB4726019416@gmail.com> <608E0BDF-6A80-4193-8B33-56B9C770D00A@yahoo.com> <715A7C8C-AB44-4D31-8A5A-49C8135435D3@yahoo.com> <9AD00066-02F7-433F-B9B6-168952F41650@yahoo.com> Date: Mon, 23 Apr 2012 09:24:39 +0800 Message-ID: Subject: Re: Geronino 3 beta Servlet issue From: li yanli To: user@geronimo.apache.org Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable X-Virus-Checked: Checked by ClamAV on apache.org Please also take geronimo-5879 as a reference : https://issues.apache.org/jira/browse/GERONIMO-5879 On Sat, Apr 21, 2012 at 9:39 AM, Forrest Xia wrote: > I don't know postgres much, but I know there is a sample called daytrader > which support multiple databases, which includes postgres, you can refer = to > a released one for example. > > http://svn.apache.org/repos/asf/geronimo/daytrader/tags/daytrader-3.0-bet= a-1/ > > > On Fri, Apr 20, 2012 at 3:17 PM, Michael Chau wrote: >> >> Thanks, Forrest. =A0I am using the Ration OSGi tool. =A0I somehow forgot= to >> check the box to compile the servlet class into the=A0WEB-INF/classes fo= lder. >> >> Now, I'm trying to figure out how to write to a Postgres db using jdbc. = =A0I >> haven't been able to find any good examples. =A0Can you point me to one = or >> give me some tips on how to go about it? >> >> Once again, thanks for the help. >> >> michael >> >> On Apr 19, 2012, at 9:24 PM, Forrest Xia wrote: >> >> Two points here: >> 1. What tools you used to genereate this eba? if using eclipse, sugguest >> you use Rational development tools for OSGi application[1] >> 2. Your sample's web module sample-web_xxx.jar file structure is not >> correct, you should put your servlet class into WEB-INF/classes folder >> >> [1] >> http://www.ibm.com/developerworks/rational/downloads/10/rationaldevtools= forosgiapplications.html >> >> Attached an updated sample for your reference. >> >> On Thu, Apr 19, 2012 at 12:42 PM, Michael Chau wrot= e: >>> >>> Sorry, I misunderstood you. =A0Here it is: >>> >>> >>> >>> On Apr 19, 2012, at 12:41 AM, Forrest Xia wrote: >>> >>> Finding the potential error via "SEE" through the text is hard work for >>> me :) >>> >>> Can you just attach your eba here? so that I can quickly have a local t= ry >>> with your eba. >>> >>> On Thu, Apr 19, 2012 at 1:07 PM, Michael Chau wrot= e: >>>> >>>> Thanks for helping me. =A0I'm new to OSGi. =A0Here are my configs and = code. >>>> >>>> SampleApp >>>> APPLICATION.MF >>>> >>>> Application-Name: sample-app >>>> Application-SymbolicName: sample-app >>>> Application-ManifestVersion: 1.0 >>>> Application-Version: 1.0.0.qualifier >>>> Application-Content: sample-api;version=3D"1.0.0", >>>> =A0sample-server;version=3D"1.0.0", >>>> =A0sample-web;version=3D"1.0.0" >>>> Manifest-Version: 1.0 >>>> >>>> SampleApi >>>> >>>> Manifest-Version: 1.0 >>>> Bundle-ManifestVersion: 2 >>>> Bundle-Name: sample-api >>>> Bundle-SymbolicName: sample-api >>>> Bundle-Version: 1.0.0.qualifier >>>> Bundle-RequiredExecutionEnvironment: JavaSE-1.6 >>>> Export-Package: com.sample.api >>>> >>>> >>>> package com.sample.api; >>>> >>>> public interface SampleService { >>>> public String sayHello(String name); >>>> } >>>> >>>> >>>> SampleServer >>>> >>>> Manifest-Version: 1.0 >>>> Bundle-Blueprint: OSGI-INF/blueprint/*.xml >>>> Bundle-Version: 1.0.0.qualifier >>>> Bundle-Name: sample-server >>>> Bundle-ManifestVersion: 2 >>>> Import-Package: com.sample.api >>>> Bundle-SymbolicName: sample-server >>>> Bundle-RequiredExecutionEnvironment: JavaSE-1.6 >>>> Export-Package: com.sample.server >>>> >>>> Source: >>>> package com.sample.server; >>>> >>>> import com.sample.api.SampleService; >>>> >>>> public class SampleServiceImpl implements SampleService { >>>> >>>> public String sayHello(String name) { >>>> // TODO Auto-generated method stub >>>> return "Hello "+name; >>>> } >>>> >>>> } >>>> >>>> ****=A0Blueprint.xml >>>> >>>> >>>> >>>> =A0 =A0 >>>> >>>> =A0 =A0 >>> interface=3D"com.sample.api.SampleService"/> >>>> >>>> >>>> >>>> SampleWeb >>>> >>>> Manifest-Version: 1.0 >>>> Bundle-ManifestVersion: 2 >>>> Bundle-Name: sample-web >>>> Bundle-SymbolicName: sample-web >>>> Bundle-Version: 1.0.0.qualifier >>>> Bundle-ClassPath: WEB-INF/classes >>>> Web-ContextPath: /sample-web >>>> Import-Package: com.sample.api, >>>> =A0javax.naming, >>>> =A0javax.servlet;version=3D"2.5", >>>> =A0javax.servlet.http;version=3D"2.5" >>>> Bundle-RequiredExecutionEnvironment:=A0JavaSE-1.6 >>>> Export-Package: com.sample.client.web >>>> >>>> >>>> package com.sample.client.web; >>>> >>>> import java.io.IOException; >>>> >>>> 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 com.sample.api.SampleService; >>>> >>>> /** >>>> =A0* Servlet implementation class SampleServlet >>>> =A0*/ >>>> public class SampleServlet extends HttpServlet { >>>> private static final long serialVersionUID =3D 1L; >>>> >>>> =A0 =A0 /** >>>> =A0 =A0 =A0* @see HttpServlet#HttpServlet() >>>> =A0 =A0 =A0*/ >>>> =A0 =A0 public SampleServlet() { >>>> =A0 =A0 =A0 =A0 super(); >>>> =A0 =A0 =A0 =A0 // TODO Auto-generated constructor stub >>>> =A0 =A0 } >>>> >>>> /** >>>> * @see HttpServlet#doGet(HttpServletRequest request, HttpServletRespon= se >>>> response) >>>> */ >>>> protected void doGet(HttpServletRequest request, HttpServletResponse >>>> response) throws ServletException, IOException { >>>> // TODO Auto-generated method stub >>>> SampleService sample =3D null; >>>> try { >>>> InitialContext ic =3D new InitialContext(); >>>> sample =3D (SampleService) ic.lookup("osgi:service/" + >>>> SampleService.class.getName()); >>>> response.getOutputStream().println("**** " + sample.sayHello("Sample >>>> Service")); >>>> } >>>> catch (NamingException e) { >>>> e.printStackTrace(System.out); >>>> } >>>> } >>>> >>>> /** >>>> * @see HttpServlet#doPost(HttpServletRequest request, >>>> HttpServletResponse response) >>>> */ >>>> protected void doPost(HttpServletRequest request, HttpServletResponse >>>> response) throws ServletException, IOException { >>>> // TODO Auto-generated method stub >>>> } >>>> >>>> } >>>> >>>> **** web.xml >>>> >>>> >>>> >>> xmlns=3D"http://java.sun.com/xml/ns/javaee" >>>> xmlns:web=3D"http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" >>>> xsi:schemaLocation=3D"http://java.sun.com/xml/ns/javaee >>>> http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd" id=3D"WebApp_ID" >>>> version=3D"3.0"> >>>> =A0 sample-web >>>> =A0 >>>> SampleServlet >>>> SampleServlet >>>> com.sample.client.web.SampleServlet >>>> =A0 >>>> =A0 >>>> SampleServlet >>>> /sample >>>> =A0 >>>> =A0 >>>> =A0 =A0 index.html >>>> =A0 =A0 index.htm >>>> =A0 =A0 index.jsp >>>> =A0 =A0 default.html >>>> =A0 =A0 default.htm >>>> =A0 =A0 default.jsp >>>> =A0 >>>> >>>> >>>> >>>> >>>> On Apr 18, 2012, at 8:44 PM, Forrest Xia wrote: >>>> >>>> Can you attach your sample here for a check? >>>> >>>> On Thu, Apr 19, 2012 at 12:43 AM, Michael Chau >>>> wrote: >>>>> >>>>> I have my SampleApi (interface) exported it. =A0I don't believe I'm >>>>> suppose to export the implementation (SampleServer) and web bundle(Sa= mple >>>>> Web). =A0But, i just tried exporting them both just to see if it will= work and >>>>> I'm still getting the same error. =A0I'm somewhat following the Count= erApp >>>>> example. =A0My web bundle is pretty much the same as the CounterWebBu= ndle >>>>> (same required import packages and no exports). >>>>> >>>>> >>>>> On Apr 18, 2012, at 12:55 AM, Forrest Xia wrote: >>>>> >>>>> Have you exported your application classes in Export-Package of >>>>> MANIFEST.MF? >>>>> >>>>> On Wed, Apr 18, 2012 at 3:42 AM, Michael Chau >>>>> wrote: >>>>>> >>>>>> Thanks, Ivan. >>>>>> >>>>>> I added the javax.naming to the import and now getting this error: >>>>>> >>>>>> 2012-04-18 00:40:53,484 ERROR [WebApplication] Unable to start web >>>>>> application for bundle sample-web >>>>>> org.apache.geronimo.common.DeploymentException: Fail to load servlet >>>>>> class >>>>>> at >>>>>> org.apache.geronimo.web25.deployment.merge.annotation.ServletSecurit= yAnnotationMergeHandler.postProcessWebXmlElement(ServletSecurityAnnotationM= ergeHandler.java:79) >>>>>> at >>>>>> org.apache.geronimo.web25.deployment.merge.MergeHelper.processWebFra= gmentsAndAnnotations(MergeHelper.java:418) >>>>>> at >>>>>> org.apache.geronimo.web25.deployment.AbstractWebModuleBuilder.basicI= nitContext(AbstractWebModuleBuilder.java:493) >>>>>> at >>>>>> org.apache.geronimo.web25.deployment.AbstractWebModuleBuilder.initCo= ntext(AbstractWebModuleBuilder.java:436) >>>>>> at >>>>>> org.apache.geronimo.osgi.web.extender.WebApplication.doRun(WebApplic= ation.java:213) >>>>>> at >>>>>> org.apache.geronimo.osgi.web.extender.WebApplication.run(WebApplicat= ion.java:125) >>>>>> at >>>>>> java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:4= 41) >>>>>> at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:303= ) >>>>>> at java.util.concurrent.FutureTask.run(FutureTask.java:138) >>>>>> at >>>>>> java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExe= cutor.java:886) >>>>>> at >>>>>> java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecuto= r.java:908) >>>>>> at java.lang.Thread.run(Thread.java:680) >>>>>> Caused by: java.lang.ClassNotFoundException: >>>>>> com.sample.client.web.SampleServlet >>>>>> at >>>>>> org.eclipse.osgi.internal.loader.BundleLoader.findClassInternal(Bund= leLoader.java:513) >>>>>> at >>>>>> org.eclipse.osgi.internal.loader.BundleLoader.findClass(BundleLoader= .java:429) >>>>>> at >>>>>> org.eclipse.osgi.internal.loader.BundleLoader.findClass(BundleLoader= .java:417) >>>>>> at >>>>>> org.apache.geronimo.hook.equinox.GeronimoClassLoader.loadClass(Geron= imoClassLoader.java:85) >>>>>> at java.lang.ClassLoader.loadClass(ClassLoader.java:247) >>>>>> at >>>>>> org.eclipse.osgi.internal.loader.BundleLoader.loadClass(BundleLoader= .java:345) >>>>>> at >>>>>> org.eclipse.osgi.framework.internal.core.BundleHost.loadClass(Bundle= Host.java:229) >>>>>> at >>>>>> org.eclipse.osgi.framework.internal.core.AbstractBundle.loadClass(Ab= stractBundle.java:1207) >>>>>> at >>>>>> org.apache.geronimo.web25.deployment.merge.annotation.ServletSecurit= yAnnotationMergeHandler.postProcessWebXmlElement(ServletSecurityAnnotationM= ergeHandler.java:52) >>>>>> ... 11 more >>>>>> >>>>>> >>>>>> On Apr 17, 2012, at 11:09 PM, Ivan wrote: >>>>>> >>>>>> From the log files, it seems that javax.naming should be added in th= e >>>>>> import-package list for the wab ? >>>>>> >>>>>> 2012/4/18 Michael Chau >>>>>>> >>>>>>> I've created a SampleApi(interface), SampleServer(implementation) a= nd >>>>>>> SampleWeb(servlet) bundles. =A0It's using Blueprint. =A0I ran it in= the Apache >>>>>>> Aries container and it was fine. =A0I tried to run it in Geronimo a= nd got >>>>>>> >>>>>>> 2012-04-17 14:44:52,759 ERROR [WebApplication] Unable to start web >>>>>>> application for bundle sample-web >>>>>>> java.lang.NoClassDefFoundError: Could not fully load class: >>>>>>> com.sample.client.web.SampleServlet >>>>>>> =A0due to:javax/naming/NamingException >>>>>>> =A0in classLoader: >>>>>>> org.apache.geronimo.hook.equinox.GeronimoClassLoader@10993991 >>>>>>> at org.apache.xbean.finder.ClassFinder.(ClassFinder.java:136) >>>>>>> at >>>>>>> org.apache.geronimo.web25.deployment.AbstractWebModuleBuilder.creat= eWebAppClassFinder(AbstractWebModuleBuilder.java:663) >>>>>>> at >>>>>>> org.apache.geronimo.web25.deployment.AbstractWebModuleBuilder.confi= gureBasicWebModuleAttributes(AbstractWebModuleBuilder.java:698) >>>>>>> at >>>>>>> org.apache.geronimo.tomcat.deployment.TomcatModuleBuilder.addGBeans= (TomcatModuleBuilder.java:483) >>>>>>> at >>>>>>> org.apache.geronimo.osgi.web.extender.WebApplication.doRun(WebAppli= cation.java:218) >>>>>>> at >>>>>>> org.apache.geronimo.osgi.web.extender.WebApplication.run(WebApplica= tion.java:125) >>>>>>> at >>>>>>> java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:= 441) >>>>>>> at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:30= 3) >>>>>>> at java.util.concurrent.FutureTask.run(FutureTask.java:138) >>>>>>> at >>>>>>> java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolEx= ecutor.java:886) >>>>>>> at >>>>>>> java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecut= or.java:908) >>>>>>> at java.lang.Thread.run(Thread.java:680) >>>>>>> >>>>>>> Any help is appreciated. >>>>>>> >>>>>>> Michael >>>>>> >>>>>> >>>>>> >>>>>> >>>>>> -- >>>>>> Ivan >>>>>> >>>>>> >>>>> >>>>> >>>>> >>>>> -- >>>>> Thanks! >>>>> >>>>> Regards, Forrest >>>>> >>>>> >>>> >>>> >>>> >>>> -- >>>> Thanks! >>>> >>>> Regards, Forrest >>>> >>>> >>> >>> >>> >>> -- >>> Thanks! >>> >>> Regards, Forrest >>> >>> >>> >> >> >> >> -- >> Thanks! >> >> Regards, Forrest >> >> >> >> > > > > -- > Thanks! > > Regards, Forrest > --=20 Best Wishes! Tina Li