javax.ejb.CreateException Java Examples

The following examples show how to use javax.ejb.CreateException. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: LocalStatelessSessionProxyFactoryBeanTests.java    From spring-analysis-note with MIT License 5 votes vote down vote up
@Test
public void testCreateException() throws Exception {
	final String jndiName = "foo";

	final CreateException cex = new CreateException();
	final MyHome home = mock(MyHome.class);
	given(home.create()).willThrow(cex);

	JndiTemplate jt = new JndiTemplate() {
		@Override
		public Object lookup(String name) throws NamingException {
			// parameterize
			assertTrue(name.equals(jndiName));
			return home;
		}
	};

	LocalStatelessSessionProxyFactoryBean fb = new LocalStatelessSessionProxyFactoryBean();
	fb.setJndiName(jndiName);
	fb.setResourceRef(false);	// no java:comp/env prefix
	fb.setBusinessInterface(MyBusinessMethods.class);
	assertEquals(fb.getBusinessInterface(), MyBusinessMethods.class);
	fb.setJndiTemplate(jt);

	// Need lifecycle methods
	fb.afterPropertiesSet();

	MyBusinessMethods mbm = (MyBusinessMethods) fb.getObject();
	assertTrue(Proxy.isProxyClass(mbm.getClass()));

	try {
		mbm.getValue();
		fail("Should have failed to create EJB");
	}
	catch (EjbAccessException ex) {
		assertSame(cex, ex.getCause());
	}
}
 
Example #2
Source File: TestCmp.java    From netbeans with Apache License 2.0 5 votes vote down vote up
public java.lang.Long ejbCreate(java.lang.Long key)  throws CreateException {
    if (key == null) {
        throw new CreateException("The field \"key\" must not be null");
    }
    
    // TODO add additional validation code, throw CreateException if data is not valid
    setPk(key);

    return null;
}
 
Example #3
Source File: testCallEJBInServlet_TestingServlet.java    From netbeans with Apache License 2.0 5 votes vote down vote up
private TestingSessionLocal lookupTestingSessionBeanLocal() {
    try {
        Context c = new InitialContext();
        TestingSessionLocalHome rv = (TestingSessionLocalHome) c.lookup("java:comp/env/TestingSessionBean");
        return rv.create();
    } catch (NamingException ne) {
        Logger.getLogger(getClass().getName()).log(Level.SEVERE, "exception caught", ne);
        throw new RuntimeException(ne);
    } catch (CreateException ce) {
        Logger.getLogger(getClass().getName()).log(Level.SEVERE, "exception caught", ce);
        throw new RuntimeException(ce);
    }
}
 
Example #4
Source File: SimpleRemoteStatelessSessionProxyFactoryBeanTests.java    From java-technology-stack with MIT License 5 votes vote down vote up
@Test
public void testCreateException() throws Exception {
	final String jndiName = "foo";

	final CreateException cex = new CreateException();
	final MyHome home = mock(MyHome.class);
	given(home.create()).willThrow(cex);

	JndiTemplate jt = new JndiTemplate() {
		@Override
		public Object lookup(String name) {
			// parameterize
			assertTrue(name.equals(jndiName));
			return home;
		}
	};

	SimpleRemoteStatelessSessionProxyFactoryBean fb = new SimpleRemoteStatelessSessionProxyFactoryBean();
	fb.setJndiName(jndiName);
	// rely on default setting of resourceRef=false, no auto addition of java:/comp/env prefix
	fb.setBusinessInterface(MyBusinessMethods.class);
	assertEquals(fb.getBusinessInterface(), MyBusinessMethods.class);
	fb.setJndiTemplate(jt);

	// Need lifecycle methods
	fb.afterPropertiesSet();

	MyBusinessMethods mbm = (MyBusinessMethods) fb.getObject();
	assertTrue(Proxy.isProxyClass(mbm.getClass()));

	try {
		mbm.getValue();
		fail("Should have failed to create EJB");
	}
	catch (RemoteException ex) {
		// expected
	}
}
 
Example #5
Source File: CmpLRBean.java    From netbeans with Apache License 2.0 5 votes vote down vote up
public java.lang.Long ejbCreate(java.lang.Long key)  throws CreateException {
    if (key == null) {
        throw new CreateException("The field \"key\" must not be null");
    }
    
    // TODO add additional validation code, throw CreateException if data is not valid
    setKey(key);
    
    return null;
}
 
