1 2 Previous Next 17 Replies Latest reply on Aug 9, 2012 5:59 AM by nishant_k123

    Question about SEAM-CONFIG

    riboriori

      Hi all, i'm experimenting seam-config. I have a class:




      public class MyClass
      {
         String field;
      
         public void setField(String field){
             this.field = field;
         }
      
         public String getField(){
             return field;
         }
      }
      





      in seam-beans.xml, under the META-INF folder under the war packaged file, inside my ear packaged application, i have:





      <beans      xmlns="http://java.sun.com/xml/ns/javaee"
                xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
                xmlns:s="urn:java:ee"                              xmlns:appConfig="urn:java:com.mycompany.myproject.configuration"
                http://jboss.org/schema/cdi/beans_1_0.xsd">
      
      
         <appConfig:MyClass>
                   <s:ApplicationScoped/>
                   <appConfig:field>someStringValue</appConfig:field>
         </appConfig:MyClass>
      
      </beans>




      In a service layer, i have a SomeManagerImpl (implements SomeManager interface) i have:








      @Stateless
      @Named
      public class SomeManagerImpl implements SomeManager{
        
         @Inject
         MyClass myclass;
        
         public void domeMthod(){
             System.out.println(myClass.getField());
         }
      }




      But the field field of myClass intance is null. I expect it's value is equals to that i had put under seam-beans.xml configuration.
      Anyone can help me?
      Best regards.










        • 1. Re: Question about SEAM-CONFIG
          riboriori

          Where i'm wrong? it is not the right way to read configured beans? can anyone correct me, please?

          • 2. Re: Question about SEAM-CONFIG
            lightguard

            I've sent this to Stuart to see if he can help out here, he's in Australia and won't see the email for a bit. A tree showing your structure may help. You could also try just in a war to see if makes a difference.

            • 3. Re: Question about SEAM-CONFIG
              riboriori

              Do you mean my app tree structure? it is an ear, like follow:


              MyApp.ear


              --META-INF
              ----application.xml
              ----beans.xml (void)
              ----MANIFEST.MF


              --lib
              ----commons-beanutils-1.8.3.jar
              ----commons-digester-2.1.jar
              ----commons-logging.jar
              ----joda-time.jar
              ----seam-catch.jar
              ----seam-persistence.jar
              ----seam-solder.jar


              --MyApp.war
              ----WEB-INF
              --------lib
              ------------seam-solder.jar
              ------------seam-servlet.jar
              ------------seam-security-3.0.1-SNAPSHOT.jar
              ------------seam-jcr-3.0.0-SNAPSHOT.jar
              ------------seam-international.jar
              ------------seam-faces.jar
              ------------seam-config-xml.jar
              ------------primefaces-3.0.M1.jar
              ------------picketlink-idm-spi.jar
              ------------picketlink-idm-core.jar
              ------------picketlink-idm-common.jar
              ------------picketlink-idm-api.jar
              ------------mvel2-2.0.16.jar
              ------------jsf-api.jar
              ------------drools-core.jar
              ------------drools-compiler.jar
              ------------drools-api.jar
              ------------aristo-1.0.1.jar
              ------------antlr-runtime-3.1.3.jar


              ----view
              ----index.xhtml
              ----META-INF
              --------seam-beans.xml  
              --------MANIFEST.MF
              --MyApp.jar
              ---- omitted jar content

              • 4. Re: Question about SEAM-CONFIG
                riboriori

                AAAHHH!! sorry for that error: how can i format correctly that message?

                • 5. Re: Question about SEAM-CONFIG
                  riboriori

                  Do you mean my app tree structure? it is an ear, like follow:




                  MyApp.ear
                  
                  --META-INF
                  ----application.xml
                  ----beans.xml (void)
                  ----MANIFEST.MF
                  
                  --lib
                  ----commons-beanutils-1.8.3.jar
                  ----commons-digester-2.1.jar
                  ----commons-logging.jar
                  ----joda-time.jar
                  ----seam-catch.jar
                  ----seam-persistence.jar
                  ----seam-solder.jar
                  
                  --MyApp.war
                  ----WEB-INF
                  --------lib
                  ------------seam-solder.jar
                  ------------seam-servlet.jar
                  ------------seam-security-3.0.1-SNAPSHOT.jar
                  ------------seam-jcr-3.0.0-SNAPSHOT.jar
                  ------------seam-international.jar
                  ------------seam-faces.jar
                  ------------seam-config-xml.jar
                  ------------primefaces-3.0.M1.jar
                  ------------picketlink-idm-spi.jar
                  ------------picketlink-idm-core.jar
                  ------------picketlink-idm-common.jar
                  ------------picketlink-idm-api.jar
                  ------------mvel2-2.0.16.jar
                  ------------jsf-api.jar
                  ------------drools-core.jar
                  ------------drools-compiler.jar
                  ------------drools-api.jar
                  ------------aristo-1.0.1.jar
                  ------------antlr-runtime-3.1.3.jar
                  
                  ----view
                  ----index.xhtml
                  ----META-INF
                  --------seam-beans.xml   <- HERE I CONFIGURED MY BEAN
                  --------MANIFEST.MF
                  --MyApp.jar
                  ---- omitted jar content



                  • 6. Re: Question about SEAM-CONFIG
                    riboriori

                    Why do you say a war? with this tree i configured successfully seam security...

                    • 7. Re: Question about SEAM-CONFIG
                      lightguard

                      If you've successfully configured Seam Security, is there still a problem? You use Seam Config to configure Security, correct?

                      • 8. Re: Question about SEAM-CONFIG
                        riboriori

                        Within same seam-beans.xml in which i configured my class, i have also configured security with success.

                        • 9. Re: Question about SEAM-CONFIG
                          ssiddiqi

                          I have a similar issue. 


                          Consider:


                          MyApp.ear
                          ...
                          ---lib
                          ------jsr305-1.3.9.jar
                          ------picketlink*.jar
                          ------seam-catch-3.00.Final.jar
                          ------seam-config-xml.3.0.0.Final.jar
                          ------seam-international-3.0.0.Final.jar
                          ------seam-security-3.0.0.Final.jar
                          ------seam-solder.3.0.0.Final.jar
                          ---MyApp.war
                          ---...
                          ------WEB-INF
                          ---------lib
                          ------------MyJar.jar
                          ---------------META-INF
                          ------------------beans.xml
                          ------------------seam-beans.xml
                          ...
                          



                          The jar in the WEB-INF/lib directory is ignored. I've debuged ResourceLoaderXmlDocumentProvider.open, and in the invocation to org.jboss.seam.solder.resourceLoader.ClasspathResourceLoader.getResource(), it appears that only the jars under the ear/lib, and those that are part of the server classpath are being recognized.  


                          I'm using JDK1.6.026.


                          Cheers,


                          -Saheem

                          • 10. Re: Question about SEAM-CONFIG
                            riboriori

                            I confirm, it works: by moving the jars  under ear/lib the bean is configured successfully.
                            Tanks a lot Saheem.
                            Regards.

                            • 11. Re: Question about SEAM-CONFIG
                              nishant_k123

                              I am facing issues when configuring beans via seam-beans.xml. I originally set it up similar to yours where i had the seam-beans.xml within the WEB-INF of the war that was packaged inside the ear. However they were not being picked up. On deploying just the war the sean-beans.xml is read but when i try accessing it from xhtml it does not appear that the beans in there are created

                               

                              03:26:30,405 INFO  [org.jboss.solder.config.xml.bootstrap.XmlConfigExtension] (MSC service thread 1-1) Reading XML file: vfs:/C:/java/jboss-as-7.1.1.Final/bin/content/rms.war/WEB-INF/seam-beans.xml

                              03:26:30,421 INFO  [org.jboss.solder.config.xml.bootstrap.XmlConfigExtension] (MSC service thread 1-1) Adding XML Defined Bean: com.archon.customer.Account

                              03:26:30,437 INFO  [org.jboss.solder.Version] (MSC service thread 1-1) Solder 3.1.0.Final (build id: 3.1.0.Final)

                              03:26:30,671 INFO  [org.jboss.solder.config.xml.bootstrap.XmlConfigExtension] (MSC service thread 1-1) Wrapping InjectionTarget to set field values: com.archon.customer.Account

                               

                               

                               

                              my seam-beans.xml

                               

                              <customers:Account accountNumber="123456" cardType="weVISA">

                                 <s:ApplicationScoped/>

                                 <s:Named value="myAccount"/>

                              </customers:Account>

                               

                              The above snippet is for an test case i am working on

                               

                              but when i use #{account.accountNumber} in my xhtml i dont see the account number set.

                               

                              Any ideas what i may be doing wrong ?

                              • 12. Re: Question about SEAM-CONFIG
                                lightguard

                                nishant_k123 wrote:

                                 

                                 

                                   <s:Named value="myAccount"/>

                                </customers:Account>

                                 

                                The above snippet is for an test case i am working on

                                 

                                but when i use #{account.accountNumber} in my xhtml i dont see the account number set.

                                 

                                Any ideas what i may be doing wrong ?

                                When you're accessing the bean via EL, you're using the wrong name. In the config you have "myAccount" as the name. In your EL snippet you have "account" instead of "myAccount".

                                • 13. Re: Question about SEAM-CONFIG
                                  nishant_k123

                                  ok i feel like an idiot. I was working thru several issues before i got to this point and had chalked this up to one those "seam" errors. Obviously did'nt look hard enough. Thanks though. that was it

                                  • 14. Re: Question about SEAM-CONFIG
                                    lightguard

                                    It gets the best of us at times

                                    1 2 Previous Next