<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<body link="#355491" alink="#4262a1" vlink="#355491" style="background: #e2e2e2; margin: 0; padding: 20px;">

<div>
        <table cellpadding="0" bgcolor="#FFFFFF" border="0" cellspacing="0" style="border: 1px solid #dadada; margin-bottom: 30px; width: 100%; -moz-border-radius: 6px; -webkit-border-radius: 6px;">
                <tbody>
                        <tr>

                                <td>

                                        <table border="0" cellpadding="0" cellspacing="0" bgcolor="#FFFFFF" style="border: solid 2px #ccc; background: #dadada; width: 100%; -moz-border-radius: 6px; -webkit-border-radius: 6px;">
                                                <tbody>
                                                        <tr>
                                                                <td bgcolor="#000000" valign="middle" height="58px" style="border-bottom: 1px solid #ccc; padding: 20px; -moz-border-radius-topleft: 3px; -moz-border-radius-topright: 3px; -webkit-border-top-right-radius: 5px; -webkit-border-top-left-radius: 5px;">
                                                                        <h1 style="color: #333333; font: bold 22px Arial, Helvetica, sans-serif; margin: 0; display: block !important;">
                                                                        <!-- To have a header image/logo replace the name below with your img tag -->
                                                                        <!-- Email clients will render the images when the message is read so any image -->
                                                                        <!-- must be made available on a public server, so that all recipients can load the image. -->
                                                                        <a href="https://community.jboss.org/index.jspa" style="text-decoration: none; color: #E1E1E1">JBoss Community</a></h1>
                                                                </td>

                                                        </tr>
                                                        <tr>
                                                                <td bgcolor="#FFFFFF" style="font: normal 12px Arial, Helvetica, sans-serif; color:#333333; padding: 20px;  -moz-border-radius-bottomleft: 4px; -moz-border-radius-bottomright: 4px; -webkit-border-bottom-right-radius: 5px; -webkit-border-bottom-left-radius: 5px;"><h3 style="margin: 10px 0 5px; font-size: 17px; font-weight: normal;">
    EJB java.lang.NoClassDefFoundError: javax/persistence/EntityManager
</h3>
<span style="margin-bottom: 10px;">
    created by <a href="https://community.jboss.org/people/squarcio">marco squarcini</a> in <i>EJB3</i> - <a href="https://community.jboss.org/message/826760#826760">View the full discussion</a>
</span>
<hr style="margin: 20px 0; border: none; background-color: #dadada; height: 1px;">

