This content has been marked as final.
Show 4 replies
-
1. Re: Integrate user defined Resources (suggestions needed)
pmuir Mar 22, 2007 5:19 AM (in response to baz)@Name("report") public class Report { private String fileName; // getter and setter @Unwrap public InputStream unwrap { return Resources.getResourceAsStream(fileName); } }
Configure through components.xml/component.properties
You could easily extend for a list of files. -
2. Re: Integrate user defined Resources (suggestions needed)
baz Mar 22, 2007 6:38 AM (in response to baz)Hello,
i tried to follow your advise.
But after starting the app i get this exception:11:26:34,437 ERROR org.apache.catalina.core.ContainerBase.[Catalina].[localhost].[/baz]: Exception sending context initialized event to listener instance of class org.jboss.seam.servlet.SeamListener java.lang.RuntimeException: error while reading /WEB-INF/components.xml at org.jboss.seam.init.Initialization.initComponentsFromXmlDocument(Initialization.java:130) at org.jboss.seam.init.Initialization.<init>(Initialization.java:81) at org.jboss.seam.servlet.SeamListener.contextInitialized(SeamListener.java:33) at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:3729) at org.apache.catalina.core.StandardContext.start(StandardContext.java:4187) at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1013) at org.apache.catalina.core.StandardHost.start(StandardHost.java:718) at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1013) at org.apache.catalina.core.StandardEngine.start(StandardEngine.java:442) at org.apache.catalina.core.StandardService.start(StandardService.java:450) at org.apache.catalina.core.StandardServer.start(StandardServer.java:709) at org.apache.catalina.startup.Catalina.start(Catalina.java:551) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) at java.lang.reflect.Method.invoke(Unknown Source) at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:294) at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:432) Caused by: java.lang.NullPointerException at org.jboss.seam.init.Initialization.installComponentsFromXmlElements(Initialization.java:211) at org.jboss.seam.init.Initialization.initComponentsFromXmlDocument(Initialization.java:126) ... 17 more 22.03.2007 11:26:34 org.apache.catalina.core.StandardContext start SCHWERWIEGEND: Error listenerStart
This is because i have not added the @Install annotation to the bean.
The corresponding code (the same in current cvs and seam 1.2.0)Patch1 in Initialization.java looks likeif ( nameAnnotation!=null && nameAnnotation.value().equals(name) ) { Install install = clazz.getAnnotation(Install.class); if ( install.value() ) { className = null; } }
If there is no @Install annotation the value of install is null and hence the npe.
After adding the @Install annotation i getCaused by: org.jboss.seam.RequiredException: In attribute requires non-null value: authorizationBean.protocolTemplate at org.jboss.seam.Component.getValueToInject(Component.java:1887) at org.jboss.seam.Component.injectAttributes(Component.java:1336) at org.jboss.seam.Component.inject(Component.java:1163)
when trying to inject my bean with @In.
But @AutoCreate is set and i have added auto-create="true" to the definition
Here is the components.xml fragment<baz:protocol-template file-name="meinFile" auto-create="true"/>
What to do next?
Ciao,
Carsten -
3. Re: Integrate user defined Resources (suggestions needed)
pmuir Mar 22, 2007 7:25 AM (in response to baz)"baz" wrote:
Caused by: java.lang.NullPointerException at org.jboss.seam.init.Initialization.installComponentsFromXmlElements(Initialization.java:211) at org.jboss.seam.init.Initialization.initComponentsFromXmlDocument(Initialization.java:126) ... 17 more
This is a bug in Seam. I've fixed it in CVS, please test.After adding the @Install annotation i get
Caused by: org.jboss.seam.RequiredException: In attribute requires non-null value: authorizationBean.protocolTemplate at org.jboss.seam.Component.getValueToInject(Component.java:1887) at org.jboss.seam.Component.injectAttributes(Component.java:1336) at org.jboss.seam.Component.inject(Component.java:1163)
when trying to inject my bean with @In.
But @AutoCreate is set and i have added auto-create="true" to the definition
Here is the components.xml fragment<baz:protocol-template file-name="meinFile" auto-create="true"/>
Well you are trying to inject a null value. Check that Resources.get... is actually returning an InputStream. -
4. Re: Integrate user defined Resources (suggestions needed)
baz Mar 22, 2007 7:57 AM (in response to baz)Thanks for the pronpt reply.
Yes you are right with the null value. This was by intention.
I have not really inhaleted the meaning of unwrap:-(
I' ll try to test the cvs version on weekend.
Ciao,
Carsten