[xwiki-devs] Problem obtaining external URL from XWikiDocument in servlet deployment
Hi, I'm writing an indexer plugin for XWiki and recently found a problem when trying to obtain the external document url: java.lang.NullPointerException at com.xpn.xwiki.XWiki.getServletPath(XWiki.java:4317) at com .xpn .xwiki .web.XWikiServletURLFactory.addServletPath(XWikiServletURLFactory.java: 208) at com .xpn .xwiki .web.XWikiServletURLFactory.createURL(XWikiServletURLFactory.java:178) at com .xpn .xwiki .web .XWikiServletURLFactory.createExternalURL(XWikiServletURLFactory.java: 273) at com.xpn.xwiki.doc.XWikiDocument.getExternalURL(XWikiDocument.java: 925) at com .kontrast .vodafone .portal .xwiki.plugins.indexer.IndexUpdater.runMainLoop(IndexUpdater.java:180) at com .kontrast .vodafone .portal.xwiki.plugins.indexer.IndexUpdater.run(IndexUpdater.java:116) I updated to XWiki version 1.7-SNAPSHOT recently. Before that I didn't experience this. Can anyone shed some light on this? Thanks, J.L.Simon
*bump* On 16.12.2008, at 13:09, Juergen Lorenz Simon wrote:
Hi,
I'm writing an indexer plugin for XWiki and recently found a problem when trying to obtain the external document url:
java.lang.NullPointerException at com.xpn.xwiki.XWiki.getServletPath(XWiki.java:4317) at com .xpn .xwiki .web .XWikiServletURLFactory.addServletPath(XWikiServletURLFactory.java: 208) at com .xpn .xwiki .web.XWikiServletURLFactory.createURL(XWikiServletURLFactory.java:178) at com .xpn .xwiki .web .XWikiServletURLFactory.createExternalURL(XWikiServletURLFactory.java: 273) at com.xpn.xwiki.doc.XWikiDocument.getExternalURL(XWikiDocument.java: 925) at com .kontrast .vodafone .portal .xwiki.plugins.indexer.IndexUpdater.runMainLoop(IndexUpdater.java:180) at com .kontrast .vodafone .portal.xwiki.plugins.indexer.IndexUpdater.run(IndexUpdater.java:116)
I updated to XWiki version 1.7-SNAPSHOT recently. Before that I didn't experience this. Can anyone shed some light on this?
Thanks, J.L.Simon _______________________________________________ devs mailing list [email protected] http://lists.xwiki.org/mailman/listinfo/devs
Hi, Is your indexer running in it's own thread ? In that case the problem is that when you ask for URL XWiki need the current URL for some informations it does not have in its configuration like the current host or protocol or even the port to be able to recreate the URL as expected. Are you sure it worked fine in 1.6 ? On Tue, Dec 16, 2008 at 1:09 PM, Juergen Lorenz Simon <[email protected]> wrote:
Hi,
I'm writing an indexer plugin for XWiki and recently found a problem when trying to obtain the external document url:
java.lang.NullPointerException at com.xpn.xwiki.XWiki.getServletPath(XWiki.java:4317) at com .xpn .xwiki .web.XWikiServletURLFactory.addServletPath(XWikiServletURLFactory.java: 208) at com .xpn .xwiki .web.XWikiServletURLFactory.createURL(XWikiServletURLFactory.java:178) at com .xpn .xwiki .web .XWikiServletURLFactory.createExternalURL(XWikiServletURLFactory.java: 273) at com.xpn.xwiki.doc.XWikiDocument.getExternalURL(XWikiDocument.java: 925) at com .kontrast .vodafone .portal .xwiki.plugins.indexer.IndexUpdater.runMainLoop(IndexUpdater.java:180) at com .kontrast .vodafone .portal.xwiki.plugins.indexer.IndexUpdater.run(IndexUpdater.java:116)
I updated to XWiki version 1.7-SNAPSHOT recently. Before that I didn't experience this. Can anyone shed some light on this?
Thanks, J.L.Simon _______________________________________________ devs mailing list [email protected] http://lists.xwiki.org/mailman/listinfo/devs
-- Thomas Mortagne
I looked a little closely and there is something weird, there is a request in your XWikiContext but it does not return any servlet path according to your stack trace. If it's running in it's own thread how do you create the XWikiContext ? On Thu, Dec 18, 2008 at 1:40 PM, Thomas Mortagne <[email protected]> wrote:
Hi,
Is your indexer running in it's own thread ?
In that case the problem is that when you ask for URL XWiki need the current URL for some informations it does not have in its configuration like the current host or protocol or even the port to be able to recreate the URL as expected.
Are you sure it worked fine in 1.6 ?
On Tue, Dec 16, 2008 at 1:09 PM, Juergen Lorenz Simon <[email protected]> wrote:
Hi,
I'm writing an indexer plugin for XWiki and recently found a problem when trying to obtain the external document url:
java.lang.NullPointerException at com.xpn.xwiki.XWiki.getServletPath(XWiki.java:4317) at com .xpn .xwiki .web.XWikiServletURLFactory.addServletPath(XWikiServletURLFactory.java: 208) at com .xpn .xwiki .web.XWikiServletURLFactory.createURL(XWikiServletURLFactory.java:178) at com .xpn .xwiki .web .XWikiServletURLFactory.createExternalURL(XWikiServletURLFactory.java: 273) at com.xpn.xwiki.doc.XWikiDocument.getExternalURL(XWikiDocument.java: 925) at com .kontrast .vodafone .portal .xwiki.plugins.indexer.IndexUpdater.runMainLoop(IndexUpdater.java:180) at com .kontrast .vodafone .portal.xwiki.plugins.indexer.IndexUpdater.run(IndexUpdater.java:116)
I updated to XWiki version 1.7-SNAPSHOT recently. Before that I didn't experience this. Can anyone shed some light on this?
Thanks, J.L.Simon _______________________________________________ devs mailing list [email protected] http://lists.xwiki.org/mailman/listinfo/devs
-- Thomas Mortagne
-- Thomas Mortagne
Hi Thomas, no, I do not create a context myself. I'm running this in Eclipse though. Could querying the servlet context cause this problem? We have a class that is supposed to resolve properties and stuff from the web.xml file, and it creates an InitialContext (jndi) for lookups: InitialContext jndiContext = new InitialContext(); Object prop = jndiContext.lookup("java:comp/env/someprop"); but it would seem far fetched that this would cause trouble, or? And the only other change since the last time it worked was migrating to 1.7. On 18.12.2008, at 13:44, Thomas Mortagne wrote:
I looked a little closely and there is something weird, there is a request in your XWikiContext but it does not return any servlet path according to your stack trace.
If it's running in it's own thread how do you create the XWikiContext ?
On Thu, Dec 18, 2008 at 1:40 PM, Thomas Mortagne <[email protected]> wrote:
Hi,
Is your indexer running in it's own thread ?
In that case the problem is that when you ask for URL XWiki need the current URL for some informations it does not have in its configuration like the current host or protocol or even the port to be able to recreate the URL as expected.
Are you sure it worked fine in 1.6 ?
On Tue, Dec 16, 2008 at 1:09 PM, Juergen Lorenz Simon <[email protected]
wrote: Hi,
I'm writing an indexer plugin for XWiki and recently found a problem when trying to obtain the external document url:
java.lang.NullPointerException at com.xpn.xwiki.XWiki.getServletPath(XWiki.java:4317) at com .xpn .xwiki .web .XWikiServletURLFactory.addServletPath(XWikiServletURLFactory.java: 208) at com .xpn .xwiki .web.XWikiServletURLFactory.createURL(XWikiServletURLFactory.java: 178) at com .xpn .xwiki .web .XWikiServletURLFactory .createExternalURL(XWikiServletURLFactory.java: 273) at com.xpn.xwiki.doc.XWikiDocument.getExternalURL(XWikiDocument.java: 925) at com .kontrast .vodafone .portal .xwiki.plugins.indexer.IndexUpdater.runMainLoop(IndexUpdater.java: 180) at com .kontrast .vodafone .portal.xwiki.plugins.indexer.IndexUpdater.run(IndexUpdater.java: 116)
I updated to XWiki version 1.7-SNAPSHOT recently. Before that I didn't experience this. Can anyone shed some light on this?
Thanks, J.L.Simon _______________________________________________ devs mailing list [email protected] http://lists.xwiki.org/mailman/listinfo/devs
-- Thomas Mortagne
-- Thomas Mortagne _______________________________________________ devs mailing list [email protected] http://lists.xwiki.org/mailman/listinfo/devs
On Thu, Dec 18, 2008 at 1:54 PM, Juergen Lorenz Simon <[email protected]> wrote:
Hi Thomas,
no, I do not create a context myself. I'm running this in Eclipse
But where do you get the XWikiContext you give to createExternalURL() ?
though. Could querying the servlet context cause this problem? We have a class that is supposed to resolve properties and stuff from the web.xml file, and it creates an InitialContext (jndi) for lookups:
InitialContext jndiContext = new InitialContext(); Object prop = jndiContext.lookup("java:comp/env/someprop");
but it would seem far fetched that this would cause trouble, or? And the only other change since the last time it worked was migrating to 1.7.
On 18.12.2008, at 13:44, Thomas Mortagne wrote:
I looked a little closely and there is something weird, there is a request in your XWikiContext but it does not return any servlet path according to your stack trace.
If it's running in it's own thread how do you create the XWikiContext ?
On Thu, Dec 18, 2008 at 1:40 PM, Thomas Mortagne <[email protected]> wrote:
Hi,
Is your indexer running in it's own thread ?
In that case the problem is that when you ask for URL XWiki need the current URL for some informations it does not have in its configuration like the current host or protocol or even the port to be able to recreate the URL as expected.
Are you sure it worked fine in 1.6 ?
On Tue, Dec 16, 2008 at 1:09 PM, Juergen Lorenz Simon <[email protected]
wrote: Hi,
I'm writing an indexer plugin for XWiki and recently found a problem when trying to obtain the external document url:
java.lang.NullPointerException at com.xpn.xwiki.XWiki.getServletPath(XWiki.java:4317) at com .xpn .xwiki .web .XWikiServletURLFactory.addServletPath(XWikiServletURLFactory.java: 208) at com .xpn .xwiki .web.XWikiServletURLFactory.createURL(XWikiServletURLFactory.java: 178) at com .xpn .xwiki .web .XWikiServletURLFactory .createExternalURL(XWikiServletURLFactory.java: 273) at com.xpn.xwiki.doc.XWikiDocument.getExternalURL(XWikiDocument.java: 925) at com .kontrast .vodafone .portal .xwiki.plugins.indexer.IndexUpdater.runMainLoop(IndexUpdater.java: 180) at com .kontrast .vodafone .portal.xwiki.plugins.indexer.IndexUpdater.run(IndexUpdater.java: 116)
I updated to XWiki version 1.7-SNAPSHOT recently. Before that I didn't experience this. Can anyone shed some light on this?
Thanks, J.L.Simon _______________________________________________ devs mailing list [email protected] http://lists.xwiki.org/mailman/listinfo/devs
-- Thomas Mortagne
-- Thomas Mortagne _______________________________________________ devs mailing list [email protected] http://lists.xwiki.org/mailman/listinfo/devs
_______________________________________________ devs mailing list [email protected] http://lists.xwiki.org/mailman/listinfo/devs
-- Thomas Mortagne
Hi, On 18.12.2008, at 14:37, Thomas Mortagne wrote:
On Thu, Dec 18, 2008 at 1:54 PM, Juergen Lorenz Simon <[email protected]
wrote: Hi Thomas,
no, I do not create a context myself. I'm running this in Eclipse
But where do you get the XWikiContext you give to createExternalURL() ?
When the indexing plugin is instantiated I grab the context: public IndexUpdater(XWiki wiki, XWikiContext context) { this.xwiki = wiki; this.context = context; } Which is obtained from XWiki at plugin initialization time: public void init(XWikiContext context) { ... // initialize the actual plugin indexUpdater = new IndexUpdater(context.getWiki(), context); indexUpdater.start(); // Hook into the document change notifications DocChangeRule docChangeRule = new DocChangeRule(indexUpdater); context .getWiki().getNotificationManager().addGeneralRule(docChangeRule); } Do you think I should use the context that comes in the notify() method instead?
though. Could querying the servlet context cause this problem? We have a class that is supposed to resolve properties and stuff from the web.xml file, and it creates an InitialContext (jndi) for lookups:
InitialContext jndiContext = new InitialContext(); Object prop = jndiContext.lookup("java:comp/env/someprop");
but it would seem far fetched that this would cause trouble, or? And the only other change since the last time it worked was migrating to 1.7.
On 18.12.2008, at 13:44, Thomas Mortagne wrote:
I looked a little closely and there is something weird, there is a request in your XWikiContext but it does not return any servlet path according to your stack trace.
If it's running in it's own thread how do you create the XWikiContext ?
On Thu, Dec 18, 2008 at 1:40 PM, Thomas Mortagne <[email protected]> wrote:
Hi,
Is your indexer running in it's own thread ?
In that case the problem is that when you ask for URL XWiki need the current URL for some informations it does not have in its configuration like the current host or protocol or even the port to be able to recreate the URL as expected.
Are you sure it worked fine in 1.6 ?
On Tue, Dec 16, 2008 at 1:09 PM, Juergen Lorenz Simon <[email protected]
wrote: Hi,
I'm writing an indexer plugin for XWiki and recently found a problem when trying to obtain the external document url:
java.lang.NullPointerException at com.xpn.xwiki.XWiki.getServletPath(XWiki.java:4317) at com .xpn .xwiki .web .XWikiServletURLFactory .addServletPath(XWikiServletURLFactory.java: 208) at com .xpn .xwiki .web.XWikiServletURLFactory.createURL(XWikiServletURLFactory.java: 178) at com .xpn .xwiki .web .XWikiServletURLFactory .createExternalURL(XWikiServletURLFactory.java: 273) at com.xpn.xwiki.doc.XWikiDocument.getExternalURL(XWikiDocument.java: 925) at com .kontrast .vodafone .portal .xwiki.plugins.indexer.IndexUpdater.runMainLoop(IndexUpdater.java: 180) at com .kontrast .vodafone .portal.xwiki.plugins.indexer.IndexUpdater.run(IndexUpdater.java: 116)
I updated to XWiki version 1.7-SNAPSHOT recently. Before that I didn't experience this. Can anyone shed some light on this?
Thanks, J.L.Simon _______________________________________________ devs mailing list [email protected] http://lists.xwiki.org/mailman/listinfo/devs
-- Thomas Mortagne
-- Thomas Mortagne _______________________________________________ devs mailing list [email protected] http://lists.xwiki.org/mailman/listinfo/devs
_______________________________________________ devs mailing list [email protected] http://lists.xwiki.org/mailman/listinfo/devs
-- Thomas Mortagne _______________________________________________ devs mailing list [email protected] http://lists.xwiki.org/mailman/listinfo/devs
On Thu, Dec 18, 2008 at 3:03 PM, Juergen Lorenz Simon <[email protected]> wrote:
Hi,
On 18.12.2008, at 14:37, Thomas Mortagne wrote:
On Thu, Dec 18, 2008 at 1:54 PM, Juergen Lorenz Simon <[email protected]
wrote: Hi Thomas,
no, I do not create a context myself. I'm running this in Eclipse
But where do you get the XWikiContext you give to createExternalURL() ?
When the indexing plugin is instantiated I grab the context:
public IndexUpdater(XWiki wiki, XWikiContext context) { this.xwiki = wiki; this.context = context; }
Which is obtained from XWiki at plugin initialization time:
public void init(XWikiContext context) { ... // initialize the actual plugin indexUpdater = new IndexUpdater(context.getWiki(), context); indexUpdater.start();
// Hook into the document change notifications DocChangeRule docChangeRule = new DocChangeRule(indexUpdater);
context .getWiki().getNotificationManager().addGeneralRule(docChangeRule); }
Do you think I should use the context that comes in the notify() method instead?
No need, even if it's cleaner but it should be exactly the same java object I think, so I don't understand why your context's request object is wrong. Could you send you full stack trace ?
though. Could querying the servlet context cause this problem? We have a class that is supposed to resolve properties and stuff from the web.xml file, and it creates an InitialContext (jndi) for lookups:
InitialContext jndiContext = new InitialContext(); Object prop = jndiContext.lookup("java:comp/env/someprop");
but it would seem far fetched that this would cause trouble, or? And the only other change since the last time it worked was migrating to 1.7.
On 18.12.2008, at 13:44, Thomas Mortagne wrote:
I looked a little closely and there is something weird, there is a request in your XWikiContext but it does not return any servlet path according to your stack trace.
If it's running in it's own thread how do you create the XWikiContext ?
On Thu, Dec 18, 2008 at 1:40 PM, Thomas Mortagne <[email protected]> wrote:
Hi,
Is your indexer running in it's own thread ?
In that case the problem is that when you ask for URL XWiki need the current URL for some informations it does not have in its configuration like the current host or protocol or even the port to be able to recreate the URL as expected.
Are you sure it worked fine in 1.6 ?
On Tue, Dec 16, 2008 at 1:09 PM, Juergen Lorenz Simon <[email protected]
wrote: Hi,
I'm writing an indexer plugin for XWiki and recently found a problem when trying to obtain the external document url:
java.lang.NullPointerException at com.xpn.xwiki.XWiki.getServletPath(XWiki.java:4317) at com .xpn .xwiki .web .XWikiServletURLFactory .addServletPath(XWikiServletURLFactory.java: 208) at com .xpn .xwiki .web.XWikiServletURLFactory.createURL(XWikiServletURLFactory.java: 178) at com .xpn .xwiki .web .XWikiServletURLFactory .createExternalURL(XWikiServletURLFactory.java: 273) at com.xpn.xwiki.doc.XWikiDocument.getExternalURL(XWikiDocument.java: 925) at com .kontrast .vodafone .portal .xwiki.plugins.indexer.IndexUpdater.runMainLoop(IndexUpdater.java: 180) at com .kontrast .vodafone .portal.xwiki.plugins.indexer.IndexUpdater.run(IndexUpdater.java: 116)
I updated to XWiki version 1.7-SNAPSHOT recently. Before that I didn't experience this. Can anyone shed some light on this?
Thanks, J.L.Simon _______________________________________________ devs mailing list [email protected] http://lists.xwiki.org/mailman/listinfo/devs
-- Thomas Mortagne
-- Thomas Mortagne _______________________________________________ devs mailing list [email protected] http://lists.xwiki.org/mailman/listinfo/devs
_______________________________________________ devs mailing list [email protected] http://lists.xwiki.org/mailman/listinfo/devs
-- Thomas Mortagne _______________________________________________ devs mailing list [email protected] http://lists.xwiki.org/mailman/listinfo/devs
_______________________________________________ devs mailing list [email protected] http://lists.xwiki.org/mailman/listinfo/devs
-- Thomas Mortagne
Hi, On 18.12.2008, at 15:08, Thomas Mortagne wrote:
On Thu, Dec 18, 2008 at 3:03 PM, Juergen Lorenz Simon <[email protected]
wrote: Hi,
On 18.12.2008, at 14:37, Thomas Mortagne wrote:
On Thu, Dec 18, 2008 at 1:54 PM, Juergen Lorenz Simon <[email protected]
wrote: Hi Thomas,
no, I do not create a context myself. I'm running this in Eclipse
But where do you get the XWikiContext you give to createExternalURL() ?
When the indexing plugin is instantiated I grab the context:
public IndexUpdater(XWiki wiki, XWikiContext context) { this.xwiki = wiki; this.context = context; }
Which is obtained from XWiki at plugin initialization time:
public void init(XWikiContext context) { ... // initialize the actual plugin indexUpdater = new IndexUpdater(context.getWiki(), context); indexUpdater.start();
// Hook into the document change notifications DocChangeRule docChangeRule = new DocChangeRule(indexUpdater);
context .getWiki().getNotificationManager().addGeneralRule(docChangeRule); }
Do you think I should use the context that comes in the notify() method instead?
No need, even if it's cleaner but it should be exactly the same java object I think, so I don't understand why your context's request object is wrong. Could you send you full stack trace ?
Of course. But it's exactly as it was: java.lang.NullPointerException at com.xpn.xwiki.XWiki.getServletPath(XWiki.java:4317) at com .xpn .xwiki .web.XWikiServletURLFactory.addServletPath(XWikiServletURLFactory.java: 208) at com .xpn .xwiki .web.XWikiServletURLFactory.createURL(XWikiServletURLFactory.java:178) at com.xpn.xwiki.doc.XWikiDocument.getURL(XWikiDocument.java:884) at com.xpn.xwiki.doc.XWikiDocument.getURL(XWikiDocument.java:898) at com.xpn.xwiki.doc.XWikiDocument.getURL(XWikiDocument.java:903) at com .kontrast .vodafone .portal .xwiki.plugins.indexer.IndexUpdater.runMainLoop(IndexUpdater.java:192) at com .kontrast .vodafone .portal.xwiki.plugins.indexer.IndexUpdater.run(IndexUpdater.java:118) this fails also, well, it returns null: String currentServletpath = context.getRequest().getServletPath(); any more ideas? We need the external URL so we can point to Wiki pages from the index. I could maybe wing it together by constructing the url in some other way, using the host name from confifuration and some elaborated guessing on the URL, but that would be brittle and unpleasant to maintain. J.
On Thu, Dec 18, 2008 at 5:38 PM, Juergen Lorenz Simon <[email protected]> wrote:
Hi,
On 18.12.2008, at 15:08, Thomas Mortagne wrote:
On Thu, Dec 18, 2008 at 3:03 PM, Juergen Lorenz Simon <[email protected]
wrote: Hi,
On 18.12.2008, at 14:37, Thomas Mortagne wrote:
On Thu, Dec 18, 2008 at 1:54 PM, Juergen Lorenz Simon <[email protected]
wrote: Hi Thomas,
no, I do not create a context myself. I'm running this in Eclipse
But where do you get the XWikiContext you give to createExternalURL() ?
When the indexing plugin is instantiated I grab the context:
public IndexUpdater(XWiki wiki, XWikiContext context) { this.xwiki = wiki; this.context = context; }
Which is obtained from XWiki at plugin initialization time:
public void init(XWikiContext context) { ... // initialize the actual plugin indexUpdater = new IndexUpdater(context.getWiki(), context); indexUpdater.start();
// Hook into the document change notifications DocChangeRule docChangeRule = new DocChangeRule(indexUpdater);
context .getWiki().getNotificationManager().addGeneralRule(docChangeRule); }
Do you think I should use the context that comes in the notify() method instead?
No need, even if it's cleaner but it should be exactly the same java object I think, so I don't understand why your context's request object is wrong. Could you send you full stack trace ?
Of course. But it's exactly as it was:
java.lang.NullPointerException at com.xpn.xwiki.XWiki.getServletPath(XWiki.java:4317) at com .xpn .xwiki .web.XWikiServletURLFactory.addServletPath(XWikiServletURLFactory.java: 208) at com .xpn .xwiki .web.XWikiServletURLFactory.createURL(XWikiServletURLFactory.java:178) at com.xpn.xwiki.doc.XWikiDocument.getURL(XWikiDocument.java:884) at com.xpn.xwiki.doc.XWikiDocument.getURL(XWikiDocument.java:898) at com.xpn.xwiki.doc.XWikiDocument.getURL(XWikiDocument.java:903) at com .kontrast .vodafone .portal .xwiki.plugins.indexer.IndexUpdater.runMainLoop(IndexUpdater.java:192) at com .kontrast .vodafone .portal.xwiki.plugins.indexer.IndexUpdater.run(IndexUpdater.java:118)
You should have more than that, who is calling IndexUpdater.run() ?
this fails also, well, it returns null:
String currentServletpath = context.getRequest().getServletPath();
any more ideas? We need the external URL so we can point to Wiki pages from the index. I could maybe wing it together by constructing the url in some other way, using the host name from confifuration and some elaborated guessing on the URL, but that would be brittle and unpleasant to maintain.
J.
_______________________________________________ devs mailing list [email protected] http://lists.xwiki.org/mailman/listinfo/devs
-- Thomas Mortagne
On Thu, Dec 18, 2008 at 6:27 PM, Thomas Mortagne <[email protected]> wrote:
On Thu, Dec 18, 2008 at 5:38 PM, Juergen Lorenz Simon <[email protected]> wrote:
Hi,
On 18.12.2008, at 15:08, Thomas Mortagne wrote:
On Thu, Dec 18, 2008 at 3:03 PM, Juergen Lorenz Simon <[email protected]
wrote: Hi,
On 18.12.2008, at 14:37, Thomas Mortagne wrote:
On Thu, Dec 18, 2008 at 1:54 PM, Juergen Lorenz Simon <[email protected]
wrote: Hi Thomas,
no, I do not create a context myself. I'm running this in Eclipse
But where do you get the XWikiContext you give to createExternalURL() ?
When the indexing plugin is instantiated I grab the context:
public IndexUpdater(XWiki wiki, XWikiContext context) { this.xwiki = wiki; this.context = context; }
Which is obtained from XWiki at plugin initialization time:
public void init(XWikiContext context) { ... // initialize the actual plugin indexUpdater = new IndexUpdater(context.getWiki(), context); indexUpdater.start();
// Hook into the document change notifications DocChangeRule docChangeRule = new DocChangeRule(indexUpdater);
context .getWiki().getNotificationManager().addGeneralRule(docChangeRule); }
Do you think I should use the context that comes in the notify() method instead?
No need, even if it's cleaner but it should be exactly the same java object I think, so I don't understand why your context's request object is wrong. Could you send you full stack trace ?
Of course. But it's exactly as it was:
java.lang.NullPointerException at com.xpn.xwiki.XWiki.getServletPath(XWiki.java:4317) at com .xpn .xwiki .web.XWikiServletURLFactory.addServletPath(XWikiServletURLFactory.java: 208) at com .xpn .xwiki .web.XWikiServletURLFactory.createURL(XWikiServletURLFactory.java:178) at com.xpn.xwiki.doc.XWikiDocument.getURL(XWikiDocument.java:884) at com.xpn.xwiki.doc.XWikiDocument.getURL(XWikiDocument.java:898) at com.xpn.xwiki.doc.XWikiDocument.getURL(XWikiDocument.java:903) at com .kontrast .vodafone .portal .xwiki.plugins.indexer.IndexUpdater.runMainLoop(IndexUpdater.java:192) at com .kontrast .vodafone .portal.xwiki.plugins.indexer.IndexUpdater.run(IndexUpdater.java:118)
You should have more than that, who is calling IndexUpdater.run() ?
Don't listen to me I answered too quickly :)
this fails also, well, it returns null:
String currentServletpath = context.getRequest().getServletPath();
any more ideas? We need the external URL so we can point to Wiki pages from the index. I could maybe wing it together by constructing the url in some other way, using the host name from confifuration and some elaborated guessing on the URL, but that would be brittle and unpleasant to maintain.
J.
_______________________________________________ devs mailing list [email protected] http://lists.xwiki.org/mailman/listinfo/devs
-- Thomas Mortagne
-- Thomas Mortagne
On Thu, Dec 18, 2008 at 6:29 PM, Thomas Mortagne <[email protected]> wrote:
On Thu, Dec 18, 2008 at 6:27 PM, Thomas Mortagne <[email protected]> wrote:
On Thu, Dec 18, 2008 at 5:38 PM, Juergen Lorenz Simon <[email protected]> wrote:
Hi,
On 18.12.2008, at 15:08, Thomas Mortagne wrote:
On Thu, Dec 18, 2008 at 3:03 PM, Juergen Lorenz Simon <[email protected]
wrote: Hi,
On 18.12.2008, at 14:37, Thomas Mortagne wrote:
On Thu, Dec 18, 2008 at 1:54 PM, Juergen Lorenz Simon <[email protected] > wrote: > Hi Thomas, > > no, I do not create a context myself. I'm running this in Eclipse
But where do you get the XWikiContext you give to createExternalURL() ?
When the indexing plugin is instantiated I grab the context:
public IndexUpdater(XWiki wiki, XWikiContext context) { this.xwiki = wiki; this.context = context; }
Which is obtained from XWiki at plugin initialization time:
public void init(XWikiContext context) { ... // initialize the actual plugin indexUpdater = new IndexUpdater(context.getWiki(), context); indexUpdater.start();
// Hook into the document change notifications DocChangeRule docChangeRule = new DocChangeRule(indexUpdater);
context .getWiki().getNotificationManager().addGeneralRule(docChangeRule); }
Do you think I should use the context that comes in the notify() method instead?
No need, even if it's cleaner but it should be exactly the same java object I think, so I don't understand why your context's request object is wrong. Could you send you full stack trace ?
Of course. But it's exactly as it was:
java.lang.NullPointerException at com.xpn.xwiki.XWiki.getServletPath(XWiki.java:4317) at com .xpn .xwiki .web.XWikiServletURLFactory.addServletPath(XWikiServletURLFactory.java: 208) at com .xpn .xwiki .web.XWikiServletURLFactory.createURL(XWikiServletURLFactory.java:178) at com.xpn.xwiki.doc.XWikiDocument.getURL(XWikiDocument.java:884) at com.xpn.xwiki.doc.XWikiDocument.getURL(XWikiDocument.java:898) at com.xpn.xwiki.doc.XWikiDocument.getURL(XWikiDocument.java:903) at com .kontrast .vodafone .portal .xwiki.plugins.indexer.IndexUpdater.runMainLoop(IndexUpdater.java:192) at com .kontrast .vodafone .portal.xwiki.plugins.indexer.IndexUpdater.run(IndexUpdater.java:118)
You should have more than that, who is calling IndexUpdater.run() ?
Don't listen to me I answered too quickly :)
this fails also, well, it returns null:
String currentServletpath = context.getRequest().getServletPath();
You are using the Tomcat launcher in Eclipse, right ?
any more ideas? We need the external URL so we can point to Wiki pages from the index. I could maybe wing it together by constructing the url in some other way, using the host name from confifuration and some elaborated guessing on the URL, but that would be brittle and unpleasant to maintain.
J.
_______________________________________________ devs mailing list [email protected] http://lists.xwiki.org/mailman/listinfo/devs
-- Thomas Mortagne
-- Thomas Mortagne
-- Thomas Mortagne
Juergen Lorenz Simon wrote:
Hi,
On 18.12.2008, at 15:08, Thomas Mortagne wrote:
On Thu, Dec 18, 2008 at 3:03 PM, Juergen Lorenz Simon <[email protected]
wrote: Hi,
On 18.12.2008, at 14:37, Thomas Mortagne wrote:
On Thu, Dec 18, 2008 at 1:54 PM, Juergen Lorenz Simon <[email protected]
wrote: Hi Thomas,
no, I do not create a context myself. I'm running this in Eclipse But where do you get the XWikiContext you give to createExternalURL() ?
When the indexing plugin is instantiated I grab the context:
public IndexUpdater(XWiki wiki, XWikiContext context) { this.xwiki = wiki; this.context = context; }
Which is obtained from XWiki at plugin initialization time:
public void init(XWikiContext context) { ... // initialize the actual plugin indexUpdater = new IndexUpdater(context.getWiki(), context); indexUpdater.start();
// Hook into the document change notifications DocChangeRule docChangeRule = new DocChangeRule(indexUpdater);
context .getWiki().getNotificationManager().addGeneralRule(docChangeRule); }
Do you think I should use the context that comes in the notify() method instead? No need, even if it's cleaner but it should be exactly the same java object I think, so I don't understand why your context's request object is wrong.
No, that is not true. The context received from the notification mechanism is always the current context, while the one from the initialization is the context created for the first request that triggered the initialization. The stale context has references to the initial ServletRequest and ServletResponse objects, but the container (usually) closes those objects. This is container-specific, and I was also bugged by this problem in Tomcat. So, what happens in Tomcat (if I remember correctly what I found a long time ago debugging), is that its HttpServletRequest object is a wrapper over another class holding the actual request data. After the request finishes, the internal object is cleaned, but the request wrapper remains in the XWikiContext, although all the calls will fail (the internal object is missing, thus the NPE).
any more ideas? We need the external URL so we can point to Wiki pages from the index. I could maybe wing it together by constructing the url in some other way, using the host name from confifuration and some elaborated guessing on the URL, but that would be brittle and unpleasant to maintain.
Yes, try using the context passed in the notify method. -- Sergiu Dumitriu http://purl.org/net/sergiu/
On 24.12.2008, at 04:05, Sergiu Dumitriu wrote:
Juergen Lorenz Simon wrote:
Hi,
On 18.12.2008, at 15:08, Thomas Mortagne wrote:
On Thu, Dec 18, 2008 at 3:03 PM, Juergen Lorenz Simon <[email protected]
wrote: Hi,
On 18.12.2008, at 14:37, Thomas Mortagne wrote:
On Thu, Dec 18, 2008 at 1:54 PM, Juergen Lorenz Simon <[email protected]
wrote: Hi Thomas,
no, I do not create a context myself. I'm running this in Eclipse But where do you get the XWikiContext you give to createExternalURL() ?
When the indexing plugin is instantiated I grab the context:
public IndexUpdater(XWiki wiki, XWikiContext context) { this.xwiki = wiki; this.context = context; }
Which is obtained from XWiki at plugin initialization time:
public void init(XWikiContext context) { ... // initialize the actual plugin indexUpdater = new IndexUpdater(context.getWiki(), context); indexUpdater.start();
// Hook into the document change notifications DocChangeRule docChangeRule = new DocChangeRule(indexUpdater);
context .getWiki().getNotificationManager().addGeneralRule(docChangeRule); }
Do you think I should use the context that comes in the notify() method instead? No need, even if it's cleaner but it should be exactly the same java object I think, so I don't understand why your context's request object is wrong.
No, that is not true. The context received from the notification mechanism is always the current context, while the one from the initialization is the context created for the first request that triggered the initialization.
The stale context has references to the initial ServletRequest and ServletResponse objects, but the container (usually) closes those objects. This is container-specific, and I was also bugged by this problem in Tomcat. So, what happens in Tomcat (if I remember correctly what I found a long time ago debugging), is that its HttpServletRequest object is a wrapper over another class holding the actual request data. After the request finishes, the internal object is cleaned, but the request wrapper remains in the XWikiContext, although all the calls will fail (the internal object is missing, thus the NPE).
Spot on. When using the context coming in with the notify() method, the url is correct. Thanks! J.L.Simon
participants (3)
-
Juergen Lorenz Simon -
Sergiu Dumitriu -
Thomas Mortagne