Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » EclipseLink » Equinox Weaving Problem(Entites are not woven)
icon5.gif  Equinox Weaving Problem [message #493930] Wed, 28 October 2009 14:35 Go to next message
Oliver Vesper is currently offline Oliver VesperFriend
Messages: 42
Registered: July 2009
Member
Hey folks,

I'm trying to give my application a big performance boost by making the lazy-loading work. Therefore I am trying to make use of dynamic weaving. As I couldn't get it to work within my Eclipse RCP application, I set up a minimalistic Equinox test environment (very similar to [1]) which can be run outside of the Eclipse IDE - it can be downloaded from [4], the complete test case including all third-party libs can be downloaded from [5].

I followed the bundle-start-level rules described in [1], weaving is enabled in persistence.xml, the weaving-hook-fragment is registered properly to the org.eclipse.osgi master bundle... I can't see what's going wrong with my test case.

Here is the code of my bundle's Activator:
public class Activator implements BundleActivator {

	public void start(final BundleContext context) throws Exception {
		if (createEntityManagerFactory()) {
			if (Helper.classImplementsInterface(Foo.class, PersistenceWeaved.class)) {
				System.out.println("Foo is woven");
			} else {
				System.err.println("Foo is not woven");
			}

			if (Helper.classImplementsInterface(Bar.class, PersistenceWeaved.class)) {
				System.out.println("Bar is woven");
			} else {
				System.err.println("Bar is not woven");
			}
		}
	}

	public boolean createEntityManagerFactory() {
		final Properties properties = new Properties();
		properties.put(PersistenceUnitProperties.CLASSLOADER, this.getClass().getClassLoader());
		final EntityManagerFactory emf = new PersistenceProvider().createEntityManagerFactory("default", properties);
		if (null == emf) {
			return false;
		}
		final EntityManager em = emf.createEntityManager();
		if (null == em) {
			emf.close();
			return false;
		}
		em.close();

		return true;
	}

	public void stop(final BundleContext context) throws Exception {
	}

}


As you can imagine, the resulting output looks like this:
Foo is not woven
Bar is not woven


The short status of my bundles looks like this:
osgi> ss

Framework is launched.

id      State       Bundle
0       ACTIVE      org.eclipse.osgi_3.6.0.v20090914
                    Fragments=1
1       RESOLVED    org.eclipse.persistence.jpa.equinox.weaving_1.2.0.v20091016-r5565
                    Master=0
2       RESOLVED    org.apache.derby_10.1.2.1_v200803061811
3       RESOLVED    org.eclipse.persistence.jpa.equinox_1.2.0.v20091016-r5565
                    Master=9
4       RESOLVED    org.eclipse.persistence.antlr_1.2.0.v20091016-r5565
5       RESOLVED    org.eclipse.persistence.core_1.2.0.v20091016-r5565
6       RESOLVED    org.eclipse.persistence.asm_1.2.0.v20091016-r5565
7       ACTIVE      org.eclipse.equinox.common_3.5.100.v20090817
8       ACTIVE      javax.persistence_1.99.6.v200910161445
9       ACTIVE      org.eclipse.persistence.jpa_1.2.0.v20091016-r5565
                    Fragments=3
10      ACTIVE      test.weaving_1.0.0.200910290705


My persistence.xml looks like this:
<?xml version="1.0" encoding="UTF-8"?>
<persistence version="1.0" xmlns="http://java.sun.com/xml/ns/persistence" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_1_0.xsd">
  <persistence-unit name="default" transaction-type="RESOURCE_LOCAL">
    <class>test.weaving.Foo</class>
    <class>test.weaving.Bar</class>
    <properties>
            <property name="eclipselink.weaving" value="true"/>

            <property name="eclipselink.jdbc.url" value="jdbc:derby:weavingtest;create=true"/>
      	    <property name="javax.persistence.jdbc.user" value="xyz"/>
      	    <property name="javax.persistence.jdbc.password" value="xyz"/>
      	    <property name="eclipselink.jdbc.driver" value="org.apache.derby.jdbc.EmbeddedDriver"/>
            <property name="eclipselink.target-database" value="Derby"/>

      	    <property name="eclipselink.jdbc.read-connections.min" value="1"/>
            <property name="eclipselink.jdbc.write-connections.min" value="1"/>
						            
            <property name="eclipselink.ddl-generation" value="drop-and-create-tables"/>
            <property name="eclipselink.ddl-generation.output-mode" value="database"/>
 
            <property name="eclipselink.logging.level" value="FINE" />
            <property name="eclipselink.logging.thread" value="false" />
            <property name="eclipselink.logging.session" value="false" />
            <property name="eclipselink.logging.exceptions" value="true" />
            <property name="eclipselink.logging.timestamp" value="false"/> 
    </properties>
  </persistence-unit>
</persistence>


Here are the versions I am currently using for this test:
- Equinox/Eclipse: 3.6M2
- Derby ([2]): 10.1.2
- EclipseLink ([3]): 1.2.0 OSGI bundles

Help is very appreciated!!! Smile

Thanks in advance,
Oliver

[1] http://wiki.eclipse.org/EclipseLink/Examples/OSGi/Equinox_By te_Code_Weaving
[2] http://download.eclipse.org/tools/orbit/downloads/drops/R200 90825191606/
[3] http://www.eclipse.org/downloads/download.php?file=/rt/eclip selink/releases/1.2.0/eclipselink-plugins-1.2.0.v20091016-r5 565.zip
[4] http://www.filefactory.com/file/a1e99hf/n/equinox_weaving_fa ilure_zip/
[5] http://www.filefactory.com/file/a07f82b/n/equniox_weaving_fa ilure_complete_zip

[Updated on: Thu, 29 October 2009 06:23]

Report message to a moderator

Re: Equinox Weaving Problem [message #494111 is a reply to message #493930] Thu, 29 October 2009 09:17 Go to previous messageGo to next message
Oliver Vesper is currently offline Oliver VesperFriend
Messages: 42
Registered: July 2009
Member
Maybe this is helpful, I can see the following output on the console after turning on the debug options:

EclipseLink: Adding WeaverRegistry Class Loading Hook
Re: Equinox Weaving Problem [message #494153 is a reply to message #493930] Thu, 29 October 2009 12:07 Go to previous messageGo to next message
Oliver Vesper is currently offline Oliver VesperFriend
Messages: 42
Registered: July 2009
Member
Could it be that for some reason no service - providing the IWeaver interface - is being registered? I had a look at the output of the "services" command and couldn't find any IWeaver service. That would cause the WeaverRegistry to not process any class at all. So who's supposed to registered such a service?

Okay, it's the EquinoxInitializer located in the bundle org.eclipse.persistence.jpa.equinox. It's creating an EquinoxWeaver instance in its registerTransformer-method. So I guess that method is not being called.

Some interesting log-output:
[EL Finest]: 2009-10-29 13:42:45.041--ServerSession(25582376)--Thread(Thread[Start Level Event Dispatcher,5,main])--property=eclipselink.logging.timestamp; value=false
[EL Finest]: ServerSession(25582376)--Thread(Thread[Start Level Event Dispatcher,5,main])--property=eclipselink.logging.thread; value=false
[EL Finest]: ServerSession(25582376)--property=eclipselink.logging.session; value=false
[EL Finest]: property=eclipselink.logging.exceptions; value=true
[EL Finest]: Begin predeploying Persistence Unit default; state Initial; factoryCount 0
[EL Finest]: property=eclipselink.weaving; value=false
[EL Finest]: property=eclipselink.orm.throw.exceptions; default value=true
[EL Finer]: Searching for default mapping file in bundleresource://11.fwk16130931/
[EL Finer]: Searching for default mapping file in bundleresource://11.fwk16130931/


Interesting because it states that the weaving-property is set to false?!

Can anybody shed some light on this?

Thx!

[Updated on: Thu, 29 October 2009 12:46]

Report message to a moderator

Re: Equinox Weaving Problem [message #494170 is a reply to message #494153] Thu, 29 October 2009 13:13 Go to previous messageGo to next message
Oliver Vesper is currently offline Oliver VesperFriend
Messages: 42
Registered: July 2009
Member
When creating my EMF I first create an instance of org.eclipse.persistence.jpa.osgi.PersistenceProvider. Looking at this class I come to org.eclipse.persistence.internal.jpa.deployment.osgi.OSGiIni tializer where two interesting things happen: the weaving-property is disabled within the checkWeaving method and the registerTransformer method's body is empty.

I don't know why but it pretty much looks like I am using this OSGIInitializer instead of the EquinoxInitializer - which I guess I should be using to get the weaving working.

So what's the right way to use the one but the other?

Thx!
icon14.gif  Re: Equinox Weaving Problem [message #494191 is a reply to message #493930] Thu, 29 October 2009 14:06 Go to previous message
Oliver Vesper is currently offline Oliver VesperFriend
Messages: 42
Registered: July 2009
Member
Holy cow - I finally got it working... I needed to pass the name of the Initializer (org.eclipse.persistence.internal.jpa.deployment.osgi.equino x.EquinoxInitializer) to the constructor of the PersistenceProvider. Before it was always null and therefore the default OSGiInitializer was created.

New question: is it this the right approach, that my bundle should create an instance of the PersistenceProvider? I realized during debugging the code that another Activator already creates the right PersistenceProvider (with the EquinoxInitializer parameter)...

Maybe someone can provide some details on this one...

Thx,
Oliver
Previous Topic:Cache coordination
Next Topic:query conflicts and "unexpected token [count]"
Goto Forum:
  


Current Time: Tue Mar 19 04:58:52 GMT 2024

Powered by FUDForum. Page generated in 0.02125 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top