Example #6
Source File: LocalStatelessSessionProxyFactoryBeanTests.java    From java-technology-stack with MIT License 5 votes vote down vote up
@Test
public void testCreateException() throws Exception {
	final String jndiName = "foo";

	final CreateException cex = new CreateException();
	final MyHome home = mock(MyHome.class);
	given(home.create()).willThrow(cex);

	JndiTemplate jt = new JndiTemplate() {
		@Override
		public Object lookup(String name) throws NamingException {
			// parameterize
			assertTrue(name.equals(jndiName));
			return home;
		}
	};

	LocalStatelessSessionProxyFactoryBean fb = new LocalStatelessSessionProxyFactoryBean();
	fb.setJndiName(jndiName);
	fb.setResourceRef(false);	// no java:comp/env prefix
	fb.setBusinessInterface(MyBusinessMethods.class);
	assertEquals(fb.getBusinessInterface(), MyBusinessMethods.class);
	fb.setJndiTemplate(jt);

	// Need lifecycle methods
	fb.afterPropertiesSet();

	MyBusinessMethods mbm = (MyBusinessMethods) fb.getObject();
	assertTrue(Proxy.isProxyClass(mbm.getClass()));

	try {
		mbm.getValue();
		fail("Should have failed to create EJB");
	}
	catch (EjbAccessException ex) {
		assertSame(cex, ex.getCause());
	}
}
 
Example #7
Source File: SimpleRemoteStatelessSessionProxyFactoryBeanTests.java    From spring-analysis-note with MIT License 5 votes vote down vote up
@Test
public void testCreateExceptionWithLocalBusinessInterface() throws Exception {
	final String jndiName = "foo";

	final CreateException cex = new CreateException();
	final MyHome home = mock(MyHome.class);
	given(home.create()).willThrow(cex);

	JndiTemplate jt = new JndiTemplate() {
		@Override
		public Object lookup(String name) {
			// parameterize
			assertTrue(name.equals(jndiName));
			return home;
		}
	};

	SimpleRemoteStatelessSessionProxyFactoryBean fb = new SimpleRemoteStatelessSessionProxyFactoryBean();
	fb.setJndiName(jndiName);
	// rely on default setting of resourceRef=false, no auto addition of java:/comp/env prefix
	fb.setBusinessInterface(MyLocalBusinessMethods.class);
	assertEquals(fb.getBusinessInterface(), MyLocalBusinessMethods.class);
	fb.setJndiTemplate(jt);

	// Need lifecycle methods
	fb.afterPropertiesSet();

	MyLocalBusinessMethods mbm = (MyLocalBusinessMethods) fb.getObject();
	assertTrue(Proxy.isProxyClass(mbm.getClass()));

	try {
		mbm.getValue();
		fail("Should have failed to create EJB");
	}
	catch (RemoteAccessException ex) {
		assertTrue(ex.getCause() == cex);
	}
}
 
Example #8
Source File: testAddCreateMethod1InEB_TestingEntityLocalHome.java    From netbeans with Apache License 2.0 2 votes vote down vote up
/**
 *
 */
test.TestingEntityLocal create(java.lang.String key)  throws javax.ejb.CreateException;
 
Example #9
Source File: testAddSelectMethod1InEB_TestingEntityLocalHome.java    From netbeans with Apache License 2.0 2 votes vote down vote up
/**
 *
 */
test.TestingEntityLocal create(java.lang.String key)  throws javax.ejb.CreateException;
 
Example #10
Source File: testAddSelectMethod1InEB_TestingEntityRemoteHome.java    From netbeans with Apache License 2.0 2 votes vote down vote up
/**
 *
 */
test.TestingEntityRemote create(java.lang.String key)  throws javax.ejb.CreateException, java.rmi.RemoteException;
 
Example #11
Source File: testAddSelectMethod2InEB_TestingEntityRemoteHome.java    From netbeans with Apache License 2.0 2 votes vote down vote up
/**
 *
 */
test.TestingEntityRemote create(java.lang.String key)  throws javax.ejb.CreateException, java.rmi.RemoteException;
 
Example #12
Source File: testAddCMPField2InEB_TestingEntityRemoteHome.java    From netbeans with Apache License 2.0 2 votes vote down vote up
/**
 *
 */
test.TestingEntityRemote create(java.lang.String key)  throws javax.ejb.CreateException, java.rmi.RemoteException;
 
Example #13
Source File: testAddHomeMethod2InEB_TestingEntityRemoteHome.java    From netbeans with Apache License 2.0 2 votes vote down vote up
/**
 *
 */
test.TestingEntityRemote create(java.lang.String key)  throws javax.ejb.CreateException, java.rmi.RemoteException;
 
