[EJB 3.0] - Re: SLSB Local Interface Exception - EjB 3.0 with jboss-4.0.
by vashistvishal
Thanks for replying ...
Here we go :)
This is my Bean
| @Stateless
|
| public class StoreAccessBean implements StoreAccessLocal, StoreAccessRemote {
| public int add (int num1 , int num2) {
| int sum = num1 + num2;
| System.out.println ("I'm at server side Sum is " + sum);
| return sum;
| }
| }
|
This is my interface
| @Local
|
| public interface StoreAccessLocal {
| public int add (int num1, int num2);
| }
|
I havent added my remote interface code here.
This is my calling client.
| public static void main(String [] args)
| {
| try
| {
| Context jndiContext = getInitialContext();
|
| Object ref = jndiContext.lookup("StoreAccessBean/remote");
| System.out.println ("Name : "+ ref.getClass().getName());
| StoreAccessRemote sa = (StoreAccessRemote)ref;
| int sum = sa.add(10, 20);
| System.out.println("Remote Bean: Sum returned from server is " + sum );
| // Until now it works fine
|
| // Problem area.... starts here
| Object reflocal = jndiContext.lookup("StoreAccessBean/local");
| System.out.println ("Name : "+ reflocal.getClass().getName());
| StoreAccessLocal salocal = (StoreAccessLocal)reflocal;
| System.out.println("I 'm fine until now ");
| // Fails here
| int sumlocal = salocal.add(10, 40);
|
| System.out.println("Local Bean: Sum returned from server is " + sumlocal );
|
|
I hope this helps in nailing down this problem.
Vishal
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=3972484#3972484
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=3972484
19 years, 7 months
[JNDI/Naming/Network] - Deployment dependencies
by jcsf
Hi -
I have never posted here for fear of being flamed, so please go gently on me :)
I'm using JBoss 4.0.4 GA
I have an EAR file which currently contains just a HAR (Hibernate) service, but which will contain more services for deployment shortly.
The Hibernate MBean is currently configured to find its Datasource in JNDI at java:/MagicDS.
On most servers this is fine - the relevant datasource is bound to that name. On some servers however, it is bound to java:/SpiritDS for legacy reasons.
Is there a mechanism by which I can deploy exactly the same EAR file to all servers, and create a "filter" of some kind, which would allow me to place the Datasource JNDI address in a file outside the EAR? Or is there another solution I am blatently overlooking?
Many thanks
JCS
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=3972481#3972481
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=3972481
19 years, 7 months
[Persistence, JBoss/CMP, Hibernate, Database] - Re: DerbyDatabase mbean in 4.0.3 missing?
by richardToren
You have to go into the deploy/jms folder and replace the hsql-jdbc2-service.xml with the following below. There was an error in the original text (it read EXITS not EXISTS). If you have the other dependencies for Derby in place and the datasource initalizes properly this should work (or to be exact, it works on 4.0.4GA for me under jdk 1.5 ):
| <?xml version="1.0" encoding="UTF-8"?>
|
| <!-- $Id: derby-jdbc2-service.xml,v 1.1.4.2 2005/12/29 15:27:57 ltexier Exp $ -->
|
|
|
| <!-- ==================================================================== -->
| <!-- Persistence and caching using DERBY-DB (Synonym: IBM-Cloudscape) -->
| <!-- See docs/examples/jms for other configurations -->
| <!-- IMPORTANT: Remove hsqldb-jdbc2-service.xml -->
| <!-- -->
| <!-- Configuration supplied by Bison Schweiz AG Hendrik Schäfer -->
| <!-- ==================================================================== -->
|
| <!--
| | The destination manager is the core service within JBossMQ
| -->
|
| <depends optional-attribute-name="MessageCache">jboss.mq:service=MessageCache
| <depends optional-attribute-name="PersistenceManager">jboss.mq:service=PersistenceManager
| <depends optional-attribute-name="StateManager">jboss.mq:service=StateManager
|
|
| <!--
| | The MessageCache decides where to put JBossMQ message that
| | are sitting around waiting to be consumed by a client.
| |
| | The memory marks are in Megabytes. Once the JVM memory usage hits
| | the high memory mark, the old messages in the cache will start getting
| | stored in the DataDirectory. As memory usage gets closer to the
| | Max memory mark, the amount of message kept in the memory cache aproaches 0.
| -->
|
| 50
| 60
| jboss.mq:service=PersistenceManager
|
|
| <!-- The PersistenceManager is used to store messages to disk. -->
| <!--
| | The jdbc2 PersistenceManager is the new improved JDBC implementation.
| | This implementation allows you to control how messages are stored in
| | the database.
| |
| | This jdbc2 PM configuration has been tested against Derby DB
| |
| -->
|
| <depends optional-attribute-name="ConnectionManager">jboss.jca:service=DataSourceBinding,name=DerbyDS
|
| BLOB_TYPE=BYTES_BLOB
| INSERT_TX = INSERT INTO JMS_TRANSACTIONS (TXID) values(?)
| INSERT_MESSAGE = INSERT INTO JMS_MESSAGES (MESSAGEID, DESTINATION, MESSAGEBLOB, TXID, TXOP) VALUES(?,?,?,?,?)
| SELECT_ALL_UNCOMMITED_TXS = SELECT TXID FROM JMS_TRANSACTIONS
| SELECT_MAX_TX = SELECT MAX(TXID) FROM JMS_MESSAGES
| DELETE_ALL_TX = DELETE FROM JMS_TRANSACTIONS
| SELECT_MESSAGES_IN_DEST = SELECT MESSAGEID, MESSAGEBLOB FROM JMS_MESSAGES WHERE DESTINATION=?
| SELECT_MESSAGE_KEYS_IN_DEST = SELECT MESSAGEID FROM JMS_MESSAGES WHERE DESTINATION=?
| SELECT_MESSAGE = SELECT MESSAGEID, MESSAGEBLOB FROM JMS_MESSAGES WHERE MESSAGEID=? AND DESTINATION=?
| MARK_MESSAGE = UPDATE JMS_MESSAGES SET TXID=?, TXOP=? WHERE MESSAGEID=? AND DESTINATION=?
| UPDATE_MESSAGE = UPDATE JMS_MESSAGES SET MESSAGEBLOB=? WHERE MESSAGEID=? AND DESTINATION=?
| UPDATE_MARKED_MESSAGES = UPDATE JMS_MESSAGES SET TXID=?, TXOP=? WHERE TXOP=?
| UPDATE_MARKED_MESSAGES_WITH_TX = UPDATE JMS_MESSAGES SET TXID=?, TXOP=? WHERE TXOP=? AND TXID=?
| DELETE_MARKED_MESSAGES_WITH_TX = DELETE FROM JMS_MESSAGES WHERE EXISTS (SELECT JMS_TRANSACTIONS.TXID FROM JMS_TRANSACTIONS \
| WHERE JMS_TRANSACTIONS.TXID = JMS_MESSAGES.TXID) \
| AND JMS_MESSAGES.TXOP = ?
| DELETE_TX = DELETE FROM JMS_TRANSACTIONS WHERE TXID = ?
| DELETE_MARKED_MESSAGES = DELETE FROM JMS_MESSAGES WHERE TXID=? AND TXOP=?
| DELETE_TEMPORARY_MESSAGES = DELETE FROM JMS_MESSAGES WHERE TXOP='T'
| DELETE_MESSAGE = DELETE FROM JMS_MESSAGES WHERE MESSAGEID=? AND DESTINATION=?
| CREATE_MESSAGE_TABLE = CREATE TABLE JMS_MESSAGES (MESSAGEID INTEGER NOT NULL, \
| DESTINATION VARCHAR(255) NOT NULL, TXID INTEGER, TXOP CHAR(1), \
| MESSAGEBLOB blob(1024M), PRIMARY KEY (MESSAGEID, DESTINATION))
| CREATE_IDX_MESSAGE_TXOP_TXID = CREATE INDEX JMS_MESSAGES_TXOP_TXID ON JMS_MESSAGES (TXOP, TXID)
| CREATE_IDX_MESSAGE_DESTINATION = CREATE INDEX JMS_MESSAGES_DESTINATION ON JMS_MESSAGES (DESTINATION)
| CREATE_TX_TABLE = CREATE TABLE JMS_TRANSACTIONS ( TXID INTEGER not null, PRIMARY KEY (TXID) )
| CREATE_TABLES_ON_STARTUP = TRUE
|
| <!-- Uncomment to override the transaction timeout for recovery per queue/subscription, in seconds -->
| <!--attribute name="RecoveryTimeout">0</attribute-->
| <!-- The number of blobs to load at once during message recovery -->
| 0
|
|
|
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=3972475#3972475
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=3972475
19 years, 7 months
[JBoss Portal] - Facing problem in getting the portal
by raj.shanmug
Hi all,
In the event of installing the JBoss Application server and Portal. These are steps that i followed
1. I have downloded the Jboss 4.0.4 CR2 and Jboss Portal 2.4 ALPHA.
I have unzipped both the zip files and now i configured the portal-sqlserverds.xml file in the portal and copied both the configured xml and the
portal.sar file to the JBOSS_Home/default/deploy directory of the App Server.
2. Then i have copied the jdbc jar files to the default/lib directory.
3. Prior to this i have also set the environment variables to the path, classpath, JBOSS_HOME; JAVA_HOME.
4. I started the run.bat file in the jboss/bin.
5. The jboss server started, but i encountered the following error when i pointed the browser to the portal.
HTTP Status 500 -
--------------------------------------------------------------------------------
type Exception report
message
description The server encountered an internal error () that prevented it from fulfilling this request.
exception
java.lang.IllegalArgumentException: Cannot invoke with a null interceptor[]
org.jboss.portal.common.invocation.Invocation.invoke(Invocation.java:163)
org.jboss.portal.server.servlet.PortalServlet.doGet(PortalServlet.java:231)
javax.servlet.http.HttpServlet.service(HttpServlet.java:697)
javax.servlet.http.HttpServlet.service(HttpServlet.java:810)
org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:96)
note The full stack trace of the root cause is available in the Apache Tomcat/5.5.16 logs.
---Raj
--------------------------------------------------------------------------------
Apache Tomcat/5.5.16
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=3972466#3972466
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=3972466
19 years, 7 months
[JBoss Portal] - Ajax Provider Servlet question
by jackpark
Situation: JBoss Portal AS 2.4.0
Homegrown portlet that feeds from a JCR backside.
Desire:
Feed an index page that loads content from an AJAX servlet.
Following the example, my portlet which appears as:
/portal/portal/default/BrainInfo
which is showing in a window called NeuroNamesPortletWindow
thus: a PortletURL looks like:
/portal/portal/default/BrainInfo/NeuroNamesPortletWindow?action=2
In the Ajax example, it uses the JSPPortlet and a Servlet class.
The webxml in that war file calls for this pattern:
<url-pattern>/InvoiceServlet</url-pattern>
and the html to call that servlet is:
"/AJAXPortlet/InvoiceServlet?invoice=" + select.value
In my case, use the pattern:
<url-pattern>/NeuronamesAjaxServlet</url-pattern>
and try calling it with this html:
"/BrainInfo/NeuronamesAjaxServlet?tree=" + select.value
That does not fire up the servlet
I have experimented with different combinations, from:
/portal/portal/default/BrainInfo/... and so on,
Those occasionally return the entire portal homepage or sometimes the portlet page itself, but never a peep from the servlet.
All that to say that my WEB-INF mimics that of the AJAX demo portlet, but my servlet never fires when called.
I should say that a difference is that my servlet doGet actually queries the backside and returns the html snippets directly.
I would greatly appreciate some ideas on how to call that servlet.
Many thanks
Jack
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=3972464#3972464
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=3972464
19 years, 7 months
[EJB 3.0] - Re: Embeddable EJB3 Alpha 9 in JUnit
by r_q_d
I am tring to follow tips from http://wiki.jboss.org/wiki/Wiki.jsp?page=EJB3EmbeddedPerformanceTips and I want to run the test case without put all the classes in to jar file, I get following error. My code is followed by the error message. Any body can provide any help? I am using jboss-EJB-3.0_Embeddable_ALPHA_9
Thanks in advance.
Quande.
ERROR 18-09 23:11:43,837 (AbstractController.java:incrementState:440) -Error installing to Start: name=java:comp/Initializer state=Create
javax.naming.NoInitialContextException: Cannot instantiate class:
org.jnp.interfaces.LocalOnlyContextFactory [Root exception is java.lang.ClassNotFoundException:
org.jnp.interfaces.LocalOnlyContextFactory]
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.(Unknown Source)
at org.jboss.ejb3.EJB3Util.getInitialContext(EJB3Util.java:95)
at org.jboss.ejb3.embedded.JavaCompInitializer.start(JavaCompInitializer.java:52)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.jboss.reflect.plugins.introspection.ReflectionUtils.invoke(ReflectionUtils.java:55)
at org.jboss.reflect.plugins.introspection.ReflectMethodInfoImpl.invoke(ReflectMethodInfoImpl.java:107)
at org.jboss.joinpoint.plugins.BasicMethodJoinPoint.dispatch(BasicMethodJoinPoint.java:66)
at org.jboss.kernel.plugins.dependency.KernelControllerContextAction.dispatchJoinPoint(KernelControllerContextAction.java:75)
at org.jboss.kernel.plugins.dependency.LifecycleAction.installAction(LifecycleAction.java:115)
at org.jboss.kernel.plugins.dependency.KernelControllerContextAction.install(KernelControllerContextAction.java:100)
at org.jboss.dependency.plugins.AbstractControllerContextActions.install(AbstractControllerContextActions.java:51)
at org.jboss.dependency.plugins.AbstractControllerContext.install(AbstractControllerContext.java:226)
at org.jboss.dependency.plugins.AbstractController.install(AbstractController.java:709)
at org.jboss.dependency.plugins.AbstractController.incrementState(AbstractController.java:429)
at org.jboss.dependency.plugins.AbstractController.resolveContexts(AbstractController.java:538)
at org.jboss.dependency.plugins.AbstractController.resolveContexts(AbstractController.java:472)
at org.jboss.dependency.plugins.AbstractController.install(AbstractController.java:274)
at org.jboss.dependency.plugins.AbstractController.install(AbstractController.java:177)
at org.jboss.kernel.plugins.deployment.AbstractKernelDeployer.deployBean(AbstractKernelDeployer.java:291)
at org.jboss.kernel.plugins.deployment.AbstractKernelDeployer.deployBeans(AbstractKernelDeployer.java:261)
at org.jboss.kernel.plugins.deployment.AbstractKernelDeployer.deploy(AbstractKernelDeployer.java:117)
at org.jboss.kernel.plugins.deployment.xml.BeanXMLDeployer.deploy(BeanXMLDeployer.java:95)
at org.jboss.ejb3.embedded.EJB3StandaloneBootstrap.boot(EJB3StandaloneBootstrap.java:373)
at com.ehelper.ejb.formsetting.EmbeddedJBossEJB3TestCaseHelper.startupEmbeddedJboss(EmbeddedJBossEJB3TestCaseHelper.java:113)
at com.ehelper.ejb.formsetting.EmbeddedJBossEJB3TestCaseHelper$1.setUp(EmbeddedJBossEJB3TestCaseHelper.java:88)
at junit.extensions.TestSetup$1.protect(TestSetup.java:18)
at junit.framework.TestResult.runProtected(TestResult.java:124)
at junit.extensions.TestSetup.run(TestSetup.java:23)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:478)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:344)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:196)
Caused by: java.lang.ClassNotFoundException:
org.jnp.interfaces.LocalOnlyContextFactory
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)
... 37 more
ERROR 18-09 23:11:43,868 (AbstractController.java:incrementState:440) -Error installing to Start: name=TransactionManagerInitializer state=Create
javax.naming.NoInitialContextException: Cannot instantiate class:
org.jnp.interfaces.LocalOnlyContextFactory [Root exception is java.lang.ClassNotFoundException:
org.jnp.interfaces.LocalOnlyContextFactory]
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.(Unknown Source)
at org.jboss.tm.TransactionManagerInitializer.start(TransactionManagerInitializer.java:108)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.jboss.reflect.plugins.introspection.ReflectionUtils.invoke(ReflectionUtils.java:55)
at org.jboss.reflect.plugins.introspection.ReflectMethodInfoImpl.invoke(ReflectMethodInfoImpl.java:107)
at org.jboss.joinpoint.plugins.BasicMethodJoinPoint.dispatch(BasicMethodJoinPoint.java:66)
at org.jboss.kernel.plugins.dependency.KernelControllerContextAction.dispatchJoinPoint(KernelControllerContextAction.java:75)
at org.jboss.kernel.plugins.dependency.LifecycleAction.installAction(LifecycleAction.java:115)
at org.jboss.kernel.plugins.dependency.KernelControllerContextAction.install(KernelControllerContextAction.java:100)
at org.jboss.dependency.plugins.AbstractControllerContextActions.install(AbstractControllerContextActions.java:51)
at org.jboss.dependency.plugins.AbstractControllerContext.install(AbstractControllerContext.java:226)
at org.jboss.dependency.plugins.AbstractController.install(AbstractController.java:709)
at org.jboss.dependency.plugins.AbstractController.incrementState(AbstractController.java:429)
at org.jboss.dependency.plugins.AbstractController.resolveContexts(AbstractController.java:538)
at org.jboss.dependency.plugins.AbstractController.resolveContexts(AbstractController.java:472)
at org.jboss.dependency.plugins.AbstractController.install(AbstractController.java:274)
at org.jboss.dependency.plugins.AbstractController.install(AbstractController.java:177)
at org.jboss.kernel.plugins.deployment.AbstractKernelDeployer.deployBean(AbstractKernelDeployer.java:291)
at org.jboss.kernel.plugins.deployment.AbstractKernelDeployer.deployBeans(AbstractKernelDeployer.java:261)
at org.jboss.kernel.plugins.deployment.AbstractKernelDeployer.deploy(AbstractKernelDeployer.java:117)
at org.jboss.kernel.plugins.deployment.xml.BeanXMLDeployer.deploy(BeanXMLDeployer.java:95)
at org.jboss.ejb3.embedded.EJB3StandaloneBootstrap.boot(EJB3StandaloneBootstrap.java:373)
at com.ehelper.ejb.formsetting.EmbeddedJBossEJB3TestCaseHelper.startupEmbeddedJboss(EmbeddedJBossEJB3TestCaseHelper.java:113)
at com.ehelper.ejb.formsetting.EmbeddedJBossEJB3TestCaseHelper$1.setUp(EmbeddedJBossEJB3TestCaseHelper.java:88)
at junit.extensions.TestSetup$1.protect(TestSetup.java:18)
at junit.framework.TestResult.runProtected(TestResult.java:124)
at junit.extensions.TestSetup.run(TestSetup.java:23)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:478)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:344)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:196)
Caused by: java.lang.ClassNotFoundException:
org.jnp.interfaces.LocalOnlyContextFactory
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)
... 36 more
FATAL 18-09 23:11:43,946 (Log4JLogger.java:fatal:129) -Failure during bootstrap of Embedded JBoss
java.lang.RuntimeException: java.lang.IllegalArgumentException: Null name
at org.jboss.ejb3.embedded.EJB3StandaloneBootstrap.boot(EJB3StandaloneBootstrap.java:386)
at com.ehelper.ejb.formsetting.EmbeddedJBossEJB3TestCaseHelper.startupEmbeddedJboss(EmbeddedJBossEJB3TestCaseHelper.java:113)
at com.ehelper.ejb.formsetting.EmbeddedJBossEJB3TestCaseHelper$1.setUp(EmbeddedJBossEJB3TestCaseHelper.java:88)
at junit.extensions.TestSetup$1.protect(TestSetup.java:18)
at junit.framework.TestResult.runProtected(TestResult.java:124)
at junit.extensions.TestSetup.run(TestSetup.java:23)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:478)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:344)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:196)
Caused by: java.lang.IllegalArgumentException: Null name
at org.jboss.dependency.plugins.AbstractController.getContext(AbstractController.java:114)
at org.jboss.kernel.plugins.dependency.AbstractKernelController.getContext(AbstractKernelController.java:94)
at org.jboss.kernel.plugins.deployment.AbstractKernelDeployer.internalValidate(AbstractKernelDeployer.java:229)
at org.jboss.kernel.plugins.deployment.AbstractKernelDeployer.validate(AbstractKernelDeployer.java:161)
at org.jboss.ejb3.embedded.EJB3StandaloneBootstrap.boot(EJB3StandaloneBootstrap.java:374)
... 8 more
Here is my code:
| import javax.persistence.EntityManager;
| import javax.transaction.TransactionManager;
| import junit.framework.Test;
| import junit.framework.TestCase;
| import com.ehelper.ejb.formsetting.EmbeddedJBossEJB3TestCaseHelper;
|
| public class EmbeddedEjb3TestCase extends TestCase {
|
| public static Test suite() throws Exception {
| return EmbeddedJBossEJB3TestCaseHelper
| .embeddedEjb3TestSuite(EmbeddedEjb3TestCase.class);
| }
|
| public void testEntityManager() throws Exception {
| System.out.println("testEntityManager");
| EntityManager em = (EntityManager) EmbeddedJBossEJB3TestCaseHelper.getInitialContext().lookup(
| "java:/EntityManagers/custdb");
| assertNotNull(em);
|
| // Obtain JBoss transaction
| TransactionManager tm = (TransactionManager) EmbeddedJBossEJB3TestCaseHelper.getInitialContext()
| .lookup("java:/TransactionManager");
|
| tm.begin();
|
| Customer cust = new Customer();
| cust.setName("Bill");
| em.persist(cust);
|
| assertTrue(cust.getId() > 0);
|
| int id = cust.getId();
|
| System.out.println("created bill in DB with id: " + id);
|
| tm.commit();
|
| tm.begin();
| cust = em.find(Customer.class, id);
| assertNotNull(cust);
| tm.commit();
| }
|
| }
|
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=3972463#3972463
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=3972463
19 years, 7 months