Hi Marine,

On Jul 7, 2010, at 11:50 AM, Marine Julian wrote:

> 
> Hi Marius,
> 
> Marius Dumitru Florea wrote:
>> 
>> The required dependency should have been found at 
>> http://maven.xwiki.org/releases/org/xwiki/platform/xwiki-core-component/2.3.1/
>>  
>> but as you can see there's no jar there. The reason is that the 
>> xwiki-core-component module was split in multiple submodules. You need 
>> to edit you pom and change the dependency from xwiki-core-component to 
>> xwiki-core-component-api like this:
>> 
>> <dependency>
>>   <groupId>org.xwiki.platform</groupId>
>>   <artifactId>xwiki-core-component-api</artifactId>
>>   <version>${pom.version}</version>
>> </dependency>
>> 
> 
> You're totally right. In fact, I just replace "xwiki-core-component" by
> "xwiki-core-component-api" and the build succeeded. So, I finally can have
> my jar ! Thanks.
> 
> Now, i'm facing that my component can't be caledl by groovy or velocity. I
> hope that you can help me again. My first thought was wondering if the
> component needs to be declared somewhere, but it seems not.

Yes it needs to be declared in a META-INF/components.txt file.
See the doc at
http://code.xwiki.org/xwiki/bin/view/Modules/ComponentModule

Thanks
-Vincent

> 
> Neither 
> {{groovy wiki="false"}} 
> def greeter =
> com.xpn.xwiki.web.Utils.getComponent(org.xwiki.essai.component.HelloWorld.class);
> println greeter.sayHello();
> {{/groovy}}
> or
> {{velocity}} $greeter.sayHello(); {{/velocity}}
> works.
> 
> The groovy code throws the following error :
> org.xwiki.rendering.macro.MacroExecutionException: Failed to evaluate Script
> Macro for content [def greeter =
> com.xpn.xwiki.web.Utils.getComponent(org.xwiki.essai.component.HelloWorld.class);
> println greeter.sayHello();] 
>    at
> org.xwiki.rendering.macro.script.AbstractJSR223ScriptMacro.evaluate(AbstractJSR223ScriptMacro.java:201)
>  
>    at
> org.xwiki.rendering.macro.script.AbstractJSR223ScriptMacro.evaluate(AbstractJSR223ScriptMacro.java:50)
>    at
> org.xwiki.rendering.macro.script.AbstractScriptMacro.execute(AbstractScriptMacro.java:200)
>  
>    at
> org.xwiki.rendering.macro.script.AbstractJSR223ScriptMacro.execute(AbstractJSR223ScriptMacro.java:137)
>  
>    at
> org.xwiki.rendering.macro.script.AbstractJSR223ScriptMacro.execute(AbstractJSR223ScriptMacro.java:50)
>  
>    [...]
>    at org.mortbay.jetty.HttpConnection.handle(HttpConnection.java:405) 
>    at
> org.mortbay.io.nio.SelectChannelEndPoint.run(SelectChannelEndPoint.java:409) 
>    at
> org.mortbay.thread.QueuedThreadPool$PoolThread.run(QueuedThreadPool.java:582) 
> Caused by: javax.script.ScriptException: javax.script.ScriptException:
> java.lang.RuntimeException: Failed to load component
> [org.xwiki.essai.component.HelloWorld] for hint [default] 
>    at
> org.codehaus.groovy.jsr223.GroovyScriptEngineImpl.eval(GroovyScriptEngineImpl.java:117)
>  
>    at
> org.xwiki.rendering.macro.script.AbstractJSR223ScriptMacro.eval(AbstractJSR223ScriptMacro.java:260)
>  
>    at
> org.xwiki.rendering.macro.script.AbstractJSR223ScriptMacro.evaluate(AbstractJSR223ScriptMacro.java:191)
> ... 79 more 
> Caused by: javax.script.ScriptException: java.lang.RuntimeException: Failed
> to load component [org.xwiki.essai.component.HelloWorld] for hint [default] 
>    at
> org.codehaus.groovy.jsr223.GroovyScriptEngineImpl.eval(GroovyScriptEngineImpl.java:317)
>  
>    at
> org.codehaus.groovy.jsr223.GroovyScriptEngineImpl.eval(GroovyScriptEngineImpl.java:111)
>  
>    ... 81 more 
> Caused by: java.lang.RuntimeException: Failed to load component
> [org.xwiki.essai.component.HelloWorld] for hint [default] at
> com.xpn.xwiki.web.Utils.getComponent(Utils.java:614) 
>    at com.xpn.xwiki.web.Utils.getComponent(Utils.java:635) 
>    at com.xpn.xwiki.web.Utils$getComponent.call(Unknown Source) 
>    at
> org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:40)
>  
>    at
> org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:117)
>  
>    at
> org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:125)
>  
>    at Script7.run(Script7.groovy:1) 
>    at
> org.codehaus.groovy.jsr223.GroovyScriptEngineImpl.eval(GroovyScriptEngineImpl.java:314)
>    ... 82 more 
> Caused by: org.xwiki.component.manager.ComponentLookupException: Can't find
> descriptor for the component [role = [org.xwiki.essai.component.HelloWorld]
> hint = [default]] 
>    at
> org.xwiki.component.embed.EmbeddableComponentManager.initialize(EmbeddableComponentManager.java:356)
>  
>    at
> org.xwiki.component.embed.EmbeddableComponentManager.lookup(EmbeddableComponentManager.java:109)
>  
>    at
> org.xwiki.component.internal.DefaultComponentManager.lookup(DefaultComponentManager.java:85)
>  
>    at com.xpn.xwiki.web.Utils.getComponent(Utils.java:612) 
>    ... 89 more  
> 
> What is the descriptor for the component ?
> Besides, like I know the tutorial outdated, I tried to modify the code of
> the component by adding annotations and a components.txt, but the build
> failed cause the annotations was unknown (at least, they seems to be
> unknown).
> 
> Can anybody give me some ideas that I can use the HelloWorld component
> through velocity in my xwiki pages ?
> -- 
> View this message in context: 
> http://xwiki.475771.n2.nabble.com/Error-when-building-new-xwiki-component-tp5259941p5264413.html
> Sent from the XWiki- Users mailing list archive at Nabble.com.
> _______________________________________________
> users mailing list
> users@xwiki.org
> http://lists.xwiki.org/mailman/listinfo/users

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

Reply via email to