java-ee-7

How to test login/authentication with Arquillian - Java EE 7

北城余情 提交于 2019-12-30 02:19:10
问题 We have a Java EE 7 application and use Arquillian to test stuff. Now we want to check for some permissions of the currently logged in user. My question is quite basic, how do I login a user when inside a testcase? I have read ProgrammaticLogin doesnt work in arquillian tests and Embedded Glassfish, security and Arquillian questions but they are not clearly answered. My current approach is something like this: // Inject services etc. @Test public void testLogin(){ UserAccount user = new

Get rid of org.jboss.weld.context.NonexistentConversationException, when a query-string parameter named cid is appended to the URL

和自甴很熟 提交于 2019-12-29 08:57:31
问题 Take a simple CDI (it could also be a JSF managed bean) bean as follows. import java.io.Serializable; import javax.inject.Named; import javax.faces.view.ViewScoped; @Named @ViewScoped public class TestManagedBean implements Serializable { private static final long serialVersionUID=1L; public TestManagedBean() {} } If this bean is accessed by an XHTML page with a query-string parameter named cid which is needed for a @ConversationScoped CDI managed bean (which may accidently/deliberately be

What are all the settings that i should take care of for Wildfly standalone-ha cluster

落爺英雄遲暮 提交于 2019-12-25 02:49:28
问题 i am trying to set cluster of Wildfly 9.0.0Final standanlone servers. I am using httpd2.2. and modcluster1.2.6. before them for load balancing. Cluster works fine until i am deploying simple war only app that can be found on link Session replication works fine. After deployment i load page put.jsp and then i kill server on which page was served. Then i go and load page get.jsp that shows me same date and hour and i know that session was saved since this request was served from other node in

Change index.html for index.jsp (JavaEE+Glassfish)

你。 提交于 2019-12-25 02:44:25
问题 I have a little problem. Is it possible 'delete' index.html and create (to replace index.html) index.jsp? How? I don't find any files (web.xml, glassfish-resource.xml) with the address to the home page (index.html) to change it (for index.jsp). I have not found an answer on the Internet... Thanks for replies! 回答1: What you need is to configure the welcome-file-list for your application. By default, it's index.html, which is why you don't find anything defining it. Take a look at web.xml

Java EE 7 containers: initialize bean at startup without adding it to beans.xml?

一世执手 提交于 2019-12-24 20:01:16
问题 Is there any bean type or Java EE annotation to get a bean initialized at container startup without adding the bean to beans.xml? 回答1: Yes, there is. This is what I use when I need a singleton, application scoped bean started on deploy: import javax.ejb.Singleton; import javax.ejb.Startup; import javax.enterprise.context.ApplicationScoped; import javax.inject.Named; import javax.annotation.PostConstruct; @Named( "myBean" ) @ApplicationScoped @Startup @Singleton public class MyBean {

@InterceptorBinding / CDI/ EJB 3.2 - problems with injection

匆匆过客 提交于 2019-12-24 17:00:14
问题 My dev environment is: WildFly 8.1, CDI, EJB 3.2, JDK 1.7. App is packed as an ear archive (one ejb + one war) because probably it gonna have other web modules in the future. I'm struggling with a custom @InterceptorBinding type used inside my EJB stateless bean. @Inherited @InterceptorBinding @Target({ TYPE, METHOD }) @Retention(RUNTIME) @Documented public @interface DetectIntegrityConstraintsViolation { } @javax.annotation.ManagedBean // make it a CDI bean. @Interceptor itself should be

ContainerRequestFilter wont run in JavaEE jersey project

好久不见. 提交于 2019-12-24 11:54:11
问题 Am new to JavaEE and have some issues getting custom ContainerRequestFilter to run in Jersey. I read the jersey documentation some more and created a new clean project straight from the ' jersey-quickstart-webapp ', added the filter seen below but no luck (added an empty beans.xml as well). import javax.ws.rs.container.ContainerRequestContext; import javax.ws.rs.container.ContainerRequestFilter; import javax.ws.rs.container.PreMatching; import javax.ws.rs.core.Response; import javax.ws.rs.ext

CDI inject into existing object

旧街凉风 提交于 2019-12-24 10:26:36
问题 Let's say I have the following class: public class MyRequestPayload implements RequestPayload { protected MyRequestPayload() {} @Override public ResponsePayload process() { String result = someService.doSomething(foo, bar); return new MyResponsePayload(result); } public final String foo; public final Integer bar; @Inject private SomeService someService; } Is there some CDI service I can invoke that will process all the @Inject annotations on an instance of this class, injecting all the

How to distribute an event to all nodes in a (Wildfly) cluster?

岁酱吖の 提交于 2019-12-24 03:08:25
问题 I would like to notify all nodes in a cluster when the state of a longer running process in my JavaEE 7 WebApp changes, so that every node can in turn notify their clients via WebSocket about that change. I am working with Wildfly 10 in a clustered environment. What JavaEE 7 API / Programming model or Wildfly Service would be todays best practice to achieve that ? 回答1: If you want to stay within JavaEE ecosystem, then JMS topic is the way to go. Topics are like broadcast channels - every

How to use JPA to query encrypted data?

筅森魡賤 提交于 2019-12-24 01:19:34
问题 I am supposed to come up with a plan to encrypt our existing personal information and be able to retrieve it and show it back to user through application if required. This is not PCI information nor password, so it requires a two way journey that is encrypt and decrypt both (and for the moment to keep things simple no tokenization, no public private key encryption either), as well as query the information through JPA if required. Here is what I have: application engine JBOSS 7, database