Example #14
Source File: testAddCMPField2InEB_TestingEntityLocalHome.java    From netbeans with Apache License 2.0 2 votes vote down vote up
/**
 *
 */
test.TestingEntityLocal create(java.lang.String key)  throws javax.ejb.CreateException;
 
Example #15
Source File: testAddCreateMethod2InEB_TestingEntityLocalHome.java    From netbeans with Apache License 2.0 2 votes vote down vote up
/**
 *
 */
test.TestingEntityLocal create(java.lang.String key)  throws javax.ejb.CreateException;
 
Example #16
Source File: testAddCMPField1InEB_TestingEntityLocalHome.java    From netbeans with Apache License 2.0 2 votes vote down vote up
/**
 *
 */
test.TestingEntityLocal create(java.lang.String key)  throws javax.ejb.CreateException;
 
Example #17
Source File: testAddHomeMethod1InEB_TestingEntityRemoteHome.java    From netbeans with Apache License 2.0 2 votes vote down vote up
/**
 *
 */
test.TestingEntityRemote create(java.lang.String key)  throws javax.ejb.CreateException, java.rmi.RemoteException;
 
Example #18
Source File: testAddHomeMethod1InEB_TestingEntityLocalHome.java    From netbeans with Apache License 2.0 2 votes vote down vote up
/**
 *
 */
test.TestingEntityLocal create(java.lang.String key)  throws javax.ejb.CreateException;
 
Example #19
Source File: testAddCMPField1InEB_TestingEntityRemoteHome.java    From netbeans with Apache License 2.0 2 votes vote down vote up
/**
 *
 */
test.TestingEntityRemote create(java.lang.String key)  throws javax.ejb.CreateException, java.rmi.RemoteException;
 
Example #20
Source File: testAddFinderMethod2InEB_TestingEntityLocalHome.java    From netbeans with Apache License 2.0 2 votes vote down vote up
/**
 *
 */
test.TestingEntityLocal create(java.lang.String key)  throws javax.ejb.CreateException;
 
Example #21
Source File: testAddCreateMethod2InEB_TestingEntityRemoteHome.java    From netbeans with Apache License 2.0 2 votes vote down vote up
/**
 *
 */
test.TestingEntityRemote create(java.lang.String key)  throws javax.ejb.CreateException, java.rmi.RemoteException;
 
Example #22
Source File: testAddHomeMethod2InEB_TestingEntityLocalHome.java    From netbeans with Apache License 2.0 2 votes vote down vote up
/**
 *
 */
test.TestingEntityLocal create(java.lang.String key)  throws javax.ejb.CreateException;
 
Example #23
Source File: testAddFinderMethod1InEB_TestingEntityRemoteHome.java    From netbeans with Apache License 2.0 2 votes vote down vote up
/**
 *
 */
test.TestingEntityRemote create(java.lang.String key)  throws javax.ejb.CreateException, java.rmi.RemoteException;
 
Example #24
Source File: testAddFinderMethod2InEB_TestingEntityRemoteHome.java    From netbeans with Apache License 2.0 2 votes vote down vote up
/**
 *
 */
test.TestingEntityRemote create(java.lang.String key)  throws javax.ejb.CreateException, java.rmi.RemoteException;
 
Example #25
Source File: testAddFinderMethod1InEB_TestingEntityLocalHome.java    From netbeans with Apache License 2.0 2 votes vote down vote up
/**
 *
 */
test.TestingEntityLocal create(java.lang.String key)  throws javax.ejb.CreateException;
 
Example #26
Source File: StatelessLRLocalHome.java    From netbeans with Apache License 2.0 votes vote down vote up
statelesslr.StatelessLRLocal create()  throws CreateException; 
Example #27
Source File: StatefulLRLocalHome.java    From netbeans with Apache License 2.0 votes vote down vote up
statefullr.StatefulLRLocal create()  throws CreateException; 
Example #28
Source File: testAddHomeMethod2InEB_TestingEntityLocalHome.java    From netbeans with Apache License 2.0 votes vote down vote up
TestingEntityLocal createTest2(String a, int b) throws CreateException, IOException; 
Example #29
Source File: CmpLRLocalHome.java    From netbeans with Apache License 2.0 votes vote down vote up
cmplr.CmpLRLocal create(java.lang.Long key)  throws CreateException; 
Example #30
Source File: testAddCreateMethod1InEB_TestingEntityLocalHome.java    From netbeans with Apache License 2.0 votes vote down vote up
TestingEntityLocal createTest1() throws CreateException;