3 Replies Latest reply on Apr 18, 2012 10:10 PM by mikevoxcap

    Calling DataSource via JNDI in ServiceMix 4.4.1

    mikevoxcap Newbie

      I have tried about every example to get this working, but I finally need to turn to the forum for help. Here is my setup:

       

      - Local ServiceMix 4.4.0

      - JDK 1.6

      - Windows

       

      As per some of the forum posts, I have created a bundle that exposes the datasource.

       

      /DSproj/src/main/resources/META-INF/spring/jndi.xml

       

       

       

      ...

       

      When I install the second project, I am now getting the following exception:

       

      Caused by: javax.naming.NamingException: scheme osgi not recognized

              at org.apache.xbean.spring.jndi.DefaultContext.lookup(DefaultContext.java:131)

       

      My thought right now is that the bundle for DAOs and entities should use a different initial context implementation over SpringInitialContextFactory, but wasn't sure if I would run into the exception I got above.

       

      I am really at a loss here. Any help would be appreciated.

        • 1. Re: Calling DataSource via JNDI in ServiceMix 4.4.1
          mikevoxcap Newbie

          Planning to try the example here:

           

          https://github.com/cschneider/Karaf-Tutorial

           

          Hopefully this resolves my issue. Thanks!

          • 2. Re: Calling DataSource via JNDI in ServiceMix 4.4.1
            mikevoxcap Newbie

            Fixed my issue. I switched from using JEE to do the JNDI lookup and moved to having everything in the persistence.xml.

            • 3. Re: Calling DataSource via JNDI in ServiceMix 4.4.1
              mikevoxcap Newbie

              Okay, I moved to trying to do this with a blueprint rather than doing this via spring configurations. It is really disappointing how long it takes to configure something that I expect to take no more than an hour (it has taken me well over 40 hours between pouring through documentation and trying different combinations). Here is where I am at.

               

              First, I have a blueprint that defines the datasource I am using:

               

               

               

              I am able to deploy this and it starts up fine.

               

              Next, I have my bundle. The bundle has the following files:

               

              /src/main/resources/jpa/EachEntity.xml

               

              These contain the entity mappings. These worked fine with a Spring configuration. Here is an example:

               

               

               

              /src/main/resources/META-INF/persistence.xml

               

              Here is a snippet:

               

               

               

              /src/main/resources/OSGI-INF/blueprint.xml

               

              This is the blueprint for the service that I am exposing.

               

               

               

              pom.xml

               

              My felix configuration:

               

                                   

               

               

              Result

               

              First, the blueprint of the service has errors for <jpa:context /> and <jpa:unit />

               

              cvc-complex-type.2.4.c: The matching wildcard is strict, but no declaration can be found for element 'jpa:context'.

               

              Second, when the bundle is deployed, there is no web service and the only log I see is:

               

              2012-04-18 20:50:36,642 | WARN  | l Console Thread | container                        | ?                                   ? | 170 - org.apache.aries.jpa.container - 0.3.0 | There are no providers available.

               

              Doesnt look like any of the beans are initialized from the blueprint.xml.

               

              Also, I am looking for opinions / information / options on the following:

               

              1) Can I use spring's component scanning mechanism in a blueprint? I was not sure if I was forced to use <jpa:context /> and <jpa:unit />.

               

              2) Looking at the documentation for aries, it also looks like the transactions schema forces me to define transactions at the DAO level. Is this true?

               

              3) Can I refer to blueprint.xml beans from the spring configured beans?

               

              Again, your help is appreciated. I really want to feel comfortable with and be an advocate for this product.