14 Replies Latest reply: Apr 3, 2012 2:14 PM by Ram V RSS

    Validation support for EJB projects in OEPE

      We are using OEPE tooling for a large Java EE project. We only use OEPE tools for EJB validation purposes. We recently migrated from EJB 2.1 to EJB 3.0 (Java EE 5).

      With the EJB 2.1 validation, we used to see errors in EJB configuration and Java code at compilation/validation time. For EJB3 code, we do not see any errors at all. For instance, when creating a stateless bean without an interface, you'd expect an error, but we do not see one.

      Could you provide us with more information on what error scenarios the EJB 3.x validator actually checks? We currently do not know if there is a problem with our validation configuration, or if the new validators simply do not check for the errors we try out as examples to see if validation works.

      Also, the weblogic-ejb-jar.xml forms editor "design" tab seems to be broken. This was already the case in EJB 2.1, but in EJB 3.0 as well, it does not produce sensible error messages, and the browse suggestions do not work for us. Are these known problems for you?

      Thank you in advance for any answers.
        • 1. Re: Validation support for EJB projects in OEPE
          Raj Alag

          Which version of OEPE are you running ? Could you also attach the sample weblogic-ejb-jar.xml which doesn't display any validation error ?

          • 2. Re: Validation support for EJB projects in OEPE
            Hi Raj,

            I work with Peter on the same project.

            We are using OEPE

            Here's an example of a weblogic-ejb-jar.xml we use:
            <?xml version="1.0" encoding="UTF-8"?>
            <wls:weblogic-ejb-jar xmlns:wls="http://xmlns.oracle.com/weblogic/weblogic-ejb-jar" 
            xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/ejb-jar_3_0.xsd http://xmlns.oracle.com/weblogic/weblogic-ejb-jar http://xmlns.oracle.com/weblogic/weblogic-ejb-jar/1.2/weblogic-ejb-jar.xsd">
            When we open the design tab and go to Beans -> PLRapportageQueueControleService, it shows errors about the EJB name not being among possible values for EJB name and that Business Remote and JNDI name must be specified. As we are using EJB 3.0, these should not be required.

            Edit: corrected version of OEPE
            • 3. Re: Validation support for EJB projects in OEPE
              Ram V

              You are trying to define EJB 2.1 style bean in EJB 3.0 DD. Here is the workaround to fix "..EJB name not being among possible..."

              - open EJB and add @Stateless annotation

              I have opened a bug for enforcing requirement of Business remote & JNDI name field.

              Thanks for you feedback!
              - Ram
              • 4. Re: Validation support for EJB projects in OEPE
                We do have our stateless session beans annotated with @Stateless. The weblogic-ejb-jar.xml only contains the WebLogic specific configuration like the max-beans-in-free-pool in the example. To my knowledge this should still be possible in EJB 3.0?

                But what about errors in the Java code, shouldn't OEPE detect these as well? Like when creating a stateless bean without an interface it doesn't give any error at all, while OEPE for EJB 2.1 did warn us for this kind of errors.

                Thanks for your help.

                • 5. Re: Validation support for EJB projects in OEPE
                  Ram V
                  Hi Pieter,

                  Do you still see "..EJB name not being among possible..." in-spite of having @Stateless annotation? Yes, i have opened a bug regarding the validation check for business remote & JNDI name requirement. I will keep you posted on this.

                  OEPE doesn't provide any additional validation for EJB 3 projects. The behavior is dependent on WTP implementation.

                  FYI, when creating EJB 3.0 bean w/o any interface there is a warning on the dialog "No client view configured. Clients will not be able to access this bean.". And in EJB 3.1 the no interface implementation is a valid use case, here is the link which provides additional documentation regarding this - http://docs.oracle.com/cd/E24329_01/web.1211/e24972/examples.htm#i1135149

                  • 6. Re: Validation support for EJB projects in OEPE
                    That's correct, I still see the error message in spite of having @Stateless annotation.

                    The bean implementation looks like this:
                    @Stateless(mappedName = MappedName.DONNA)
                    public class TwdServiceBean implements TwdService {
                    and when I look at the design-tab of the weblogic ejb-jar.xml it gives me the errormessage: ''TwdServiceBean" is not among possible values for EJB name. Also, when I click on the 'Browse' button, the dialog is empty so I can't select a bean name either.

                    By the way, it also gives the same error for any security-role-assignment I define, while there is a bean annoted with @RolesAllowed with that role.

                    Is OEPE also dependent on WTP, or only the EJB java code validation? If yes, should there be any specific plugins installed besides OEPE for the validation to work?
                    • 7. Re: Validation support for EJB projects in OEPE
                      Ram V
                      Hi Pieter,

                      It is strange, I am not able to reproduce the issue that results in "<name> is not among possible values for EJB name". Here is what my sample bean and it shows in weblogic-ejb-jar.xml file.

                      @Stateless(mappedName = MappedName.DONNA)
                      public class HelloWorldBean implements SomeInterface{ ...}

                      To make sure if this is a consistent behavior, can you try to reproduce in a new EJB project.
                      Create a new EJB 3 project
                      Copy-paste your EJB bean into source folder
                      Open weblogic-ejb-jar.xml and verify using "Add from existing bean..." or Browse | EJB name dialog
                      Also, create a new Session Bean and verify if this shows up in weblogic-ejb-jar.xml file

                      I am able to reproduce the "security-role-assignment" error, please try the following workaround:
                      if you do not have ejb-jar.xml, right click on EJB Project > Java EE tools | Generate Deployment Descriptor Stub
                      define the security-role-assignment in ejb-jar.xml

                      This should resolve the reference in weblogic-ejb-jar.xml file.

                      NOTE: I have logged a bug to read this information via @RolesAllowed annotation, will keep you posted.

                      FYI: Validation

                      Depending on the feature area OEPE provides additional validation on top of what you get from WTP. In some cases, like in EJB3 it is all WTP validation.

                      If you feel the need for some additional validation, we can open an issue against WTP project (https://bugs.eclipse.org/bugs/enter_bug.cgi?product=WTP%20EJB%20Tools&format=guided)

                      • 8. Re: Validation support for EJB projects in OEPE

                        I will look into the "<name> is not among possible values for EJB name" problem. It's good to know it's not a bug, so I can investigate the problem further.

                        Thanks for your help, I'll update this thread if I have more information.

                        • 9. Re: Validation support for EJB projects in OEPE
                          Adding an EJB to weblogic-ejb-jar.xml using "add from existing bean..." does work initially, but sometimes (not always) after reopening the weblogic-ejb-jar.xml the validation problems with the EJB name return. This is both for our existing projects and new EJB projects configured from scratch.
                          • 10. Re: Validation support for EJB projects in OEPE
                            Ram V
                            Hi Pieter,


                            FYI, you need to define the security role before you access them:

                            The roles defined in EJB using @DeclareRoles show up in weblogic-ejb-jar.xml file (for Security Role Assignment).

                            • 11. Re: Validation support for EJB projects in OEPE
                              According to http://java.sun.com/developer/technicalArticles/J2EE/security_annotation/ the @DeclareRoles is only needed if you need more complicated authorization logic, so in my opinion it should also work without it.

                              By the way, if I add the @DeclareRoles annotation it still gives me the same error, but that could also be because of the intermittent issue Peter described in his last post. We'll have to do some more experimenting to further analyze that issue.
                              • 12. Re: Validation support for EJB projects in OEPE
                                Ram V
                                Hi Pieter,

                                Yes, we confirm this is an issue and the bug is in open source code. Here is the bug logged against jst.j2ee component.


                                We appreciate your feedback!

                                • 13. Re: Validation support for EJB projects in OEPE

                                  I looked into the problem and adding an empty <stateless-session-descriptor> element to every <weblogic-enterprise-bean> seems to have resolved the issue. If this element is missing it defaults to an entity bean en gives the mentioned error.

                                  Thanks for your help.

                                  • 14. Re: Validation support for EJB projects in OEPE
                                    Ram V
                                    Hi Pieter,

                                    Like you mentioned there is some inconsistent behavior which causes the error "... not among possible values for EJB name." and I was able to reproduce the issue. The problem has been fixed in the latest build, please switch to (http://www.oracle.com/technetwork/developer-tools/eclipse/downloads/oepe-12111-1560492.html) release. FYI, we now add an empty <wls:stateless-session-descriptor></wls:stateless-session-descriptor> for defining a bean.

                                    We appreciate your feedback!