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


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

JSP / JSTL :: How Bean Object Have Been Tagged

Sep 13, 2012

How bean object have been tagged to JSTL?

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 :: 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 :: 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

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

JSF :: Managed Bean Is Not Getting Instantiated Intermittently

Jun 5, 2014

I have a JSF bean which is request scope and corresponding JSF UI page. when user tries to open this page, we are getting exception 'Cannot instantiate user.java class <default constructor>'. This does not come always. It comes very rarely. JSF version is 1.2

View Replies View Related

JSF :: Value Input Text Cannot Bind To Bean

Feb 28, 2011

I have following bean:

public class LoginBean {
private String email;
private String password;
private SessionId sessionId;
private UserController userController;
public LoginBean() {
this.email = "";
this.password = "";

[code]....

And the jsp page is html and css and next part

<h:form id="form">
<p><h:inputText value="#{loginBean.email}" /></p>
<p><h:inputSecret value="#{loginBean.password}" /></p>
<p><h:message for="form"/></p>
<p><h:commandButton value="login" action="#{loginBean.login}" /></p>
</h:form>

I can't get the values out of the inputtext in any way?

View Replies View Related

How To Print Contents Of Java Bean

Mar 24, 2015

I'm trying to debug a program and I need to see the values in a Bean. I tried

" system.out.println("OrderManager.java: packagePricing, packBean= "+packBean);"

but that just gives me

"OrderManager.java: packagePricing, packBean=com.voxportal.web.device.PackageBean@73dde7ae"

which I think is a reference to the bean but not the actual contents of the Bean.

View Replies View Related

EJB / EE :: Bean Annotations And Unit Testing?

Mar 6, 2014

I have a bean that represents data been collected from a form on a jsp page. Currently I would like to validate my fields and write some test cases for them. As you can see from my test case example I test a string in the hope that it fails because it contains only one letter. My problem is my unit test is passing. The reason this is from what I can tell is that at runtime it fails when I try to persist my object using my entity manager. During my unit test I just I don’t call my entity manager I just try and set the field.

What I thought would happen was that when I use my bean fields set method the annotations would be checked and fail at that point. Hence why I expected my unit test in this case to fail.

What I would like to know is

1.Are annotations specifically designed to validate when I persist my object and am I using them incorrectly at this point?

2.Is this the best method to use to validate fields, is there a better way, should I write my own code to validate for me when I set my value?

a. Should I throw an exception from the set method of each bean field?

Unit Test:

@Test
public void testName(){
Human h=new Human();
try {
h.setFname("a");
} catch (Exception e) {
// TODO Auto-generated catch block
fail("failed");
e.printStackTrace();

[code]....

View Replies View Related

JSF :: Create A Managed Bean Per View

Jun 11, 2014

About creating views,

1. When we have a view and this uses two or three managed beans and not only one, is this ok? is a good design?

2 If we have two views and both of them only share one functionality (they need to display datatable with clients) , for the second view and for the shared functionality, should I in the managed bean for the second view create the same method that gets the clients or reuse the method in the managed bean created for the first view?

View Replies View Related

JSF :: What Causes Backing Bean Return Null

Apr 6, 2015

I tried to create my first javaweb project. However when some action were being invoke I received an error. Here is what I did:

Person.javapackage org.javaeesample.entities;
import java.io.Serializable;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;

[Code].....

When tried to run my project what happened were:

1. When i clicked the link from show.xhtml

<h:link value="#{p.name}" outcome="details">
<f:param name="pid" value="#{p.id}"/>
</h:link>

It output the page but without data being displayed.

but on the url it shows: [URL] .....

1. When i clicked 'Save' button in create.xhtml here is the error i received:

An Error Occurred:

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

Passing Java Bean Name In A Method

Jun 13, 2014

Here I am taking response data from JSON using jackson API.I found a feature like using Jackson the properties can be set to bean properties.
 
private static String readUrl(String urlString) throws Exception {       
BufferedReader reader = null;       
try {           
URL url = new URL(urlString);           
reader = new BufferedReader(new InputStreamReader(url.openStream()));     

[Code] ....

I got the correct output here. But now I want to generalize my method into a utility class so that I can reuse the same method for setting response data directly to respective beans as given below:-
 
My question is how will I pass the bean object in my utility class?

public static Object getResponseData(String response,[b]String bean[/b]) throws Exception {       
ObjectMapper mapper = new ObjectMapper(); 
mapper.configure(DeserializationConfig.Feature.FAIL_ON_UNKNOWN_PROPERTIES, false);       
JsonNode root = mapper.readTree(response);

[Code] ....

View Replies View Related

EJB / EE :: Bean Validation Error In JPA When Trying To Persist Entity

Aug 5, 2012

i get this error when trying to Persist a customer Entity in my web application using netbeans with the default glassfish server persistence provider eclipselink(JPA2.0)

error is

SEVERE: javax.validation.ConstraintViolationException: Bean Validation constraint(s) violated while executing Automatic Bean Validation on callback event:'prePersist'. Please refer to embedded ConstraintViolations for details.

the table that i want to write to has the following colums
id ==> primarykey auto increment not null int
name == varchar(45) not null
phone ==> varchar(19)
nationalIdNo ==>varchar(19)
balance ==> bigdecimal(6,2) not null default(0.00)

in my addNewCustomer i only need to set name, phone and nationalIdNo only this is my code

/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package session;

import cart.Cart;
import entity.Customer;
import javax.ejb.Stateless;
import javax.ejb.LocalBean;
import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;

[code].....

why am i getting this error? and how do you do a bean validation?

View Replies View Related

Servlets :: How To Pass Bean Class Instance

May 10, 2014

here i have my bean class

package com.emp;
public class salarybean {
private String name;
private Double days;
private Double id;
public String getName() {
return name;

[code]...

now i want to retrieve all these values in another servlet where i want to do some calculation but not able to retrieve it is showing null and indicating for this value in my eclispe IDE " Iterator<salarybean> itr=list.iterator(); "

public class Time extends HttpServlet {
public void doGet(HttpServletRequest request, HttpServletResponse response)
throws ServletException, java.io.IOException

[code]....

View Replies View Related

JSF :: Reset Values In Back Form Bean

Jun 3, 2014

When we have a jsf form to store clients in a ddbb for example and the backing bean is in session scope.... Lets think of a user that requests 3 times the xhtml view with the form to store 3 clients.

1) If we dont reset the backing bean each time the form is processed, he would see the values he sent beforea and it doesnt have much sense, right?

2) Here there is an example of clearing form after submitting : [URL] ...... Clearing the form after submititng is a common practice for the reason of the statement 1, right?

3 ) What is the best or normal approach to reset values in a form? when the user requests it or done automatically by the application after processing a form?

4) Are there known issues about resetting or not resetting the values in a form bean?

View Replies View Related

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 View Related

JSF :: How To Access Application Scoped Bean From A Scheduled Job

Mar 29, 2015

I am coming from a Seam 2 and ATG background, and working on re-writing an old Seam 2 application using JSF 2 on Tomcat 8. I've run into a snag:

I have an application scoped managed bean, let's call it EMail. It holds a collection of Email objects, and does some other stuff.

I have an IMAPClient, which is currently setup as an application scoped managed bean (mostly to simply configuration, etc...).

I need to call a method on the IMAPClient to go check email every X seconds (let's call it 60 seconds), and add any new email into the Email managed bean's collection of email. In Seam 2 this was easy with the @Asynchronous annotation. In JSF 2 I can't figure out how to do it. I've tried using Quartz, which will happily run my IMAPCheckJob every 60 seconds, but I am so far unable to figure out how the IMAPCheckJob can get access to either the IMAPClient or the EMail beans.. There's no dependency injection into the Quartz Job, and since it's not executing in a HTTP request flow, there's no Faces context available.

It seems like there has to be some way to allow for scheduling and still have access to the benefits of the Application scoped managed bean DI system...

Or do I need to give up and move to JBoss with EJBs and CDI instead of JSF beans?

View Replies View Related

EJB / EE :: Cannot Access Simple Bean Using JBOSS-JNDI

Nov 26, 2014

I'm not able to access my bean class (not an EJB) using a given JNDI name in JBoss 5.0.1, where the same is working in Tommcat 7.0.

META-INF/context.xml
<Context>
<Resource name="test/TestDAO" auth="Container"
type="ws.jndi.MyBeanDAO"
factory="org.apache.naming.factory.BeanFactory"/>

[code]....

View Replies View Related

JSF :: Passing Content Of Input-text To Bean?

Apr 8, 2014

I have an xhtml file with this content:

<h:inputText tabindex="7" styleClass="input" id="title" value="#{register.title}"
required="true">
</h:inputText>

Basically I want the user to enter his title (e.g. Mr., Dr.), which would be passed on to a bean which would send this information to me in email.

I also have a bean called register, along with setters and getters:

private String title;
public String getTitle() {
return title;
}
public void setTitle(String title) {
this.title = title;
}

I want to pass this information to a String called body, within the bean:

body = body+"Title: "+this.title+"
";

I would then send the String in an email.

View Replies View Related

JSF :: Injection Of EJB Into CDI Bean Call Of Method Not Allowed

Apr 21, 2014

In an JEE6 webprofile project, using JBoss EAP 6.1:

I have a CDI Bean:

import javax.faces.bean.SessionScoped;
import javax.inject.Inject;
import javax.inject.Named;
import de.dpunkt.myaktion.model.Organisator;
import de.dpunkt.myaktion.services.OrganisatorDAO;

[code]....

When I call doCreate() I get

javax.servlet.ServletException: javax.ejb.EJBAccessException: JBAS014502: Aufruf an Methode: public abstract void de.dpunkt.myaktion.services.OrganisatorDAO.save(de.dpunkt.myaktion.model.Organisator) von Bean: OrganisatorDAOBean ist nicht gestattet
javax.faces.webapp.FacesServlet.service(FacesServlet.java:606)

which translates to: call of method: .... from Bean ... is not allowed

View Replies View Related







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