Return-Path: Delivered-To: apmail-openejb-users-archive@www.apache.org Received: (qmail 34280 invoked from network); 23 Oct 2007 09:59:39 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 23 Oct 2007 09:59:39 -0000 Received: (qmail 68369 invoked by uid 500); 23 Oct 2007 09:59:26 -0000 Delivered-To: apmail-openejb-users-archive@openejb.apache.org Received: (qmail 68361 invoked by uid 500); 23 Oct 2007 09:59:26 -0000 Mailing-List: contact users-help@openejb.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: users@openejb.apache.org Delivered-To: mailing list users@openejb.apache.org Received: (qmail 68352 invoked by uid 99); 23 Oct 2007 09:59:26 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 23 Oct 2007 02:59:26 -0700 X-ASF-Spam-Status: No, hits=3.7 required=10.0 tests=DNS_FROM_OPENWHOIS,FORGED_HOTMAIL_RCVD2,SPF_HELO_PASS,SPF_PASS,WHOIS_MYPRIVREG X-Spam-Check-By: apache.org Received-SPF: pass (athena.apache.org: domain of lists@nabble.com designates 216.139.236.158 as permitted sender) Received: from [216.139.236.158] (HELO kuber.nabble.com) (216.139.236.158) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 23 Oct 2007 09:59:28 +0000 Received: from isper.nabble.com ([192.168.236.156]) by kuber.nabble.com with esmtp (Exim 4.63) (envelope-from ) id 1IkGXT-00083W-OK for users@openejb.apache.org; Tue, 23 Oct 2007 02:59:07 -0700 Message-ID: <13360830.post@talk.nabble.com> Date: Tue, 23 Oct 2007 02:59:07 -0700 (PDT) From: satsuma To: users@openejb.apache.org Subject: Re: Where do I get javax.persistence package? In-Reply-To: <9EEF4530-C548-4517-B454-BA8FD4402FA7@iq80.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Nabble-From: karijakari@hotmail.com References: <13279676.post@talk.nabble.com> <13281604.post@talk.nabble.com> <52671.64.71.26.219.1192754980.squirrel@64.71.26.219> <13329543.post@talk.nabble.com> <13346735.post@talk.nabble.com> <9EEF4530-C548-4517-B454-BA8FD4402FA7@iq80.com> X-Virus-Checked: Checked by ClamAV on apache.org Thanks for the help Dain, but still not working. @Resources does not work either. The error message is the same "Cannot find symbol: class Resources". I also tried with @Resource inside the class like you said, but no success. I added geronimo-activation...jar to my classpath so that the compiler won't give error about the DataSource. Dain Sundstrom wrote: > > The class level annotation for declaring resource jndi entries is > @Resources: > > @Resources({ @Resource(name="PostgreSQL Database", > type=DataSource.class) }) > > Also the type attribute is a java.lang.Class object not a > java.lang.String object. > > BTW it is much easier to use field injection like this: > > @Stateless > public class HelloBean implements Hello { > @Resource > private DataSource dataSource; > > public String sayHello() { > return "Hello from EJB world!"; > } > } > > This way you can avoid all the annoying boiler plate JNDI code. > > -dain > > On Oct 22, 2007, at 10:02 AM, satsuma wrote: > >> >> Hi, >> >> This is not actually solved yet. When I try to compile my bean >> class, I get >> an error that says: >> >> HelloBean.java:7: cannot find symbol >> symbol: class Resource >> @Resource(name = "PostgreSQL Database", type = "javax.sql.DataSource") >> ^ >> 1 error >> >> My source files look like this >> >> // Remote interface >> import javax.ejb.Remote; >> import java.util.List; >> >> @Remote >> public interface Hello >> { >> public String sayHello(); >> } >> >> // Bean class >> >> import java.util.List; >> import javax.ejb.Stateless; >> import javax.persistence.*; >> >> @Resource(name = "PostgreSQL Database", type = "javax.sql.DataSource") >> @Stateless >> public class HelloBean implements Hello >> { >> public String sayHello() >> { >> return "Hello from EJB world!"; >> } >> } >> >> There's no database operations yet, because I'm first trying to get it >> through the compiler with the Resource annotation. The >> PersistenceContext >> annotation does not cause any errors. >> >> My classpath is >> >> .:/opt/apache-tomcat-6.0.10/lib/servlet-api.jar: >> /opt/apache-tomcat-6.0.10/lib/jsp-api.jar: >> /usr/share/java/postgresql-jdbc3-8.1.jar:/opt/junit/junit-4.4.jar: >> /opt/openejb-3.0-beta-1/lib/geronimo-ejb_3.0_spec-1.0.jar: >> /opt/openejb-3.0-beta-1/lib/openejb-client-3.0-beta-1.jar: >> /opt/openejb-3.0-beta-1/lib/geronimo-jpa_3.0_spec-1.1.jar >> >> Is there something missing? >> >> Java is version 1.5.0_08. >> >> >> satsuma wrote: >>> >>> Thanks Dario, that does it! >>> >>> Allthough I have no problem with the compilation part any more, but I >>> still can't get the database connection to work. I'll make a >>> thread for >>> the new question, to keep this thread under the current subject. >>> >>> >>> Dario Laverde wrote: >>>> >>>> Hello Satsuma, >>>> >>>> Add the following 2 jars to your classpath: >>>> >>>> geronimo-ejb_3.0_spec-1.0.jar >>>> geronimo-jpa_3.0_spec-1.1.jar >>>> >>>> For an example (using Tomcat) check my blog entry at: >>>> http://javanotebook.com/2007/09/28/openejb_3_and_tomcat_6.html >>>> >>>> -Dario >>>> >>>>> Thank you Mohammad for your reply. >>>>> >>>>> I can not find such a jar file from the lib directory. The only >>>>> ones >>>>> close >>>>> to that(containing 'persistence') are openjpa- >>>>> persistence-1.0.0.jar and >>>>> openjpa-persistence-jdbc-1.0.0.jar, so I added both of those to my >>>>> classpath, but that didn't solve the problem. Any more tips? >>>>> >>>>> >>>>> >>>>> Mohammad Nour El-Din wrote: >>>>>> >>>>>> Try including the persistence-api-XXXX.jar found in the >>>>>> ${openejb.home}/lib >>>>>> directory . >>>>>> >>>>>> On 10/18/07, satsuma wrote: >>>>>>> >>>>>>> >>>>>>> Hi, >>>>>>> >>>>>>> I have just started EJB programming and I ran into a problem, >>>>>>> when >>>>>>> trying >>>>>>> to >>>>>>> implement a simple stateless session bean that accesses >>>>>>> database. I >>>>>>> have >>>>>>> been following the instruction in the openEJB documentation page, >>>>>>> http://openejb.apache.org/databases.html >>>>>>> >>>>>>> When I try to compile my class, I get an error that states >>>>>>> "package >>>>>>> javax.persistence.* does not exist" and because of this I can >>>>>>> not use >>>>>>> annotations such as @Resource or @PersistenceContext. The >>>>>>> @Stateless >>>>>>> annotation on the other hand, works as supposed(I made the >>>>>>> hello world >>>>>>> tutorial from the documentation). >>>>>>> >>>>>>> I have added geronimo-ejb_3.0_spec-1.0.jar and >>>>>>> openejb-client-3.0-beta-1.jar >>>>>>> to my classpath, do I need to add something more? >>>>>>> >>>>>>> Thanks. >>>>>>> -- >>>>>>> View this message in context: >>>>>>> http://www.nabble.com/Where-do-I-get-javax.persistence- >>>>>>> package--tf4648542.html#a13279676 >>>>>>> Sent from the OpenEJB User mailing list archive at Nabble.com. >>>>>>> >>>>>>> >>>>>> >>>>>> >>>>>> -- >>>>>> Thanks >>>>>> - Mohammad Nour >>>>>> >>>>>> >>>>> >>>>> -- >>>>> View this message in context: >>>>> http://www.nabble.com/Where-do-I-get-javax.persistence-package-- >>>>> tf4648542.html#a13281604 >>>>> Sent from the OpenEJB User mailing list archive at Nabble.com. >>>>> >>>>> >>>> >>>> >>>> >>>> >>> >>> >> >> -- >> View this message in context: http://www.nabble.com/Where-do-I-get- >> javax.persistence-package--tf4648542.html#a13346735 >> Sent from the OpenEJB User mailing list archive at Nabble.com. >> > > > -- View this message in context: http://www.nabble.com/Where-do-I-get-javax.persistence-package--tf4648542.html#a13360830 Sent from the OpenEJB User mailing list archive at Nabble.com.