-
1. Re: @Service loading resource file fails
jaikiran Jun 10, 2010 8:48 AM (in response to osnetwork)Which version of JBoss AS is this? @Service is deprecated starting AS-6.0.0.M3 since we now have EJB3.1 @Singleton implemented in this version.
manager = new DefaultCacheManager("mycache.xml");
cache = manager.getCache("testCache");
...It fails on the startup of the application, it can't find the mycache.xml files.
I have tried also with different paths like resources/mycache.xml and /mycache.xmlThe fact is that *properties files are loaded correctly with resources/file.properties but those are loaded after the application has been deployed.
It all depends on where the DefaultCacheManager looks for the file. I guess it looks for the file in the classpath. So where exactly in the .jar (or .ear) is that file located. The path you posted looks more like the path in your source rather than in the binary .jar/.ear.
-
2. Re: @Service loading resource file fails
osnetwork Jun 10, 2010 9:13 AM (in response to jaikiran)The AS version is 5.1.0 GA
The application is packaged as a jar. The structure is like that:
-app.jar
- classes
- *xml
- *properties
-
3. Re: @Service loading resource file fails
jaikiran Jun 10, 2010 9:16 AM (in response to osnetwork)And can you please post the entire exception stacktrace?
-
4. Re: @Service loading resource file fails
osnetwork Jun 10, 2010 10:22 AM (in response to jaikiran)I'll post it as soon as I'll get home.
Anyway, it was happening on the startup of the AS and the exception if I'm not wrong was a FileNotFoundException -
5. Re: @Service loading resource file fails
osnetwork Jun 10, 2010 3:33 PM (in response to jaikiran)ok here is the code and the stacktrace.
try {manager = new DefaultCacheManager("/cache-config.xml");} catch (IOException e) {log.error("Cannot load the cache configuration");log.debug("Cannot load the cache configuration", e);}cache = manager.getCache("gametableCache");The last line of the code is the line 35.
Here is the stacktrace:
20:26:55,920 ERROR [CacheService] Cannot load the cache configuration20:26:55,921 ERROR [AbstractKernelController] Error installing to Create: name=jboss.j2ee:ear=ggPokerFruit.ear,jar=ggCore.jar,name=CacheService,service=EJB3 state=Configuredjava.lang.NullPointerExceptionat com.os.ggCore.cache.CacheService.<init>(CacheService.java:35)at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)at java.lang.reflect.Constructor.newInstance(Constructor.java:513)at java.lang.Class.newInstance0(Class.java:355)at java.lang.Class.newInstance(Class.java:308)at org.jboss.ejb3.EJBContainer.construct(EJBContainer.java:844)at org.jboss.ejb3.service.ServiceContainer.create(ServiceContainer.java:202)at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)at java.lang.reflect.Method.invoke(Method.java:597)at org.jboss.reflect.plugins.introspection.ReflectionUtils.invoke(ReflectionUtils.java:59)at org.jboss.reflect.plugins.introspection.ReflectMethodInfoImpl.invoke(ReflectMethodInfoImpl.java:150)at org.jboss.joinpoint.plugins.BasicMethodJoinPoint.dispatch(BasicMethodJoinPoint.java:66)at org.jboss.kernel.plugins.dependency.KernelControllerContextAction$JoinpointDispatchWrapper.execute(KernelControllerContextAction.java:241)at org.jboss.kernel.plugins.dependency.ExecutionWrapper.execute(ExecutionWrapper.java:47)at org.jboss.kernel.plugins.dependency.KernelControllerContextAction.dispatchExecutionWrapper(KernelControllerContextAction.java:109)at org.jboss.kernel.plugins.dependency.KernelControllerContextAction.dispatchJoinPoint(KernelControllerContextAction.java:70)at org.jboss.kernel.plugins.dependency.LifecycleAction.installActionInternal(LifecycleAction.java:221)at org.jboss.kernel.plugins.dependency.InstallsAwareAction.installAction(InstallsAwareAction.java:54)at org.jboss.kernel.plugins.dependency.InstallsAwareAction.installAction(InstallsAwareAction.java:42)at org.jboss.dependency.plugins.action.SimpleControllerContextAction.simpleInstallAction(SimpleControllerContextAction.java:62)at org.jboss.dependency.plugins.action.AccessControllerContextAction.install(AccessControllerContextAction.java:71)at org.jboss.dependency.plugins.AbstractControllerContextActions.install(AbstractControllerContextActions.java:51)at org.jboss.dependency.plugins.AbstractControllerContext.install(AbstractControllerContext.java:348)at org.jboss.dependency.plugins.AbstractController.install(AbstractController.java:1631)at org.jboss.dependency.plugins.AbstractController.incrementState(AbstractController.java:934)at org.jboss.dependency.plugins.AbstractController.resolveContexts(AbstractController.java:1082)at org.jboss.dependency.plugins.AbstractController.resolveContexts(AbstractController.java:984)at org.jboss.dependency.plugins.AbstractController.install(AbstractController.java:774)at org.jboss.dependency.plugins.AbstractController.install(AbstractController.java:540)at org.jboss.deployers.vfs.deployer.kernel.BeanMetaDataDeployer.deploy(BeanMetaDataDeployer.java:121)at org.jboss.deployers.vfs.deployer.kernel.BeanMetaDataDeployer.deploy(BeanMetaDataDeployer.java:51)at org.jboss.deployers.spi.deployer.helpers.AbstractSimpleRealDeployer.internalDeploy(AbstractSimpleRealDeployer.java:62)at org.jboss.deployers.spi.deployer.helpers.AbstractRealDeployer.deploy(AbstractRealDeployer.java:50)at org.jboss.deployers.plugins.deployers.DeployerWrapper.deploy(DeployerWrapper.java:171)at org.jboss.deployers.plugins.deployers.DeployersImpl.doDeploy(DeployersImpl.java:1439)at org.jboss.deployers.plugins.deployers.DeployersImpl.doInstallParentFirst(DeployersImpl.java:1157)at org.jboss.deployers.plugins.deployers.DeployersImpl.doInstallParentFirst(DeployersImpl.java:1178)at org.jboss.deployers.plugins.deployers.DeployersImpl.doInstallParentFirst(DeployersImpl.java:1210)at org.jboss.deployers.plugins.deployers.DeployersImpl.install(DeployersImpl.java:1098)at org.jboss.dependency.plugins.AbstractControllerContext.install(AbstractControllerContext.java:348)at org.jboss.dependency.plugins.AbstractController.install(AbstractController.java:1631) -
6. Re: @Service loading resource file fails
osnetwork Jun 10, 2010 8:04 PM (in response to jaikiran)I have fixed thanks.
The problem was in the cache.xml file
It was failing the XSD validation due to the fact that I had:
<infinispan>
instead of having
<infinispan
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="urn:infinispan:config:4.0 http://www.infinispan.org/schemas/infinispan-config-4.0.xsd"
xmlns="urn:infinispan:config:4.0">now it works like a charm.
Cheers,
Luca