Hi Jamie,

comments below.


On 24 Jun 2010, at 23:12, jamie campbell wrote:

> Hello,
> 
> I'm trying to get the blog sample (specifically with jpa persistence) working 
> within felix/karaf 1.6.0 .. if docs on how to do this already exist, then I'd 
> love a link to them.
> 
> Otherwise.. here's what I've got so far..
> 
> my startup.properties file has "the usual", then at the end I have:
> 
> <><><><><><><><><><><>
> #needed by openjpa
> javax.persistence/com.springsource.javax.persistence/2.0.0/com.springsource.javax.persistence-2.0.0.jar=35
> org.apache.commons/com.springsource.org.apache.commons.collections/3.2.0/com.springsource.org.apache.commons.collections-3.2.0.jar=35
> org.apache.commons/com.springsource.org.apache.commons.lang/2.4.0/com.springsource.org.apache.commons.lang-2.4.0.jar=35
> org.apache.commons/com.springsource.org.apache.commons.pool/1.5.3/com.springsource.org.apache.commons.pool-1.5.3.jar=35
> javax.transaction/com.springsource.javax.transaction/1.1.0/com.springsource.javax.transaction-1.1.0.jar=35
> net.sourceforge.serp/com.springsource.serp/1.13.1/com.springsource.serp-1.13.1.jar=35
> 
> org.apache.openjpa/openjpa/2.0.0/openjpa-2.0.0.jar=40
> 
> org.apache.derby/derby/10.6.1.0/derby-10.6.1.0.jar=42
> 
> #aries jpa base level stuff
> org.apache.aries.jpa/org.apache.aries.jpa.api/0.1-incubating/org.apache.aries.jpa.api-0.1-incubating.jar=43
> org.apache.aries/org.apache.aries.util/0.1-incubating/org.apache.aries.util-0.1-incubating.jar=43
> #org.apache.aries.jpa/org.apache.aries.jpa.container/0.1-incubating/org.apache.aries.jpa.container-0.1-incubating.jar=44
> org.apache.aries.jpa/org.apache.aries.jpa.blueprint.aries/0.1-incubating/org.apache.aries.jpa.blueprint.aries-0.1-incubating.jar=44
> 
> #aries blog example stuff
> org.apache.aries.samples.blog/org.apache.aries.samples.blog.api/0.1-incubating/org.apache.aries.samples.blog.api-0.1-incubating.jar=45
> org.apache.aries.samples.blog/org.apache.aries.samples.blog.datasource/0.1-incubating/org.apache.aries.samples.blog.datasource-0.1-incubating.jar=46
> org.apache.aries.samples.blog/org.apache.aries.samples.blog.biz/0.1-incubating/org.apache.aries.samples.blog.biz-0.1-incubating.jar=47
> org.apache.aries.samples.blog/org.apache.aries.samples.blog.persistence.jpa/0.1-incubating/org.apache.aries.samples.blog.persistence.jpa-0.1-incubating.jar=48
> <><><><><><><><><><><><><><><><><><><><><><>
> 
> I'm unsure whether the jpa.container or jpa.blueprint.aries or both are 
> needed or in what order.  Whichever one I do generates a warning related to 
> not having a provider   (eg jpa.container gets WARN  | rint Extender: 3 | 
> container                        | er.impl.PersistenceBundleManager  549 | 45 
> - org.apache.aries.jpa.container - 0.1.0.incubating | There are no providers 
> available.)

Both jpa.container and jpa.blueprint.aries are needed for the blog sample as 
well as the jpa.container.context bundle, which appears to be missing from your 
list.
- jpa.container provides the core integration of scanning persistence bundles 
and creating persistence units 
- jpa.container.context provides container-managed JPA and in particular allows 
container-managed EntityMangers to be created from the persistence units 
provided by jpa.container
- jpa.container.blueprint provides the extension namespace for injecting jpa 
resources directly into a blueprint bean.

All three are needed to make the snippet below in the blog.persistence.jpa 
bundle work:

        <bean id="persistenceImpl"
                
