From users-return-21372-apmail-tomee-users-archive=tomee.apache.org@tomee.apache.org Tue Sep 1 06:24:23 2015 Return-Path: X-Original-To: apmail-tomee-users-archive@www.apache.org Delivered-To: apmail-tomee-users-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id A1330179DF for ; Tue, 1 Sep 2015 06:24:23 +0000 (UTC) Received: (qmail 37128 invoked by uid 500); 1 Sep 2015 06:24:18 -0000 Delivered-To: apmail-tomee-users-archive@tomee.apache.org Received: (qmail 37099 invoked by uid 500); 1 Sep 2015 06:24:18 -0000 Mailing-List: contact users-help@tomee.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: users@tomee.apache.org Delivered-To: mailing list users@tomee.apache.org Received: (qmail 37085 invoked by uid 99); 1 Sep 2015 06:24:18 -0000 Received: from Unknown (HELO spamd4-us-west.apache.org) (209.188.14.142) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 01 Sep 2015 06:24:18 +0000 Received: from localhost (localhost [127.0.0.1]) by spamd4-us-west.apache.org (ASF Mail Server at spamd4-us-west.apache.org) with ESMTP id B82D7C0F46 for ; Tue, 1 Sep 2015 06:24:17 +0000 (UTC) X-Virus-Scanned: Debian amavisd-new at spamd4-us-west.apache.org X-Spam-Flag: NO X-Spam-Score: 4.963 X-Spam-Level: **** X-Spam-Status: No, score=4.963 tagged_above=-999 required=6.31 tests=[DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, HTML_MESSAGE=3, KAM_INFOUSMEBIZ=0.75, SPF_PASS=-0.001, URIBL_BLOCKED=0.001, URI_HEX=1.313] autolearn=disabled Authentication-Results: spamd4-us-west.apache.org (amavisd-new); dkim=pass (2048-bit key) header.d=gmail.com Received: from mx1-eu-west.apache.org ([10.40.0.8]) by localhost (spamd4-us-west.apache.org [10.40.0.11]) (amavisd-new, port 10024) with ESMTP id Ou8ke1L0_Dh1 for ; Tue, 1 Sep 2015 06:24:08 +0000 (UTC) Received: from mail-la0-f41.google.com (mail-la0-f41.google.com [209.85.215.41]) by mx1-eu-west.apache.org (ASF Mail Server at mx1-eu-west.apache.org) with ESMTPS id 716EF2578F for ; Tue, 1 Sep 2015 06:24:07 +0000 (UTC) Received: by laboe4 with SMTP id oe4so59559544lab.0 for ; Mon, 31 Aug 2015 23:24:01 -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; bh=Di9f1qJWQkV2TQz9LWxCwbM1FH0Ud0fJdL3A56D7XuE=; b=m6YQI1/jyVZ8SgFQgiDHOw7Jyd1q+TcoCOvn+lqKvsR0q/XqXwWm+yyC6wjVFlJVTO BjYPpGJzRQ0oYsITpDDN54CKYvy0EISqr2A05IreYYXEmtK7UQWOgEyLKC91s3l0HIUM Elna1faOv3NR/ruyjNoqNmpZtHGPM+fN2TxEFgQxmebnvHaVFc0YGxuwHB4BfWBgmp1a lIivxG2VqEpz0nk6aMTXYBOXScvLAplSbbuawUROyeMLLeWvVHL9pVGvmy75NwhREEJ/ KPjHZ9UX4HQiNZ2/f5W4ZWvAnscUqfCpS+x7wfhX58G7fuvoYOuFSu7HdITS8qd2ASbC zfnA== MIME-Version: 1.0 X-Received: by 10.152.23.132 with SMTP id m4mr11629978laf.107.1441088641572; Mon, 31 Aug 2015 23:24:01 -0700 (PDT) Received: by 10.112.140.37 with HTTP; Mon, 31 Aug 2015 23:24:01 -0700 (PDT) Received: by 10.112.140.37 with HTTP; Mon, 31 Aug 2015 23:24:01 -0700 (PDT) In-Reply-To: <1441072525682-4676034.post@n4.nabble.com> References: <1441072525682-4676034.post@n4.nabble.com> Date: Tue, 1 Sep 2015 08:24:01 +0200 Message-ID: Subject: Re: JCache annotations in web app test From: Romain Manni-Bucau To: users@tomee.apache.org Content-Type: multipart/alternative; boundary=089e0160b5ee922a07051ea99820 --089e0160b5ee922a07051ea99820 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Hi Le 1 sept. 2015 04:01, "sgjava" a =C3=A9crit : > > I have JCache annotations working with a unit test: > > KeyValueBean using @CacheDefaults(cacheName =3D "testCache") > > @CacheResult > public String add(@CacheKey String key, String value) { > log.info(String.format("Adding key: %s, value: %s", key, value)); > return value; > } > > Test: > > /** > * Injected cache bean. > */ > @EJB > private CacheBean cacheBean; > /** > * Our key/value bean. > */ > @EJB > private KeyValueBean keyValueBean; > > container =3D EJBContainer.createEJBContainer(); > container.getContext().bind("inject", this); > > keyValueBean.add("key1", "value1"); > > INFO: Key: org.jsr107.ri.annotations.DefaultGeneratedCacheKey@322dd1, Value: > value1 > > But using a web test: > > final Map p =3D new HashMap(); > p.put(Context.INITIAL_CONTEXT_FACTORY, > "org.apache.openejb.core.LocalInitialContextFactory"); > p.put("openejb.embedded.initialcontext.close ", "DESTROY"); > p.put("openejb.embedded.remotable", "true"); The 3 previous props are for openejb embedded and not tomee-embedded > p.put(EJBContainer.APP_NAME, "my-jaxrs-test"); > p.put(EJBContainer.PROVIDER, "tomee-embedded"); > // Add WAR and MDB modules > p.put(EJBContainer.MODULES, new File[]{Archive.archive().copyTo( > "WEB-INF/classes", jarLocation(UserService.class)).asDir()}); Dont you miss a beans.xml? > // Random port > p.put(EmbeddedTomEEContainer.TOMEE_EJBCONTAINER_HTTP_PORT, "-1"); > container =3D EJBContainer.createEJBContainer(p); > > And a service: > > /** > * Injected cache bean. > */ > @EJB > private CacheBean cacheBean; > /** > * Our key/value bean. > */ > @EJB > private KeyValueBean keyValueBean; > > The annotations do not work, but I can see cache inside the service class= : > > log.info(String.format("Cache names: %s", > cacheBean.getCacheManager(). > getCacheNames())); > > INFO: Cache names: [testCache] > > Is this a scope or class loader issue with the test container? > > > > > -- > View this message in context: http://tomee-openejb.979440.n4.nabble.com/JCache-annotations-in-web-app-tes= t-tp4676034.html > Sent from the TomEE Users mailing list archive at Nabble.com. --089e0160b5ee922a07051ea99820--