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


ADVERTISEMENT

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

Enterprise JavaBeans :: Accessing Another Bean - No Such Entity

Oct 22, 2008

I am using EJB 2.1 when i am tryinh to access another bean from one bean I am getting :

javax.ejb.ObjectNotFoundException:No such entity the full stack trace is given ...

javax.ejb.ObjectNotFoundException: No such entity!
09:06:05,795 ERROR [STDERR] at org.jboss.ejb.plugins.cmp.jdbc.JDBCFindEntityCommand.execute(JDBCFindEntityCommand.java:46)
09:06:05,795 ERROR [STDERR] at org.jboss.ejb.plugins.cmp.jdbc.JDBCStoreManager.findEntity(JDBCStoreManager.java:591)
09:06:05,795 ERROR [STDERR]

[Code] .....

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

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

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

Enterprise JavaBeans :: JPQL Does TRIM Column Containing Only Blank Spaces Returns Null?

Oct 6, 2014

In Oracle SQL, when you do trim(column_name), if column_name is blank spaces only (say datatype is CHAR(8)), then "trim(column_name) is null" is true.
 
In JPQL, if you do "TRIM ( BOTH FROM p.column_name ) is null", does it evaluate to true just like in Oracle SQL?
 
The reason I'm asking, is my colleague wrote some code in JPQL like below:

... TRIM ( BOTH FROM CONCAT(p.column_name, '#@') ) = '#@'

He said he originally wanted to compare the TRIM result to empty String '', but the result is false, so he concat the column to some junk.

So if after the TRIM, the result is the same junk he added, then the column contains only blanks. I think this works but there could a simpler way to do it.

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

EJB / EE :: Create Stateless Bean That Instead Of Returning A String Returns Object

Jul 31, 2014

I'm training myself with the EJB 3 technology. I would like to create a stateless bean that instead of returning a String, it returns an object. I tried in the same way I did with the first exercise, but I'm getting several errors.

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

Changing Canvas Returns With NullPointerException

Jun 21, 2014

I'm currently having trouble with a Breakout clone that I'm working on when I want to change the scenes of the game. When I start out with the main menu and I hit play, the main menu calls for the StateManager to remove the MainMenu and then to add the GameState to start playing through the levels. But, whenever this is done it just gives a NullPointerException and freezes the game. I know the code for initially starting a State is fine because that is the same way the MainMenu is loaded but there seems to be an issue with changing from one to another...

This is the StateManager class that adds and removes the States/Canvases to and from the JFrame/Main class:

