You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@avalon.apache.org by Jan Stary <js...@artax.karlin.mff.cuni.cz> on 2002/01/10 17:25:33 UTC
ExcaliburComponentManager.configure() throws NUllPointerException
Hi list,
when going through the examples in 'Developing with Avalon'
I got stuck with $SUBJ. The following jsp page ...
<jsp:useBean id="container" scope="application"
class="org.apache.bizserver.docs.ContainerComponent"/>
initializing container: <% container.initialize();%> done
... gives the following result:
java.lang.NullPointerException
at org.apache.avalon.excalibur.component.ExcaliburComponentManager.configure(ExcaliburComponentManager.java:378)
at org.apache.bizserver.docs.ContainerComponent.initialize(ContainerComponent.java:23)
The call actually does
public void initialize() throws Exception {
DefaultConfigurationBuilder builder = new
DefaultConfigurationBuilder();
Configuration sysConfig = builder.buildFromFile(
"/home/hans/casopis/system.xml");
this.manager.contextualize(new DefaultContext());
this.manager.configure(sysConfig);
this.manager.initialize();
}
The evil happens in the configure() call - when commented out,
it works, except the components are not configured, of course :-)
Could this be due to errors in system.xml? It's copied directly
from DwAA:
<my-system>
<component
role="org.apache.avalon.excalibur.datasource.DataSourceComponentSelector"
class="org.apache.avalon.excalibur.component.ExcaliburComponentSelector">
<component-instance name="documents"
class="org.apache.avalon.excalibur.datasource.JdbcDataSource">
<pool-controller min="5" max="10"/>
<auto-commit>false</auto-commit>
<driver>org.mysql.MySqlDriver</driver>
<dburl>jdbc:mysql:localhost/mydb</dburl>
<user>test</user>
<password>test</password>
</component-instance>
<component-instance name="security"
class="org.apache.avalon.excalibur.datasource.JdbcDataSource">
<pool-controller min="5" max="10"/>
<auto-commit>false</auto-commit>
<driver>org.mysql.MySqlDriver</driver>
<dburl>jdbc:mysql:localhost/myotherdb</dburl>
<user>test</user>
<password>test</password>
</component-instance>
</component>
<component
role="org.apache.bizserver.docs.DocumentRepository"
class="org.apache.bizserver.docs.DatabaseDocumentRepository">
<dbpool>documents</dbpool>
</component>
<component
role="org.apache.bizserver.docs.GuardianComponent"
class="org.apache.bizserver.docs.DocumentGuardianComponent">
<dbpool>security</dbpool>
<policy file="/home/system/document.policy"/>
</component>
</my-system>
Or is it because something else? I don't expect Excalibur actually
tests the db connection when parsing the file, so the meaningless
'myotherdb' etc should matter.
Thanks a lot.
Jan
--
To unsubscribe, e-mail: <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>
File "null" not found
Posted by Jan Stary <js...@artax.karlin.mff.cuni.cz>.
Hello druzja,
the following code in ContainerComponent
(still referring ti the white paper) ...
-- cut ----------------
public void initialize() throws Exception {
DefaultConfigurationBuilder builder = new DefaultConfigurationBuilder();
Configuration sysConfig = builder.buildFromFile(
"/home/hans/casopis/system.xml");
Configuration roleConfig =
builder.build(this.getClass().getClassLoader().
getResourceAsStream("/home/hans/casopis/roles.xml"));
//DefaultRoleManager roles = new DefaultRoleManager();
//roles.enableLogging(Hierarchy.getDefaultHierarchy().getLoggerFor(
// "/home/hans/casopis/roles.xml"));
//roles.configure(roleConfig);
this.manager.setLogger(Hierarchy.getDefaultHierarchy().
getLoggerFor("casopis"));
this.manager.contextualize(new DefaultContext());
//this.manager.setRoleManager(roles);
this.manager.configure(sysConfig);
this.manager.initialize();
}
-- cut ----------------
... compiles ok (the lines are commented out just
to locate the evil), but when visiting a page which calls
container.initialize(), I get
-- cut ---
javax.servlet.ServletException: File "null" not found.
at org.apache.jasper.runtime.PageContextImpl.handlePageException(PageContextImpl.java:457)
at org.apache.jsp.index$jsp._jspService(index$jsp.java:107)
at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:107)
etc ....
root cause
org.xml.sax.SAXParseException: File "null" not found.
at org.apache.xerces.framework.XMLParser.reportError(XMLParser.java:1202)
at org.apache.xerces.readers.DefaultEntityHandler.startReadingFromDocument(DefaultEntityHandler.java:499)
at org.apache.xerces.framework.XMLParser.parseSomeSetup(XMLParser.java:312)
etc ...
-- cut ---
Why does this happen? Which file can't be found? Or should I provide
a filename somewhere (and I don't)?
Thanks for any ideas
Jan
--
To unsubscribe, e-mail: <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>
Re: ExcaliburComponentManager.configure() throws NUllPointerException
Posted by Jeremias Maerki <je...@outline.ch>.
On Mon, 14 Jan 2002 18:15:19 +0100 Jan Stary wrote:
> On Jan 11 09:53:49, Berin Loritsch wrote:
> :Jan Stary wrote:
> :
> :> :public void initialize() throws Exception {
> :> : org.apache.log.Logger logger = Hierarchy.getDefaultHierarchy().
> :> : getLoggerFor("document");
> :> :
> :> : DefaultConfigurationBuilder builder = new DefaultConfigurationBuilder();
> :> : Configuration sysConfig = builder.buildFromFile(
> :> : "/home/hans/casopis/system.xml");
> :> : Configuration roleConfig =
> :> : builder.build(this.getClass().getClassLoader().getResourceAsStream(
> :> : "/home/hans/casopis/document.roles"));
> :> : DefaultRoleManager roles = new DefaultRoleManager();
> :> :
> :> : roles.enableLogging(new LogKitLogger( logger ));
> :> :
> :> : roles.configure(roleConfig);
> :> :
> :> : this.manager.setLogger(logger);
> :> :
> :> : this.manager.contextualize(new DefaultContext());
> :> : this.manager.setRoleManager(roles);
> :> : this.manager.configure(sysConfig);
> :> : this.manager.initialize();
> :> :}
> :>
> :> Well ... this doesn't compile (cannot resolve symbol LogKitLogger)
> :> - looking into org/apache/log, there is really no LogKitLogger,
> :> and it doesn't compile with 'new LogKit(logger)' neither
> :>
> :> It logkit.jar that comes vith excalibur 4.0b4
> :
> :
> :Try org.apache.avalon.framework.logger.LogKitLogger
> :That is where the new Logger abstraction stuff is.
> :
>
> I upgraded to all the most recent versions, but anyway, there is no
> enableLogging method in class DefaultRoleMAnager (which is what roles
> is an instance of)...
>
> Am I doing something wrong?
DefaultRoleManager is Loggable in the CVS. It's not yet LogEnabled.
Maybe Berin has modified it but not yet checked in. You will have to
change the line after the creation of DefaultRoleManager to:
roles.setLogger(logger);
Cheers,
Jeremias Märki
mailto:jeremias.maerki@outline.ch
OUTLINE AG
Postfach 3954 - Rhynauerstr. 15 - CH-6002 Luzern
Fon +41 (41) 317 2020 - Fax +41 (41) 317 2029
Internet http://www.outline.ch
--
To unsubscribe, e-mail: <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>
Re: ExcaliburComponentManager.configure() throws NUllPointerException
Posted by Jan Stary <js...@artax.karlin.mff.cuni.cz>.
On Jan 11 09:53:49, Berin Loritsch wrote:
:Jan Stary wrote:
:
:> :public void initialize() throws Exception {
:> : org.apache.log.Logger logger = Hierarchy.getDefaultHierarchy().
:> : getLoggerFor("document");
:> :
:> : DefaultConfigurationBuilder builder = new DefaultConfigurationBuilder();
:> : Configuration sysConfig = builder.buildFromFile(
:> : "/home/hans/casopis/system.xml");
:> : Configuration roleConfig =
:> : builder.build(this.getClass().getClassLoader().getResourceAsStream(
:> : "/home/hans/casopis/document.roles"));
:> : DefaultRoleManager roles = new DefaultRoleManager();
:> :
:> : roles.enableLogging(new LogKitLogger( logger ));
:> :
:> : roles.configure(roleConfig);
:> :
:> : this.manager.setLogger(logger);
:> :
:> : this.manager.contextualize(new DefaultContext());
:> : this.manager.setRoleManager(roles);
:> : this.manager.configure(sysConfig);
:> : this.manager.initialize();
:> :}
:>
:> Well ... this doesn't compile (cannot resolve symbol LogKitLogger)
:> - looking into org/apache/log, there is really no LogKitLogger,
:> and it doesn't compile with 'new LogKit(logger)' neither
:>
:> It logkit.jar that comes vith excalibur 4.0b4
:
:
:Try org.apache.avalon.framework.logger.LogKitLogger
:That is where the new Logger abstraction stuff is.
:
I upgraded to all the most recent versions, but anyway, there is no
enableLogging method in class DefaultRoleMAnager (which is what roles
is an instance of)...
Am I doing something wrong?
Thanks
Jan
--
To unsubscribe, e-mail: <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>
Re: ExcaliburComponentManager.configure() throws NUllPointerException
Posted by Jan Stary <js...@artax.karlin.mff.cuni.cz>.
:> :public void initialize() throws Exception {
:> : org.apache.log.Logger logger = Hierarchy.getDefaultHierarchy().
:> : getLoggerFor("document");
:> :
:> : DefaultConfigurationBuilder builder = new DefaultConfigurationBuilder();
:> : Configuration sysConfig = builder.buildFromFile(
:> : "/home/hans/casopis/system.xml");
:> : Configuration roleConfig =
:> : builder.build(this.getClass().getClassLoader().getResourceAsStream(
:> : "/home/hans/casopis/document.roles"));
:> : DefaultRoleManager roles = new DefaultRoleManager();
:> :
:> : roles.enableLogging(new LogKitLogger( logger ));
:> :
:> : roles.configure(roleConfig);
:> :
:> : this.manager.setLogger(logger);
:> :
:> : this.manager.contextualize(new DefaultContext());
:> : this.manager.setRoleManager(roles);
:> : this.manager.configure(sysConfig);
:> : this.manager.initialize();
:> :}
:>
:> Well ... this doesn't compile (cannot resolve symbol LogKitLogger)
:> - looking into org/apache/log, there is really no LogKitLogger,
:> and it doesn't compile with
:> new LogKit(logger)
:> neither
:>
:> It 's logkit.jar that comes vith excalibur 4.0b4
:
:
:Try org.apache.avalon.framework.logger.LogKitLogger
:That is where the new Logger abstraction stuff is.
I just got the latest Framework, so I got LogKitLogger,
but still the
roles.enableLogging()
doesn't compile. From who should (RefaultRoleManager)roles
inherit this method?
Thanks again for patience
Jan
--
To unsubscribe, e-mail: <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>
Re: ExcaliburComponentManager.configure() throws NUllPointerException
Posted by Berin Loritsch <bl...@apache.org>.
Jan Stary wrote:
> :public void initialize() throws Exception {
> : org.apache.log.Logger logger = Hierarchy.getDefaultHierarchy().
> : getLoggerFor("document");
> :
> : DefaultConfigurationBuilder builder = new DefaultConfigurationBuilder();
> : Configuration sysConfig = builder.buildFromFile(
> : "/home/hans/casopis/system.xml");
> : Configuration roleConfig =
> : builder.build(this.getClass().getClassLoader().getResourceAsStream(
> : "/home/hans/casopis/document.roles"));
> : DefaultRoleManager roles = new DefaultRoleManager();
> :
> : roles.enableLogging(new LogKitLogger( logger ));
> :
> : roles.configure(roleConfig);
> :
> : this.manager.setLogger(logger);
> :
> : this.manager.contextualize(new DefaultContext());
> : this.manager.setRoleManager(roles);
> : this.manager.configure(sysConfig);
> : this.manager.initialize();
> :}
>
> Well ... this doesn't compile (cannot resolve symbol LogKitLogger)
> - looking into org/apache/log, there is really no LogKitLogger,
> and it doesn't compile with
> new LogKit(logger)
> neither
>
> It logkit.jar that comes vith excalibur 4.0b4
Try org.apache.avalon.framework.logger.LogKitLogger
That is where the new Logger abstraction stuff is.
--
"They that give up essential liberty to obtain a little temporary safety
deserve neither liberty nor safety."
- Benjamin Franklin
--
To unsubscribe, e-mail: <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>
Re: ExcaliburComponentManager.configure() throws NUllPointerException
Posted by Jan Stary <js...@artax.karlin.mff.cuni.cz>.
:public void initialize() throws Exception {
: org.apache.log.Logger logger = Hierarchy.getDefaultHierarchy().
: getLoggerFor("document");
:
: DefaultConfigurationBuilder builder = new DefaultConfigurationBuilder();
: Configuration sysConfig = builder.buildFromFile(
: "/home/hans/casopis/system.xml");
: Configuration roleConfig =
: builder.build(this.getClass().getClassLoader().getResourceAsStream(
: "/home/hans/casopis/document.roles"));
: DefaultRoleManager roles = new DefaultRoleManager();
:
: roles.enableLogging(new LogKitLogger( logger ));
:
: roles.configure(roleConfig);
:
: this.manager.setLogger(logger);
:
: this.manager.contextualize(new DefaultContext());
: this.manager.setRoleManager(roles);
: this.manager.configure(sysConfig);
: this.manager.initialize();
:}
Well ... this doesn't compile (cannot resolve symbol LogKitLogger)
- looking into org/apache/log, there is really no LogKitLogger,
and it doesn't compile with
new LogKit(logger)
neither
It logkit.jar that comes vith excalibur 4.0b4
Any help appreciated.
Jan
--
To unsubscribe, e-mail: <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>
Re: ExcaliburComponentManager.configure() throws NUllPointerException
Posted by Berin Loritsch <bl...@apache.org>.
Jan Stary wrote:
> Thanks! continuing ...
>
<snip/>
> but when compiling it says
>
>
> [javac] /home/hans/casopis/src/org/apache/bizserver/docs/ContainerComponent.java:25: cannot resolve symbol
> [javac] symbol : method enableLogging (org.apache.log.Logger)
> [javac] location: class org.apache.avalon.excalibur.component.DefaultRoleManager
> [javac] roles.enableLogging(Hierarchy.getDefaultHierarchy().getLoggerFor(
> [javac] ^
> [javac] 1 error
>
>
> I suppose I don't "have already set up my LogKit Logger" - how do I do that,
> please?
Avalon Framework is migrating to the LogEnabled interface with the Logger abstraction.
That way, you are not bound to any one Logging package, and as you logging needs change,
you can still build your project with Avalon. Because ExcaliburComponentManager must remain
backwards compatible, it must use the legacy Loggable interface.
The RoleManager is LogEnabled, and now that I think about it, it was premature to move
that just yet.
For LogEnabled classes, you would wrap the logging package logger with one of the wrappers
supplied in Avalon. That means your code for your example would be like this:
public void initialize() throws Exception {
org.apache.log.Logger logger = Hierarchy.getDefaultHierarchy().
getLoggerFor("document");
DefaultConfigurationBuilder builder = new DefaultConfigurationBuilder();
Configuration sysConfig = builder.buildFromFile(
"/home/hans/casopis/system.xml");
Configuration roleConfig =
builder.build(this.getClass().getClassLoader().getResourceAsStream(
"/home/hans/casopis/document.roles"));
DefaultRoleManager roles = new DefaultRoleManager();
roles.enableLogging(new LogKitLogger( logger ));
roles.configure(roleConfig);
this.manager.setLogger(logger);
this.manager.contextualize(new DefaultContext());
this.manager.setRoleManager(roles);
this.manager.configure(sysConfig);
this.manager.initialize();
}
I am working on a replacement that is LogEnabled clean so there is no mixture.
--
"They that give up essential liberty to obtain a little temporary safety
deserve neither liberty nor safety."
- Benjamin Franklin
--
To unsubscribe, e-mail: <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>
Re: ExcaliburComponentManager.configure() throws NUllPointerException
Posted by Jan Stary <js...@artax.karlin.mff.cuni.cz>.
Thanks! continuing ...
:> public void initialize() throws Exception {
:> DefaultConfigurationBuilder builder = new
:> DefaultConfigurationBuilder();
:> Configuration sysConfig = builder.buildFromFile(
:> "/home/hans/casopis/system.xml");
:>
:> this.manager.contextualize(new DefaultContext());
:> this.manager.configure(sysConfig);
:> this.manager.initialize();
:> }
:
:
:The ExcaliburComponentManager is Loggable, and the configure() method uses the
:logger that was supposed to be given to it.
:Before contextualize() you should have done this:
:this.manager.setLogger( getLogger() );
:Of course, that assumes you have already set up your LogKit Logger.
Now my container.initialize() looks like this:
(as in DwAA)
public void initialize() throws Exception {
DefaultConfigurationBuilder builder = new DefaultConfigurationBuilder();
Configuration sysConfig = builder.buildFromFile(
"/home/hans/casopis/system.xml");
Configuration roleConfig =
builder.build(this.getClass().getClassLoader().getResourceAsStream(
"/home/hans/casopis/document.roles"));
DefaultRoleManager roles = new DefaultRoleManager();
roles.enableLogging(Hierarchy.getDefaultHierarchy().getLoggerFor(
"/home/hans/casopis/document.roles"));
roles.configure(roleConfig);
this.manager.setLogger(Hierarchy.getDefaultHierarchy().
getLoggerFor("document"));
this.manager.contextualize(new DefaultContext());
this.manager.setRoleManager(roles);
this.manager.configure(sysConfig);
this.manager.initialize();
}
but when compiling it says
[javac] /home/hans/casopis/src/org/apache/bizserver/docs/ContainerComponent.java:25: cannot resolve symbol
[javac] symbol : method enableLogging (org.apache.log.Logger)
[javac] location: class org.apache.avalon.excalibur.component.DefaultRoleManager
[javac] roles.enableLogging(Hierarchy.getDefaultHierarchy().getLoggerFor(
[javac] ^
[javac] 1 error
I suppose I don't "have already set up my LogKit Logger" - how do I do that,
please?
Does this have something to do with the fact that I do
this.manager.setLogger(Hierarchy.getDefaultHierarchy().getLoggerFor("document"));
instead of
this.manager.setLogger( getLogger() );
?
Thanks again
Jan
--
To unsubscribe, e-mail: <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>
Re: ExcaliburComponentManager.configure() throws NUllPointerException
Posted by Berin Loritsch <bl...@apache.org>.
Jan Stary wrote:
> Hi list,
>
> when going through the examples in 'Developing with Avalon'
> I got stuck with $SUBJ. The following jsp page ...
>
> <jsp:useBean id="container" scope="application"
> class="org.apache.bizserver.docs.ContainerComponent"/>
>
> initializing container: <% container.initialize();%> done
>
> ... gives the following result:
>
> java.lang.NullPointerException
> at org.apache.avalon.excalibur.component.ExcaliburComponentManager.configure(ExcaliburComponentManager.java:378)
> at org.apache.bizserver.docs.ContainerComponent.initialize(ContainerComponent.java:23)
>
> The call actually does
>
> public void initialize() throws Exception {
> DefaultConfigurationBuilder builder = new
> DefaultConfigurationBuilder();
> Configuration sysConfig = builder.buildFromFile(
> "/home/hans/casopis/system.xml");
>
> this.manager.contextualize(new DefaultContext());
> this.manager.configure(sysConfig);
> this.manager.initialize();
> }
The ExcaliburComponentManager is Loggable, and the configure() method uses the logger that was
supposed to be given to it.
Before contextualize() you should have done this:
this.manager.setLogger( getLogger() );
Of course, that assumes you have already set up your LogKit Logger.
> The evil happens in the configure() call - when commented out,
> it works, except the components are not configured, of course :-)
>
> Could this be due to errors in system.xml? It's copied directly
> from DwAA:
>
> <my-system>
> <component
> role="org.apache.avalon.excalibur.datasource.DataSourceComponentSelector"
> class="org.apache.avalon.excalibur.component.ExcaliburComponentSelector">
> <component-instance name="documents"
> class="org.apache.avalon.excalibur.datasource.JdbcDataSource">
> <pool-controller min="5" max="10"/>
> <auto-commit>false</auto-commit>
> <driver>org.mysql.MySqlDriver</driver>
> <dburl>jdbc:mysql:localhost/mydb</dburl>
> <user>test</user>
> <password>test</password>
> </component-instance>
> <component-instance name="security"
> class="org.apache.avalon.excalibur.datasource.JdbcDataSource">
> <pool-controller min="5" max="10"/>
> <auto-commit>false</auto-commit>
> <driver>org.mysql.MySqlDriver</driver>
> <dburl>jdbc:mysql:localhost/myotherdb</dburl>
> <user>test</user>
> <password>test</password>
> </component-instance>
> </component>
> <component
> role="org.apache.bizserver.docs.DocumentRepository"
> class="org.apache.bizserver.docs.DatabaseDocumentRepository">
> <dbpool>documents</dbpool>
> </component>
> <component
> role="org.apache.bizserver.docs.GuardianComponent"
> class="org.apache.bizserver.docs.DocumentGuardianComponent">
> <dbpool>security</dbpool>
> <policy file="/home/system/document.policy"/>
> </component>
> </my-system>
>
> Or is it because something else? I don't expect Excalibur actually
> tests the db connection when parsing the file, so the meaningless
> 'myotherdb' etc should matter.
--
"They that give up essential liberty to obtain a little temporary safety
deserve neither liberty nor safety."
- Benjamin Franklin
--
To unsubscribe, e-mail: <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>