当前位置: 首页>>代码示例>>Java>>正文


Java EJBException类代码示例

本文整理汇总了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;
    }
 
开发者ID:WASdev,项目名称:sample.daytrader3,代码行数:22,代码来源:TradeSLSBBean.java

示例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();
    }
}
 
开发者ID:servicecatalog,项目名称:oscm,代码行数:26,代码来源:DataServiceBeanIT.java

示例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();
    }
}
 
开发者ID:servicecatalog,项目名称:oscm,代码行数:19,代码来源:ServiceProvisioningServiceBeanIT.java

示例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());
}
 
开发者ID:servicecatalog,项目名称:oscm,代码行数:22,代码来源:EventServiceBean.java

示例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();
    }
}
 
开发者ID:servicecatalog,项目名称:oscm,代码行数:38,代码来源:OrganizationIT.java

示例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);
    }
}
 
开发者ID:servicecatalog,项目名称:oscm,代码行数:17,代码来源:ServiceProvisioningServiceBeanPermissionIT.java

示例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();
	}
}
 
开发者ID:PacktPublishing,项目名称:Mastering-Java-EE-Development-with-WildFly,代码行数:24,代码来源:XMLTestCase.java

示例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();
    }
}
 
开发者ID:servicecatalog,项目名称:oscm,代码行数:18,代码来源:IdentityServiceBeanLdapWithDbIT.java

示例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();
    }
}
 
开发者ID:servicecatalog,项目名称:oscm,代码行数:23,代码来源:ProductToPaymentTypeIT.java

示例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;
	}
}
 
开发者ID:wfink,项目名称:jboss-eap7.1-playground,代码行数:20,代码来源:SimpleWildFlyConfigClient.java

示例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;
}
 
开发者ID:wwu-pi,项目名称:tap17-muggl-javaee,代码行数:18,代码来源:RequestBean.java

示例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);
}
 
开发者ID:servicecatalog,项目名称:oscm,代码行数:26,代码来源:ADMUMStartupTest.java

示例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();
    }
}
 
开发者ID:servicecatalog,项目名称:oscm,代码行数:38,代码来源:OrganizationIT.java

示例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));
}
 
开发者ID:servicecatalog,项目名称:oscm-app,代码行数:23,代码来源:APPTimerServiceBeanIT.java

示例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);
    }
}
 
开发者ID:wwu-pi,项目名称:tap17-muggl-javaee,代码行数:25,代码来源:RequestBeanQueries.java


注:本文中的javax.ejb.EJBException类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。