<div class="jive-rendered-content"><p><span class="short_text" id="result_box" lang="en"><span class="hps">Hello</span> <span class="hps">to all,</span></span></p><p><span class="short_text" lang="en"><span class="hps">I'm new to javaEE and JBoss AS and </span></span><span class="short_text" id="result_box" lang="en"><span class="hps">i</span><span>'m trying to learn developing EJB applications but i have a problem i don't know how to solve.</span></span></p><p><span class="short_text" id="result_box" lang="en"><span>I use NetBeans 7.3 and JBoss AS 7.1.1.</span></span></p><p><span class="short_text" id="result_box" lang="en"><span>I have been created an EJB 3.1 module with an entity bean and a session bean with remote interface that </span></span><span id="result_box" lang="en"><span class="hps">performs the</span> <span class="hps">database operations</span> <span class="hps">using the entity bean.</span></span></p><p><span lang="en"><span class="hps">After i have been created a java application to access the EJB module:</span></span></p><ol><li style="text-align: start;"><span lang="en"><span class="hps">inside the library of the project i put the jboss-client.jar and the EJB module.jar files</span></span></li><li style="text-align: start;"><span lang="en"><span class="hps">i have been created a config package with the jboss-ejb-client.properties file</span></span></li><li style="text-align: start;"><span lang="en"><span class="hps">i lookup the bean with the method :<br/></span></span></li></ol><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>public static ControllerPrenotazioniRemote lookupRemoteControllerPrenotazioni() throws NamingException {</p><p>&#160;&#160;&#160;&#160;&#160;&#160;&#160; final Hashtable jndiProperties = new Hashtable();</p><p>&#160;&#160;&#160;&#160;&#160;&#160;&#160; jndiProperties.put(Context.URL_PKG_PREFIXES, "org.jboss.ejb.client.naming");</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>&#160;&#160;&#160;&#160;&#160;&#160;&#160; final Context context = new InitialContext(jndiProperties);</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>&#160;&#160;&#160;&#160;&#160;&#160;&#160; final String appName = "";</p><p>&#160;&#160;&#160;&#160;&#160;&#160;&#160; final String moduleName = "EJBModule1";</p><p>&#160;&#160;&#160;&#160;&#160;&#160;&#160; final String distinctName = "";</p><p>&#160;&#160;&#160;&#160;&#160;&#160;&#160; final String beanName = ControllerPrenotazioni.class.getSimpleName();</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>&#160;&#160;&#160;&#160;&#160;&#160;&#160; final String viewClassName = ControllerPrenotazioniRemote.class.getName();</p><p>&#160;&#160;&#160;&#160;&#160;&#160;&#160; System.out.println("Looking EJB via JNDI ");</p><p>&#160;&#160;&#160;&#160;&#160;&#160;&#160; System.out.println("ejb:" + appName + "/" + moduleName + "/" + distinctName + "/" + beanName + "!" + viewClassName);</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>&#160;&#160;&#160;&#160;&#160;&#160;&#160; return (ControllerPrenotazioniRemote) context.lookup("ejb:/EJBModule1/ControllerPrenotazioni!"</p><p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; + ControllerPrenotazioniRemote.class.getName() + "?stateful");</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>&#160;&#160;&#160; }</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>I deploy the EJB module less problems,but when i try to run the java application i see thi error in the output tab of NetBeans:</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>Exception in thread "main" java.lang.NoClassDefFoundError: javax/persistence/EntityManager</p><p>&#160;&#160;&#160; at controllers.ControllerPrenotazioni.trovaPrenotazione(ControllerPrenotazioni.java:133)</p><p>&#160;&#160;&#160; at principale.Main.main(Main.java:22)</p><p>Caused by: java.lang.ClassNotFoundException: javax.persistence.EntityManager</p><p>&#160;&#160;&#160; at java.net.URLClassLoader$1.run(URLClassLoader.java:366)</p><p>&#160;&#160;&#160; at java.net.URLClassLoader$1.run(URLClassLoader.java:355)</p><p>&#160;&#160;&#160; at java.security.AccessController.doPrivileged(Native Method)</p><p>&#160;&#160;&#160; at java.net.URLClassLoader.findClass(URLClassLoader.java:354)</p><p>&#160;&#160;&#160; at java.lang.ClassLoader.loadClass(ClassLoader.java:424)</p><p>&#160;&#160;&#160; at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:308)</p><p>&#160;&#160;&#160; at java.lang.ClassLoader.loadClass(ClassLoader.java:357)</p><p>&#160;&#160;&#160; ... 2 more</p><p>Java Result: 1</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p><span class="short_text" id="result_box" lang="en"><span class="hps">I do not know</span> <span class="hps">where</span> <span class="hps">I'm wrong!S</span></span>omeone can help me to solve this problem?</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>Thank you to all in advance....</p></div>

<div style="background-color: #f4f4f4; padding: 10px; margin-top: 20px;">
    <p style="margin: 0;">Reply to this message by <a href="https://community.jboss.org/message/826760#826760">going to Community</a></p>
        <p style="margin: 0;">Start a new discussion in EJB3 at <a href="https://community.jboss.org/choose-container!input.jspa?contentType=1&containerType=14&container=2029">Community</a></p>
</div></td>
                        </tr>
                    </tbody>
                </table>


                </td>
            </tr>
        </tbody>
    </table>

</div>

</body>
</html>