11 Replies Latest reply on Aug 24, 2013 6:36 AM by cirix

    MongoDB using issue

    anikulin

      Hi

       

      I have a SY project, that uses MongoDB. One of my SY beans connects to Mongo server in constructor like this one:

       

      MongoClient mongoClient = new MongoClient( "localhost" , 27017 );

       

      When I used SY-0.6.-Final everything was ok and worked fine, now I've decided to move to SY 0.8 and have some problems.

      Beans tries to connect to mongodb server, but then this proccess hangs and in some time deployment is rollbacked. I can see in logs smth like these:

       

      00:25:25,143 INFO  [com.magick.barService.service.BarServiceBean] (MSC service thread 1-5) Initializing Mongo Client, trying to connect to 127.0.0.1:27017

      00:26:20,354 INFO  [org.jboss.as.server] (DeploymentScanner-threads - 2) JBAS015870: Deploy of deployment "barService.jar" was rolled back with failure message Operation cancelled

       

      Can you help, maybe there is some new modules which can conflict with mongo library or smth like that?

       


      Regards, Anton

        • 1. Re: MongoDB using issue
          kcbabo

          We didn't make any direct changes w/r/t MongoDB between those versions.  What is the bean in question here?  Is it a CDI bean service?  Beans are constructed by CDI and not by SY directly.  One change between those versions was the move to DeltaSpike from Weld, so that is one possibility.  Have you tried deferring the MongoClient creation to a service method instead of doing it in the constructor?

          • 2. Re: MongoDB using issue
            anikulin

            Yes, this is a CDI bean service. Have tried to move MongoClient connection to a service method, but there is still no result. It just starts connecting and hangs up.

            • 3. Re: MongoDB using issue
              anikulin

              Moreover, if i use objects from mongoDB in CDI service methods, it hangs at the stage of weld deploying, and the last log i see is

               

              01:43:07,623 INFO  [org.jboss.weld.deployer] (MSC service thread 1-7) JBAS016008: Starting weld service for deployment barService.jar

               

              Smth really strange.

              • 4. Re: MongoDB using issue
                mageshbk

                Hi Anton,

                 

                Could you enable TRACE logging on org.switchyard package and see if that shows anything? You should be able to see TRACE messages in server.log.

                • 5. Re: MongoDB using issue
                  anikulin

                  Hi Magesh

                   

                  Yes, sure. I've turned on TRACE logging, but still can't find there smth that can explain app deployment rollback. Could you please take a loot at it?

                   

                  Thanks a lot

                  • 6. Re: MongoDB using issue
                    mageshbk

                    Anton,

                     

                    One simple and silly question, do you have the MongoDB driver in the classpath of the server like the SY-0.6 server setup? Have you configured that in a similar way in SY-0.8? There could be a possibility that the config files were overriden when you installed SY-0.8. Can you turn TRACE/DEBUG level for the entire server and see if that shows anything?

                     

                    regards,

                    Magesh

                    • 7. Re: MongoDB using issue
                      mageshbk

                      BTW, I could not see anything from the attached log.

                      • 8. Re: MongoDB using issue
                        anikulin

                        Yes, everything is the same. I just change SY version in pom.xml and with 0.6 on AS7-SY-0.6 it works, but with 0.8 on AS7-SY-0.8 doesn't. As for logs, I turned on TRACE for the whole log system and that attached file was already with this configuration.

                         

                        I created kind of a simple example for working with MongoDB, could you please try to deploy it on your server. Probably, that's smth wrong with my instance.

                         

                        Thanks a lot, Anton.

                        • 9. Re: MongoDB using issue
                          mageshbk

                          Hi Anton,

                           

                          It definitely should be your environment. I modified your code to initialize and add some data like this:

                              public MongoServiceBean() {
                                  initializeMongoDB();
                                  addResult(new Result(true, "One"));
                                  addResult(new Result(false, "Two"));
                              }
                          

                           

                          The server said:

                          INFO  [org.jboss.as.server] (DeploymentScanner-threads - 2) JBAS018559: Deployed "switchyard-mongo-0.0.1-SNAPSHOT.jar"
                          

                           

                          And the shell shows now:

                          > use resultDB
                          switched to db resultDB
                          > db.results.find()
                          { "_id" : ObjectId("51a03ba79a478b9de516d267"), "success" : true, "discription" : "One" }
                          { "_id" : ObjectId("51a03ba99a478b9de516d268"), "success" : false, "discription" : "Two" }
                          

                           

                          regards,

                          Magesh

                          • 10. Re: MongoDB using issue
                            anikulin

                            Thanks a lot, Magesh!

                             

                            My problem was missing java.net module in AS7. MongoDB requires SocketFactory class, do i added dependency on java.net in main.xml, but forgot to add this module to modules folder, and AS didn't write any messages about its missing.

                            • 11. Re: MongoDB using issue
                              cirix

                              When you say you added the <module name="java.net" /> deps in module.xml what do you mean and that you installed the java.net module.The required class is part of the jdk(part of the rt.jar). I have some problems also because I have defined the module but when I another module reference it it's never deployed correctly.It would be nice if you could post the module.xml of the mongo module.