本文整理匯總了Java中javax.ejb.EJBException類的典型用法代碼示例。如果您正苦於以下問題:Java EJBException類的具體用法?Java EJBException怎麽用?Java EJBException使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
EJBException類屬於javax.ejb包,在下文中一共展示了EJBException類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: createOrder
import javax.ejb.EJBException; //導入依賴的package包/類
private OrderDataBean createOrder(AccountDataBean account, QuoteDataBean quote, HoldingDataBean holding, String orderType, double quantity) {
OrderDataBean order;
if (Log.doTrace())
Log.trace("TradeSLSBBean:createOrder(orderID="
+ " account=" + ((account == null) ? null : account.getAccountID())
+ " quote=" + ((quote == null) ? null : quote.getSymbol())
+ " orderType=" + orderType
+ " quantity=" + quantity);
try {
order = new OrderDataBean(orderType, "open", new Timestamp(System.currentTimeMillis()), null, quantity, quote.getPrice().setScale(FinancialUtils.SCALE,
FinancialUtils.ROUND),
TradeConfig.getOrderFee(orderType), account, quote, holding);
entityManager.persist(order);
} catch (Exception e) {
Log.error("TradeSLSBBean:createOrder -- failed to create Order", e);
throw new EJBException("TradeSLSBBean:createOrder -- failed to create Order", e);
}
return order;
}
示例2: testGetCurrentUserExistingButNoAdminClientCert
import javax.ejb.EJBException; //導入依賴的package包/類
@Test(expected = InvalidUserSession.class)
public void testGetCurrentUserExistingButNoAdminClientCert()
throws Exception {
String dn = "dn=1";
createOrgAndUserForWS(dn, false,
OrganizationRoleType.TECHNOLOGY_PROVIDER);
container.login(dn);
PlatformUser user = runTX(new Callable<PlatformUser>() {
@Override
public PlatformUser call() throws Exception {
return mgr.getCurrentUserIfPresent();
}
});
Assert.assertNull("No valid user object expected", user);
try {
runTX(new Callable<PlatformUser>() {
@Override
public PlatformUser call() throws Exception {
return mgr.getCurrentUser();
}
});
} catch (EJBException e) {
throw e.getCausedByException();
}
}
示例3: testCreateMarketingProductImageTypeInvalid
import javax.ejb.EJBException; //導入依賴的package包/類
@Test(expected = SaaSSystemException.class)
public void testCreateMarketingProductImageTypeInvalid() throws Exception {
VOTechnicalService tp = createTechnicalProduct(svcProv);
VOServiceDetails product = new VOServiceDetails();
product.setServiceId("test");
VOImageResource imageResource = new VOImageResource();
byte[] content = BaseAdmUmTest.getFileAsByteArray(
ServiceProvisioningServiceBeanIT.class, "icon1.png");
imageResource.setBuffer(content);
imageResource.setContentType("image/png");
imageResource.setImageType(ImageType.SHOP_LOGO_LEFT);
try {
container.login(supplierUserKey, ROLE_SERVICE_MANAGER);
svcProv.createService(tp, product, imageResource);
} catch (EJBException e) {
throw e.getCausedByException();
}
}
示例4: isEntityExistsException
import javax.ejb.EJBException; //導入依賴的package包/類
/**
* Tests whether this exception or any nested exception is a
* {@link EntityExistsException}. Unfortunately {@link EJBException}
* sometimes nests cause exception in {@link Throwable#getCause()},
* sometimes in {@link EJBException#getCausedByException()}. Arrrrg.
*/
private boolean isEntityExistsException(final Throwable e) {
if (e == null) {
return false;
}
if (e instanceof PersistenceException) {
return true;
}
if (e instanceof EJBException) {
final EJBException ejbex = (EJBException) e;
if (isEntityExistsException(ejbex.getCausedByException())) {
return true;
}
}
return isEntityExistsException(e.getCause());
}
示例5: testModifyOrganization
import javax.ejb.EJBException; //導入依賴的package包/類
/**
* <b>Testcase:</b> Modify an existing organization object <br>
* <b>ExpectedResult:</b>
* <ul>
* <li>Modification is saved to the DB</li>
* <li>History object created for the organization</li>
* <li>usedPayment unchanged</li>
* <li>No new history object for PaymentInfo</li>
* </ul>
*
* @throws Throwable
*/
@Test
public void testModifyOrganization() throws Throwable {
try {
runTX(new Callable<Void>() {
public Void call() throws Exception {
doTestModifyOrganizationPrepare();
return null;
}
});
runTX(new Callable<Void>() {
public Void call() throws Exception {
doTestModifyOrganization();
return null;
}
});
runTX(new Callable<Void>() {
public Void call() throws Exception {
doTestModifyOrganizationCheck();
return null;
}
});
} catch (EJBException e) {
throw e.getCause();
}
}
示例6: savePriceModelForCustomer_asBroker
import javax.ejb.EJBException; //導入依賴的package包/類
@Test
public void savePriceModelForCustomer_asBroker() throws Exception {
// given
container.login(1L, UserRoleType.BROKER_MANAGER.name());
// when
try {
sps.savePriceModelForCustomer(new VOServiceDetails(),
new VOPriceModel(), new VOOrganization());
fail();
} catch (EJBException e) {
// then
assertTrue(e.getCausedByException() instanceof EJBAccessException);
}
}
示例7: testRemoteXML
import javax.ejb.EJBException; //導入依賴的package包/類
@Test
@RunAsClient
public void testRemoteXML() throws Exception {
logger.info("starting remoting ejb client test");
try {
createInitialContext();
String hostname = getLocalHost().getHostName().toLowerCase();
final UserTransaction userTransaction = getUserTransaction(hostname);
XMLRemote bean = lookup(XMLRemote.class, "bank");
assertEquals(STATUS_NO_TRANSACTION, bean.transactionStatus());
try {
userTransaction.begin();
bean.transactionStatus();
fail("the transaction is not supported");
} catch (EJBException | IllegalStateException e) {
logger.info("the transaction is not supported");
}
} finally {
closeContext();
}
}
示例8: createUser_LDAPUsed
import javax.ejb.EJBException; //導入依賴的package包/類
@Test(expected = UnsupportedOperationException.class)
public void createUser_LDAPUsed() throws Exception {
try {
final VOUserDetails userToCreate = new VOUserDetails();
userToCreate.setUserId("newUser");
runTX(new Callable<Void>() {
@Override
public Void call() throws Exception {
idMgmt.createUser(userToCreate, Collections.singletonList(
UserRoleType.ORGANIZATION_ADMIN), null);
return null;
}
});
} catch (EJBException e) {
throw e.getCausedByException();
}
}
示例9: testAdd_Duplicate
import javax.ejb.EJBException; //導入依賴的package包/類
@Test(expected = NonUniqueBusinessKeyException.class)
public void testAdd_Duplicate() throws Exception {
try {
runTX(new Callable<Void>() {
@Override
public Void call() throws Exception {
doTestAdd();
return null;
}
});
runTX(new Callable<Void>() {
@Override
public Void call() throws Exception {
doTestAdd();
return null;
}
});
} catch (EJBException e) {
throw e.getCausedByException();
}
}
示例10: main
import javax.ejb.EJBException; //導入依賴的package包/類
public static void main(String[] args) throws NamingException {
checkArgs(args);
// One option is to use the java context, the INITIAL_CONTEXT_FACTORY is added by jndi.properties
// the URI and credentials by wildfly-config.xml
InitialContext ic = new InitialContext();
Simple proxy = (Simple) ic.lookup("ejb:EAP71-PLAYGROUND-server/ejb/SimpleBean!" + Simple.class.getName());
try {
if(proxy.checkApplicationUser("user1")) {
log.info("Expected 'user1'");
} else {
log.severe("Unexpected user, see server.log");
}
} catch (EJBException e) {
throw e;
}
}
示例11: locateVendorsByPartialName
import javax.ejb.EJBException; //導入依賴的package包/類
public List<String> locateVendorsByPartialName(String name) {
List<String> names = new ArrayList<>();
try {
List vendors = em.createNamedQuery(
"findVendorsByPartialName")
.setParameter("name", name)
.getResultList();
for (Iterator iterator = vendors.iterator(); iterator.hasNext();) {
Vendor vendor = (Vendor)iterator.next();
names.add(vendor.getName());
}
} catch (Exception e) {
throw new EJBException(e.getMessage());
}
return names;
}
示例12: setUp
import javax.ejb.EJBException; //導入依賴的package包/類
@Before
public void setUp() {
cfg = new ConfigurationServiceStub() {
@Override
public ConfigurationSetting getConfigurationSetting(
ConfigurationKey key, String context) {
if (throwExceptionWhenRetrievingSettings) {
throw new EJBException();
}
if (key == ConfigurationKey.LOG_FILE_PATH) {
return new ConfigurationSetting(
ConfigurationKey.LOG_FILE_PATH,
Configuration.GLOBAL_CONTEXT, ".");
}
return new ConfigurationSetting();
}
};
testClass = new ADMUMStartup();
testClass.cs = cfg;
testClass.localizer = mock(LocalizerServiceLocal.class);
testClass.prodSessionMgmt = mock(SessionServiceLocal.class);
testClass.timerMgmt = mock(TimerServiceBean.class);
testClass.searchService = mock(SearchServiceLocal.class);
}
示例13: testDeleteOrganization
import javax.ejb.EJBException; //導入依賴的package包/類
/**
* <b>Testcase:</b> Delete an existing organization object <br>
* <b>ExpectedResult:</b>
* <ul>
* <li>Organization marked as deleted in the DB</li>
* <li>History object created for the deleted organization</li>
* <li>PaymentInfo (usedPayment) marked as deleted in the DB</li>
* <li>History object created for the deleted PaymentInfo</li>
* </ul>
*
* @throws Throwable
*/
@Test
public void testDeleteOrganization() throws Throwable {
try {
runTX(new Callable<Void>() {
public Void call() throws Exception {
doTestDeleteOrganizationPrepare();
return null;
}
});
runTX(new Callable<Void>() {
public Void call() throws Exception {
doTestDeleteOrganization();
return null;
}
});
runTX(new Callable<Void>() {
public Void call() throws Exception {
doTestDeleteOrganizationCheck();
return null;
}
});
} catch (EJBException e) {
throw e.getCause();
}
}
示例14: testHandleEJBErrorDuringCreation
import javax.ejb.EJBException; //導入依賴的package包/類
/**
* Validates error handling on case of EJB exception during creation
* (Bugzilla #9566)
*/
@Test
public void testHandleEJBErrorDuringCreation() throws Exception {
// given
createServiceInstance(ProvisioningStatus.WAITING_FOR_SYSTEM_CREATION);
// Throw EJB exception when creation status is invoked
EJBException e = new EJBException("ejb_error");
when(controller.getInstanceStatus(matches("appInstanceId"),
any(ProvisioningSettings.class))).thenThrow(e);
// when
handleTimer();
// then
verify(besDAOMock, times(1)).notifyAsyncSubscription(
any(ServiceInstance.class), any(InstanceResult.class),
eq(false), any(APPlatformException.class));
}
示例15: getPlayersByCity
import javax.ejb.EJBException; //導入依賴的package包/類
public List<PlayerDetails> getPlayersByCity(String city) {
logger.info("getPlayersByCity");
List<Player> players = null;
try {
CriteriaQuery<Player> cq = cb.createQuery(Player.class);
if (cq != null) {
Root<Player> player = cq.from(Player.class);
Join<Player, Team> team = player.join(Player_.team);
// Get MetaModel from Root
//EntityType<Player> Player_ = player.getModel();
// set the where clause
cq.where(cb.equal(team.get(Team_.city), city));
cq.select(player).distinct(true);
TypedQuery<Player> q = em.createQuery(cq);
players = q.getResultList();
}
return copyPlayersToDetails(players);
} catch (Exception ex) {
throw new EJBException(ex);
}
}