Atomikos Forum |
|
Hi there,
Please find below some modifications to the "jars" goal of the ant build of transactions-essentials. It inserts the manifest headers necessary to be able to load the atomikos jars into an OSGi container. I have down the work for all the jars except the ones related to hibernate* I have imported the resulting jars inside eclipse-PDE and successfully ran jetty-hightide's test-jndi webapp setup with atomikos's xa-transactions: http://github.com/intalio/hightide-on-osgi/blob/master/org.eclipse.jetty.hightide.testjndi/contexts/test-jndi.xml here is the bundle that consumes those atomikos bundles: http://github.com/intalio/hightide-on-osgi/blob/master/org.eclipse.jetty.hightide.testjndi/META-INF/MANIFEST.MF When you run the build please make sure that the version number defined in the build.properties is not "3.5.8-modified-locally" as eclipse won't recognize the resulting jars as OSGi bundles. 3.5.8.1 will do. I had one difficulty getting com.atomikos.util.SerializableObjectFactory to able to load objects located inside bundles that it does not depend on. It worked for me once I replaced inside the method getObjectInstance this line of code: ObjectInputStream in = new ObjectInputStream ( bin ); by this: ObjectInputStream in = new ObjectInputStream ( bin ) { protected Class<?> resolveClass(ObjectStreamClass desc) throws IOException, ClassNotFoundException { try { return super.resolveClass(desc); } catch (ClassNotFoundException ex) { //try the context classloader then. return Thread.currentThread().getContextClassLoader() .loadClass(desc.getName()); } } }; I hope this helps. Please let me know, Best, Hugues. <target name="jars" description="(re)generates the jar files"> <input message="WARNING: about to overwrite jar files in folder ${jars.destination.dir} - continue?" validargs="y,n" addproperty="jars.overwrite"/> <condition property="do.abort"> <equals arg1="n" arg2="${jars.overwrite}"/> </condition> <fail if="do.abort">Build aborted by user.</fail> <antcall target="clean"/> <antcall target="prepare"/> <antcall target="compile"/> <delete dir="${jars.destination.dir}" quiet="true"/> <mkdir dir="${jars.destination.dir}"/> <jar destfile="${jars.destination.dir}/transactions-api.jar"> <fileset dir="${build.dir}"> <include name="com/atomikos/datasource/*.class"/> <include name="com/atomikos/icatch/*.class"/> <include name="com/atomikos/icatch/config/*.class"/> <include name="com/atomikos/icatch/admin/*.class"/> </fileset> <manifest> <attribute name="Implementation-Title" value="transactions-api.jar"/> <attribute name="Implementation-Version" value="${build.version}"/> <attribute name="Implementation-Vendor" value="Atomikos"/> <attribute name="Atomikos-Version" value="${build.version}"/> <attribute name="Bundle-ManifestVersion" value="2"/> <attribute name="Bundle-Name" value="transactions-api"/> <attribute name="Bundle-SymbolicName" value="com.atomikos.transactions.api"/> <attribute name="Bundle-Version" value="${build.version}"/> <attribute name="Bundle-Vendor" value="Atomikos"/> <attribute name="Export-Package" value="com.atomikos.datasource,com.atomikos.icatch,com.atomikos.icatch.admin,com.atomikos.icatch.config"/> <attribute name="Import-Package" value="com.atomikos.finitestates,com.atomikos.util,javax.transaction;version="1.1.0",javax.transaction.xa;version="1.1.0""/> </manifest> </jar> <jar destfile="${jars.destination.dir}/transactions.jar"> <fileset dir="${build.dir}"> <include name="com/atomikos/icatch/admin/imp/*.class"/> <include name="com/atomikos/icatch/admin/jmx/*.class"/> <include name="com/atomikos/icatch/config/imp/*.class"/> <include name="com/atomikos/icatch/imp/*.class"/> <include name="com/atomikos/icatch/system/*.class"/> <include name="com/atomikos/persistence/*.class"/> <include name="com/atomikos/persistence/imp/*.class"/> <include name="com/atomikos/icatch/imp/thread/*.class"/> </fileset> <manifest> <attribute name="Implementation-Title" value="transactions.jar"/> <attribute name="Implementation-Version" value="${build.version}"/> <attribute name="Implementation-Vendor" value="Atomikos"/> <attribute name="Atomikos-Version" value="${build.version}"/> <attribute name="Bundle-ManifestVersion" value="2"/> <attribute name="Bundle-Name" value="atomikos-transactions"/> <attribute name="Bundle-SymbolicName" value="com.atomikos.transactions"/> <attribute name="Bundle-Version" value="${build.version}"/> <attribute name="Bundle-Vendor" value="Atomikos"/> <attribute name="Export-Package" value="com.atomikos.icatch.admin.imp,com.atomikos.icatch.admin.jmx,com.atomikos.icatch.config.imp,com.atomikos.icatch.imp,com.atomikos.icatch.imp.thread,com.atomikos.icatch.system,com.atomikos.persistence,com.atomikos.persistence.imp"/> <attribute name="Import-Package" value="com.atomikos.datasource,com.atomikos.diagnostics,com.atomikos.finitestates,com.atomikos.icatch,com.atomikos.icatch.admin,com.atomikos.icatch.config,com.atomikos.swing,com.atomikos.timing,com.atomikos.util"/> </manifest> </jar> <jar destfile="${jars.destination.dir}/transactions-jta.jar"> <fileset dir="${build.dir}"> <include name="com/atomikos/datasource/xa/**/*.class"/> <include name="com/atomikos/datasource/pool/**/*.class"/> <include name="com/atomikos/icatch/jta/*.class"/> <include name="com/atomikos/icatch/standalone/*.class"/> </fileset> <manifest> <attribute name="Implementation-Title" value="transactions-jta.jar"/> <attribute name="Implementation-Version" value="${build.version}"/> <attribute name="Implementation-Vendor" value="Atomikos"/> <attribute name="Atomikos-Version" value="${build.version}"/> <attribute name="Bundle-ManifestVersion" value="2"/> <attribute name="Bundle-Name" value="atomikos-transactions-jta"/> <attribute name="Bundle-SymbolicName" value="com.atomikos.transactions.jta"/> <attribute name="Bundle-Version" value="${build.version}"/> <attribute name="Bundle-Vendor" value="Atomikos"/> <attribute name="Export-Package" value="com.atomikos.datasource.pool,com.atomikos.datasource.xa,com.atomikos.datasource.xa.jca,com.atomikos.datasource.xa.jdbc,com.atomikos.datasource.xa.jms,com.atomikos.datasource.xa.jmx,com.atomikos.datasource.xa.session,com.atomikos.icatch.jta,com.atomikos.icatch.standalone"/> <attribute name="Import-Package" value="com.atomikos.datasource,com.atomikos.diagnostics,com.atomikos.icatch,com.atomikos.icatch.admin,com.atomikos.icatch.admin.imp, com.atomikos.icatch.config,com.atomikos.icatch.config.imp,com.atomikos.icatch.imp,com.atomikos.icatch.imp.thread,com.atomikos.icatch.system,com.atomikos.persistence,com.atomikos.persistence.imp,com.atomikos.timing,com.atomikos.util,javax.jms;version="1.1.0";resolution:=optional,javax.management,javax.naming,javax.naming.spi,javax.resource;version="1.5.0",javax.resource.spi;version="1.5.0",javax.transaction;version="1.1.0",javax.transaction.xa;version="1.1.0""/> </manifest> </jar> <jar destfile="${jars.destination.dir}/transactions-jms.jar"> <fileset dir="${build.dir}"> <include name="com/atomikos/jms/**/*.class"/> </fileset> <manifest> <attribute name="Implementation-Title" value="transactions-jms.jar"/> <attribute name="Implementation-Version" value="${build.version}"/> <attribute name="Implementation-Vendor" value="Atomikos"/> <attribute name="Atomikos-Version" value="${build.version}"/> <attribute name="Bundle-ManifestVersion" value="2"/> <attribute name="Bundle-Name" value="atomikos-transactions-jms"/> <attribute name="Bundle-SymbolicName" value="com.atomikos.transactions.jms"/> <attribute name="Bundle-Version" value="${build.version}"/> <attribute name="Bundle-Vendor" value="Atomikos"/> <attribute name="Export-Package" value="com.atomikos.jms,com.atomikos.jms.extra"/> <attribute name="Import-Package" value="com.atomikos.beans,com.atomikos.datasource,com.atomikos.datasource.pool,com.atomikos.datasource.xa,com.atomikos.datasource.xa.jms,com.atomikos.datasource.xa.session,com.atomikos.icatch,com.atomikos.icatch.jta,com.atomikos.icatch.system,com.atomikos.util,javax.jms,javax.transaction;version="1.1.0",javax.transaction.xa;version="1.1.0""/> </manifest> </jar> <jar destfile="${jars.destination.dir}/transactions-jdbc.jar"> <fileset dir="${build.dir}"> <include name="com/atomikos/jdbc/*.class"/> <include name="com/atomikos/jdbc/nonxa/*.class"/> </fileset> <manifest> <attribute name="Implementation-Title" value="transactions-jdbc.jar"/> <attribute name="Implementation-Version" value="${build.version}"/> <attribute name="Implementation-Vendor" value="Atomikos"/> <attribute name="Atomikos-Version" value="${build.version}"/> <attribute name="Bundle-ManifestVersion" value="2"/> <attribute name="Bundle-Name" value="atomikos-transactions-jdbc"/> <attribute name="Bundle-SymbolicName" value="com.atomikos.transactions.jdbc"/> <attribute name="Bundle-Version" value="${build.version}"/> <attribute name="Bundle-Vendor" value="Atomikos"/> <attribute name="Export-Package" value="com.atomikos.jdbc,com.atomikos.jdbc.nonxa"/> <attribute name="Import-Package" value="com.atomikos.beans,com.atomikos.datasource,com.atomikos.datasource.pool,com.atomikos.datasource.xa,com.atomikos.datasource.xa.jdbc, com.atomikos.datasource.xa.session,com.atomikos.icatch,com.atomikos.icatch.jta,com.atomikos.icatch.system,com.atomikos.util"/> </manifest> </jar> <jar destfile="${jars.destination.dir}/atomikos-util.jar"> <fileset dir="${build.dir}"> <include name="com/atomikos/beans/*.class"/> <include name="com/atomikos/diagnostics/*.class"/> <include name="com/atomikos/finitestates/*.class"/> <include name="com/atomikos/swing/*.class"/> <include name="com/atomikos/timing/*.class"/> <include name="com/atomikos/util/*.class"/> </fileset> <manifest> <attribute name="Implementation-Title" value="atomikos-util.jar"/> <attribute name="Implementation-Version" value="${build.version}"/> <attribute name="Implementation-Vendor" value="Atomikos"/> <attribute name="Atomikos-Version" value="${build.version}"/> <attribute name="Bundle-ManifestVersion" value="2"/> <attribute name="Bundle-Name" value="atomikos-util"/> <attribute name="Bundle-SymbolicName" value="com.atomikos.util"/> <attribute name="Bundle-Version" value="${build.version}"/> <attribute name="Bundle-Vendor" value="Atomikos"/> <attribute name="Export-Package" value="com.atomikos.beans,com.atomikos.diagnostics,com.atomikos.finitestates,com.atomikos.swing,com.atomikos.timing,com.atomikos.util"/> <attribute name="Import-Package" value="javax.servlet;version="2.4.0";resolution:=optional,javax.servlet.http;version="2.4.0";resolution:=optional,org.slf4j;resolution:=optional"/> <!-- if you want to be able to resolve classes that are not in this bundle with Class.forName then maybe use this extra eclipse-equinox only header: Eclipse-BuddyPolicy: register my recommendation is a little patch in the ObjectFactory implementations to also look into the context classloader. attribute name="Eclipse-BuddyPolicy" value="register" --> </manifest> </jar> <jar destfile="${jars.destination.dir}/transactions-hibernate2.jar"> <fileset dir="${build.dir}"> <include name="com/atomikos/icatch/jta/hibernate/*.class"/> </fileset> <manifest> <attribute name="Implementation-Title" value="transactions-hibernate2.jar"/> <attribute name="Implementation-Version" value="${build.version}"/> <attribute name="Implementation-Vendor" value="Atomikos"/> <attribute name="Atomikos-Version" value="${build.version}"/> </manifest> </jar> <jar destfile="${jars.destination.dir}/transactions-hibernate3.jar"> <fileset dir="${build.dir}"> <include name="com/atomikos/icatch/jta/hibernate3/*.class"/> </fileset> <manifest> <attribute name="Implementation-Title" value="transactions-hibernate3.jar"/> <attribute name="Implementation-Version" value="${build.version}"/> <attribute name="Implementation-Vendor" value="Atomikos"/> <attribute name="Atomikos-Version" value="${build.version}"/> </manifest> </jar> <jar jarfile="${jars.destination.dir}/transactions-essentials-all.jar" basedir="${build.dir}"> <manifest> <attribute name="Implementation-Title" value="transactions-essentials.jar"/> <attribute name="Implementation-Version" value="${build.version}"/> <attribute name="Implementation-Vendor" value="Atomikos"/> <attribute name="Atomikos-Version" value="${build.version}"/> </manifest> </jar> </target> |