Hi xwiki-users,

I'm trying to bootstrap a component from the wiki itself (via Groovy).  I
have an interface defined as follows:

// This is the text inside the User.UserDAO document
{{groovy}}
interface UserDAO
{
    def ROLE = UserDAO.class.name

    /**
     * Returns the current user name.
     */
    def getUserName()

    /**
     * Returns the current user's password
     */
    def getPassword()
}
{{/groovy}}

I also have a dummy implementation defined as follows:

// This is the text inside the User.UserXWQLDAO document
{{include document="User.UserDAO" /}}
{{groovy}}
import org.xwiki.component.annotation.Component
import org.xwiki.component.annotation.Requirement
import org.xwiki.component.descriptor.DefaultComponentDescriptor
import org.xwiki.query.Query
import org.xwiki.query.QueryManager

import com.xpn.xwiki.web.Utils

@Component(roles = [ UserDAO.class ])
class UserXWQLDAO implements UserDAO
{
    @Requirement
    def QueryManager queryManager

    /**
     * Returns the current user name.
     */
    def getUserName() {
        return "bleh"
    }

    /**
     * Returns the current user's password
     */
    def getPassword() {
        return "bleh"
    }
}

if(!Utils.componentManager.hasComponent(UserDAO.class))
{
    def componentDescriptor = new DefaultComponentDescriptor()
    componentDescriptor.setImplementation(UserDAO.class)

    Utils.componentManager.registerComponent(componentDescriptor, new
UserXWQLDAO())
}
{{/groovy}}

The first problem I ran into was that Groovy 1.6.5 ran into
IncompatibleClassChangeErrors (http://jira.codehaus.org/browse/GROOVY-3830).
Upgrading to 1.6.6 fixed this issue.  But, then I ran into a NPE:

*exception*

javax.servlet.ServletException: Failed to initialize Request/Response or Session
        
com.xpn.xwiki.web.XWikiAction.initializeContainerComponent(XWikiAction.java:391)
        
com.xpn.xwiki.web.XWikiAction.initializeXWikiContext(XWikiAction.java:372)
        com.xpn.xwiki.web.XWikiAction.execute(XWikiAction.java:112)
        
org.apache.struts.action.RequestProcessor.processActionPerform(RequestProcessor.java:431)
        
org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:236)
        org.apache.struts.action.ActionServlet.process(ActionServlet.java:1196)
        org.apache.struts.action.ActionServlet.doPost(ActionServlet.java:432)
        javax.servlet.http.HttpServlet.service(Unknown Source)
        javax.servlet.http.HttpServlet.service(Unknown Source)
        
com.xpn.xwiki.wysiwyg.server.filter.ConversionFilter.doFilter(ConversionFilter.java:152)
        com.xpn.xwiki.web.ActionFilter.doFilter(ActionFilter.java:119)
        
com.xpn.xwiki.plugin.webdav.XWikiDavFilter.doFilter(XWikiDavFilter.java:68)
        
com.xpn.xwiki.web.SavedRequestRestorerFilter.doFilter(SavedRequestRestorerFilter.java:295)
        
com.xpn.xwiki.web.SetCharacterEncodingFilter.doFilter(SetCharacterEncodingFilter.java:112)

*root cause*

org.xwiki.container.servlet.ServletContainerException: Failed to
initialize request
        
org.xwiki.container.servlet.internal.DefaultServletContainerInitializer.initializeRequest(DefaultServletContainerInitializer.java:98)
        
com.xpn.xwiki.web.XWikiAction.initializeContainerComponent(XWikiAction.java:387)
        
com.xpn.xwiki.web.XWikiAction.initializeXWikiContext(XWikiAction.java:372)
        com.xpn.xwiki.web.XWikiAction.execute(XWikiAction.java:112)
        
org.apache.struts.action.RequestProcessor.processActionPerform(RequestProcessor.java:431)
        
org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:236)
        org.apache.struts.action.ActionServlet.process(ActionServlet.java:1196)
        org.apache.struts.action.ActionServlet.doPost(ActionServlet.java:432)
        javax.servlet.http.HttpServlet.service(Unknown Source)
        javax.servlet.http.HttpServlet.service(Unknown Source)
        
com.xpn.xwiki.wysiwyg.server.filter.ConversionFilter.doFilter(ConversionFilter.java:152)
        com.xpn.xwiki.web.ActionFilter.doFilter(ActionFilter.java:119)
        
com.xpn.xwiki.plugin.webdav.XWikiDavFilter.doFilter(XWikiDavFilter.java:68)
        
com.xpn.xwiki.web.SavedRequestRestorerFilter.doFilter(SavedRequestRestorerFilter.java:295)
        
com.xpn.xwiki.web.SetCharacterEncodingFilter.doFilter(SetCharacterEncodingFilter.java:112)

*root cause*

java.lang.NullPointerException


Haven't investigated any further than this, but has anyone successfully
created components completely within a wiki document?  That would just be so
cool!  Great work!

-- Lewis
_______________________________________________
users mailing list
users@xwiki.org
http://lists.xwiki.org/mailman/listinfo/users

Reply via email to