facebook

EJB 3 Tutorial with JBoss

  1. MyEclipse IDE
  2.  > 
  3. Java EE Development (EJB, JSP, Struts, XDoclet, etc.)
Viewing 15 posts - 16 through 30 (of 37 total)
  • Author
    Posts
  • #252235 Reply

    isitsi
    Member

    Hi !!

    My configuration is :
    Eclipse 3.1.2
    jboss-4.0.4.GA
    JDK 1.5

    I’m experencing MyEclipse plugin for a school project. I followed the first-ejb3-ant tutorial and I dident succeded to deploy the application. this is what I get in JBOOS while running it:

    
    17:17:46,107 ERROR [URLDeploymentScanner] Incomplete Deployment listing:
    
    --- MBeans waiting for other MBeans ---
    ObjectName: persistence.units:jar=FirstEJB3Tutorial Ant.jar,unitName=FirstEjb3Tu
    torial
      State: FAILED
      Reason: org.hibernate.HibernateException: Hibernate Dialect must be explicitly
     set
      I Depend On:
        jboss.jca:service=ManagedConnectionFactory,name=ejb3ExampleDS
      Depends On Me:
        jboss.j2ee:jar=FirstEJB3Tutorial Ant.jar,name=BookTestBean,service=EJB3
    
    ObjectName: jboss.j2ee:jar=FirstEJB3Tutorial Ant.jar,name=BookTestBean,service=E
    JB3
      State: NOTYETINSTALLED
      I Depend On:
        persistence.units:jar=FirstEJB3Tutorial Ant.jar,unitName=FirstEjb3Tutorial
    
    --- MBEANS THAT ARE THE ROOT CAUSE OF THE PROBLEM ---
    ObjectName: persistence.units:jar=FirstEJB3Tutorial Ant.jar,unitName=FirstEjb3Tu
    torial
      State: FAILED
      Reason: org.hibernate.HibernateException: Hibernate Dialect must be explicitly
     set
      I Depend On:
        jboss.jca:service=ManagedConnectionFactory,name=ejb3ExampleDS
      Depends On Me:
        jboss.j2ee:jar=FirstEJB3Tutorial Ant.jar,name=BookTestBean,service=EJB3
    
    

    Anyway I tried to lunch the application but it didnt work (naturally)

    
    C:\workspace\TestEJB\classes>java test.de.laliluna.library.FirstEJB3TutorialClie
    nt
    javax.naming.NoInitialContextException: Need to specify class name in environmen
    t or system property, or as an applet parameter, or in an application resource f
    ile:  java.naming.factory.initial
            at javax.naming.spi.NamingManager.getInitialContext(Unknown Source)
            at javax.naming.InitialContext.getDefaultInitCtx(Unknown Source)
            at javax.naming.InitialContext.getURLOrDefaultInitCtx(Unknown Source)
            at javax.naming.InitialContext.lookup(Unknown Source)
            at test.de.laliluna.library.FirstEJB3TutorialClient.main(Unknown Source)
    
    Exception in thread "main" java.lang.RuntimeException: javax.naming.NoInitialCon
    textException: Need to specify class name in environment or system property, or
    as an applet parameter, or in an application resource file:  java.naming.factory
    .initial
            at test.de.laliluna.library.FirstEJB3TutorialClient.main(Unknown Source)
    
    Caused by: javax.naming.NoInitialContextException: Need to specify class name in
     environment or system property, or as an applet parameter, or in an application
     resource file:  java.naming.factory.initial
            at javax.naming.spi.NamingManager.getInitialContext(Unknown Source)
            at javax.naming.InitialContext.getDefaultInitCtx(Unknown Source)
            at javax.naming.InitialContext.getURLOrDefaultInitCtx(Unknown Source)
            at javax.naming.InitialContext.lookup(Unknown Source)
            ... 1 more
    
    C:\workspace\TestEJB\classes>
    

    Please help because I must make a demo this monday to my schoolmates

    Thanks in advance

    #252242 Reply

    isitsi
    Member

    Hi again I resolved my problem I forgot to put the driver cause I reinstalled Jboss 😳

    I think my ejb are well deployed but I cant lanch my application this is my Error

    [quote=JDK]
    C:\jboss-4.0.4.GA\server\default\deploy\FirstEjb3Tutorial.jar>java test.de.lalil
    una.library.FirstEJB3TutorialClient
    javax.naming.NoInitialContextException: Cannot instantiate class: org.jnp.interf
    aces.NamingContextFactory [Root exception is java.lang.ClassNotFoundException: o
    rg.jnp.interfaces.NamingContextFactory]
    at javax.naming.spi.NamingManager.getInitialContext(Unknown Source)
    at javax.naming.InitialContext.getDefaultInitCtx(Unknown Source)
    at javax.naming.InitialContext.init(Unknown Source)
    at javax.naming.InitialContext.<init>(Unknown Source)
    at test.de.laliluna.library.FirstEJB3TutorialClient.main(FirstEJB3Tutori
    alClient.java:36)
    Caused by: java.lang.ClassNotFoundException: org.jnp.interfaces.NamingContextFac
    tory
    at java.net.URLClassLoader$1.run(Unknown Source)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.net.URLClassLoader.findClass(Unknown Source)
    at java.lang.ClassLoader.loadClass(Unknown Source)
    at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
    at java.lang.ClassLoader.loadClass(Unknown Source)
    at java.lang.ClassLoader.loadClassInternal(Unknown Source)
    at java.lang.Class.forName0(Native Method)
    at java.lang.Class.forName(Unknown Source)
    at com.sun.naming.internal.VersionHelper12.loadClass(Unknown Source)
    … 5 more
    Exception in thread “main” java.lang.RuntimeException: javax.naming.NoInitialCon
    textException: Cannot instantiate class: org.jnp.interfaces.NamingContextFactory
    [Root exception is java.lang.ClassNotFoundException: org.jnp.interfaces.NamingC
    ontextFactory]
    at test.de.laliluna.library.FirstEJB3TutorialClient.main(FirstEJB3Tutori
    alClient.java:47)
    Caused by: javax.naming.NoInitialContextException: Cannot instantiate class: org
    .jnp.interfaces.NamingContextFactory [Root exception is java.lang.ClassNotFoundE
    xception: org.jnp.interfaces.NamingContextFactory]
    at javax.naming.spi.NamingManager.getInitialContext(Unknown Source)
    at javax.naming.InitialContext.getDefaultInitCtx(Unknown Source)
    at javax.naming.InitialContext.init(Unknown Source)
    at javax.naming.InitialContext.<init>(Unknown Source)
    at test.de.laliluna.library.FirstEJB3TutorialClient.main(FirstEJB3Tutori
    alClient.java:36)
    Caused by: java.lang.ClassNotFoundException: org.jnp.interfaces.NamingContextFac
    tory
    at java.net.URLClassLoader$1.run(Unknown Source)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.net.URLClassLoader.findClass(Unknown Source)
    at java.lang.ClassLoader.loadClass(Unknown Source)
    at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
    at java.lang.ClassLoader.loadClass(Unknown Source)
    at java.lang.ClassLoader.loadClassInternal(Unknown Source)
    at java.lang.Class.forName0(Native Method)
    at java.lang.Class.forName(Unknown Source)
    at com.sun.naming.internal.VersionHelper12.loadClass(Unknown Source)
    … 5 more

    C:\jboss-4.0.4.GA\server\default\deploy\FirstEjb3Tutorial.jar>

    Thanks In Advance

    #252270 Reply

    Riyad Kalla
    Member

    Not sure but you may be missing something on your classpath.

    #252841 Reply

    Nicole Wilms
    Member

    I did not get the example working with 4.0.4 GA.

    I had to add the project name in front of the jndi name:

    public static final String RemoteJNDIName = “TestEJB3App/” + BookTestBean.class.getSimpleName() + “/remote”;

    public static final String LocalJNDIName = “TestEJB3App/” + BookTestBean.class.getSimpleName() + “/local”;

    Greetings,

    Edwin

    #257541 Reply

    idtech
    Member

    Hi, I am an EJB3 newbie. I’m trying to deploy laliluna EJB3 tutorial but I came across problems.

    Here are my settings
    __
    MS Win Xp pro SP2
    Java 1.5.0_07
    Eclipse 3.2 with JBoss Eclipse IDE 1.6.0.GA plugin installed
    JBoss 4.0.4 GA installed and running
    jboss-EJB-3.0_Embeddable_ALPHA_8-patch2 libraries available
    MySQL DBMS 4.1.7
    MySQL driver Connector/J 3.1.13 copied in the server/default/lib directory

    I have not created “by hand” any tutorial database in the DBMS.
    __

    I created an EJB project in Eclipse and followed the FirstEjb3Tutorial notes, downloaded from the laliluna website.

    My persistence.xml file is


    <persistence>
    <persistence-unit name=”FirstEjb3Tutorial”>
    <jta-data-source>java:/ejb3ProjectDS</jta-data-source>
    <properties>
    <property name=”hibernate.hbm2ddl.auto” value=”create-drop” />
    <property name=”hibernate.dialect” value=”org.hibernate.dialect.MySQLInnoDBDialect”/>
    </properties>
    </persistence-unit>
    </persistence>

    My mysql-ds.xml in the server/default/deploy dir is


    <datasources>
    <local-tx-datasource>
    <jndi-name>ejb3ExampleDS</jndi-name>
    <connection-url>jdbc:mysql://localhost:3306/ejb3Example</connection-url>
    <driver-class>com.mysql.jdbc.Driver</driver-class>
    <user-name>omissis</user-name>
    <password>omissis</password>
    <exception-sorter-class-name>org.jboss.resource.adapter.jdbc.vendor.MySQLExceptionSorter</exception-sorter-class-name>
    <!– should only be used on drivers after 3.22.1 with “ping” support
    <valid-connection-checker-class-name>org.jboss.resource.adapter.jdbc.vendor.MySQLValidConnectionChecker</valid-connection-checker-class-name>
    –>
    <!– sql to call when connection is created
    <new-connection-sql>some arbitrary sql</new-connection-sql>
    –>
    <!– sql to call on an existing pooled connection when it is obtained from pool – MySQLValidConnectionChecker is preferred for newer drivers
    <check-valid-connection-sql>some arbitrary sql</check-valid-connection-sql>
    –>

    <!– corresponding type-mapping in the standardjbosscmp-jdbc.xml (optional) –>
    <metadata>
    <type-mapping>mySQL</type-mapping>
    </metadata>
    </local-tx-datasource>
    </datasources>

    ..and the ejb-jar.xml is


    <?xml version=”1.0″ encoding=”UTF-8″?>
    <ejb-jar>
    <enterprise-beans>
    </enterprise-beans>
    </ejb-jar>

    When I deploy the tutorial I get the following log from JBOSS

    —————————————————————————————
    13:49:49,293 INFO [Ejb3Deployment] EJB3 deployment time took: 532
    13:49:49,324 INFO [JmxKernelAbstraction] installing MBean: persistence.units:ja
    r=FirstEjb3Tutorial.jar,unitName=FirstEjb3Tutorial with dependencies:
    13:49:49,324 INFO [JmxKernelAbstraction] jboss.jca:name=ejb3ProjectDS,ser
    vice=ManagedConnectionFactory
    13:49:49,402 INFO [JmxKernelAbstraction] installing MBean: jboss.j2ee:jar=First
    Ejb3Tutorial.jar,name=BookTestBean,service=EJB3 with dependencies:
    13:49:49,402 INFO [JmxKernelAbstraction] persistence.units:jar=FirstEjb3T
    utorial.jar,unitName=FirstEjb3Tutorial
    13:49:49,418 INFO [EJB3Deployer] Deployed: file:/C:/Programmi/jboss-4.0.4.GA/se
    rver/default/deploy/FirstEjb3Tutorial.jar
    13:49:49,418 ERROR [URLDeploymentScanner] Incomplete Deployment listing:

    — MBeans waiting for other MBeans —
    ObjectName: persistence.units:jar=FirstEjb3Tutorial.jar,unitName=FirstEjb3Tutorial
    State: NOTYETINSTALLED
    I Depend On:
    jboss.jca:name=ejb3ProjectDS,service=ManagedConnectionFactory
    Depends On Me:
    jboss.j2ee:jar=FirstEjb3Tutorial.jar,name=BookTestBean,service=EJB3

    ObjectName: jboss.j2ee:jar=FirstEjb3Tutorial.jar,name=BookTestBean,service=EJB3
    State: NOTYETINSTALLED
    I Depend On:
    persistence.units:jar=FirstEjb3Tutorial.jar,unitName=FirstEjb3Tutorial

    — MBEANS THAT ARE THE ROOT CAUSE OF THE PROBLEM —
    ObjectName: jboss.jca:name=ejb3ProjectDS,service=ManagedConnectionFactory
    State: NOTYETINSTALLED
    Depends On Me:
    persistence.units:jar=FirstEjb3Tutorial.jar,unitName=FirstEjb3Tutorial
    —————————————————————————————

    I can’t go further in the exercise, is there anyone can help me do succeed?

    thanks

    G.

    #257568 Reply

    Riyad Kalla
    Member

    idtech,
    Be sure to email Sebastian over at LaLiLuna and please post your findings here if you get the issue resolved (off hand I don’t know what is wrong, I’m sorry)

    #258202 Reply

    alexeinov
    Member

    @idtech wrote:

    — MBEANS THAT ARE THE ROOT CAUSE OF THE PROBLEM —
    ObjectName: jboss.jca:name=ejb3ProjectDS,service=ManagedConnectionFactory
    State: NOTYETINSTALLED

    Read carefully the quoted output. It says that a deployer is missing the ejb3ProjectDS datasource. There can be two reasons for that:

    1. Youre datasource is named something different. Make sure that your *-ds.xml datasource descriptor file really declares this name.

    <jndi-name>ejb3ProjectDS</jndi-name>

    2. The *-ds.xml file is not deployed. Copy the file to the jboss/server/default folder

    Don’t forget to restart jboss

    #264723 Reply

    deeeed
    Member

    Hi, i try to test the tutorial but i have a problem with the persistance unit.
    I can’t see the jndi name corresponding to my ejb in the web-console.
    My persistance.xml file is:

    <persistence>
    <persistence-unit name=”FirstEjb3Tutorial”>
    <jta-data-source>java:/ejb3ProjectDS</jta-data-source>
    <properties>
    <property name=”hibernate.hbm2ddl.auto”
    value=”create-drop”/>
    </properties>
    </persistence-unit>
    </persistence>

    I also have deployed a file mysql-ds.xml which is:

    <?xml version="1.0" encoding="UTF-8"?>
    
    <!-- $Id: mysql-ds.xml 41016 2006-02-07 14:23:00Z acoliver $ -->
    <!--  Datasource config for MySQL using 3.0.9 available from:
    http://www.mysql.com/downloads/api-jdbc-stable.html
    -->
    
    <datasources>
      <local-tx-datasource>
        <jndi-name>MySqlDS</jndi-name>
        <connection-url>jdbc:mysql://localhost:3306/examples</connection-url>
        <driver-class>com.mysql.jdbc.Driver</driver-class>
        <user-name>root</user-name>
        <password></password>
        <!-- the minimum size of the connection pool -->
        <min-pool-size>1</min-pool-size>
        <!-- The maximum connections in a pool/sub-pool -->
         <max-pool-size>4</max-pool-size>
         
        <exception-sorter-class-name>org.jboss.resource.adapter.jdbc.vendor.MySQLExceptionSorter</exception-sorter-class-name>
        <!-- should only be used on drivers after 3.22.1 with "ping" support
        <valid-connection-checker-class-name>org.jboss.resource.adapter.jdbc.vendor.MySQLValidConnectionChecker</valid-connection-checker-class-name>
        -->
        <!-- sql to call when connection is created
        <new-connection-sql>some arbitrary sql</new-connection-sql>
          -->
        <!-- sql to call on an existing pooled connection when it is obtained from pool - MySQLValidConnectionChecker is preferred for newer drivers
        <check-valid-connection-sql>some arbitrary sql</check-valid-connection-sql>
          -->
    
        <!-- corresponding type-mapping in the standardjbosscmp-jdbc.xml (optional) -->
        <metadata>
           <type-mapping>mySQL</type-mapping>
        </metadata>
      </local-tx-datasource>
    </datasources>
    
    

    When i start my jboss server i have the following erros:


      00:49:54,718 INFO [ConnectionFactoryBindingService] Bound ConnectionManager ‘jboss.jca:service=ConnectionFactoryBinding,name=JmsXA’ to JNDI name ‘java:JmsXA’
      00:49:54,843 INFO [WrapperDataSourceService] Bound ConnectionManager ‘jboss.jca:service=DataSourceBinding,name=MySqlDS’ to JNDI name ‘java:MySqlDS’
      00:49:55,062 INFO [Ejb3Deployment] EJB3 deployment time took: 156
      00:49:55,156 INFO [JmxKernelAbstraction] installing MBean: jboss.j2ee:jar=FirstEjb3Tutorial.jar,name=BookTestBean,service=EJB3 with dependencies:
      00:49:55,156 INFO [JmxKernelAbstraction] persistence.units:unitName=FirstEjb3Tutorial
      00:49:55,156 INFO [EJB3Deployer] Deployed: file:/C:/java/serveurs/jboss-4.0.5.GA/server/all/deploy/FirstEjb3Tutorial.jar
      00:49:55,187 INFO [TomcatDeployer] deploy, ctxPath=/jmx-console, warUrl=…/deploy/jmx-console.war/
      00:49:55,484 ERROR [URLDeploymentScanner] Incomplete Deployment listing:

      — MBeans waiting for other MBeans —
      ObjectName: jboss.j2ee:jar=FirstEjb3Tutorial.jar,name=BookTestBean,service=EJB3
      State: NOTYETINSTALLED
      I Depend On:
      persistence.units:unitName=FirstEjb3Tutorial

      — MBEANS THAT ARE THE ROOT CAUSE OF THE PROBLEM —
      ObjectName: persistence.units:unitName=FirstEjb3Tutorial
      State: NOTYETINSTALLED
      Depends On Me:
      jboss.j2ee:jar=FirstEjb3Tutorial.jar,name=BookTestBean,service=EJB3

      00:49:55,578 INFO [Http11BaseProtocol] Starting Coyote HTTP/1.1 on http-0.0.0.0-8080

    I tried to edit my persistance.xml but i always have erros.
    Do you know where is the problem with my persistance unit ?

    #268393 Reply

    fulgutza
    Member

    Hm.. I have the same error when trying to deploy the example. The persistence.xml file seems to be ok…

    #271333 Reply

    Jeromy Evans
    Member

    The example at http://www.laliluna.de/ejb-3-tutorial-jboss.html does not work if you copy-and-paste the code because the datasource name in persistence.xml is “ejb3ProjectDS” but the datasource name in myFavouriteName-ds.xml is “ejb3ExampleDS”.

    The mismatch will cause the error:

    --- MBEANS THAT ARE THE ROOT CAUSE OF THE PROBLEM ---
    ObjectName: jboss.jca:name=ejb3ProjectDS,service=ManagedConnectionFactory
    State: NOTYETINSTALLED 

    because ejb3ProjectDS is not defined.

    To fix it ensure the datasource name in your persistence.xml file matches the jndi name of the datasource in your *-ds.xml file. Use any name you like.

    – Jeromy

    #274337 Reply

    Andy Ghosh
    Member

    I am getting the following error. Can someone please tell me which jar file has this NamingContextFactory class?
    Thanks
    Andy
    javax.naming.NoInitialContextException: Cannot instantiate class: org.jnp.interfaces.NamingContextFactory [Root exception is java.lang.ClassNotFoundException: org.jnp.interfaces.NamingContextFactory]
    at javax.naming.spi.NamingManager.getInitialContext(Unknown Source)
    at javax.naming.InitialContext.getDefaultInitCtx(Unknown Source)
    at javax.naming.InitialContext.init(Unknown Source)
    at javax.naming.InitialContext.<init>(Unknown Source)
    at com.andy.ejb3.AdviceClient.main(AdviceClient.java:20)
    Caused by: java.lang.ClassNotFoundException: org.jnp.interfaces.NamingContextFactory
    at java.net.URLClassLoader$1.run(Unknown Source)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.net.URLClassLoader.findClass(Unknown Source)
    at java.lang.ClassLoader.loadClass(Unknown Source)
    at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
    at java.lang.ClassLoader.loadClass(Unknown Source)
    at java.lang.ClassLoader.loadClassInternal(Unknown Source)
    at java.lang.Class.forName0(Native Method)
    at java.lang.Class.forName(Unknown Source)
    at com.sun.naming.internal.VersionHelper12.loadClass(Unknown Source)

    #281622 Reply

    Joe
    Member

    Thanks, Jeromy, that was exactly the problem I encountered. You saved my day. This will probably happen to many many people…

    #281664 Reply

    amir55
    Participant

    hi all

    I am on the full subscription of MyEclipse IDe with the latest one is 6

    so I rely more on the help search for tutorial of project called SampleEJBProject . The one now is ejb3. I followed all the steps .but only difference that I use Jboss.so Please read the error I get. in numbers.

    1 – last four lines of deploying

    10:12:24,171 INFO [JmxKernelAbstraction] creating wrapper delegate for: org.jboss.ejb3.stateless.StatelessContainer
    10:12:24,187 INFO [JmxKernelAbstraction] installing MBean: jboss.j2ee:jar=SampleEJBProject.jar,name=MyBean,service=EJB3 with dependencies:
    10:12:25,046 INFO [EJBContainer] STARTED EJB: com.myeclipseide.ejb3.MyBean ejbName: MyBean
    10:12:25,656 INFO [EJB3Deployer] Deployed: file:/D:/Jboss_Group/jboss-4.2.1.GA/server/default/deploy/SampleEJBProject.jar/

    2 – error message
    avax.naming.NameNotFoundException: com.myeclipseide.ejb3.MyBeanRemote not bound

    3 – source of error here

    InitialContext ctx = new InitialContext();
    MyBeanRemote bean = (MyBeanRemote) ctx.lookup(“com.myeclipseide.ejb3.MyBeanRemote”);

    4 – I use MyEclipse 6, Jboss 4.2 windos 2000

    I have error too in Mr Sabastian’s tutorial but he uses entity which I like to get a seesoin only to work first also I use mysql which needs different annotaions that I do not know where to palce too. moreover I like Myeclipse help tutorials more

    please guide to the problem of if any good guy would email me the working code zipped or I send hih/her mine to very slightly amendment or JBoss slight setting.

    my email alhakim55@yahoo.com or PM.

    kinds to all
    Amir

    I

    #282127 Reply

    sachin6870
    Member

    I am trying to deploy this sample application to jboss ejb container.
    jmx console is not showing BookTestBean deployed, but I can see datasource ejb3ExampleDS.

    Also I am not getting any error message on system console and jboss log.

    log message:
    2008-02-26 16:54:39,703 DEBUG [org.jboss.ejb.EjbModule] Started jboss.j2ee:service=EjbModule,module=FirstEJB3Tutorial.jar

    I am totally new to ejbs, I have never tried provious version of ejb.
    am I missing anything?
    any pointer will be greatly appreciated…

    Thanks

    Sachin.

    #282172 Reply

    tuhucon
    Member

    hello,
    thanks for your post. can you post a EJB 3 tutorial with glassfish ???

Viewing 15 posts - 16 through 30 (of 37 total)
Reply To: EJB 3 Tutorial with JBoss

You must be logged in to post in the forum log in