java-ee

What is the default session timeout for a Java EE website?

情到浓时终转凉″ 提交于 2019-12-17 18:16:24
问题 If I do not specify the following in my web.xml file: <session-config> <session-timeout>10</session-timeout> </session-config> What will be my default session timeout? (I am running Tomcat 6.0) 回答1: If you're using Tomcat, it's 30 minutes. You can read more about it here. 回答2: You can also set this in code, for a specific session using the HttpSession setMaxInactiveInterval API: Specifies the time, in seconds, between client requests before the servlet container will invalidate this session.

How does UserTransaction propagate?

本小妞迷上赌 提交于 2019-12-17 18:07:11
问题 I have a stateless bean with bean-managed transactions, and a method like this: @Stateless @TransactionManagement(TransactionManagementType.BEAN) public class ... { @Resource private UserTransaction ut; @EJB private OtherStatelessBeanLocal other; public void invokeSomeMethods() ut.begin(); ... // invoke other bean's methods here. other.method(); ... ut.commit(); } } So how does the UserTransaction propagate to the OtherStatelessBeanLocal bean? 回答1: The UserTransaction object is an object

Convert JSON query parameters to objects with JAX-RS

回眸只為那壹抹淺笑 提交于 2019-12-17 17:44:27
问题 I have a JAX-RS resource, which gets its paramaters as a JSON string like this: http://some.test/aresource?query={"paramA":"value1", "paramB":"value2"} The reason to use JSON here, is that the query object can be quite complex in real use cases. I'd like to convert the JSON string to a Java object, dto in the example: @GET @Produces("text/plain") public String getIt(@QueryParam("query") DataTransferObject dto ) { ... } Does JAX-RS support such a conversion from JSON passed as a query param to

How to add WAR inside EAR with Maven

别来无恙 提交于 2019-12-17 17:39:09
问题 I have EAR with an application and I need to extend this app with my own code that is packaged as a WAR. Is there a maven plugin that can help me with putting the WAR inside the EAR? The manual procedure is to put WAR inside EAR and add module to application.xml. I would like to automate that. EDIT: small clarification - the WAR project is using maven but for EAR I have only the binary file nothing more. 回答1: I'd create a new module that has <packaging>ear</packaging> . In the dependencies

Why choose tomcat over a java EE compliant application server?

大兔子大兔子 提交于 2019-12-17 17:26:59
问题 Java EE application servers provide all the features of tomcat, so why use tomcat (instead of glassfish for example as it is the official one)? Especially when Java EE features are needed like JPA, JAX-RS, JSF, and therefore more libraries have to be packaged with the application, while a EE-compliant application server would have provided it out of the box? 回答1: The question that was in our mind and the entire reason we created TomEE was, why should people have to choose? The whole "Tomcat

Tyrus websocket: IllegalStateException cannot set WriteListener for non-async request

淺唱寂寞╮ 提交于 2019-12-17 17:15:31
问题 I have a standard websocket endpoint based on Tyrus implementation which times to times triggers the java.lang.IllegalStateException: Cannot set WriteListener for non-async or non-upgrade request . We are running on Payara 4.1. My standard implementation @ServerEndpoint(value = "...", decoders=MessageDecoder.class, encoders=MessageEncoder.class) public class EndpointImpl extends AbstractEndpoint{ // onOpen, onClose, onMessage, onError methods } Where the abstract class is public abstract

Changing Java Timestamp format causes a change of the timestamp

て烟熏妆下的殇ゞ 提交于 2019-12-17 17:14:43
问题 I'm a bit puzzled regarding the Java timestamp formatting functions as they seem to change the timestamp by a few minutes. My Pivotal CloudFoundry app writes a new entry into a PostgreSQL 9.4.5 database. Doing so, I let PostgreSQL generate and store a timestamp for that entry (within the SQL statement I use 'now()' for that particular column). All that works fine so far. Problems arise when I read the entry with my app because I have to format the timestamp to ISO 8601 (company policy) and

Changing Java Timestamp format causes a change of the timestamp

限于喜欢 提交于 2019-12-17 17:13:23
问题 I'm a bit puzzled regarding the Java timestamp formatting functions as they seem to change the timestamp by a few minutes. My Pivotal CloudFoundry app writes a new entry into a PostgreSQL 9.4.5 database. Doing so, I let PostgreSQL generate and store a timestamp for that entry (within the SQL statement I use 'now()' for that particular column). All that works fine so far. Problems arise when I read the entry with my app because I have to format the timestamp to ISO 8601 (company policy) and

No bean named 'transactionManager' is defined

瘦欲@ 提交于 2019-12-17 16:30:39
问题 I have configured two persistent units with the entity managers set up as show below: <bean id="liveEntityManagerFactory" class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean" p:dataSource-ref="LiveDataSource"> <property name="persistenceUnitName" value="LivePersistenceUnit" /> </bean> <bean id="archiveEntityManagerFactory" class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean" p:dataSource-ref="ArchiveDataSource"> <property name="persistenceUnitName"

dynamic roles on a Java EE server

不打扰是莪最后的温柔 提交于 2019-12-17 16:27:49
问题 I want to manage user and roles in a dedicated application. For example a user of this application ("customerX boss") can create a new role "customerX employee". If an employee accesses the Java EE application server (GlassFish 3) he should get the role "customerX employee". It sounds simple, but it is not supported by Java EE, because groups are mapped to roles at start-up time and the roles within the application are static. What is the best way to manage user roles at runtime in a Java EE