Announcement Announcement Module
Collapse
No announcement yet.
spring within jboss container Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • spring within jboss container

    Hi,

    I have some doubts with spring integrated in jboss.

    There are many application context xml files.

    I'm using @Inject to inject a bean.
    Now if my xml has spring integration modules like "ftp -channel addapter" , there is no bean but I have to resolve the channels in the adapters.
    For this purpose I need the application contxt and I think I should be using BeanFactoryChannelResolver to pass the application context and then use the channel resolver.

    How do I get the application context.

    Any help is appreciated.

    Thanks

  • #2
    Every namespace-based component (e.g., channel, adapter, filter etc.) is a bean. So if it has an ID you can inject it anywhere you want as any other bean.
    When you say many application context do you actually mean cross-application context communication (e.g., many different WARs) or many application context configuration files?

    Comment


    • #3
      one war file but many application context files.

      So for SFTpSessionFactory I used @inject sftpsessionfactory and for sftp channel id I used
      @Inject MessageChannel <ChannelName> but for the channel name I get null pointer exception

      Thanks

      Comment


      • #4
        can you show your configuration and code that triggers NPE?

        Comment


        • #5
          Also, have you gone through our samples? There are quite a few container based samples there.

          Comment


          • #6
            Please point to the exact example for the container based samples.

            Comment


            • #7
              'http', 'ws-inbound' etc. Just go through README files and see what the instructions are and any sample that requires a server is what you are looking for

              Comment


              • #8
                I saw the http example and I'm using the spring beans to configure the context.xml but in the test demo you seem to be using the ClassPathApplicationConext to get the bean.Please provide pointerss to see how the bean can be injected and how the channels are resolved.

                Thanks

                Comment


                • #9
                  Please read the README file which gives you all the details you need. The demos like HTTP and others alike consists of two parts - server and client to interact with server component. The server part is what's being deployed to JBoss, Websphere, Tomcat or any other Java application server and the client is what talks to the server.

                  Comment


                  • #10
                    Please correct me if I'm wrong.

                    I wasn't able to get to the correct sample.I need to get the reference of the sftp namespace and then get the channel id.i wasnt able to get this information from the samples.

                    Thanks

                    Comment


                    • #11
                      I am not sure what do you mean to get a reference to the SFTP namespace. All you need to do is have SFTP module on the class-path and update the schema definition in the XML file to reflect dependency on SFTP which you can get from this sample https://github.com/SpringSource/spri...ter/basic/sftp
                      As far as reference to a channel - it is just like any other bean. For example <channel id="myChannel"/> can be referenced by name 'myChannel' and/or pulled as a bean via context.getBean("myChannel") or used with annotations etc.
                      Can you please clarify your use case a bit more?

                      Comment


                      • #12
                        So I have this namespace..I'm not having the context

                        <sftp:outbound-channel-adapter channel="sendChannel"
                        session-factory="sftpSessionFactory" id="sftpInboundAdapter"
                        auto-create-directory="true"

                        In my code

                        For session factory
                        I simply used

                        @Inject
                        SftpSessionFactory sftpsessionFactory and was able to get the reference..

                        I used

                        @Inject
                        MessageChannel sendChannel;
                        but this was returning null pointer exception

                        so do I have to specifically mention it as

                        @Inject (Named ="sendChannel")
                        MessageChannel sendChannel;

                        Is this the way it should be written.

                        Thanks

                        Comment


                        • #13
                          Please help me with the above example.

                          Thank you

                          Comment


                          • #14
                            Please re-read this section of Core Spring documentation http://static.springsource.org/sprin...rd-annotations

                            You have many channels in the context so @Inject is not enough for Spring Container to know which one are you interested in. I don't know what triggers NPE since you are not including a stack trace but i suspect it injects nothing and you are not doing a null check in your code.
                            Why do you need SftpSessionFactory in your Java code?

                            Please, as I asked you before can you explain your use case instead of the problem you are facing. You obviously doing something wrong and as much as we want to help you we can't until we know what you want.

                            Comment


                            • #15
                              Will take a look at the annotations..

                              I need the session factory to get the host details which i have configured in the properties file.Exactly ,since there a many channel ids i wasn't sure of how to get the reference of each of them.

                              Exception sending context initialized event to listener instance of class org.springframework.web.context.ContextLoaderListe ner: org.springframework.beans.factory.BeanCreationExce ption: Error creating bean with name 'org.springframework.integration.config.ServiceAct ivatorFactoryBean#0': Cannot resolve reference to bean 'myMessageHandler' while setting bean property 'targetObject'; nested exception is org.springframework.beans.factory.BeanCreationExce ption: Error creating bean with name 'myMessageHandler': Injection of autowired dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationExce ption: Could not autowire field: private org.springframework.integration.MessageChannel com.fujitsu.alpine.app.pm.impl.PMExporter.sftpChan nel; nested exception is org.springframework.beans.factory.NoSuchBeanDefini tionException: No unique bean of type [org.springframework.integration.MessageChannel] is defined: expected single matching bean but found 9: [inboundAdapter, sendChannel, processChannel, retrySftpCahnnel, inboundFailedFiles, nullChannel, errorChannel, retrySftpChannel, retryChannel]


                              Thanks

                              Comment

                              Working...
                              X