Hi Debajit,
On 14 Oct 2015 at 00:17:49, Debajit Adhikary ([email protected](mailto:[email protected])) wrote: > I created an XWiki component which is available as a jar file. > > I have a ScriptService class for the component too: > > ---- > > @Role > public interface SearchClient > { > String search(); > } > > ---- > > @Component > @Singleton > public class InternalSearchClient implements SearchClient > { > public String search() > { > return "test search results"; > } > } > > ---- > > @Component > @Named("internalSearch") > @Singleton > public class InternalSearchScriptService implements ScriptService > { > @Inject > private InternalSearchClient searchClient; > > public String search() > { > return this.searchClient.search(); > } > } > > ---- > > I've added all the above files into their own jar with a components.txt > file: Where have you put this file? in META-INF? You can do a "jar tvf” to verify that it’s present at the right location in your generated JAR. > com.mycompany.wiki.search.InternalSearchClient > com.mycompany.wiki.search.InternalSearchScriptService > > and in my Wiki's pom.xml, I have the following: > > > org.xwiki.commons > xwiki-commons-script > ${commons.version} > > > > Now from my Wiki page, when I do the following: > > {{groovy}} > println(services.internalSearch.search()) > {{/groovy}} > > I get an error message saying "java.lang.NullPointerException: Cannot > invoke method search() on null object” Try: println services println services.internalSearch Also have you deloyed this JAR in WEB-INF/lib? Otherwise, looks good! Thanks -Vincent > > What am I doing wrong here? > > (I followed the directions in > http://platform.xwiki.org/xwiki/bin/view/DevGuide/WritingComponents — have > these directions changed, and/or is there anything else I need to do? ) _______________________________________________ users mailing list [email protected] http://lists.xwiki.org/mailman/listinfo/users
