I'm unable to run the BatchStockItemUpsertService, there are still 12 "merlin" beans in the spring context for which I don't have classes. We need to strip the code down to isolate the problem from the supporting code, or add in the supporting code so that I can get the exception to throw. Mock classes would be appropriate (e.g. to replace merlin.persistence.EventDAOImpl).
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
One thing does occur to me for you to try before we dig in any deeper: The exception being thrown looks like failure of validation inside the xerces parser due to One-JAR presenting URL's of the form "jar:file:<path-to-one-jar>!/<resource>". This new (default) URL format was introduced in 0.97 to support spring annotation scanning. Since you don't appear to be using annotations, you might be able to fix the problem by switching back to the "onejar:" URL form by following these instructions:
when i included <manifest>
<attribute name="One-Jar-URL-Factory" value="com.simontuffs.onejar.JarClassLoader$OneJarURLFactory"/>
</manifest> in the manifest i am getting following error
21-Jul-2010 09:48:24 Started batch email sending service
21-Jul-2010 09:48:28 prepending / to /ehcache.xml. It should be placed in the ro
otof the classpath rather than in a package.
21-Jul-2010 09:48:28 Creating EhCacheProvider from a specified resource: /ehcach
e.xml. Resolved to URL:
21-Jul-2010 09:48:28 Creating new CacheManager with config URL: onejar:/lib/merl
in-business.jar//ehcache.xml
21-Jul-2010 09:48:28 Configuring ehcache from URL: onejar:/lib/merlin-business.j
ar//ehcache.xml
Exception in thread "main" java.lang.reflect.InvocationTargetException
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.
java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAcces
sorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at com.simontuffs.onejar.Boot.run(Boot.java:340)
at com.simontuffs.onejar.Boot.main(Boot.java:166)
Caused by: org.springframework.beans.factory.BeanCreationException: Error creati
ng bean with name 'entityManagerFactory' defined in URL [onejar:/lib/merlin-busi
ness.jar/merlin-business-spring-context.xml]: Invocation of init method failed;
nested exception is net.sf.ehcache.CacheException: Error configuring from onejar
:/lib/merlin-business.jar//ehcache.xml. Initial cause was cl.getByteStream() ret
urned null for /lib/merlin-business.jar//ehcache.xml
at org.springframework.beans.factory.support.AbstractAutowireCapableBean
Factory.initializeBean(AbstractAutowireCapableBeanFactory.java:1401)
at org.springframework.beans.factory.support.AbstractAutowireCapableBean
Factory.doCreateBean(AbstractAutowireCapableBeanFactory.java:512)
at org.springframework.beans.factory.support.AbstractAutowireCapableBean
Factory.createBean(AbstractAutowireCapableBeanFactory.java:450)
at org.springframework.beans.factory.support.AbstractBeanFactory$1.getOb
ject(AbstractBeanFactory.java:290)
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistr
y.getSingleton(DefaultSingletonBeanRegistry.java:222)
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBe
an(AbstractBeanFactory.java:287)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean
(AbstractBeanFactory.java:189)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.
preInstantiateSingletons(DefaultListableBeanFactory.java:540)
at org.springframework.context.support.AbstractApplicationContext.finish
BeanFactoryInitialization(AbstractApplicationContext.java:842)
at org.springframework.context.support.AbstractApplicationContext.refres
h(AbstractApplicationContext.java:416)
at org.springframework.context.support.ClassPathXmlApplicationContext.<i
nit>(ClassPathXmlApplicationContext.java:139)
at org.springframework.context.support.ClassPathXmlApplicationContext.<i
nit>(ClassPathXmlApplicationContext.java:83)
at merlin.utility.batchupsertstockitem.BatchStockItemUpsertService.main(
Unknown Source)
... 6 more
Caused by: net.sf.ehcache.CacheException: Error configuring from onejar:/lib/mer
lin-business.jar//ehcache.xml. Initial cause was cl.getByteStream() returned nul
l for /lib/merlin-business.jar//ehcache.xml
at net.sf.ehcache.config.ConfigurationFactory.parseConfiguration(Configu
rationFactory.java:103)
at net.sf.ehcache.CacheManager.parseConfiguration(CacheManager.java:501)
at net.sf.ehcache.CacheManager.init(CacheManager.java:290)
at net.sf.ehcache.CacheManager.<init>(CacheManager.java:253)
at net.sf.ehcache.CacheManager.create(CacheManager.java:715)
at net.sf.ehcache.hibernate.SingletonEhCacheProvider.start(SingletonEhCa
cheProvider.java:100)
at org.hibernate.cache.impl.bridge.RegionFactoryCacheProviderBridge.star
t(RegionFactoryCacheProviderBridge.java:72)
at org.hibernate.impl.SessionFactoryImpl.<init>(SessionFactoryImpl.java:
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
i can get this jar working , but only if i remove my ehcache.xml from my internal jars, is there anyway i can get this working without removing my ehcache.xml, please advise
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I don't know the detailed workings of Hibernate, but I'll try to take a look as I splunk through the 0.98 release. From the exception message:
21-Jul-2010 09:48:28 prepending / to /ehcache.xml. It should be placed in the root of the classpath rather than in a package.
Try putting a copy of your ehcache.xml in the top-level of the One-JAR (<one-jar> is a <jar> task in Ant, you can just add <filesets> to it.
This might stop the problem. The top-level ehcache.xml should be loaded first by the classloader, and should hide any others in the jar files. You may get a warning if it duplicates another different file..
--simon.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
When I added in the root of the classpath i.e, in one-jar tag in my build.xml
<one-jar destfile="${dist.dir}/merlin-housekeeping.jar" manifest="...">
<zipfileset dir="${config.dir}" includes="log4j.xml,ehcache.xml" />
<main jar="${dist.dir}/main.jar">
</main>
<lib>
<fileset dir="${dependencies.dir}"/>
</lib>........................
getting following exception
nested exception is net.sf.ehcache.CacheException: Error configuring from onejar
:////ehcache.xml. Initial cause was cl.getByteStream() returned null for ////ehc
ache.xml
at org.springframework.beans.factory.support.AbstractAutowireCapableBean
Factory.initializeBean(AbstractAutowireCapableBeanFactory.java:1401)
at org.springframework.beans.factory.support.AbstractAutowireCapableBean
Factory.doCreateBean(AbstractAutowireCapableBeanFactory.java:512)
at org.springframework.beans.factory.support.AbstractAutowireCapableBean
Factory.createBean(AbstractAutowireCapableBeanFactory.java:450)
at org.springframework.beans.factory.support.AbstractBeanFactory$1.getOb
ject(AbstractBeanFactory.java:290)
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistr
y.getSingleton(DefaultSingletonBeanRegistry.java:222)
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBe
an(AbstractBeanFactory.java:287)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean
(AbstractBeanFactory.java:189)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.
preInstantiateSingletons(DefaultListableBeanFactory.java:540)
at org.springframework.context.support.AbstractApplicationContext.finish
BeanFactoryInitialization(AbstractApplicationContext.java:842)
at org.springframework.context.support.AbstractApplicationContext.refres
h(AbstractApplicationContext.java:416)
at org.springframework.context.support.ClassPathXmlApplicationContext.<i
nit>(ClassPathXmlApplicationContext.java:139)
at org.springframework.context.support.ClassPathXmlApplicationContext.<i
nit>(ClassPathXmlApplicationContext.java:83)
at merlin.utility.housekeeping.HouseKeepingService.main(HouseKeepingServ
ice.java:43)
... 6 more
Caused by: net.sf.ehcache.CacheException: Error configuring from onejar:////ehca
che.xml. Initial cause was cl.getByteStream() returned null for ////ehcache.xml
at net.sf.ehcache.config.ConfigurationFactory.parseConfiguration(Configu
rationFactory.java:103)
at net.sf.ehcache.CacheManager.parseConfiguration(CacheManager.java:501)
at net.sf.ehcache.CacheManager.init(CacheManager.java:290)
at net.sf.ehcache.CacheManager.<init>(CacheManager.java:253)
at net.sf.ehcache.CacheManager.create(CacheManager.java:715)
at net.sf.ehcache.hibernate.SingletonEhCacheProvider.start(SingletonEhCa
cheProvider.java:100)
at org.hibernate.cache.impl.bridge.RegionFactoryCacheProviderBridge.star
t(RegionFactoryCacheProviderBridge.java:72)
at org.hibernate.impl.SessionFactoryImpl.<init>(SessionFactoryImpl.java:
215)
at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.jav
a:1327)
at org.hibernate.cfg.AnnotationConfiguration.buildSessionFactory(Annotat
ionConfiguration.java:867)
at org.hibernate.ejb.Ejb3Configuration.buildEntityManagerFactory(Ejb3Con
figuration.java:669)
at org.hibernate.ejb.HibernatePersistence.createContainerEntityManagerFa
ctory(HibernatePersistence.java:132)
at org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean.cr
eateNativeEntityManagerFactory(LocalContainerEntityManagerFactoryBean.java:225)
at org.springframework.orm.jpa.AbstractEntityManagerFactoryBean.afterPro
pertiesSet(AbstractEntityManagerFactoryBean.java:288)
at org.springframework.beans.factory.support.AbstractAutowireCapableBean
Factory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1460)
at org.springframework.beans.factory.support.AbstractAutowireCapableBean
Factory.initializeBean(AbstractAutowireCapableBeanFactory.java:1398)
... 18 more
Caused by: java.io.IOException: cl.getByteStream() returned null for ////ehcache
.xml
at com.simontuffs.onejar.Handler$1.getInputStream(Handler.java:54)
at java.net.URL.openStream(URL.java:1010)
at net.sf.ehcache.config.ConfigurationFactory.parseConfiguration(Configu
rationFactory.java:100)
... 33 more
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
The line-numbers in your exception trace don't line up with the source-code in spring-framework 3.0.2.RELEASE. Which version of Spring are you using?
The path "////ehcache.xml" being requested as a byte stream is the clue to this problem, but I'm not sure why that is the requested URL from the Spring code.
At this point I'm going to need a stripped down spring project to run in order to diagnose this further.
Or, it's probably easier for you to debug this: all the source-code you need for One-JAR is contained in the one-jar-boot.jar inside the one-jar-ant-task-0.97.jar in the com/simontuffs/onejar/ant folder: you should be able to extract the one-jar-boot.jar file and put it on the source-path of your debugger and look inside the Handler class. If I had to guess I'd say that the JarClassLoader.OneJarURLFactory needs to strip some of those leading slashes in this case.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Update: I may have a clue for you, and a self-help step to take. I think the problem may be in the OneJarURLFactory.getURL() method:
public static class OneJarURLFactory implements IURLFactory {
public OneJarURLFactory(JarClassLoader jcl) {
// Argument not used.
}
public URL getURL(String codebase, String resource) throws MalformedURLException {
String base = resource.endsWith(".class")? "": codebase + "/";
URL url = new URL(Handler.PROTOCOL + ":/" + base + resource);
return url;
}
public URL getCodeBase(String jar) throws MalformedURLException {
return new URL(Handler.PROTOCOL + ":" + jar);
}
}
Note the append of the "/" for non .class files. This really ought to pre-strip any leading slashes from the resource. Best approach for you is to take this class, modify it, and inject it using the One-Jar-URL-Factory manifest attrbute. You should be able to debug it at that point.
--simon.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
The way I fixed is:
1) switched to "onejar:" URL scheme
2) patched JarClassLoader as per below. Please consider including this patch into the main tree.
===================================================================
--- ../../../../../Libraries/OneJar/_trunk/main.br/OneJar/Boot/src/main/java/com/simontuffs/onejar/JarClassLoader.java (revision 4054160)
+++ ../../../../../Libraries/OneJar/_trunk/main.br/OneJar/Boot/src/main/java/com/simontuffs/onejar/JarClassLoader.java (revision 4054188)
@@ -917,10 +917,11 @@
// Contributed by SourceForge "ffrog_8" (with thanks, Pierce. T. Wetter III).
// Handles JPA loading from jars.
if (result == null) {
- if (jarNames.contains(resource)) {
+ String slashStrippedResource = resource.replaceAll("^/", "").replaceAll("/$", "");
+ if (jarNames.contains(slashStrippedResource)) {
// resource wanted is an actual jar
- INFO("loading resource file directly" + resource);
- result = super.getResourceAsStream(resource);
+ INFO("loading resource file directly" + slashStrippedResource);
+ result = super.getResourceAsStream(slashStrippedResource);
}
}
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
View and moderate all "bugs Discussion" comments posted by this user
Mark all as spam, and block user from posting to "Bugs"
main java class
View and moderate all "bugs Discussion" comments posted by this user
Mark all as spam, and block user from posting to "Bugs"
throwing error when spring context file read jpavendoradaptor which in turn read xsd file from hibernate etitimanager
View and moderate all "bugs Discussion" comments posted by this user
Mark all as spam, and block user from posting to "Bugs"
attached is the hibernateentitymanager.jar
Thanks for the use-case, I will take a look.
I'm unable to run the BatchStockItemUpsertService, there are still 12 "merlin" beans in the spring context for which I don't have classes. We need to strip the code down to isolate the problem from the supporting code, or add in the supporting code so that I can get the exception to throw. Mock classes would be appropriate (e.g. to replace merlin.persistence.EventDAOImpl).
One thing does occur to me for you to try before we dig in any deeper: The exception being thrown looks like failure of validation inside the xerces parser due to One-JAR presenting URL's of the form "jar:file:<path-to-one-jar>!/<resource>". This new (default) URL format was introduced in 0.97 to support spring annotation scanning. Since you don't appear to be using annotations, you might be able to fix the problem by switching back to the "onejar:" URL form by following these instructions:
https://sourceforge.net/apps/wordpress/one-jar/2010/06/27/guice-finalizer-regression-rc9/
Guice also has limitations in the URL's it finds acceptable, and this fixes that problem.
--simon.
when i included <manifest>
<attribute name="One-Jar-URL-Factory" value="com.simontuffs.onejar.JarClassLoader$OneJarURLFactory"/>
</manifest> in the manifest i am getting following error
21-Jul-2010 09:48:24 Started batch email sending service
21-Jul-2010 09:48:28 prepending / to /ehcache.xml. It should be placed in the ro
otof the classpath rather than in a package.
21-Jul-2010 09:48:28 Creating EhCacheProvider from a specified resource: /ehcach
e.xml. Resolved to URL:
21-Jul-2010 09:48:28 Creating new CacheManager with config URL: onejar:/lib/merl
in-business.jar//ehcache.xml
21-Jul-2010 09:48:28 Configuring ehcache from URL: onejar:/lib/merlin-business.j
ar//ehcache.xml
Exception in thread "main" java.lang.reflect.InvocationTargetException
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.
java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAcces
sorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at com.simontuffs.onejar.Boot.run(Boot.java:340)
at com.simontuffs.onejar.Boot.main(Boot.java:166)
Caused by: org.springframework.beans.factory.BeanCreationException: Error creati
ng bean with name 'entityManagerFactory' defined in URL [onejar:/lib/merlin-busi
ness.jar/merlin-business-spring-context.xml]: Invocation of init method failed;
nested exception is net.sf.ehcache.CacheException: Error configuring from onejar
:/lib/merlin-business.jar//ehcache.xml. Initial cause was cl.getByteStream() ret
urned null for /lib/merlin-business.jar//ehcache.xml
at org.springframework.beans.factory.support.AbstractAutowireCapableBean
Factory.initializeBean(AbstractAutowireCapableBeanFactory.java:1401)
at org.springframework.beans.factory.support.AbstractAutowireCapableBean
Factory.doCreateBean(AbstractAutowireCapableBeanFactory.java:512)
at org.springframework.beans.factory.support.AbstractAutowireCapableBean
Factory.createBean(AbstractAutowireCapableBeanFactory.java:450)
at org.springframework.beans.factory.support.AbstractBeanFactory$1.getOb
ject(AbstractBeanFactory.java:290)
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistr
y.getSingleton(DefaultSingletonBeanRegistry.java:222)
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBe
an(AbstractBeanFactory.java:287)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean
(AbstractBeanFactory.java:189)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.
preInstantiateSingletons(DefaultListableBeanFactory.java:540)
at org.springframework.context.support.AbstractApplicationContext.finish
BeanFactoryInitialization(AbstractApplicationContext.java:842)
at org.springframework.context.support.AbstractApplicationContext.refres
h(AbstractApplicationContext.java:416)
at org.springframework.context.support.ClassPathXmlApplicationContext.<i
nit>(ClassPathXmlApplicationContext.java:139)
at org.springframework.context.support.ClassPathXmlApplicationContext.<i
nit>(ClassPathXmlApplicationContext.java:83)
at merlin.utility.batchupsertstockitem.BatchStockItemUpsertService.main(
Unknown Source)
... 6 more
Caused by: net.sf.ehcache.CacheException: Error configuring from onejar:/lib/mer
lin-business.jar//ehcache.xml. Initial cause was cl.getByteStream() returned nul
l for /lib/merlin-business.jar//ehcache.xml
at net.sf.ehcache.config.ConfigurationFactory.parseConfiguration(Configu
rationFactory.java:103)
at net.sf.ehcache.CacheManager.parseConfiguration(CacheManager.java:501)
at net.sf.ehcache.CacheManager.init(CacheManager.java:290)
at net.sf.ehcache.CacheManager.<init>(CacheManager.java:253)
at net.sf.ehcache.CacheManager.create(CacheManager.java:715)
at net.sf.ehcache.hibernate.SingletonEhCacheProvider.start(SingletonEhCa
cheProvider.java:100)
at org.hibernate.cache.impl.bridge.RegionFactoryCacheProviderBridge.star
t(RegionFactoryCacheProviderBridge.java:72)
at org.hibernate.impl.SessionFactoryImpl.<init>(SessionFactoryImpl.java:
View and moderate all "bugs Discussion" comments posted by this user
Mark all as spam, and block user from posting to "Bugs"
i can get this jar working , but only if i remove my ehcache.xml from my internal jars, is there anyway i can get this working without removing my ehcache.xml, please advise
I don't know the detailed workings of Hibernate, but I'll try to take a look as I splunk through the 0.98 release. From the exception message:
21-Jul-2010 09:48:28 prepending / to /ehcache.xml. It should be placed in the root of the classpath rather than in a package.
Try putting a copy of your ehcache.xml in the top-level of the One-JAR (<one-jar> is a <jar> task in Ant, you can just add <filesets> to it.
This might stop the problem. The top-level ehcache.xml should be loaded first by the classloader, and should hide any others in the jar files. You may get a warning if it duplicates another different file..
--simon.
When I added in the root of the classpath i.e, in one-jar tag in my build.xml
<one-jar destfile="${dist.dir}/merlin-housekeeping.jar" manifest="...">
<zipfileset dir="${config.dir}" includes="log4j.xml,ehcache.xml" />
<main jar="${dist.dir}/main.jar">
</main>
<lib>
<fileset dir="${dependencies.dir}"/>
</lib>........................
getting following exception
nested exception is net.sf.ehcache.CacheException: Error configuring from onejar
:////ehcache.xml. Initial cause was cl.getByteStream() returned null for ////ehc
ache.xml
at org.springframework.beans.factory.support.AbstractAutowireCapableBean
Factory.initializeBean(AbstractAutowireCapableBeanFactory.java:1401)
at org.springframework.beans.factory.support.AbstractAutowireCapableBean
Factory.doCreateBean(AbstractAutowireCapableBeanFactory.java:512)
at org.springframework.beans.factory.support.AbstractAutowireCapableBean
Factory.createBean(AbstractAutowireCapableBeanFactory.java:450)
at org.springframework.beans.factory.support.AbstractBeanFactory$1.getOb
ject(AbstractBeanFactory.java:290)
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistr
y.getSingleton(DefaultSingletonBeanRegistry.java:222)
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBe
an(AbstractBeanFactory.java:287)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean
(AbstractBeanFactory.java:189)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.
preInstantiateSingletons(DefaultListableBeanFactory.java:540)
at org.springframework.context.support.AbstractApplicationContext.finish
BeanFactoryInitialization(AbstractApplicationContext.java:842)
at org.springframework.context.support.AbstractApplicationContext.refres
h(AbstractApplicationContext.java:416)
at org.springframework.context.support.ClassPathXmlApplicationContext.<i
nit>(ClassPathXmlApplicationContext.java:139)
at org.springframework.context.support.ClassPathXmlApplicationContext.<i
nit>(ClassPathXmlApplicationContext.java:83)
at merlin.utility.housekeeping.HouseKeepingService.main(HouseKeepingServ
ice.java:43)
... 6 more
Caused by: net.sf.ehcache.CacheException: Error configuring from onejar:////ehca
che.xml. Initial cause was cl.getByteStream() returned null for ////ehcache.xml
at net.sf.ehcache.config.ConfigurationFactory.parseConfiguration(Configu
rationFactory.java:103)
at net.sf.ehcache.CacheManager.parseConfiguration(CacheManager.java:501)
at net.sf.ehcache.CacheManager.init(CacheManager.java:290)
at net.sf.ehcache.CacheManager.<init>(CacheManager.java:253)
at net.sf.ehcache.CacheManager.create(CacheManager.java:715)
at net.sf.ehcache.hibernate.SingletonEhCacheProvider.start(SingletonEhCa
cheProvider.java:100)
at org.hibernate.cache.impl.bridge.RegionFactoryCacheProviderBridge.star
t(RegionFactoryCacheProviderBridge.java:72)
at org.hibernate.impl.SessionFactoryImpl.<init>(SessionFactoryImpl.java:
215)
at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.jav
a:1327)
at org.hibernate.cfg.AnnotationConfiguration.buildSessionFactory(Annotat
ionConfiguration.java:867)
at org.hibernate.ejb.Ejb3Configuration.buildEntityManagerFactory(Ejb3Con
figuration.java:669)
at org.hibernate.ejb.HibernatePersistence.createContainerEntityManagerFa
ctory(HibernatePersistence.java:132)
at org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean.cr
eateNativeEntityManagerFactory(LocalContainerEntityManagerFactoryBean.java:225)
at org.springframework.orm.jpa.AbstractEntityManagerFactoryBean.afterPro
pertiesSet(AbstractEntityManagerFactoryBean.java:288)
at org.springframework.beans.factory.support.AbstractAutowireCapableBean
Factory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1460)
at org.springframework.beans.factory.support.AbstractAutowireCapableBean
Factory.initializeBean(AbstractAutowireCapableBeanFactory.java:1398)
... 18 more
Caused by: java.io.IOException: cl.getByteStream() returned null for ////ehcache
.xml
at com.simontuffs.onejar.Handler$1.getInputStream(Handler.java:54)
at java.net.URL.openStream(URL.java:1010)
at net.sf.ehcache.config.ConfigurationFactory.parseConfiguration(Configu
rationFactory.java:100)
... 33 more
The line-numbers in your exception trace don't line up with the source-code in spring-framework 3.0.2.RELEASE. Which version of Spring are you using?
The path "////ehcache.xml" being requested as a byte stream is the clue to this problem, but I'm not sure why that is the requested URL from the Spring code.
At this point I'm going to need a stripped down spring project to run in order to diagnose this further.
Or, it's probably easier for you to debug this: all the source-code you need for One-JAR is contained in the one-jar-boot.jar inside the one-jar-ant-task-0.97.jar in the com/simontuffs/onejar/ant folder: you should be able to extract the one-jar-boot.jar file and put it on the source-path of your debugger and look inside the Handler class. If I had to guess I'd say that the JarClassLoader.OneJarURLFactory needs to strip some of those leading slashes in this case.
Update: I may have a clue for you, and a self-help step to take. I think the problem may be in the OneJarURLFactory.getURL() method:
public static class OneJarURLFactory implements IURLFactory {
public OneJarURLFactory(JarClassLoader jcl) {
// Argument not used.
}
public URL getURL(String codebase, String resource) throws MalformedURLException {
String base = resource.endsWith(".class")? "": codebase + "/";
URL url = new URL(Handler.PROTOCOL + ":/" + base + resource);
return url;
}
public URL getCodeBase(String jar) throws MalformedURLException {
return new URL(Handler.PROTOCOL + ":" + jar);
}
}
Note the append of the "/" for non .class files. This really ought to pre-strip any leading slashes from the resource. Best approach for you is to take this class, modify it, and inject it using the One-Jar-URL-Factory manifest attrbute. You should be able to debug it at that point.
--simon.
Edit: (since sf.net doesn't let you edit):
Use this version of OneJarURLFactory as a starting point: the one posted below won't work for you.
public class OneJarURLFactory implements IURLFactory {
public URL getURL(String codebase, String resource) throws MalformedURLException {
String base = resource.endsWith(".class")? "": codebase + "/";
URL url = new URL(Handler.PROTOCOL + ":/" + base + resource);
return url;
}
public URL getCodeBase(String jar) throws MalformedURLException {
return new URL(Handler.PROTOCOL + ":" + jar);
}
}
--simon.
The way I fixed is:
1) switched to "onejar:" URL scheme
2) patched JarClassLoader as per below. Please consider including this patch into the main tree.
===================================================================
--- ../../../../../Libraries/OneJar/_trunk/main.br/OneJar/Boot/src/main/java/com/simontuffs/onejar/JarClassLoader.java (revision 4054160)
+++ ../../../../../Libraries/OneJar/_trunk/main.br/OneJar/Boot/src/main/java/com/simontuffs/onejar/JarClassLoader.java (revision 4054188)
@@ -917,10 +917,11 @@
// Contributed by SourceForge "ffrog_8" (with thanks, Pierce. T. Wetter III).
// Handles JPA loading from jars.
if (result == null) {
- if (jarNames.contains(resource)) {
+ String slashStrippedResource = resource.replaceAll("^/", "").replaceAll("/$", "");
+ if (jarNames.contains(slashStrippedResource)) {
// resource wanted is an actual jar
- INFO("loading resource file directly" + resource);
- result = super.getResourceAsStream(resource);
+ INFO("loading resource file directly" + slashStrippedResource);
+ result = super.getResourceAsStream(slashStrippedResource);
}
}
Thank you for this work: I will integrate it into the next release.