Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Virgo » Bundle Classpath Problem - Hibernate Mapping Files(Hibernate mapping files referenced in Spring bundle can't be found on the classpath.)
Bundle Classpath Problem - Hibernate Mapping Files [message #653934] Fri, 11 February 2011 17:54 Go to next message
Aaron  is currently offline Aaron
Messages: 21
Registered: February 2011
Junior Member
I'm porting an existing Spring/Hibernate app over to Virgo. I'm using Virgo 2.1.0 and Spring 3.0.5. To clarify, when I copied my project dependencies over to $VIRGO_HOME/repository/usr, those dependencies included Spring 3.0.5. I'm unclear on whether Spring 3.0.5 is being used only by my application or by the Virgo kernel as well. The 'OSGi State' admin page displays Spring 3.0.5.

My Spring bundle context includes a Hibernate session factory that is configured by:
<bean id="irisCore.sessionFactory" class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
	<property name="dataSource" ref="dataSource" />
	<property name="mappingResources">
		<list>
			<value>gov/noaa/nws/iris/authentication/User.hbm.xml</value>
			...
		</list>
	</property>
	<property name="hibernateProperties">
		<props>
			...
		</props>
	</property>
</bean>

When I attempt to install my bundle, I get the following error:
Error creating bean with name 'irisCore.sessionFactory' defined in URL [bundleentry://111.fwk1534925604/META-INF/spring/bundle-context.xml]: Invocation of init method failed; nested exception is java.io.FileNotFoundException: class path resource [gov/noaa/nws/iris/authentication/User.hbm.xml] cannot be opened because it does not exist

I can extract the contents of my bundle jar and see that User.hbm.xml does exist right where the Spring context says it should be:
bundle/
├── META-INF
│   ├── MANIFEST.MF
│   └── spring
│       ├── bundle-context-osgi.xml
│       └── bundle-context.xml
├── gov
│   └── noaa
│       └── nws
│           └── iris
│               ├── authentication
│               │   ├── User.class
│               │   ├── User.hbm.xml

Here is my MANIFEST.MF:
Manifest-Version: 1.0
Archiver-Version: Plexus Archiver
Created-By: Apache Maven
Built-By: aaron
Build-Jdk: 1.6.0_22
Import-Bundle: com.springsource.org.hibernate;version="[3.3.2.GA,3.3.2
 .GA]"
Bundle-Vendor: NWS
Bundle-Version: 0.0.1
Tool: Bundlor 1.0.0.RELEASE
Bundle-Name: IrisCore
Bundle-ManifestVersion: 2
Bundle-SymbolicName: gov.noaa.nws.iris.IrisCore
Import-Package: com.vividsolutions.jts.geom,com.vividsolutions.jts.sim
 plify,gov.noaa.nws.iris.JAXB,gov.noaa.nws.iris.authentication,gov.noa
 a.nws.iris.communication,gov.noaa.nws.iris.contact,gov.noaa.nws.iris.
 contact.address,gov.noaa.nws.iris.contact.email,gov.noaa.nws.iris.con
 tact.phone,gov.noaa.nws.iris.fire,gov.noaa.nws.iris.geodata,gov.noaa.
 nws.iris.message,gov.noaa.nws.iris.nwsoffice,gov.noaa.nws.iris.outrea
 ch,gov.noaa.nws.iris.product,gov.noaa.nws.iris.product.hvtec,gov.noaa
 .nws.iris.product.lsr,gov.noaa.nws.iris.product.pvtec,gov.noaa.nws.ir
 is.utilities,javax.sql;version="0",org.apache.log4j,org.dom4j,org.dom
 4j.io,org.geotools.referencing,org.hibernate,org.hibernate.classic,or
 g.hibernate.collection,org.hibernate.criterion,org.hibernate.engine,o
 rg.hibernate.id,org.hibernate.metadata,org.hibernate.persister.entity
 ,org.hibernate.transform,org.hibernate.type,org.hibernatespatial,org.
 hibernatespatial.criterion,org.jabsorb,org.jabsorb.serializer,org.jso
 n,org.springframework.dao;version="3.0.5.RELEASE",org.springframework
 .orm.hibernate3;version="3.0.5.RELEASE",org.springframework.orm.hiber
 nate3.support;version="3.0.5.RELEASE",org.springframework.security.ac
 cess;version="3.0.4.RELEASE",org.springframework.security.access.expr
 ession.method;version="3.0.4.RELEASE",org.springframework.security.ac
 cess.hierarchicalroles;version="3.0.4.RELEASE",org.springframework.se
 curity.access.prepost;version="3.0.4.RELEASE",org.springframework.sec
 urity.authentication;version="3.0.4.RELEASE",org.springframework.secu
 rity.authentication.dao;version="3.0.4.RELEASE",org.springframework.s
 ecurity.authentication.encoding;version="3.0.4.RELEASE",org.springfra
 mework.security.config;version="3.0.4.RELEASE",org.springframework.se
 curity.core;version="3.0.4.RELEASE",org.springframework.security.core
 .authority;version="3.0.4.RELEASE",org.springframework.security.core.
 context;version="3.0.4.RELEASE",org.springframework.security.core.use
 rdetails;version="3.0.4.RELEASE",org.springframework.security.ldap;ve
 rsion="3.0.4.RELEASE",org.springframework.security.ldap.authenticatio
 n;version="3.0.4.RELEASE",org.springframework.transaction.annotation;
 version="3.0.5.RELEASE"

I'm not sure what's going on here. Is there another class loader coming into play that does not know about the classes loaded by the bundle class loader? Is there something fundamental I am missing?

Thank you for any suggestions.

Aaron

[Updated on: Mon, 14 February 2011 16:23]

Report message to a moderator

Re: Bundle Classpath Problem - Hibernate Mapping Files [message #653939 is a reply to message #653934] Fri, 11 February 2011 19:01 Go to previous messageGo to next message
Dmitry Sklyut is currently offline Dmitry Sklyut
Messages: 272
Registered: January 2010
Senior Member
Hi Aaron,

Can you try adding a "/" in front of the resource path.

<property name="mappingResources">
		<list>
			<value>/gov/noaa/nws/iris/authentication/User.hbm.xml</value>
			...
		</list>
	</property>



Re: Bundle Classpath Problem - Hibernate Mapping Files [message #653944 is a reply to message #653939] Fri, 11 February 2011 19:59 Go to previous messageGo to next message
Aaron  is currently offline Aaron
Messages: 21
Registered: February 2011
Junior Member
Hi Dmitry,

Thanks for the reply. I have tried that and it does not work.

Thanks,
Aaron
Re: Bundle Classpath Problem - Hibernate Mapping Files [message #653961 is a reply to message #653944] Fri, 11 February 2011 23:10 Go to previous messageGo to next message
Glyn Normington is currently offline Glyn Normington
Messages: 1222
Registered: July 2009
Senior Member
To use Spring 3.0.5, you need to replace all the Spring 3.0.0 bundles and .libd file in repository/ext with the Spring 3.0.5 bundles and .libd file. Then the Virgo kernel will use 3.0.0 and your application will see 3.0.5.

To use Hibernate with Virgo, see bug 335174 for a fixed version of Hibernate in the Enterprise Bundle Repository.

Alternatively, if you want to use Hibernate 3.6, see Dmitry's hibernate sample on github.

[Updated on: Fri, 11 February 2011 23:13]

Report message to a moderator

Re: Bundle Classpath Problem - Hibernate Mapping Files [message #654269 is a reply to message #653961] Mon, 14 February 2011 15:16 Go to previous messageGo to next message
Aaron  is currently offline Aaron
Messages: 21
Registered: February 2011
Junior Member
Thanks for the information. I went ahead and replaced all Spring 3.0.0 bundles and libd file in repository/ext with the 3.0.5 versions. I also modified by dependency on org.hibernate.ejb-library to use 3.4.0.GA-A as the comments in bug 335174 suggest. Hibernate seems to resolve with no problems. My OSGi state page displays:
Bundle Id	Bundle Symbolic Name					Bundle Version	Hosts/Fragments		State
30		com.springsource.org.hibernate				3.3.2.GA	Fragments: 31 33 34	Active
31		com.springsource.org.hibernate.annotations		3.4.0.GA	Host: 30	 	Resolved
32		com.springsource.org.hibernate.annotations.common	3.3.0.ga		 		Active
33		com.springsource.org.hibernate.cache			3.3.2.GA	Host: 30	 	Resolved
34		com.springsource.org.hibernate.ejb			3.4.0.GA-A	Host: 30	 	Resolved

Does that look okay?

When I attempt to install my bundle, I still get the same error as in my original post about how it can't find the mapping file on the classpath. I'm not sure how a seemingly simple error about a file not being found on the classpath could be related to Hibernate bundle resolution problems, and like I said, It appears that Hibernate is resolved.

Any ideas?

Thanks,
Aaron
Re: Bundle Classpath Problem - Hibernate Mapping Files [message #654339 is a reply to message #654269] Tue, 15 February 2011 04:31 Go to previous messageGo to next message
Glyn Normington is currently offline Glyn Normington
Messages: 1222
Registered: July 2009
Senior Member
I don't think you've got quite the right .libd or com.springsource.org.hibernate.annotations bundle: both should have versions ending in '-A'. However, I'm not optimistic that will help your problem, but please confirm.

Maybe someone else can suggest a way forward.
Re: Bundle Classpath Problem - Hibernate Mapping Files [message #654422 is a reply to message #654339] Tue, 15 February 2011 12:10 Go to previous messageGo to next message
Aaron  is currently offline Aaron
Messages: 21
Registered: February 2011
Junior Member
Hi Glyn,

It seems weird that Hibernate problems could be causing my classpath issues, but I'm hopeful it will work because I can create Spring-powered non-Hibernate bundles that are able to resolve files on the classpath with no problem.

I'm a little confused about how to get org.hibernate.ejb-library 3.0.4.GA-A to actually have the correct dependencies on version 3.3.2.GA-A of com.springsource.org.hibernate and version 3.0.4.GA-A of com.springsource.org.hibernate.annotations... I see that the EBR page for org.hibernate.ejb-library 3.0.4.GA-A shows those dependencies the way you describe they should be, but the org.hiberante.ejb-library 3.0.4.GA-A pom specifies the non '-A' version of both of those dependencies:

<?xml version="1.0" encoding="UTF-8"?>
<!--
   Apache Maven 2 POM generated by Apache Ivy
   http://ant.apache.org/ivy/
   Apache Ivy version: 2.0.0-rc1-local-20080411224353 20080411224353
-->
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">

  <modelVersion>4.0.0</modelVersion>
  <groupId>org.hibernate</groupId>
  <artifactId>org.hibernate.ejb-library</artifactId>
  <packaging>libd</packaging>
  <version>3.4.0.GA-A</version>
  <dependencies>
    <dependency>
      <groupId>org.hibernate</groupId>
      <artifactId>com.springsource.org.hibernate</artifactId>
      <version>3.3.2.GA</version>
      <scope>compile</scope>
    </dependency>
    <dependency>
      <groupId>org.hibernate</groupId>
      <artifactId>com.springsource.org.hibernate.annotations</artifactId>
      <version>3.4.0.GA</version>
      <scope>compile</scope>
    </dependency>
    <dependency>
      <groupId>org.hibernate</groupId>
      <artifactId>com.springsource.org.hibernate.annotations.common</artifactId>
      <version>3.3.0.ga</version>
      <scope>compile</scope>
    </dependency>
    <dependency>
      <groupId>org.hibernate</groupId>
      <artifactId>com.springsource.org.hibernate.ejb</artifactId>
      <version>3.4.0.GA-A</version>
      <scope>compile</scope>
    </dependency>
  </dependencies>
</project>

Am I missing something?

Thanks,
Aaron
Re: Bundle Classpath Problem - Hibernate Mapping Files [message #654424 is a reply to message #654422] Tue, 15 February 2011 12:24 Go to previous messageGo to next message
Aaron  is currently offline Aaron
Messages: 21
Registered: February 2011
Junior Member
Actually, a correction... The EBR page shows that only the com.springsource.org.hibernate.ejb and com.springsource.org.hibernate.annotations bundles are supposed to be '-A' versions. So, the only possible error in the org.hibernate.ejb-library pom I posted above if for the version of com.springsource.org.hibernate.annotations.

Thanks,
Aaron
Re: Bundle Classpath Problem - Hibernate Mapping Files [message #654535 is a reply to message #654424] Wed, 16 February 2011 04:10 Go to previous messageGo to next message
Glyn Normington is currently offline Glyn Normington
Messages: 1222
Registered: July 2009
Senior Member
Thanks for spotting this bug! I fixed it under the original issue EBR-712. Please give it an hour or so to propagate to the site.

[Updated on: Wed, 16 February 2011 04:10]

Report message to a moderator

Re: Bundle Classpath Problem - Hibernate Mapping Files [message #655005 is a reply to message #653934] Thu, 17 February 2011 18:21 Go to previous messageGo to next message
Aaron  is currently offline Aaron
Messages: 21
Registered: February 2011
Junior Member
Okay. I think I figured out my problem.

I'm new to OSGi and did not realize what was going on until now. I had split some packages between bundles. Package foo was being exported by bundle A while my Hibernate mappings were in package foo of bundle B. It seems that bundle B was looking for the Hibernate mapping files in package foo which was associated with bundle A. I re-factored so I now have no split packages and everything seems to work.

Thanks for the ideas. At least we found another EBR bug while we were at it...

Aaron
Re: Bundle Classpath Problem - Hibernate Mapping Files [message #655029 is a reply to message #655005] Thu, 17 February 2011 23:13 Go to previous message
Glyn Normington is currently offline Glyn Normington
Messages: 1222
Registered: July 2009
Senior Member
Congratulations and thanks for persisting! Wink
Previous Topic:Virgo as NT Service or Unix deamon using Java Service Wrapper
Next Topic:Virgo and Remote Management
Goto Forum:
  


Current Time: Wed Aug 27 17:22:45 EDT 2014

Powered by FUDForum. Page generated in 0.08370 seconds