java-ee

How to know the number of the current day in the current years using Java?

一曲冷凌霜 提交于 2019-12-24 16:48:01
问题 I have to calculate in Java what is the number of the current day in the year. For example if today is the 1 of January the resut should be 1 . If it is the 5 of February the result should be 36 How can I automatically do it in Java? Exist some class (such as Calendar ) that natively supports this feature? 回答1: You can use java.util.Calendar class. Be careful that month is zero based. So in your case for the first of January it should be: Calendar calendar = new GregorianCalendar(2015, 0, 1);

Wildfly Form Auth fails when using special characters

最后都变了- 提交于 2019-12-24 16:26:29
问题 We are deploying our GWT app to a Wildly 8.1.0 server and are using form authentication for security. Our problem is that every time our customer has a special character (æøåäëö, etc.) in their username or password, they cannot login. I have seen other people having the same issue: https://developer.jboss.org/thread/42859?tstart=0 UTF-8 encoded j_security_check username incorrectly decoded as Latin-1 in Tomcat realm Spring security: Form login special characters but they are using Tomcat

HttpSession.setMaxInactiveInterval not working in Tomcat 6

亡梦爱人 提交于 2019-12-24 15:27:09
问题 I'm trying to adjust the session timeout using HttpSession.setMaxInactiveInterval and it's not working. Here is my code (Groovy), which is executing without exceptions: def paramValue = WebAttributes.REQUEST.getParameter('maxInactiveSeconds'); println 'paramValue=' + paramValue; if (paramValue != null) { def seconds = Integer.parseInt(paramValue); WebAttributes.REQUEST.getSession().setMaxInactiveInterval(seconds); } Some details: Tomcat 6.0.16 This is happening in a webapp separate from the

Dependency injection does not work in Arquillian Test

杀马特。学长 韩版系。学妹 提交于 2019-12-24 15:22:59
问题 This is test class: I try to inject a Paper object then perform the action to test whether the injection is failed or not. @RunWith(Arquillian.class) public class ExcelProcessorTest { // Not work. Because Paper and ExcelProcessorTest are in different modules? @Inject private Paper paper; @Deployment public static JavaArchive createDeployment() { JavaArchive jar = ShrinkWrap.create(JavaArchive.class, "test.jar") .addClasses(Paper.class) .addAsManifestResource(EmptyAsset.INSTANCE, "beans.xml");

Stateful session beans unexpected behaviour when packaged in a war and packaged in an ear->jar

怎甘沉沦 提交于 2019-12-24 15:18:45
问题 I am new to ejbs. I wrote a stateful session bean scoped @SessionScoped. Then I injected the ejb into my servlet. @Local @SessionScoped @Statueful public class CartServiceImpl implements CartService { private int i = 0; public int getI() { return i++; } } In my servlet @Inject private CartService cartService; . . . out.print(cartService.getI()); Then I opened two browsers (IE, FF) and have hit the servlet. In IE I see output starting from 0 to n. In firefox also I see the output starting from

JSP include page doesn't work

允我心安 提交于 2019-12-24 14:50:10
问题 I have a JSP file, member.jsp which is as follows : <%@ page import="java.util.*" %> <jsp:include page="/html_functions.jsp" /> <% String heading = "Header" %> <%= formStart("a_form") %> <%= printPageHeader(heading) %> <%= startMyLi() %> <%= endLi() %> <%= formEnd() %> and my html_functions.jsp is as follows : <%! public String formStart(String name) { String structure = "<div id=\"content\"><form name=\"" + name + "\" method=\"post\"><ul>"; return structure; }//formStart public String

Using log4j with Web container (part of the J2EE server)

你离开我真会死。 提交于 2019-12-24 14:42:38
问题 When our application throws errors that we catch, we put the message and stacktrace in a log file created specifically for our application (myapp.log). For example: public class SomeClass { OurLogger log = OurLogger.getLogger ("myapp", SomeClass.class); public void someMethod { try { //code } catch (DataAccessException e) { log.error(e.getMessage(), e); } } } We do this because since we are in a environment where multiple apps reside on an application server...ours and every other

How to open a JChannel (JGroups) using Openshift Wildfly 8 Cartridge

时光毁灭记忆、已成空白 提交于 2019-12-24 14:34:46
问题 We are developing a Java-EE Application running on Wildfly 8 in the Wildfly-Openshift-Cartridge. The Openshift Application is set to scaled, therefore, more than one JVM node will be running as a cluster. The communicate between the different nodes, I like to use JGroups. However, I fail to open a new JChannel even though the JGroups itself seems to work. The application itself does also work, if I deploy the application locally to e.g. 3 wildfly standalone instances. The default standalone

arquillian-was-embedded-8 runs but can't inject EJB. NullPointerException

≯℡__Kan透↙ 提交于 2019-12-24 14:34:30
问题 I tried to inject my EJB bean in Arquillian integration tests with WebSphere embedded container. When injecting EJB I get the NullPointerException. But container is started correctly, because translogs are occured. I followed the exmaple at the https://github.com/arquillian/arquillian-container-was/blob/master/was-embedded-8/src/test/java/org/jboss/arquillian/container/was/embedded_8/WebSphereEmbeddedIntegrationClientTestCase.java My test code: package com.daoleen.websphere.arquillian.test;

How do I programmatically start/stop an EJB

老子叫甜甜 提交于 2019-12-24 14:13:00
问题 Does anyone know if it's possible to start/stop an EJB within my application code? Eg. I have some MDBs that I wish to selectively start/stop while my application is running? Any ideas? Can this maybe be done via JMX? Cheers! 回答1: The EJB spec has no mechanism to start/stop individual EJBs (or even modules) within an application. It is possible to start/stop applications dynamically using JMX via JSR 77. (I see you're using the jboss tag. I have no expertise in JBoss, so I don't know if it