RE: Barracuda: DefaultApplicationAssembler unable to find the assembly-descriptor file
Jacob Kjome <[email protected]>
| Newsgroups | gmane.comp.java.enhydra.barracuda.general |
|---|---|
| Message-ID | <[email protected]> |
Hi Christian and Franck,
The changes I made to DefaultApplicationAssembler should fix this
issue. However, I didn't have things set up perfectly and I improved on
the loading of the assembler resource even more. I just checked the latest
changes in. I'll look at ObjectRepositoryAssember tomorrow or later this
weekend. Read on...
It really doesn't matter whether the path given is "/WEB-INF/..." or
"WEB-INF/....". In fact, all the following are valid ways to load the
event-gateway.xml file....
/WEB-INF/event-gateway.xml
WEB-INF/event-gateway.xml
The leading "/" is removed if it exists and re-added so that both paths are
equivalent.
In fact, any valid path inside the webapp will work and I try loading it in
a number of ways. For instance, the following path could be relative to the
webapp, WEB-INF/, WEB-INF/classes, or a package path somewhere in the
classloader. So....
Given the path:
conf/event-gateway.xml (or /conf/event-gateway.xml, of course)
The following places will be searched (in order):
1. /conf/event-gateway.xml
2. /WEB-INF/conf/event-gateway.xml
3. /WEB-INF/classes/conf/event-gateway.xml
4. a .jar file containing the package with conf/event-gateway.xml or maybe
CATALINA_HOME/shared/classes/conf/event-gateway.xml ....basically anywhere
in the classpath available to the current classloader
5. If DefaultEventGateway exists in a parent classloader ( ie...
CATALINA_HOME/shared/lib) and the event-gateway.xml file is in a child
classloader (ie.. the WebappClassloader) then the thread context
classloader will find it as long as the proper package path has been given
for the file so.... /WEB-INF/classes/conf/event-gateway.xml or in a .jar
file in WEB-INF/lib with that package path.
Note that if you provide the full path from the root of the webapp, your
class will be found on the first try. For instance, knowing that your file
exists in "/WEB-INF/conf/event-gateway.xml", instead of giving
"/conf/event-gateway.xml" having the first loading try fail, you can just
give the full (former) path and make it succeed on the first try. It
really doesn't matter so much though. The nice thing is that it is pretty
fool proof so you can specify pretty much any relative path and
DefaultEventGateway will find it. Just make sure that you don't give a
totally bogus path. That's about the only way to defeat this thing.
In fact, you can also just specify the file itself ( "event-gateway.xml" )
and the DefaultApplicationGateway will attempt to load it from one of the
following places, preferentially, in the following order...
Oh, and if all that doesn't work, it might mean you provide a hardcoded
system path (a *big* no-no in webapps). However, we still support it so as
long as the path is valid on the system, it will be loaded such as....
C:\mydirectory\event-gateway.xml
So, there are actually 6 different ways that your resoruce might get
loaded. Pretty neat, eh?
Moral of the story, update to the latest DefaultApplicationAssembler :-)
Here's sample debugging output and the relevant code for those interested....
Attempting to load assembly file via servlet context at:
/C:\mydirectory\event-gateway.xml
Attempting to load assembly file via servlet context at:
/WEB-INF/C:\mydirectory\event-gateway.xml
Attempting to load assembly file via servlet context at:
/WEB-INF/classes/C:\mydirectory\event-gateway.xml
Attempting to load assembly file inside the local classloader:
C:\mydirectory\event-gateway.xml
Attempting to load assembly file inside all available classloaders:
C:\mydirectory\event-gateway.xml
Attempting to load assembly file via file IO at:
C:\mydirectory\event-gateway.xml
String normalizedFilePath = getNormalizedPath(iassemblySourceFile);
//Attempt to load from the WEB-INF Dir
if (iservletConfig!=null) {
//first assume that the file was given the full path specified
relative to the root of the webapp.
//eg... "/WEB-INF/myresource.xml" or "WEB-INF/myresource.xml"
if (logger.isDebugEnabled()) logger.debug("Attempting to load assembly
file via servlet context at: /"+normalizedFilePath);
is = iservletConfig.getServletContext().getResourceAsStream("/" +
normalizedFilePath);
if (is==null) {
//maybe only the filename is provided with no extra path.
Alternatively, maybe the path
//given was a path relative to /WEB-INF/ rather than the root of
the webapp. Try loading from /WEB-INF/.
if (logger.isDebugEnabled()) logger.debug("Attempting to load
assembly file via servlet context at: /WEB-INF/"+normalizedFilePath);
is =
iservletConfig.getServletContext().getResourceAsStream("/WEB-INF/" +
normalizedFilePath);
if (is==null) {
//maybe only the filename is provided with no extra
path. Alternatively, maybe the path
//given was a package path, in which case the path
would be relative to /WEB-INF/classes/
//rather than the root of the webapp. Try loading from
/WEB-INF/classes/.
if (logger.isDebugEnabled()) logger.debug("Attempting
to load assembly file via servlet context at:
/WEB-INF/classes/"+normalizedFilePath);
is =
iservletConfig.getServletContext().getResourceAsStream("/WEB-INF/classes/"
+ normalizedFilePath);
}
}
}
//resource does not exist inside the webapp at the path specified. Try
loading via the classloader.
if (is==null) {
if (logger.isDebugEnabled()) logger.debug("Attempting to load assembly
file inside the local classloader: "+normalizedFilePath);
is =
this.getClass().getClassLoader().getResourceAsStream(normalizedFilePath);
if (is==null) {
//this should only get triggered in the case that this class
exists in a parent
//classloader and the resource exists in a child
classloader. eg... in the WebappClassloader.
if (logger.isDebugEnabled()) logger.debug("Attempting to load
assembly file inside all available classloaders: "+normalizedFilePath);
Thread.currentThread().getContextClassLoader().getResourceAsStream(normalizedFilePath);
}
}
//Not a webapp or path specified is outside of the webapp. Attempt to load
using the full file path
if (is==null) {
realPath = iassemblySourceFile;
if (logger.isDebugEnabled()) logger.debug("Attempting to load assembly
file via file IO at: "+realPath);
File f = new File(realPath);
is = new FileInputStream(f);
}
Jake
At 06:16 PM 12/6/2002 -0500, you wrote:
>Hi Franck,
>
>Well, I'm not exactly sure why, but my entry looks like this:
>
><param-name>AssemblyDescriptor</param-name>
><param-value>/WEB-INF/event-gateway.xml</param-value>
> ^
> +---Notice the leading /
>
>Are you using the latest version from cvs? My guess is that Jakes change
>here: jrk_120302_1 probably needs to be applied to
>ObjectRepositoryAssembler, so as to make them work the same. Jake, you want
>to comment on this?
>
>Christian
>----------------------------------------------
>Christian Cryder [[email protected]]
>Internet Architect, ATMReports.com
>Barracuda - http://barracuda.enhydra.org
>----------------------------------------------
>"Coffee? I could quit anytime, just not today"
>
>
> > -----Original Message-----
> > From: [email protected] [mailto:[email protected]]On
> > Behalf Of franck routier
> > Sent: Friday, December 06, 2002 4:29 PM
> > To: [email protected]
> > Subject: Barracuda: DefaultApplicationAssembler unable to find the
> > assembly-descriptor file
> >
> >
> > Hi,
> >
> > I'm trying to learn how to use the application assembly descriptor in
> > Barracuda (until now, I used plain servlet extending from
> > ApplicationGateway).
> >
> > I have a very simple file called event-gateway.xml in the WEB-INF/
> > directory of my web app.
> >
> > When I deploy the app (under jboss 3.0.4 / Tomcat 4.1.12 bundle), I get
> > an exception saying DefaultApplicationAssembler is unable to find the
> > assembly descriptor file.
> >
> > Notice the object respository assembler works just fine, with an
> > object-repository.xml file beeing in the same place.
> >
> > May this be connected with my failing unit test (see thread about
> > comiling under jdk 1.3.1) ??
> > I've seen a comment in DefaultApplicationAssemble saying it was dealing
> > with file separator...
> >
> > Any idea ?
> >
> > Thanks,
> >
> > Franck
> >
> >
> > Here is a snippset of my web.xml file :
> >
> > <servlet>
> > <servlet-name>ApplicationGateway</servlet-name>
> > <servlet-class>org.enhydra.barracuda.core.event.ApplicationGateway
> > </servlet-class>
> > <init-param>
> > <param-name>ApplicationAssembler</param-name>
> > <param-value>org.enhydra.barracuda.core.event.DefaultApplicationAs
> > sembler</param-value>
> > </init-param>
> > <init-param>
> > <param-name>AssemblyDescriptor</param-name>
> > <param-value>WEB-INF/event-gateway.xml</param-value>
> > </init-param>
> > <init-param>
> > <param-name>SAXParser</param-name>
> > <param-value>org.apache.xerces.parsers.SAXParser</param-value>
> > </init-param>
> > <load-on-startup>3</load-on-startup>
> > </servlet>
> >
> >
> > And I get the following log :
> >
> > 2-12-05 22:36:23,717 INFO [org.jboss.web.localhost.Engine]
> > StandardWrapper[/comptadu:default]: Loading container servlet default
> > 2002-12-05 22:36:23,769 INFO [org.jboss.web.localhost.Engine]
> > StandardWrapper[/comptadu:invoker]: Loading container servlet invoker
> > 2002-12-05 22:36:23,796 INFO
> > [org.enhydra.barracuda.plankton.data.ObjectRepositoryAssembler]
> > Attempting to setup default ObjectRepository (HTTP interface)
> > 2002-12-05 22:36:23,837 INFO
> > [org.enhydra.barracuda.plankton.data.ObjectRepositoryAssembler]
> > Configuring GlobalOR from File: WEB-INF/object-repository.xml
> > 2002-12-05 22:36:23,848 INFO [STDOUT] Configuring GlobalOR from File:
> > WEB-INF/object-repository.xml
> > 2002-12-05 22:36:23,858 INFO
> > [org.enhydra.barracuda.plankton.data.ObjectRepositoryAssembler]
> > Instantiating parser (org.apache.xerces.parsers.SAXParser)
> > 2002-12-05 22:36:24,137 INFO
> > [org.enhydra.barracuda.plankton.data.ObjectRepositoryAssembler] Getting
> > input source from Servlet (WEB-INF/object-repository.xml)
> > 2002-12-05 22:36:24,149 INFO
> > [org.enhydra.barracuda.plankton.data.ObjectRepositoryAssembler] Parsing
> > the source file...
> > 2002-12-05 22:36:24,721 INFO
> > [org.enhydra.barracuda.plankton.data.ObjectRepositoryAssembler] Assembly
> > complete!
> > 2002-12-05 22:36:25,006 INFO
> > [org.enhydra.barracuda.core.event.ApplicationGateway] Instantiating
> > org.enhydra.barracuda.core.event.ApplicationGateway@5d1be32e
> > 2002-12-05 22:36:25,017 INFO
> > [org.enhydra.barracuda.core.event.ApplicationGateway] initializing servlet
> > 2002-12-05 22:36:25,070 INFO
> > [org.enhydra.barracuda.core.event.DefaultEventPool] Instantiating
> > EventPool:org.enhydra.barracuda.core.event.DefaultEventPool@58df232f
> > Pool size:50 Timeout:60000 Retry Interval:50 Max Retries:3 Cleanup
> > Interval:600000
> > 2002-12-05 22:36:25,086 INFO
> > [org.enhydra.barracuda.core.event.DefaultEventPool] Starting
> > EventListCleanerUpper (ELCU)...
> > 2002-12-05 22:36:25,120 INFO
> > [org.enhydra.barracuda.core.event.DefaultApplicationAssembler]
> > Assembling system from input source
> > 2002-12-05 22:36:25,130 INFO
> > [org.enhydra.barracuda.core.event.DefaultApplicationAssembler]
> > Instantiating parser (org.apache.xerces.parsers.SAXParser)
> > 2002-12-05 22:36:25,144 WARN
> > [org.enhydra.barracuda.core.event.DefaultApplicationAssembler] Error
> > assembling system!
> > java.lang.NullPointerException
> > at java.io.File.<init>(File.java(Compiled Code))
> > at
> > org.enhydra.barracuda.core.event.DefaultApplicationAssembler.assem
> > ble(DefaultApplicationAssembler.java:295)
> > at
> > org.enhydra.barracuda.core.event.ApplicationGateway.init(Applicati
> > onGateway.java:833)
> > at javax.servlet.GenericServlet.init(GenericServlet.java:256)
> > at
> > org.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapp
> > er.java:924)
> > at
> > org.apache.catalina.core.StandardWrapper.load(StandardWrapper.java:813)
> > at
> > org.apache.catalina.core.StandardContext.loadOnStartup(StandardCon
> > text.java:3341)
> > at
> > org.apache.catalina.core.StandardContext.start(StandardContext.java:3534)
> > at
> > org.apache.catalina.core.ContainerBase.addChildInternal(ContainerB
> > ase.java:821)
> > at
> > org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:807)
> > at
> > org.apache.catalina.core.StandardHost.addChild(StandardHost.java:579)
> > at
> > org.jboss.web.catalina.EmbeddedCatalinaService41.createWebContext(
>EmbeddedCatalinaService41.java:427)
> > at
> > org.jboss.web.catalina.EmbeddedCatalinaService41.performDeploy(Emb
> > eddedCatalinaService41.java:302)
> > at
> > org.jboss.web.AbstractWebContainer.start(AbstractWebContainer.java:300)
> > at org.jboss.deployment.MainDeployer.start(MainDeployer.java:802)
> > at org.jboss.deployment.MainDeployer.deploy(MainDeployer.java:616)
> > at org.jboss.deployment.MainDeployer.deploy(MainDeployer.java:580)
> > at java.lang.reflect.Method.invoke(Native Method)
> > at
> > org.jboss.mx.capability.ReflectedMBeanDispatcher.invoke(ReflectedM
> > BeanDispatcher.java(Compiled
> > Code))
> > at
> > org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java(Compiled
> > Code))
> > at
> > org.jboss.util.jmx.MBeanProxy.invoke(MBeanProxy.java(Compiled Code))
> > at $Proxy4.deploy(Unknown Source)
> > at
> > org.jboss.deployment.scanner.URLDeploymentScanner.deploy(URLDeploy
> > mentScanner.java:427)
> > at
> > org.jboss.deployment.scanner.URLDeploymentScanner.scanDirectory(UR
> > LDeploymentScanner.java:648)
> > at
> > org.jboss.deployment.scanner.URLDeploymentScanner.scan(URLDeployme
> > ntScanner.java:499)
> > at
> > org.jboss.deployment.scanner.AbstractDeploymentScanner.startServic
> > e(AbstractDeploymentScanner.java:261)
> > at
> > org.jboss.system.ServiceMBeanSupport.start(ServiceMBeanSupport.java:164)
> > at java.lang.reflect.Method.invoke(Native Method)
> > at
> > org.jboss.mx.capability.ReflectedMBeanDispatcher.invoke(ReflectedM
> > BeanDispatcher.java:284)
> > at
> > org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:517)
> > at
> > org.jboss.system.ServiceController$ServiceProxy.invoke(ServiceCont
> > roller.java:976)
> > at $Proxy0.start(Unknown Source)
> > at
> > org.jboss.system.ServiceController.start(ServiceController.java:397)
> > at java.lang.reflect.Method.invoke(Native Method)
> > at
> > org.jboss.mx.capability.ReflectedMBeanDispatcher.invoke(ReflectedM
> > BeanDispatcher.java:284)
> > at
> > org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:517)
> > at org.jboss.util.jmx.MBeanProxy.invoke(MBeanProxy.java:174)
> > at $Proxy3.start(Unknown Source)
> > at org.jboss.deployment.SARDeployer.start(SARDeployer.java:249)
> > at org.jboss.deployment.MainDeployer.start(MainDeployer.java:802)
> > at org.jboss.deployment.MainDeployer.deploy(MainDeployer.java:616)
> > at org.jboss.deployment.MainDeployer.deploy(MainDeployer.java:580)
> > at org.jboss.deployment.MainDeployer.deploy(MainDeployer.java:564)
> > at java.lang.reflect.Method.invoke(Native Method)
> > at
> > org.jboss.mx.capability.ReflectedMBeanDispatcher.invoke(ReflectedM
> > BeanDispatcher.java:284)
> > at
> > org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:517)
> > at org.jboss.system.server.ServerImpl.doStart(ServerImpl.java:324)
> > at org.jboss.system.server.ServerImpl.start(ServerImpl.java:221)
> > at org.jboss.Main.boot(Main.java:148)
> > at org.jboss.Main$1.run(Main.java:381)
> > at java.lang.Thread.run(Thread.java:512)
> >
> > _______________________________________________
> > Barracuda mailing list
> > [email protected]
> > http://www.enhydra.org/mailman/listinfo.cgi/barracuda
> > FAQ - http://www.jguru.com/faq/Barracuda
>
>_______________________________________________
>Barracuda mailing list
>[email protected]
>http://www.enhydra.org/mailman/listinfo.cgi/barracuda
>FAQ - http://www.jguru.com/faq/Barracuda