EJB / EE :: Stateful Session Bean Client Servlet

Jun 1, 2014

In stateful session bean client servlet we are explicitly setting shoppingCart to session attribute. I do not remember doing similar step withStatelessSession bean.

request.getSession(true).setAttribute("cart",shoppingCart);

I do have have annotation as well

@EJB
ShoppingCart shoppingCart

View Replies


ADVERTISEMENT

Enterprise JavaBeans :: Calling Singleton Bean From Session Bean Returns NullPointerException

Feb 23, 2013

I am doing this

@Startup
@Singleton
@ConcurrencyManagement(ConcurrencyManagementType.CONTAINER)
@Lock(LockType.READ)
public class ResourceBean {

[Code] ....

And I call this singleton bean from a stateless session bean like this

@Stateless
public class ClientBean {
@EJB
ResourceBean resource;

public String create(String r)
{
String res=resource.returnString(r);
return res;
}
}

But resource.returnString(r); gives a org.apache.jasper.JasperException: java.lang.NullPointerException I started the glassfish server in debug mode and found out that "resource" was null. but @PostConstruct in singleton does print which means singleton bean exists.

Can we call singleton beans with no interface in such a way form a session bean? I actually want to acquire instance of singleton bean when a client invokes method in Client bean...

View Replies View Related

EJB / EE :: Session Bean Must Not Extend Another Session Bean?

Nov 9, 2014

I have tried this example ([URL].../) with CarDao extending the BaseDao, it works like a charm.However, from the CarDao class, my NetBeans underlined the class name “CarDao” with the error message “A session bean must not extend another session bean.” But I can compile, deploy and run the application without any problem.

I have also heard that a session bean cannot extend another session bean, but why it works here?

I am using Java EE 6, NetBeans 8.0.1 and WebLogic 12c for this code testing.

View Replies View Related

JSF :: Application / Session Bean

Jan 30, 2015

When i create an application Bean how i can update it from another bean? Lets say application Bean has variable h=1 and i want to update from another bean and make it 2 how i can do it? And how i can access the value of a session bean from another bean?

View Replies View Related

EJB / EE :: Local Session Stateless Bean

Feb 18, 2015

Below is my ejb-jar.xml

<!DOCTYPE ejb-jar PUBLIC '-//Sun Microsystems, Inc.//DTD Enterprise JavaBeans 2.0//EN' 'http://java.sun.com/dtd/ejb-jar_2_0.dtd'>
<ejb-jar>
<display-name>TestEJB</display-name>
<enterprise-beans>
<session>
<ejb-name>TestSessionLocal</ejb-name>

[code]....

All my classes implement proper local classes EJBLocalHome and EJBLocalObject.This configuration used to work fine in JBOSS 5.1.0 G

View Replies View Related

JSF :: Get Data From Managed Bean Method After Servlet Filter

Feb 15, 2015

I have a situation to load data while JSF page loads. Also have a filter which populates user information from http request.

I was expecting the filter first to populate the user information and in the managed bean get method to verify the user information and get the data (from database). But in this case i see the managed bean get method is invoked before filter populates user information and i get null pointer exception because the user information is null.

I had to work around to get the user information from FacesContext in the managed bean get method because the user information wasn't available. Is there a way to make sure the filter is invoked first?

View Replies View Related

JSF :: Count Number Of Views Created In A Session While Using Managed Bean With View Scope

Jan 30, 2014

I am trying to restrict the number of views in JSF 2.0.2 using

<context-param>
<param-name>org.apache.myfaces.NUMBER_OF_VIEWS_IN_SESSION</param-name>
<param-value>5</param-value>
</context-param>

In my case my managed bean is View Scoped and it supports a UI page which has multiple forms and each form is submitted as AJAX POST request.

As per the statndard, setting restriction to 5 should create 5 views and after that based on LRU algorithm the oldest views should get deleted if 6th views is created.

Therefore any action on the oldest view will throw the ViewExpiredException and i simply redirect the user to view expired page.

1) When i set the restriction to 5 views, i open 4 tabs with 3 forms each.
2) I submit the 3 forms on first tab everything works fine.
3) As soon as I go to 2nd tab and submit the first form thr, i get view expired exception
4) It seems I am exceeding the number of views I mentioned in web.xml