public class StateManager
{
private ArrayList<State> states;
private int currentState;
private JFrame gameFrame;
public StateManager(JFrame gameFrame)
{
this.gameFrame = gameFrame;
states = new ArrayList<State>();

[Code] ....

I've tried messing around with the order of which things are added/loading from the StateManager but am just failing to see what I did wrong.

View Replies View Related

Enterprise JavaBeans :: MDB For Getting Message From MQ

Jan 21, 2013

How to get messages from WebSphere MQ using ejb MDBs and I have to deploy this in Weblogic server.

View Replies View Related

Swing/AWT/SWT :: Changing Canvas Returns With NullPointerException

Jun 22, 2014

I'm currently having trouble with a Breakout clone that I'm working on when I want to change the scenes of the game. When I start out with the main menu and I hit play, the main menu calls for the StateManager to remove the MainMenu and then to add the GameState to start playing through the levels. But, whenever this is done it just gives a NullPointerException and freezes the game. I know the code for initially starting a State is fine because that is the same way the MainMenu is loaded but there seems to be an issue with changing from one to another...

This is the StateManager class that adds and removes the States/Canvases to and from the JFrame/Main class:
package com.pathtocreating.Breakout_V2.state;

import java.awt.BorderLayout;
import java.util.ArrayList;
import javax.swing.JFrame;
public class StateManager {
private ArrayList<State> states;

[Code] ....

The code that calls the change of state in MainMenuState is called in the update method:

if(inputController.isMouseClicked("LeftClick")) {
if(playHover) {
soundManager.playSound("ButtonClick");
BreakoutMain.sm.changeStates("GameState");

[Code] ....

Here is the full stack trace when clicking the area to change states:

Exception in thread "Thread-2" java.lang.NullPointerException
at sun.java2d.SunGraphics2D.validateColor(Unknown Source)
at sun.java2d.SunGraphics2D.<init>(Unknown Source)
at sun.awt.image.SunVolatileImage.createGraphics(Unknown Source)

[Code] ...

It gives that same value both before and after clicking on the region.

Printing out b after the State is changed to GameState gives the following:

java.awt.Component$BltSubRegionBufferStrategy@66116674

I've tried messing around with the order of which things are added/loading from the StateManager but am just failing to see what I did wrong.

View Replies View Related

Enterprise JavaBeans :: Error In InitialContext Looking Up

Jun 15, 2014

IDE: Netbeans 8.0.
Server ejb:
"@Stateless
public class ejb implements ejbRemote{
    public String say(){
    return "hello";

[Code] ....
 
When I run the Web project on the Server host, it's OK. But when I run it on another host it returns error. I can access 192.168.0.2:7676 in browser(returns some context string), so it may not be caused by firewall.

I think the problem is the initalContext is not generated from 192.168.0.2:7676 but from local JVM, because when when running it in the Server I change the ip address to random number it also is OK.

View Replies View Related

Enterprise JavaBeans :: How To Use Log4j In Module

Apr 22, 2014

I have included the log4j.jar in libraries; added log4j.xml in the sources folder; but I am getting an error: 
 
<Apr 22, 2014 11:07:50 AM PKT> <Warning> <EJB> <BEA-010065> <MessageDrivenBean threw an Exception in onMessage().

The exception is:

java.lang.NoClassDefFoundError: org/apache/log4j/Logger.
java.lang.NoClassDefFoundError: org/apache/log4j/Logger
    at test.MyMessageBean.onMessage(MyMessageBean.java:39)
    at weblogic.ejb.container.internal.MDListener.execute(MDListener.java:575)
    at weblogic.ejb.container.internal.MDListener.transactionalOnMessage(MDListener.java:477)
    at weblogic.ejb.container.internal.MDListener.onMessage(MDListener.java:375)
    at weblogic.jms.client.JMSSession.onMessage(JMSSession.java:4855)
    Truncated. see log file for complete stacktrace
 
how to resolve this???

View Replies View Related

Enterprise JavaBeans :: How To Keep Only One Character Of Enumeration In JPA

Feb 14, 2013

I have a question about enumerations,

class Test{
   public enum Gender{
     Male, Female
   }
@Enumerated(EnumType.STRING)
@Column(length=1)
private Gender gender;
}

My question is this correct? My goal is to keep only one character of the enumeration .

View Replies View Related

Enterprise JavaBeans :: First In First Out Job Queue Processing

Mar 3, 2013

I am looking for the ability, on the server side, to run programs or "jobs" in a job queue, where the jobs are processed as first in first out. If you are familiar with the IBM iSeries, they have a built in job queue mechanism which accomplishes what I am looking for. The primary purposes for this would be to process and update large amounts of data in a thread safe environment.

View Replies View Related

Enterprise JavaBeans :: Name Not Found Exception

Jun 7, 2013

I tried to develop a sample project with reference to : [URL] .....

When I try to run the client, I get the following error

javax.naming.NameNotFoundException: ejb: not bound
   at org.jnp.server.NamingServer.getBinding(NamingServer.java:771)
   at org.jnp.server.NamingServer.getBinding(NamingServer.java:779)
   at org.jnp.server.NamingServer.getObject(NamingServer.java:785)
   at org.jnp.server.NamingServer.lookup(NamingServer.java:396)
   at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

[Code] .....

View Replies View Related

Enterprise JavaBeans :: Integrating Struts In Two Server?

Jul 5, 2013

I am runing ejb3 in weblogic 10.3 and struts in tomcat server. both communication is not happening .
 
root dir
onlyenb6
account class
package ejb3.onlyejb;
import java.io.Serializable;
import javax.persistence.Entity;
import javax.persistence.Id;

[Code] ....
 
Get error
 
accno=44
na=hjhjhj
bal=777.0
enter in to if loop
jndi properties nuderprocess
jndi properties nuderprocess22
loading p file={java.naming.provider.url=t3://localhost:7001,

[Code] ....

View Replies View Related

Enterprise JavaBeans :: Change Default Context Of EAR File

Mar 19, 2013

I'm deploying an EAR file on weblogic 10.3.4. The EAR file contains a war file and a jar file that implements web services using EJBs.

The application deploys and is functioning correctly. The application is available from the following URLs:

web application: [URL] ....
web services: [URL] ....

However, I would like configure the deployment to insert the "app1" string into the URL so the application is available like this:

web application: [URL] ....
web services: [URL] ....

I've been looking at some of the configuration options in deployment plans, but can't seem to get anything working.

View Replies View Related

Enterprise JavaBeans :: Unable To Load Module - DeploymentContext Does Not Contain Any EJB

Apr 1, 2013

I'm writing an enterprise application to familiarize myself with Glassfish 3.1.2 and EJB 3.1. I've created several local, stateless beans, and injected one into a JSF managed bean. The ejb and web modules compile fine, but when I launch the application with Glassfish I get the following startup error and the application does not deploy.

SEVERE: Exception while invoking class org.glassfish.ejb.startup.EjbDeployer prepare method
SEVERE: Exception while invoking class org.glassfish.javaee.full.deployment.EarDeployer prepare method
SEVERE: Exception while preparing the app
SEVERE: Unable to load the EJB module. DeploymentContext does not contain any EJB.

org.glassfish.deployment.common.DeploymentException: Unable to load the EJB module. DeploymentContext does not contain any EJB.

Check the archive to ensure correct packaging for D:DocumentsNetBeansProjectsTestdistgfdeployTestTest-war_war.

If you use EJB component annotations to define the EJB, and an ejb or web deployment descriptor is also used, please make sure that the deployment descriptor references a Java EE 5 or higher version schema, and that the metadata-complete attribute is not set to true, so the component annotations can be processed as expected :

     at org.glassfish.javaee.full.deployment.EarDeployer.prepare(EarDeployer.java:166)
     at com.sun.enterprise.v3.server.ApplicationLifecycle.prepareModule(ApplicationLifecycle.java:871)
     at com.sun.enterprise.v3.server.ApplicationLifecycle.deploy(ApplicationLifecycle.java:410)
     at com.sun.enterprise.v3.server.ApplicationLifecycle.deploy(ApplicationLifecycle.java:240)
     at org.glassfish.deployment.admin.DeployCommand.execute(DeployCommand.java:389)

[Code] ......

View Replies View Related

Enterprise JavaBeans :: Connection To Multiple Databases Using Single EJB

Mar 9, 2013

How can I connect to multiple Databases (using @PersistenceContext) using an EJB? Did I need to connect various Entity Managers corresponding to the each database and simply send my Queries?

I am using Glassfish Application Server
Netbeans IDE
Java Derby Database
Oracle Database
Java Persistence API

View Replies View Related

Enterprise JavaBeans :: Column Name In Database Starts With A Number

Feb 14, 2013

Recently we updated out database and we changed our tables' and columns' names, I'm developing an adf application with EJB3.0 the question is that the new column names start with a number (eg. 001U_ID), its a kind of encoding the names of the tables so no one can modify the values.

When I create a query on the table it is throwing an exception:

Caused by: com.microsoft.sqlserver.jdbc.SQLServerException: Incorrect syntax near 'U_ID'.

I think the problem is that the EJB3.0 doesn't recognize column names starting with a number!!! What can I do to solve this issue?

View Replies View Related

Enterprise JavaBeans :: How To Use Application Managed Entity Manager In EJB

May 9, 2014

I finish reading The EntityManager Interface in JEE tutorial. I know I can use container manager entity manager in EJB, but I want to explore how to use application managed entity manager in EJB.
 
Can I use application managed entity manager in EJB (container management JTA transaction is used)? Where do I should close entity manager if can?
 
The following is an example from JEE tutorial, but didn't find where to calose entity manager. and can I create mutiple EntityManagerFactory objects and Entity Manager objects to use them in a JTA transaction?
 
@PersistenceUnit
EntityManagerFactory emf;
EntityManager em;
@Resource
UserTransaction utx;

[Code] .....

View Replies View Related







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