glassfish-3

Multiple apps in glassfish JUL logging to different log files?

*爱你&永不变心* 提交于 2019-12-06 17:40:43
I use java.util.logging and have multiple war apps in glassfish servers. I'd like JUL to log to a different file for each war (currently glassfish logs everything to server.log). I know this is easy to do with log4j or other logging modules, but I'd like to stick to JUL. (Would not like to discuss if JUL is my best option). Is it possible? Thanks It is possible to append a different FileHandler to a Logger. If you have a normal logger: private final static Logger LOGGER = Logger.getLogger(Something.class.getName()); Add a new FileHandler: Handler fh = new FileHandler("/home/file.log"); LOGGER

Possible to access remote EJBs from a custom LoginModule?

妖精的绣舞 提交于 2019-12-06 13:21:10
I found some nice hints on how to write a custom realm and loginModule. I'm wondering though if it is possible to access a remote EJB within the custom loginModule. In my case, I have remote EJBs that provide access to user-entities (via JPA) -- can I use them (e.g. via @EJB annotation)? Ok, I found the answer myself: works fine! I can get a reference to the remote SLSB via an InitialContext. Here's the code: public class UserLoginModule extends AppservPasswordLoginModule { Logger log = Logger.getLogger(this.getClass().getName()); private UserFacadeLocal userFacade; public UserLoginModule() {

Atmosphere can't get session on Glassfish 3.1.2

╄→尐↘猪︶ㄣ 提交于 2019-12-06 13:14:32
问题 I got the chat example working from Atmosphere, and now I want to get the session, but I get a null pointer exception. My configuration: GlassFish 3.1.2 Atmosphere 1.0.0-SNAPSHOT My ChatAtmosphereHandler.java file: @Override public void onRequest(AtmosphereResource r) throws IOException { AtmosphereRequest req = r.getRequest(); // First, tell Atmosphere to allow bi-directional communication by suspending. if (req.getMethod().equalsIgnoreCase("GET")) { /* ------- ADDED LINES BY ME ------- */

JavaEE + Glassfishv3.0.1: Losing session attribute (SessionId is not the same between request)

回眸只為那壹抹淺笑 提交于 2019-12-06 12:54:24
问题 I have a home.jsf that invoke a login servlet that look into database and query out the user object given the username and password. Then I save that user object into session under attribute name user , like this request.getSession().setAttribute("user", user); protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { String username = request.getParameter("username"); String password = request.getParameter("password"); boolean

How to serialize java.sql.Date as Long, when using web services?

混江龙づ霸主 提交于 2019-12-06 11:19:56
I have a simple web service method that returns a simple java class as return value. @WebMethod() public SimpleClass myMethod(); @XmlRootElement() public class SimpleClass { @XmlElement(name="myDate") @XmlJavaTypeAdapter(value=MyDateAdapter.class) public java.sql.Date myDate = new java.sql.Date(new java.util.Date().getTime()); } I want that java.sql.Date will transmitted as Long value in the XML (because the client is J2ME that cannot handle complex things). For this puprpose I took the solution that was mentioned in many places before, and worked great on Glassfish v2. First, I declare the

configure glassfish embedded server with logback logging

♀尐吖头ヾ 提交于 2019-12-06 10:59:52
Is there any way to configure Glassfish embedded server for testing with third party logging frameworks - particularly Logback (or) LOG4j. Note: Glassfish embedded server is used for unit testing our EJB Beans. 来源: https://stackoverflow.com/questions/21645652/configure-glassfish-embedded-server-with-logback-logging

jsf check user logged in

泄露秘密 提交于 2019-12-06 06:26:16
How can I check if a user is logged in using jsf? This is how I am doing it and it's not working: <ui:fragment rendered="#{!request.getUserPrincipal().getName().equalsIgnoreCase('anonymous')}"> <h:outputLink value="logout"> <h:outputText value="Logout" /> </h:outputLink> </ui:fragment> Just check if HttpServletRequest#getUserPrincipal() is not null . <ui:fragment rendered="#{request.userPrincipal != null}"> <h:outputLink value="logout"> <h:outputText value="Logout" /> </h:outputLink> </ui:fragment> It also works for HttpServletRequest#getRemoteUser() . <ui:fragment rendered="#{request

Session replication in Glassfish Cluster on EC2

不打扰是莪最后的温柔 提交于 2019-12-06 04:45:21
I've built a cluster on Glassfish administred via SSH, where there are 2 instances. I deployed an application that shows the "Session id". This application has in the web.config: <distributable/> And in the sun-web.xml: <session-config> <cookie-properties> <property name="cookieDomain" value="compute.amazonaws.com"/> </cookie-properties> </session-config> I enabled "Availability" in Edit Application. But when I access the 2 web app versions I see different session ids. Can anyone help me? EDIT: As some users noticed, in EC2 is not supported multicast. A solution comes with Glassfish v3.1.2,

Glassfish v3: Can't Deploy MessageDriven Bean - Missing Destination JNDI Name

。_饼干妹妹 提交于 2019-12-06 04:34:43
I am trying to deploy an ear that contains an EJB jar. The jar only contains one MDB class: package my.package; import javax.ejb.ActivationConfigProperty; import javax.ejb.MessageDriven; import javax.jms.JMSException; import javax.jms.Message; import javax.jms.MessageListener; import javax.jms.ObjectMessage; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @MessageDriven(mappedName = "jms/FileUploadedQueue", activationConfig = { @ActivationConfigProperty(propertyName = "acknowledgeMode", propertyValue = "Auto-acknowledge"), @ActivationConfigProperty(propertyName = "destinationType",

Glassfish - uploading images - doing it right

隐身守侯 提交于 2019-12-06 04:10:14
问题 I am on latest glassfish (3.1.2) - so no need for apache FileItem and no bugs with getPart(). I read that the best practice on uploading images is saving them on the file system (see here for instance). I am editing already existing code - smelly at that - so I had the idea to do : Part p1 = request.getPart("file"); System.out.println("!!!!!P1 : " + p1); Prints : !!!!!P1 : File name=DSC03660.JPG, StoreLocation=C:\_\glassfish3\glassfish\domains\domain1\generated\jsp\elkethe\upload_7cb06306