I want to know :

1) Does every AJAX POST submit itself creates a view ?
2) How I can count the number of views created in a session ?
3)Can i force expiry of a view in JSF 2.0.2 while the session is still alive ?
4) Normally JSF 2.0.2 session cachces the views. Lets assume session is alive the entire day but a view was created in morning at 9:00 AM and is not used again the entire day. Assuming that session doesn't reaches the max number of views it can save in entire day, will the view created in morning expire on its own after certain interval of time ? If not , can we still force its expiry while keeping the session alive ?

View Replies View Related

Enterprise JavaBeans :: How To Start A Socket Client Connection With EJB3 Timer Bean

May 28, 2013

I have some embedded systems (with web server) putting their states, sensor values into an XML file.

<sensor1>
<temp>21.4</temp>
<unit>°C</unit>
</sensor1>

Now I played a little with EJB3. I want to start a timer bean in a 10second interval which retrieves the IP of registered devices from a databases, opens client sockets with a Thread Pool and retrieves the XML file over HTTP GET of each device listed in the db.

Is it possbile with EJB3? how to start thread based background services like that within EJB3 timer bean?

View Replies View Related

Enterprise JavaBeans :: Does Container Managed Entity Manager Is Thread-safe In Stateless Session Bean?

May 8, 2014

I read JEE6 doc and confused with : Does container managed entity manager (injected by PersistenceContext annotation) is thread-safe in stateless session bean in multiple-thread env?
 
See code below, if there are 2 requests to stateless sesion bean in 2 concurrent threads ,  is it using same Entity Manager Instance or not?
 
@Stateless(name = "HRFacade", mappedName = "HR_FACES_EJB_JPA-HRFacade-HRFacade")
public class HRFacadeBean implements HRFacade, HRFacadeLocal {
    @Resource
    SessionContext sessionContext;
   
