我有一个简单的请求作用域bean,它包含一个注入的主体,因此我可以确定当前用户的ID。然后将该bean注入到Servlet中,Servlet使用bean显示用户的ID。
接口:
public interface UserManager {
public String getCurrentUserName();
}
实现:
@RequestScoped
public class CdiUserManager implements UserManager {
@Inject
private Principal principal;
public Cd
我们正在将我们的JavaEE应用程序从WebLogic10.3.6迁移到WebLogic12.2.1.2。作为迁移的一部分,我们将JSF托管bean更改为使用CDI注释,而不是标准的JSF注释。@ManagedBean到@Named,javax.faces.bean.ViewScoped到javax.faces.view.ViewScoped。事实证明,这是成功的,只是出现了一些小问题。然而,我在尝试运行我们的测试时遇到了一个很大的问题。测试失败,并显示以下错误:
WebBeans context with scope type annotation @ViewScoped does not
我正在将一个应用程序迁移到JavaEE7,并希望迁移到CDI1.1。但我不明白bean-discovery-mode="annotated"的意思。不是很有帮助。至少我没有找到任何有用的段落。我错过了吗?
此示例可以很好地与bean-discovery-mode="all"一起运行,并注入LoggingClass的一个实例
public class LoggingClass {
public Logger logger = Logger.getLogger("ALOGGER");
}
@Test
public class MMLogg
我不知道我做错了什么,但我真的很沮丧,正在与时间赛跑。我有从数据库派生的EJB实体,将这些实体持久化到db中的无状态本地会话bean(大多数是facade),以及使用会话bean的托管bean。
因此,我的托管bean如下所示:
@ManagedBean
public class SomeBean {
//attributes
@EJB
private SomeSessionBean sb;
// getters and setters and other methods
public void createObject(){
//
我正在尝试在我的Arquillian JBoss服务器容器中运行Arquillian测试。当我运行它们时,我得到了以下信息消息:
16:49:48,648 INFO [org.jboss.weld.ClassLoading] (MSC service thread 1-1) WELD-000119 Not generating any bean definitions from package.ChartofaccountDAO because of underlying class loading error
16:49:48,768 INFO [org.jboss.weld.Class
一些可能有用的信息:
项目:基于maven的cdi
环境: Ubuntu 16.04
JDK: oracle 8
IDE: Netbeans 8.2
下面是正在测试的CDI:
@Named
@SessionScoped
public class UserPreferencies implements Serializable {
private Locale currentLocale;
public UserPreferencies() {
//locale is initiated to French but may be overriden in th
我正在一个使用weld CDI和JPA的项目中安装Arquillian,并且我正在尝试使用嵌入式GlassFish容器(我读到Weld embedded container不支持JPA)。
我已经在pom.xml中添加了GlassFishContainer,但在运行测试用例时收到一条错误消息。下面是错误消息的id:
Multiple service implementations found for interface
org.jboss.arquillian.container.spi.client.container.DeployableContainer.
org.jboss.ar
我使用Arquillian与嵌入式玻璃鱼4.0容器进行测试。到目前为止,我设法使它工作,但一个测试用例不断失败,我不知道为什么。这是我的测试代码:
// Test Class
@Inject
private CompetenceService competenceService;
@Test
public void createSingleCompetence() {
Competence c = new Competence();
// fill the competence with data
c = com
我试图使用Arquillian和TestNG以混合模式运行测试套件。
基于这里的文档:
我希望能够像这样写我的测试:
public class ExampleTest extends Arquillian {
@Deployment
public static EnterpriseArchive createDeployment() {
return ear; //contains both web and jar modules
}
@Test @RunAsClient
public void testA(@Arquil
是否有可能在带有单元测试框架的java-ee容器中模拟多个“会话”,比如Arquillian?我有many sessions that interact with each other,我想在生产容器本身中用测试来模拟这种情况。还有一些JPA2数据库行为,我想同时测试一下。
但我也想确保CDI和会话范围内的bean正在做他们应该做的事情。我不想运行服务器,几个小时后我发现,我认为会话范围内的bean,无论出于什么原因,在同一会话中被实例化不止一次。
非常感谢你的帮助!
编辑:我找到了关于的这个页面,但是我很难理解它。这种方法是否适用于上述情况?
我正在尝试从运行一个简单的CDI测试。下面是我的JUNIT和POM。不确定错误是什么。感谢任何人的帮助。
错误
java.lang.NullPointerException
at com.aravind.jee6.cdi.basic.GreeterTest.greet(GreeterTest.java:32)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorIm
我有一个应用程序与PicketLink包括作为maven的依赖性。我写了一个arquillian测试用例,没有以任何方式涉及picketlink,但测试失败,因为在PicketLink中的CDI。
@RunWith(Arquillian.class)
public class WebServiceTest {
@Deployment
public static WebArchive deployment() {
return ShrinkWrap.create(WebArchive.class, "test.war")
在使用Glassfish嵌入式插件使用Arquillian运行单元测试时,我得到以下CDI错误:
2015-09-18 06:25:24,376 DEBUG | main | org.jboss.weld.Reflection | WELD-000620: interface com.SupportedLocales is not declared @Target(METHOD, FIELD, PARAMETER, TYPE). Weld will use this annotation, however this may make