Hi:
I am using MyEclipse 5.1.1 and Microsoft SQL 2000.
I was able to get the HelloWorld with the Hibernate Core on page 46 to work and the HelloWorld to work with the annotations page 69 to work.
I was not able to get the HelloWorld to work on page 85.
This is the error:
Exception:MessageHandlerBean not bound
I used the jar files from the CaveatTemptor JPA/EJB 3.0 project on the url:
http://www.hibernate.org/400.html.
I get the following exception:
e NameNotFoundException (id=94)
cause NameNotFoundException (id=94)
detailMessage "MessageHandlerBean not bound"
remainingName null
resolvedName null
resolvedObj null
rootException null
stackTrace null
when it execute the following line:
MessageHandler msgHandler = (MessageHandler) initialContext.lookup("MessageHandlerBean/local");
Here is my HelloWorld.java:
package hello;
import org.jboss.ejb3.embedded.EJB3StandaloneBootstrap;
import javax.naming.InitialContext;
public class HelloWorld {
public static void main(String[] args)
{
// Bott the JBoss Microcontainer with EJB3 settings, automaticall
// loads ejb3-interceptors-aop.xml and embedded-jboss-beans.xml
EJB3StandaloneBootstrap.boot(null);
// Deploy custom stateless beans (datasource, mostly)
EJB3StandaloneBootstrap
.deployXmlResource("META-INF/helloworld-beans.xml");
// Deploy all EJBs found on classpath (slow, scans all)
// EJB3StandaloneBootstrap.scanClasspath();
// Deploy all EJBs found on classpath (fast, scans build directory)
// This is a relative location, matching the substring end of one
// of java.class.path locations. Print out the value of
// System.getProperty("java.class.path") to see all paths
EJB3StandaloneBootstrap.scanClasspath("HelloWorldEJB3/bin");
try
{
// Create InitialContext from jdni.properties
InitialContext initialContext = new InitialContext();
// Look up the stateless MessageHandler EJB
MessageHandler msgHandler = (MessageHandler) initialContext.lookup("MessageHandlerBean/local");
// Call the stateless EJB
msgHandler.saveMessages();
msgHandler.showMessages();
}
catch(Exception e)
{
System.out.println("Exception:"+e.getMessage());
}
// Shut down EJB container
EJB3StandaloneBootstrap.shutdown();
}
}
Here is my persistence.xml:
<persistence xmlns="http://java.sun.com/xml/ns/persistence"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/persistence
http://java.sun.com/xml/ns/persistence/ ... ce_1_0.xsd"
version="1.0">
<persistence-unit name="helloworld">
<jta-data-source>java:/HelloWorldDS</jta-data-source>
<properties>
<!-- SQL to stdout logging -->
<property name="show_sql" value="true"/>
<property name="format_sql" value="true"/>
<property name="dialect" value="org.hibernate.dialect.SQLServerDialect"/>
<property name="hibernate.hbm2ddl.auto" value="create"/>
</properties>
</persistence-unit>
</persistence>
Here is my helloworld-beans.xml:
<?xml version="1.0" encoding="UTF-8"?>
<deployment xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="urn:jboss:bean-deployer bean-deployer_1_0.xsd"
xmlns="urn:jboss:bean-deployer:2.0">
<!-- Enable a JCA datasource available through JNDI -->
<bean name="helloWorldDatasourceFactory"
class="org.jboss.resource.adapter.jdbc.local.LocalTxDataSource">
<property name="jndiName">java:/HelloWorldDS</property>
<!-- HSQL DB -->
<property name="driverClass">net.sourceforge.jtds.jdbc.Driver</property>
<property name="connectionURL">jdbc:jtds:sqlserver://albertlam:1433/Hibernate</property>
<property name="userName">sa</property>
<property name="password">mychau1</property>
<property name="minSize">0</property>
<property name="maxSize">10</property>
<property name="blockingTimeout">1000</property>
<property name="idleTimeout">100000</property>
<property name="transactionManager"><inject bean="TransactionManager"/></property>
<property name="cachedConnectionManager"><inject bean="CachedConnectionManager"/></property>
<property name="initialContextProperties"><inject bean="InitialContextProperties"/></property>
</bean>
<bean name="HelloWorldDS" class="java.lang.Object">
<constructor factoryMethod="getDatasource">
<factory bean="helloWorldDatasourceFactory"/>
</constructor>
</bean>
</deployment>
Any help would be greatly appreciated!!!!
Yours,
Curious