    @PersistenceContext(unitName = "HRFacade")
    private EntityManager em;
 
[Code] .....

View Replies View Related

Java Servlet :: How To Renew Session ID Of User

Aug 3, 2012

How we can renew the session Id of the logged in user in order to prevent any session fixation problems. Is there any API in servlets to do it?

View Replies View Related

Java Servlet :: How Is Session Maintained In Application Server

Aug 3, 2012

How is session maintained in the application server, internally what happens when the user has logged in ? We create a session and store the user details which will be stored in the session object in the server with a unique sessionID which will be validated when the same user login the system again? But how exactly the session is maintained in the Server internally?

View Replies View Related

Java Servlet :: Implement Session Timeout For Users

Dec 7, 2012

Coding a web application using Java 6. Try to implement the session timeout for users.

In the web.xml, I added:

<session-config>
<session-timeout>480</session-timeout> <!-- jsp will expire in 8 hours -->
</session-config>

Now, during the runtime, if a user does not touch the jsp page for 8 hours (after the user has signed in), the session timeout mechanism will kick in. At that point, the server side will automatically execute:

rd = req.getRequestDispatcher("/signin.jsp");

So that the user will have to re-sign in, before continue the work.

How can I achieve this goal?

View Replies View Related

Java Servlet :: Session Information Is Getting Overwritten Once Multiple User Logged In

Aug 18, 2012

I am using following servlet code to store the logged in user information in the session.

session = request.getSession();
session.setAttribute("userName", userName );
session.setAttribute( "LoginId", loginId );

The information is getting stored in the session and i am able to retrieve the same for single user. The trouble starts when 2 user logged in from different browser (for example chrome, IE) from the same machine. The 2nd logged in user, overwrite the session information of first user.

How to prevent this.

My environment: Windows 7 64 bit, IBM websphere server, Oracle 11g, JSP, Sevrlet.

View Replies View Related

Java Servlet :: Can Use Request To Get Client Information (IP Address)

Jul 17, 2013

So far I only know  using

request.getRemoteAddr() get

to get user IP address, is that a way to get Users PC memory?
 
long maxMemory = runtime.maxMemory();
long allocatedMemory = runtime.totalMemory();
long freeMemory = runtime.freeMemory();
 
Only get server memory not the client....

View Replies View Related

JSP / JSTL :: Page Set Bean Variables But Give NullPointerException When Bean Try To Merge In DB

Nov 21, 2013

I'm new to JSP but I've to use it to grab data coming from an external site, pass data to a Bean, write data in a DB and redirect the user to another page. Follow the JSP page.

<%@page import="EJB.getResponse"%>
<%
long paymentID = Long.parseLong(request.getParameter("paymentid"));
String responsecode = "9999";
getResponse g = new getResponse();

[Code] ....
 
This is the bean:

@ManagedBean
@RequestScoped
public class getResponse implements Serializable {
private Long paymentId;
private String result;
private String auth;

[Code] ....
 
On the console I see the prints but I receive the NullPointerException

WARNING: StandardWrapperValve[jsp]: PWC1406: Servlet.service() for servlet jsp threw exception
java.lang.NullPointerException
at EJB.getResponse.printData(getResponse.java:72)
at org.apache.jsp.notify_jsp._jspService(notify_jsp.java from :60)
at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:111)

[Code] ....

View Replies View Related

JSP :: Page Directive Attribute Session False - Yet Session Created

Feb 26, 2014

May be I did not understand the meaning and usage of attribute "session" in page directive. My understanding is if session=false, in page directive, then the JSP page will not participate in the session. However, I have my welcomepage as below:

<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
pageEncoding="ISO-8859-1" session="true"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
........
.......
<%= session %>
<c:out value="${pageContext.request.session}"/>

if I choose session=true, then both ways of accessing session works , which means the JSP page participated in the session.

But if I change the session=false, then <%= session %> fails, but <c:out value="${pageContext.request.session}"/> does not fail.

how can c:out still show the session, when session = false

View Replies View Related

Servlets :: Can Access Session Object Even Session Is Time Out

Jun 4, 2014

Can I access the session object even session has been expired? I need to check whether session is expired or not for each request.The session invalidation is set null the session object. What I concluded, session time out I can access session object but session invalidation I can not access session object. How can I find the session time out by using session object?

View Replies View Related

Web Services :: Rest Session Not Getting Invalidated After Invalidating UI Session?

Dec 17, 2014

I have 2 war in 1 EAR.

War A corresponds to UI

War B corresponds to Rest

1) From War A, I login to the application and then fetch some users that is a rest call. I get the response back from rest in json form that ui consumes and display the data on page.

2) Now I click on the logout link from ui jsp. This logs out the session from Ui. I use <form data-dojo-type="dijit/form/Form" based logout.

3) I then go to the proxy (using burp) and manually request the rest call which I made in step no 1), the rest gives the response back with the same json object returned in step no 1) This shows that the logout action on step 2) is invalidated the session from War A (ui war) but the session or cookie based from WAR B (rest war) is not invalidated.

Expected outcome:After I Logout from War A(ui war), the session must also get invalidated from war B (rest war) and manually request from proxy should not get the same response object as received in step 1)

View Replies View Related

Servlets :: Updating Session Value But Same Session In JSP Page Not Updated

Jul 8, 2014

I am developing a e-commerce college project, here i add the items in the cart(a div tag in the jsp page) via servlet by creating sessions,