class="org.apache.aries.samples.blog.persistence.jpa.BlogPersistenceServiceImpl">
                <tx:transaction method="*" value="Required" />
                <jpa:context property="entityManager" unitname="blogExample" />
        </bean>

The warning is generated because apparently there are no persistence providers 
present when the jpa container tries to find one for the blog persistence 
bundle. To be an OSGi compatible persistence provider, openjpa 2.0.0 needs to 
publish a service with interface javax.persistence.spi.PersistenceProvider and 
property javax.persistence.provider, which gives the implementation class name. 
Now, the version of openjpa we use in the samples (beta3) is compliant and as 
far as I recall the release one should be as well but it is very worth checking 
that the PersistenceProvider service gets registered. The other option is that 
there is a race condition between the service coming up and the 
blog.persistence bundle being parsed.

> I also get a warning about not being able to do persistence units (WARN  | 
> rint Extender: 3 | container                        | 
> er.impl.PersistenceBundleManager  305 | 45 - org.apache.aries.jpa.container - 
> 0.1.0.incubating | The bundle 
> org.apache.aries.samples.blog.persistence.jpa_0.1.0.incubating is already 
> active, it may not be possible to create managed persistence units for it.)

This again to me suggests that there is a race condition in the way that the 
bundles are started. The blog.persistence.jpa bundle should not be active when 
it is scanned by the jpa.container. My guess is that the root problem is that 
the jpa.container is blueprint managed, which means the jpa extender gets 
started asynchronously to the jpa.container bundle starting and hence 
potentially later then the blog bundles, which come directly afterwards in the 
start order. If I remember correctly zoe had similar issues with setting up the 
blog sample itests.

To avoid the race condition you could (for the moment) not start the blog 
bundles manually after the runtime has come up. That said I believe this 
warning is harmless for a case like the blog sample where the JPA entities are 
pre-enhanced.

> and jndi lookup failures (ERROR | rint Extender: 3 | container                
>         | nit.impl.PersistenceUnitInfoImpl  103 | 45 - 
> org.apache.aries.jpa.container - 0.1.0.incubating | No JTA datasource could 
> be located using the JNDI name 
> aries:services/javax.sql.DataSource/(osgi.jndi.service.name=jdbc/blogdb)
> javax.naming.NoInitialContextException: Need to specify class name in 
> environment or system property, or as an applet parameter, or in an 
> application resource file:  java.naming.factory.initial) and (ERROR | rint 
> Extender: 3 | container                        | 
> nit.impl.PersistenceUnitInfoImpl  141 | 45 - org.apache.aries.jpa.container - 
> 0.1.0.incubating | No Non JTA datasource could be located using the JNDI name 
> aries:services/javax.sql.DataSource/(osgi.jndi.service.name=jdbc/blogdbnojta)
> javax.naming.NoInitialContextException: Need to specify class name in 
> environment or system property, or as an applet parameter, or in an 
> application resource file:  java.naming.factory.initial)

As far as I can see you are missing the jndi bundles (api, core and url). I am 
not hundred percent certain that their absence explains the error message you 
see. However, without those
bundles the aries:services JNDI namespace will not be defined.

> There are also a pile of namespace handler warnings but I get the impression 
> from googling that this may be an issue with karaf 1.6.0 itself rather than 
> having anything to do with Aries.
> 
> Am I missing some bundles?  Or bundles in the wrong order?  Or I need to 
> write some additional bundles to properly load the blog sample?  It seems I 
> need to write one or more bundles to *use* the BloggingService, but I wasn't 
> sure if I needed to write bundles to get it to the point of being *ready* for 
> use...

The BloggingService is used by the blog.web bundle, which appears to be missing 
from your collection of blog bundles. Without the web bundle the blog sample 
doesn't really do anything :)
For the web bundle to run you will also need and OSGi Web Extender such as Pax 
Web if you haven't got one in the runtime already.

> If I can get it going I'd be happy to write a tutorial to add to the 
> tutorials section for this type of use :)

That would be awesome :)

> -Jamie

Reply via email to