1 2 Previous Next 20 Replies Latest reply on Mar 21, 2006 2:23 PM by Serge Emmanuel Pagop

    Help me please!! Mapping Problems with JBoss 4.0.3

    kourosh bagheri Newbie

      I am working with JBoss ejb 3.0 - CMP in a an EJB 3.0-Webapplication with Servlets and JSPs.

      I have (CMP) Entities, which are mapped to a mySQL DB(4.1). The name of my MySQL Datasource is : estore.
      I have a datasource-config-file in the deploy directory, called estore-ds.xml, and an persistence.xml file whithin my entities.par archiv.

      Everything was working fine with jboss-EJB_3.0_RC1, but since I work with the last version of JBoss (jboss-EJB_3.0 Production state) nothing works anymore!!

      I guess, the problem is, that my JNDI Bindings do not work properly in the production version of JBoss.

      here is (a part of) the exception:

      Caused by: javax.naming.NameNotFoundException: estore not bound
      at org.jnp.server.NamingServer.getBinding(NamingServer.java:514)
      at org.jnp.server.NamingServer.getBinding(NamingServer.java:522)
      at org.jnp.server.NamingServer.getObject(NamingServer.java:528)
      at org.jnp.server.NamingServer.lookup(NamingServer.java:281)
      at org.jnp.server.NamingServer.lookup(NamingServer.java:255)
      at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:610)
      at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:572)
      at javax.naming.InitialContext.lookup(InitialContext.java:351)
      at org.jboss.ejb3.injection.PersistenceContextHandler.getManagedEntityMa
      nagerFactory(PersistenceContextHandler.java:81)


      here are the JNDI Bindings( JNDI-MBean: (localhost:8080/jmx-console MBean.list() ):
      -----------------
      java: Namespace

      +- jaas (class: javax.naming.Context)
       | +- JmsXARealm (class: org.jboss.security.plugins.SecurityDomainContext)
       | +- jbossmq (class: org.jboss.security.plugins.SecurityDomainContext)
       | +- HsqlDbRealm (class: org.jboss.security.plugins.SecurityDomainContext)
       +- TransactionPropagationContextImporter (class: org.jboss.tm.TransactionPropagationContextImporter)
       +- comp.ejb3 (class: javax.naming.Context)
       | NonContext: null
       +- JmsXA (class: org.jboss.resource.adapter.jms.JmsConnectionFactoryImpl)
       +- managedEntityFactories (class: org.jnp.interfaces.NamingContext)
       +- DefaultDS (class: org.jboss.resource.adapter.jdbc.WrapperDataSource)
       +- StdJMSPool (class: org.jboss.jms.asf.StdServerSessionPoolFactory)
       +- TransactionManager (class: org.jboss.tm.TxManager)
       +- TransactionPropagationContextExporter (class: org.jboss.tm.TransactionPropagationContextFactory)
       +- ConnectionFactory (class: org.jboss.mq.SpyConnectionFactory)
       +- DefaultJMSProvider (class: org.jboss.jms.jndi.JNDIProviderAdapter)
       +- XAConnectionFactory (class: org.jboss.mq.SpyXAConnectionFactory)
       +- Mail (class: javax.mail.Session)
       +- EntityManagerFactories (class: org.jnp.interfaces.NamingContext)
       +- timedCacheFactory (class: javax.naming.Context)
      Failed to lookup: timedCacheFactory, errmsg=org.jboss.util.TimedCachePolicy
       +- SecurityProxyFactory (class: org.jboss.security.SubjectSecurityProxyFactory)
       +- estore (class: org.jboss.resource.adapter.jdbc.WrapperDataSource)
       +- ActualEntityManagerFactories (class: org.jnp.interfaces.NamingContext)
       +- comp (class: javax.naming.Context)
       +- EntityManagers (class: org.jnp.interfaces.NamingContext)

      ----------------


      I have to work with the production version of jboss, because the production version of jboss 4.0.3 promises to be free of CASCADE DELETE problems. Otherwise I would rather work with the version before!

      Please help me!!

        • 1. Re: Help me please!! Mapping Problems with JBoss 4.0.3
          Aaron Novice

          Check your log files for DEBUG messages. I have found, when working with EJB3.0 and EntityManagers, that if you have a failure for one of your beans, the EntityManager will not bind the name declared in your persistence.xml file.

          • 2. Re: Help me please!! Mapping Problems with JBoss 4.0.3
            kourosh bagheri Newbie

            Hi,
            thank you for your response.

            "Neelixx" wrote:
            Check your log files for DEBUG messages.
            I will do that.

            I have found, when working with EJB3.0 and EntityManagers, that if you have a failure for one of your beans, the EntityManager will not bind the name declared in your persistence.xml file.


            But I hat the same application running with the jboss version before and everything was working fine.

            I had just error messages (in the log files of thelast version of jboss), which had no effect on the application, but they were logged.

            Here they are(an example) :

            ERROR [org.hibernate.tool.hbm2ddl.SchemaExport] Unsuccessful: create table CUSTOMERS (CUSTOMERID integer generated by default as identity (start with 1), STATE varchar(20), COUNTRY varchar(30), TITLE varchar(4) not null, CITY varchar(20), EMAIL varchar(40) not null, PHONE varchar(20), LASTNAME varchar(40) not null, FIRSTNAME varchar(40) not null, birthday varchar(255), USERPWD varchar(15) not null, STREET varchar(40), ZIPCODE varchar(5), REGISTERED timestamp not null, primary key (CUSTOMERID))


            And also cascade deletes was not supported.

            Do you use the production version of jboss too?

            Have you been similar problems?

            • 3. Re: Help me please!! Mapping Problems with JBoss 4.0.3
              Aaron Novice

              Yes I do, and am using EJB3.0 entity and session beans. I had the problem, where my session beans couldn't load the EntityManager. That was because I had mapping issues with my EntityBeans, which showed up in my log.

              If the tables can't be created, then your entity beans can't be initialized. Ergo, your EM won't be bound.

              If you already have your tables in your DB, turn off hbm2ddl. It looks like you have it set at "create-drop". Every time you deploy your application, it will try to drop your tables, and recreate them.

              Is this running on a production server? If not, change your log settings to the following:

              org.jboss.EJB3 = DEBUG
              org.hibernate = DEBUG

              Redeploy your app, and view the server log. Maybe that will give you more insight.

              • 4. Re: Help me please!! Mapping Problems with JBoss 4.0.3
                kourosh bagheri Newbie

                Thank you so much!
                You are great! It is true! And that seems to be the reason, why I saw those lod statements again and again.


                "Neelixx" wrote:

                If the tables can't be created, then your entity beans can't be initialized. Ergo, your EM won't be bound.


                But why does it work on the "NON PRODUCTION" version of jboss?

                "Neelixx" wrote:

                If you already have your tables in your DB, turn off hbm2ddl. It looks like you have it set at "create-drop". Every time you deploy your application, it will try to drop your tables, and recreate them.


                I had allready created the db schema, and hibernat tried to create them again and again.
                Now I set the value to update to switch the auto-generation to OFF. Is it the right way? Because I couln't find a "SWITCH OFF" property value.

                <property name="hibernate.hbm2ddl.auto" value="update" />


                Or is there another value, which you can set to
                the hibernate.hbm2ddl.auto property?

                "Neelixx" wrote:

                Is this running on a production server? If not, change your log settings to the following:

                org.jboss.EJB3 = DEBUG
                org.hibernate = DEBUG

                Redeploy your app, and view the server log. Maybe that will give you more insight.


                I am using the "jboss 4.0.3 production version" but I guess you are speaking of another thing, don't you?
                No! It is my own pc at home. I am developing a little application for my study. So I could easily change everything I have to change.

                Now I will search the doc. fo find out, where I can set these "DEBUG" values.
                I will tell you what happend.



                • 5. Re: Help me please!! Mapping Problems with JBoss 4.0.3
                  Aaron Novice

                  You can set the log values two ways: Through the log4j.xml file, or via the jmx-console.

                  I prefer the jmx-console, as it is easy access, but either way works.

                  Go to your jmx-console (http://localhost:8080/jmx-console)

                  Scroll down to the heading "jboss.system" and choose the "service=Logging,type=Log4jService".

                  Scroll down to "void setLoggerLevel()". There are two parameters. The log that you want to set, and the level that logging should happen.

                  For the "logger" parameter, type in "org.jboss.EJB3". For the level parameter, type in "DEBUG". Do the same for "org.hibernate".

                  Redeploy your app, and view the log file in /server/default/log/server.log.

                  But why does it work on the "NON PRODUCTION" version of jboss?

                  I apologize if this is a stupid question, but I don't follow you by saying "NON-PRODUCTION" version. I am running JBoss4.0.3 final. Not RC1 or RC2.

                  Not sure why it runs in your "NON-PRODUCTION" version, other than code changes.

                  I am using the "jboss 4.0.3 production version" but I guess you are speaking of another thing, don't you?
                  No! It is my own pc at home. I am developing a little application for my study. So I could easily change everything I have to change.


                  I was referring to a "production" server or "development" server. YOu answered the question correctly by specifying running it on your home machine.

                  • 6. Re: Help me please!! Mapping Problems with JBoss 4.0.3
                    kourosh bagheri Newbie

                    >>"I was referring to a "production" server or "development" server. YOu answered the question correctly by specifying running it on your home machine."
                    I am sorry, I didn't understand correctly, what you ment. You should know, tht I'm german, am my english is not the best.

                    Anyway, I have to tell you that I have got it with your aid, thank you sooo much!

                    The application is now running again, but this time with jboss 4.0.3 production release, as I wanted!

                    You seem to be very familar with the topic.
                    May I ask another question(s)?! :o)

                    I have a sfsb, which is my shoppingCart Bean.

                    1) How do I handle the use case, that someone puts somthing into the cart, but doesn't proceed, How do I terminate the EJB3 sfsb?
                    I know the @Remove annotation, but who/what should invoke such a method? Or schoul I better work with timer objects and timeouts?

                    2) Would you ammotate this Bean as @Remote? Is ist possible to make an interface both (remotely and locally) available?

                    I woul be really thankfull to hear some expert opinions, and maybe some hints, maybe about what one can do wrongy or what one could do better.

                    Thank you very much for your hints.

                    • 7. Re: Help me please!! Mapping Problems with JBoss 4.0.3
                      Aaron Novice

                      I, myself, am learning the EJB3.0 and JBoss system (and Java for that matter), so bear with me.....

                      "jbossChecker" wrote:


                      1) How do I handle the use case, that someone puts somthing into the cart, but doesn't proceed, How do I terminate the EJB3 sfsb?
                      I know the @Remove annotation, but who/what should invoke such a method? Or schoul I better work with timer objects and timeouts?


                      The container manages the session. If someone was to just close out the browser, or go to another site without "checking-out" or "logging-out", then the container is responsible for timing-out the session. When the session gets removed, I believe that's when the @Remove annotation is called.

                      You can modify your session timeout values in your descriptors.

                      "jbossChecker" wrote:
                      2) Would you ammotate this Bean as @Remote? Is ist possible to make an interface both (remotely and locally) available?


                      It depends on how you want to run your application. Running your beans with a @Remote interface, means other JVM's can access your bean (such as two seperate JBoss Servers). If you plan on running your application in the same JVM (such as a single server), then you will only need a local interface.

                      There are exceptions to the rule, such as clustering JBoss servers, and your application architecture. However, if you are just learning the EJB and JBoss technologies, I'd stick with local interfaces for now.

                      Also, I'm used to the bad english grammer, as my wife is also german (though her accent is nearly gone), and I'm used to reading her typing. :)

                      Good luck! Hope this helps!

                      --Aaron

                      • 8. Re: Help me please!! Mapping Problems with JBoss 4.0.3
                        kourosh bagheri Newbie

                        Hi Aaron,
                        thank you once more for spending your time in responding to me.
                        It lets me hope, when you call yourself a kind of beginner too! But you have a great advantage, speaking english as your mother language.
                        Its sometimes really hart to understand the stuff (docs etc.)

                        A very last question please:
                        Are you working with eclipse too?
                        If yes, how/what is the right way/which packages do you insert to the build path of your application?
                        I have problems with that! Suddently, I see in the log files the (parent ) directories of my application directory in the log files on JBOSS.log file!!!!!!!!

                        I am getting crazy!! It seems to me, as my build path had issues.
                        I know that you have to put the jboss-ejb3.jar and jboss.ejb3x.jar to the build path/ classpath (ownestly I dont know the difference) but which jars else?

                        It doesen't matter, when you do not have the time to answer. I can understand that. You helped me enough.

                        Greeting to your german wife from Hamburg Germany, and thank you very much again.
                        bye

                        • 9. Re: Help me please!! Mapping Problems with JBoss 4.0.3
                          Aaron Novice

                          Yes, I'm using Eclipse3.1 with JBossIDE1.5. In my build path, I have:

                          J2EE 1.4 libraries (JBoss-IDE) - included with JBoss-IDE1.5
                          JBoss-EJB3 libraries (JBoss-IDE) - included with JBoss-IDE1.5

                          Along-side those, I do alot of unit testing, so I also have JUnit and Cactus libraries. But that's it.

                          I then package all my ear, war, ejb3, and par files using the "Packaging Configuration" in Eclipse.

                          On a side note, the ejb3x.jar defines the ejb annotations, whereas the ejb3.jar defines your EJB's (session, stateless, entity, persistence, etc)

                          I'm looking at my library list now, and this is what's included in the EJB3.0 libraries:

                          http://www.thepaxson5.org/Members/Aaron/ejb3Libraries

                          Hope this helps!

                          • 10. Re: Help me please!! Mapping Problems with JBoss 4.0.3
                            kourosh bagheri Newbie

                            Hi Aaron, thank you once more, for your response.

                            I have seen your path entries, my problem is not to know, which sort of Inclluding one have to choose, because eclipse offers :
                            In the Project Explorer view -> Properties -> Java Build Path ->
                            1) Add Jars...
                            2) Add external jars
                            3) Add Variable
                            4) Add Library
                            5) Add Class Folder

                            I know that I do not need # 5 but which way is exactly the right one?

                            Or does it make any difference on which way one do that?

                            I have also seen your past projects, your blog Caffeinated ans so on.

                            I have also seen your cute children and now, thank internet, my girl friend an I, we know even your cat and dog and your barbecue! :o)

                            Nice to see such a sympathic family.

                            I wish you the best, and would really return the favour.

                            If I could do smothing to get even, let me know!
                            For example I could send german beer, or sausages to you. :o)

                            Here is my ... a d r. ( DO String.trim() !! ):

                            m y n e w s 2001 A T g m x . n e t

                            I have also tried to register at www.thepaxson5.org, but the register form/function did not accept my email address!

                            Here is the message:

                            We were unable to send your password to your email address: {'mynews2001@gmx.net': (554, '<m y n e ws 2001 AT g m x . n e t>: Recipient address rejected: Relay access denied')}


                            Thanks 1000000 times and take care!

                            • 11. Re: Help me please!! Mapping Problems with JBoss 4.0.3
                              kourosh bagheri Newbie

                              Hi Aaron,
                              It's me again! Excuse me please! There are rarely helpers in these forums, so I have to bother you again! Sorry!

                              I would like to tell you what happend as did it the way you do.

                              Till now, I had a lib directory, where I had placed the single jar files in my eclipse app structure, like this:

                              APP_ROOT\lib\jboss-ejb3.jar
                              APP_ROOT\lib\jboss-ejb3x.jar
                              APP_ROOT\lib\jboss-j2ee.jar
                              APP_ROOT\lib\hibernate3.jar

                              And I referenced to those jars from whithin the Eclipse-Buildpath, or did the same references to those files in JBOSS_HOME\server\default\deploy\EJB3.0_Deployer\related_jar_files and it worked fine.

                              But I knew, that it was not the best way, so I decided to do it like you told to me, so a included the Libraries JBOSS_EJB3_libraries, J2EE 1.4 Libraries to my build path and removed my old references. But now unfortunately, all imports are red underlined, in other words, they are not recognized.

                              Is there something else I should do? Do you have any Idea?

                              P.S.: I have just noticed, that my "JBOSS_EJB3_LIBRARIES" Entry hat only these 5 jars:
                              - jnp-client.jar
                              - jbosssx-client.jar
                              - jboss-j2ee.jar
                              - jboss-transaction-client.jar
                              - commons-logging.jar

                              Is it normal like that? where are theothers (jboss-ejb3 and jboss-ejb3x.jar etc.?)

                              • 12. Re: Help me please!! Mapping Problems with JBoss 4.0.3
                                Aaron Novice

                                If you are using libraries included with JBoss, the best way to do it, is to reference the libraries through Eclipse, and not in your lib, as you would not need to export those libraries. They are already on the server.

                                However, you obviously need to have those libraries available to you in Eclipse, or your objects won't resolve.

                                If you are using Eclipse-IDE (which you should be using. I'm using 1.5), then those libraries are already installed in Eclipse, you just need to add them to your build path.

                                Right-click on your project, and choose properties. Go into your build-path.

                                Under the libraries tab, choose the "Add Libraries" button. From there, again, IF you are using JBoss-IDE, you should choose, at a minimum, "J2EE1.4 Libraries" and "JBoss EJB3 Libraries". Those libraries are now available on your build path.

                                As far as "how" you include your libraries is a matter of preference. Every developer is different. As long as they get included is what's important.

                                If you are not using JBoss-IDE, or a version of JBoss-IDE that does not include EJB3, then you should create a "user library" that contains ejb3.jar and ejb3x.jar. Call the library EJB3 and add it.

                                Hoffe das ich dir geholfen habe

                                Tschuss Aaron

                                (My wife helped me ((grin)) )

                                • 13. Re: Help me please!! Mapping Problems with JBoss 4.0.3
                                  kourosh bagheri Newbie

                                   

                                  "Neelixx" wrote:
                                  If you are using libraries included with JBoss, the best way to do it, is to reference the libraries through Eclipse, and not in your lib, as you would not need to export those libraries. They are already on the server.

                                  However, you obviously need to have those libraries available to you in Eclipse, or your objects won't resolve.

                                  If you are using Eclipse-IDE (which you should be using. I'm using 1.5), then those libraries are already installed in Eclipse, you just need to add them to your build path.

                                  Right-click on your project, and choose properties. Go into your build-path.

                                  Under the libraries tab, choose the "Add Libraries" button. From there, again, IF you are using JBoss-IDE, you should choose, at a minimum, "J2EE1.4 Libraries" and "JBoss EJB3 Libraries". Those libraries are now available on your build path.

                                  As far as "how" you include your libraries is a matter of preference. Every developer is different. As long as they get included is what's important.

                                  If you are not using JBoss-IDE, or a version of JBoss-IDE that does not include EJB3, then you should create a "user library" that contains ejb3.jar and ejb3x.jar. Call the library EJB3 and add it.

                                  Hoffe das ich dir geholfen habe

                                  Tschuss Aaron

                                  (My wife helped me ((grin)) )


                                  Hi Aaron,
                                  thank you again.
                                  Vielen vielen Dank! Du hast mir sogar viel geholfen.

                                  I guess I have issues with the .classpath file of eclipse itself, because I am working with JBoss IDE 1.5 , like you and thousends of developers more!

                                  The problem is, when I edit the build path (right click on my project...) and then add the EJB 3.0 libraries to my build path, I can see the needed jars in that dialog (project properties dialog) but when I come back to the "package explorer view" the jars are all away, except 5 of them, which are not the needed ones (needed = ejb3.jar, ejb3x.jar etc.)...

                                  It seems like a kind of bug in eclipse, or a kind of mismatch in the .classpath file, as I could read in similar threads in internet.

                                  Or maybe I have to put some entries in my OS environment variables?! I don't know!
                                  I have to finish my app very soon, because I have to hand it over, so I have to keep on working with the given situation, and the \lib solution in the project structure.
                                  Anyway, I have to thank you, once more.
                                  Dankeschön!!
                                  Best wishes!
                                  Aufwiedersehen / (Aufwiederschreiben!!)


                                  • 14. Re: Help me please!! Mapping Problems with JBoss 4.0.3
                                    kourosh bagheri Newbie

                                    [img]C:\project_buildpath.gif[/img]

                                    1 2 Previous Next