flow control: shopping jsp (when user wants to add an item in the cart) --> item servlet (which is used to create session and synchronized it) --> cart servlet(which is used to add items in the arraylist and show them in the shopping.jsp's div tag + it also sets the total purchase amount in the session variable "totalpurchase")

now after that user wants to proceed to checkout, here i use the onclick event to check the minimumshopping amount must be less than the totalpurchase (totalpurchase which i had setted in the session),but my jsp page is unable to rechognise the updated value of the totalpurchase, yes, if i reload the page, it rechognises the new updated value of the totalpurchase? but i want it to rechognise the updated total purchase value, without reloading he jsp page..

View Replies View Related

Comparing Sample Client With Real Time Client - Transport Error 404

Jan 23, 2015

I have tried each and every thing in all the other answers. Like setting chunked to false, changing parameters, changing http1.1 -1.0. I am just writing a sample client to compare it with my real time client. Following is the code of client:

package com.webservicemart.ws;
import java.rmi.RemoteException;
import org.apache.axis2.AxisFault;
import com.webservicemart.ws.USZipStub.ValidateZip;
public class UsZipClient {
public static void main(String[] args) {

[Code] ....

And Following is the error :

[INFO] Unable to sendViaPost to url[http://www.webservicemart.com/uszip.asmx]
org.apache.axis2.AxisFault: Transport error: 404 Error: Not Found
at org.apache.axis2.transport.http.HTTPSender.handleResponse(HTTPSender.java:310)
at org.apache.axis2.transport.http.HTTPSender.sendViaPost(HTTPSender.java:194)
at org.apache.axis2.transport.http.HTTPSender.send(HTTPSender.java:75)

[Code] ....

I have tried with other geoIP service and weather forecast too. I get the same error.

View Replies View Related

Java Servlet :: Showing Error While Compiling Servlet

Jan 23, 2013

I am a beginner want to compile servlet with following path

javac -classpath Program FilesApache Software FoundationTomcat 5.5commonlibservlet-api.jar;classes:.-d classes srccomexamplewebBeerSelect.java

Problem arises as follows:

javac: invalid flag: FilesApache
Usage: javac <options> <source files>
use -help for a list of possible options

View Replies View Related

JSF :: Scope Of Bean Associated With Form?

Aug 8, 2014

I have a managed bean for a form. I map the fields filled in the form with managed bean properties. when I submit the form and click new form , values from the previous form submitted gets displayed in the input fields. I used the scope of the from bean to session. what should be its scope so that values should be destroyed after I submit the form .For every new form ,new bean has to be initialized. On submit I navigate to another bean with session scope.

View Replies View Related

JSF :: How To Pass Value To Bean Class

Nov 7, 2014

Getting JS -> JSF value to Bean class? I have tried with below code:

JSF code:

<h:commandButton styleClass="buttonpos" value="Get Value" action="#{myBean.action}" onclick="document.getElementById('crForm:hiddenInput').value">
<h:inputHidden id="hiddenInput" value="#{myBean.action}"/>
</h:commandButton>
Java Beans
public class CurrencyExchangeBean {
protected static Logger logger = ILogger.getLogger(CurrencyExchangeBean.class);

[Code] .....

View Replies View Related

JSP :: Getting And Setting Bean Property With Tag

May 11, 2014

Will it make any difference if I put the last line of code inside the useBean tag ?

<jsp:useBean id="person" class="foo.Person" scope="page" >
<jsp:setProperty name="person" property="name" value="Fred" />
</jsp:useBean>
<jsp:getProperty name="person" property="name" />

It gives me the same output though....

View Replies View Related

JSF :: Binding Xhtml And Bean Not Working?

Mar 29, 2014

I am working on eclipse kepler, JSF 2.2 with PrimeFaces 4.0 / Mojarra 2.2 library.

actually there are 2 Problems:

I still get this server message no matter what I do.

(( javax.el.PropertyNotFoundException: /Order.xhtml @28,76 value="#{kk.refugee.id}": Target Unreachable, 'refugee' returned null))

and if I delete the input text puls the hidden, the message keeps pop up for 'material' selectOneMenu. -

I have no chance to examin : ((is this javascript code correct, to copy the value of one component to the other.)) these are my xhtml file and java calsses.


**kk.java**
-----------
package khldqr.beans;
import javax.faces.bean.ManagedBean;
import javax.faces.bean.SessionScoped;
@SessionScoped
@ManagedBean
public class kk {

[code]....

View Replies View Related

JSF :: Passing Backing Bean To Another Class

Mar 7, 2014

I am new to JSF and was trying to find an example.

My question is in the processPage() method... how do i pass the managed bean to the ProjectDAO insert statement?

Faces-config.xml

<managed-bean>
<managed-bean-name>projectBean_backing</managed-bean-name>
<managed-bean-class>com.att.ped.backing.Project</managed-bean-class>
<managed-bean-scope>request</managed-bean-scope>
</managed-bean>

[Code] .....

View Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved