JavaBeans in EJB App
In which circumstances to use JavaBeans in Ejb application?
I have created a simple e-commerce application using EJB components but without JavaBeans at all.
The thing is that i have a problem with the jsp page which presents all the products under a particular category, (each product has a link to add it to the shopping cart of the user).
After the user select a category, a servlet getting the products list from a session ejb and put the result as an attribute in the request. Then i'm prining all the products - till here no problem.
In order to add a product to the shopping cart i'm sending to a servlet some info about the product , but this info sometimes contains a special characters , so i decided to use <c:url> with <c:param> for the attributes.
<%
java.util.List<Entity.Products> products=(java.util.List<Entity.Products>)request.getAttribute("products");
for(Entity.Products product : products)
%>
<c:url value="ShoppingCartServlet" var="productUrl">
<c:param name="productId" value="" />
<c:param name="productName" value=""/>
</c:url>
<A href="${productUrl}">Add</A>now how can i set the values of the params?
i can't use scripting elements (<%=%>) , it is not allowed.
Do i need to use JavaBeans?
Thanks in advanced.
is it so hard? Looky here:
; hostname: 127.0.0.1; port: 3820"The application is trying to connect to the localhost, and the glassfish server is not running on the localhost. The JNDI properties of the application must point to the actual host that the glassfish server is running on.
Similar Messages
-
Errors during deploying EJB app
Hello all,
I am trying the develop an EJB app in eclipse juno with weblogic 9.1. I have installed the oracle tools and weblogic has been configured with the EJB project in eclipse. When I start weblogic from the servers tab within eclipse the following error occurs:
There are 1 nested errors:
java.lang.NoClassDefFoundError: Class not found: com.mainframe.pdu.types.PDU24
at weblogic.ejb.container.compliance.EJBComplianceChecker.check(EJBComplianceChecker.java:270)
at weblogic.ejb.container.compliance.EJBComplianceChecker.checkDeploymentInfo(EJBComplianceChecker.java:215)
at weblogic.ejb.container.ejbc.EJBCompiler.complianceCheckJar(EJBCompiler.java:868)
The jar file containing the PDU24 class is in the project build path and it is included in the order/export tab also. Since I am pretty new with all this I probably missed a vital step somewhere. Any help will be appreciated.
Also, what would be helpful is if I could be recommended a tutorial on how to create an ejb app on eclipse using weblogic as the runtime.
Cheers.Hi There,
is the PDU24 a class from weblogic or a 3rd party library that you are using into your project.? Also, I recommend that you create a new domain into WLS using the OEPE wizard when creating a new runtime server. Doing it that way, it is going to add all necessary classes that you need to run EJB-based applications.
Our latest tutorial on ADF development on OEPE covers creation of entity classes on part 2: here is the link. http://www.oracle.com/webfolder/technetwork/eclipse/adf/gettingStarted/Tutorial/ADFwithOEPE_2.html
Cheers,
Juan Camilo -
What is relationship between javabeans and Ejb ?
I am new to javabeans and Ejb .
thanks in advance.
zzl_hz_cnnada. null. nil. void. zero. zilch.
-
hi
I am new to EJB and i have not worked on javabeans...
My question is very basic... what is the difference between javabeans and EJB other than EJB running on a container and javabeans in jvm?
Thanks for your helpThat's it in a nutshell, isn't it? EJBs require a J2EE container, and JavaBeans are components that follow the JavaBeans spec and run in a JVM.
But think about all that the "container" means and all the services it provides. That's all the difference in the world.
% -
What is the diffrence between a javabean and EJB
hi!
what is the diffrence between a javabean and entreprise jvaabeans! i mean which are the uitilization featires of eaxh one !i am seeking for a solution for my problem , in fact i ma trying to implement and develop an application with java that allows a certain range of IP adresses to be connected to a database server in order to extract the suitable data from the server .
let me explain mor ethe suitation , in fact what i am loking for is to use javabeans to grant my application much more consistence and pertinence : si i am asking if it could be possible to use javabeans in my case especially if i am not trying to developp a web application but a cleint /server one allowing some services.
The application is in fact dealing with a stock exchange market and what i am trying to do is to grant particilar registrated customers to have the informations that they need ( portofolio, currency's status, market indicators, .) also drawing some charts decribing rates, variations, and others specefic financial caracterestics .So , if we consider that this application is not a web application ( no HTTP request and no servers like apache or others ) how it is possible to use javabeans and not EJB to build the application? i mean what could be suitable and preferable to rely on and dvelop to ensure a good java application !!
if you need more details to help you find the answer for me don't hesitate to answer me back !!
Someone here gave me that answer
use RMI to code the services and (Updateable) Value Objects to pass the information between tiers.
RMI is an all-java distributed component framework (ie. EJB, CORBA, DCE/RPC, DCOM, etc.), that is very suitable for developing non-containerized multi-tier applications. Refer to the RMI trail in the Java Tutorial as a starting point for coding RMI solutions (http://java.sun.com/docs/books/tutorial/index.html). Under this scenario you would code the database access service as an RMI service (server-side). Client/server communication should be facilitated through the use of JavaBeans/classes that wrap the information being passed (customer information, portfolio details, market information, etc.) - these are refered to as 'Updateable Value Objects' (a design pattern). Graphing and charting would be handled in your client from the information received from the (RMI) server. GUI JavaBeans can be used to provide this functionality as well as other client-side services. There are numerous "shrink-wrapped" components for GUIs available on the market just peruse any Java magazine to find them.
but how comes? how can i do it !! and where can i find more information please about 'Updateable Value Object "
thanks -
Trying to write a basic EJB app w/ JPA and remote client
I'm trying to put together a simple sample app that shows a simple stateless session bean that grabs a Java EE 5 entity from the DB and sends it to the remote caller. I have an entity class called Person that simply has getId() and getName() methods.
I'm trying to get a reference to the session bean (using InitialContext.lookup()), which works. Then I try to call a method on that bean, which works as long as the type being returned is not a Person object. I've had the bean always return "Hello" and it works just fine.
Here's the bean code.
@Stateless(mappedName="RolodexSession")
public class RolodexSessionBean implements RolodexSessionRemote {
@PersistenceContext
private EntityManager em;
/** Creates a new instance of RolodexSessionBean */
public RolodexSessionBean() {
public Object getPersonByName(String name)
Query q = em.createQuery("select object(o) from Person o where o.name=:n");
q.setParameter("n",name);
List results = q.getResultList();
if (results.isEmpty())
return "emtpy";
// this would work just fine...
// return "Some string";
// but this doesn't work at all
return results.get(0);
}Here's the client code...
public class Main {
@EJB
protected RolodexSessionRemote rolodexSession;
/** Creates a new instance of Main */
public Main() throws NamingException {
Context ctx = new InitialContext();
rolodexSession = (RolodexSessionRemote)ctx.lookup("RolodexSession");
Object result = rolodexSession.getPersonByName("John Smith");
System.out.println(result);
* @param args the command line arguments
public static void main(String[] args) throws NamingException {
Main m = new Main();
}I made sure to put a Person object into my database with the name "John Smith".
The error I keep getting is...
Dec 7, 2006 4:40:29 PM com.sun.corba.ee.impl.encoding.CDRInputStream_1_0 read_value
WARNING: "IOP00810257: (MARSHAL) Could not find class"
org.omg.CORBA.MARSHAL: vmcid: SUN minor code: 257 completed: Maybe
at com.sun.corba.ee.impl.logging.ORBUtilSystemException.couldNotFindClass(ORBUtilSystemException.java:8309)
at com.sun.corba.ee.impl.encoding.CDRInputStream_1_0.read_value(CDRInputStream_1_0.java:984)
at com.sun.corba.ee.impl.encoding.CDRInputStream.read_value(CDRInputStream.java:259)
at com.sun.corba.ee.impl.io.IIOPInputStream.inputObjectField(IIOPInputStream.java:1987)
at com.sun.corba.ee.impl.io.IIOPInputStream.inputClassFields(IIOPInputStream.java:2211)
at com.sun.corba.ee.impl.io.IIOPInputStream.inputObject(IIOPInputStream.java:1219)
at com.sun.corba.ee.impl.io.IIOPInputStream.simpleReadObject(IIOPInputStream.java:398)
at com.sun.corba.ee.impl.io.ValueHandlerImpl.readValueInternal(ValueHandlerImpl.java:329)
at com.sun.corba.ee.impl.io.ValueHandlerImpl.readValue(ValueHandlerImpl.java:295)
at com.sun.corba.ee.impl.encoding.CDRInputStream_1_0.read_value(CDRInputStream_1_0.java:1005)
at com.sun.corba.ee.impl.encoding.CDRInputStream_1_0.read_value(CDRInputStream_1_0.java:850)
at com.sun.corba.ee.impl.encoding.CDRInputStream.read_value(CDRInputStream.java:255)
at com.sun.corba.ee.impl.corba.TCUtility.unmarshalIn(TCUtility.java:269)
at com.sun.corba.ee.impl.corba.AnyImpl.read_value(AnyImpl.java:558)
at com.sun.corba.ee.impl.encoding.CDRInputStream_1_0.read_any(CDRInputStream_1_0.java:710)
at com.sun.corba.ee.impl.encoding.CDRInputStream.read_any(CDRInputStream.java:225)
at com.sun.corba.ee.impl.javax.rmi.CORBA.Util.readAny(Util.java:449)
at com.sun.corba.ee.impl.presentation.rmi.DynamicMethodMarshallerImpl$10.read(DynamicMethodMarshallerImpl.java:251)
at com.sun.corba.ee.impl.presentation.rmi.DynamicMethodMarshallerImpl.readResult(DynamicMethodMarshallerImpl.java:424)
at com.sun.corba.ee.impl.presentation.rmi.StubInvocationHandlerImpl.privateInvoke(StubInvocationHandlerImpl.java:162)
at com.sun.corba.ee.impl.presentation.rmi.StubInvocationHandlerImpl.invoke(StubInvocationHandlerImpl.java:119)
at com.sun.corba.ee.impl.presentation.rmi.bcel.BCELStubBase.invoke(BCELStubBase.java:197)
at session.__RolodexSessionRemote_Remote_DynamicStub.getPersonByName(__RolodexSessionRemote_Remote_DynamicStub.java)
at session._RolodexSessionRemote_Wrapper.getPersonByName(session._RolodexSessionRemote_Wrapper.java)
at clientapp.Main.<init>(Main.java:33)
at clientapp.Main.main(Main.java:41)I'm running this on the Sun Java System App Server 9.0.
Any ideas?I've narrowed down the issue. The Person object that I'm trying to send back has a one-to-many relationship with Address objects. I have this all setup correctly, I think. Here's the code from Person.java that establishes that relationship.
* Holds value of property addresses.
@OneToMany(mappedBy = "person")
private List<Address> addresses;
* Getter for property addresses.
* @return Value of property addresses.
public List<Address> getAddresses() {
return this.addresses;
* Setter for property addresses.
* @param addresses New value of property addresses.
public void setAddresses(List<Address> addresses) {
this.addresses = addresses;
}In Address.java I have the other side of the relationship defined (again, correctly, I think).
IF I COMMENT OUT THIS RELATIONSHIP EVERYTHING WORKS! So, the problem seems to be related to using foreign key associations. Is there something I'm missing here? Perhaps it's related to lazy-loading of foreign keys? -
Hi Experts:
Can anyone tell me DIFFERENCE between JAVABEANS and ENTERPRISE JAVABEANS? I am a newbie to JavaBean world. How do we know which one to use when?
Also, any startup BASIC TUTORIAL Link would be appreciated.
Thanks!A javabean is simply a class that, through established conventions, exposes certain elements as standard properties. See http://developer.java.sun.com/developer/onlineTraining/Beans/beans01/ and http://developer.java.sun.com/developer/onlineTraining/Beans/beans02/ for a tutorial. Javabeans are a common part of most java programming.
An enterprise java bean (EJB) is a heavyweight, transactional, remotable component running in a managed "container." EJB has little or nothing to do with regular javabeans. Use EJBs to build web applications and web services with steep scalability, failover and transactional requirements. See http://www2.theserverside.com/books/masteringEJB/index.jsp for a lengthy and comprehensive tutorial. -
Foreign key fields not getting populated in datacontrol palette for EJB app
Hi,
I am quite new to ADF and EJB.I developed a jdeveloper application with JSF and EJB tiers.(I am using jdeveloper 10.1.3.5)
For database the default HR database is used.I created the entities for the EMPLOYEES and DEPARTMENTS table.
I also created a session bean and a data control for the session bean.
I am having a JSF page that receives all the details of a new Employee and insert into database (i.e persistEntity)
But the Employees constructor from the Data control palette is not populating the MANAGERID and DEPARTMENTID fields which are
the foreign key constraints for the EMPLOYEES table and hence while trying to persist the entity
with the auto populated fields an error message is thrown.
If I used ADF BC instead of EJB then i could populate all the fields including MANAGERID and DEPARTMENTID.
Is it possible to have two text fields for Manager and Department in the jsf to insert the Employee details with EJB as the Model?.
If possible how do I bind the values of these fields to the Employees entity object in EJB.
Kindly need your insights on this.
Thanks,
Guna.Hi,
How are you using MANAGER_ID and DEPARTMENT_ID fields, are they exposed as Long (or some other numeric type), or did you map them on the entity, something like this
@ManyToOne
private Employee manager; // this by default uses the column named MANAGER_ID
@ManyToOne
private Department department; // this by default uses the column named DEPARTMENT_ID
.... If you mapped them (which is the right way), when you create an employee you should set these attributes before persisting the entity, by using employee.setManager(manager) and employee.setDepartment(department). Then, the foreign keys get populated automatically by your persistence provider (Toplink).
If you are using data controls, it is a little different process to set the department and manager, but you should take a look at this tutorial http://www.oracle.com/technology/obe/obe11jdev/ps1/ejb/ejb.html , it will hopefully answer a lot of your questions.
Pedja -
Problem in developing a simple ejb app
Hi readers,
i am new to ejb technology, so have doubt in developing and deploying a simple ejb application
i am using EJB 2.0, JBOSS 4.0 , eclipse 3.2 and java 1.5
i searched in the net , got through many materials that can guide to develop one of it.
all are using higher versions of the above, i mean, using ejb 3.0 or using xdoclet etc.
i am need of material which guides me to develop and deploy the ejb application using the same versions of softwares step by step.
please help me in thisHi readers,
i am new to ejb technology, so have doubt in developing and deploying a simple ejb application
i am using EJB 2.0, JBOSS 4.0 , eclipse 3.2 and java 1.5
i searched in the net , got through many materials that can guide to develop one of it.
all are using higher versions of the above, i mean, using ejb 3.0 or using xdoclet etc.
i am need of material which guides me to develop and deploy the ejb application using the same versions of softwares step by step.
please help me in this -
Storing property values specific to an ejb app
On a Weblogic 102 , how can I store atrributes specific to an ejb. This could contain passwords for other system. Connection Pooling is not an option for the external system, so the password has to be stored some where the EJB can read, preferably not in clear text ? I am trying to keep this property file out of the source code ....
Hi Mat,
Not sure whether the following will suit your requirement or not but you can try the following:
<font color=maroon>Step1). </font>run the "setDomainEnv.sh" in the command Shell.
<font color=maroon>Step2).</font> Run the following command to encrypt the your EJBUsername and EJBUserPassword
java weblogic.security.Encrypt ${Clear_Text_Password}
Example:
$ java weblogic.security.Encrypt <font color=red>MyEJBUser</font>
{3DES}0HYiEySifDiz0IcqDhelGA==
$ java weblogic.security.Encrypt <font color=red>MyEJBPassword</font>
{3DES}0HYiEySif12hhaqDheSa==
<font color=maroon>Step3). </font>Now store the above Encrypted USername and Passwords in a properties file (myEjbUsers.properties) like following:
userOneName={3DES}0HYiEySifDiz0IcqDhelGA==
userOnePassword={3DES}0HYiEySif12hhaqDheSa==
<font color=maroon>Step4).</font> Now Place this File some where in your File system ...better if you place it inside the <DOMAIN_HOME> directory....sothat your application can read it Just like following: (No Need to specify the Path of properties file if it is available inside the DOMAIN_HOME root directroy)
FileReader fr=new FileReader("myEjbUsers.properties");
<font color=maroon>Step5).</font> Inside your EJB When you get the Username & Password sent by the EJB Client...get them and then Inside your Code Encrypt them and match with the Encrypted values present in your Properties file....
Thanks
Jay SenSharma
http://weblogic-wonders.com/weblogic (WebLogic Wonders Are Here) -
Deploying non-EJB apps to WebLogic
Hey All,
I'm deploying some VERY BASIC functionality, really just 1 servlet, maybe a bean
or two, and some jsp pages - no EJBs. We're using WebLogic because the Content Management
System we're using uses it. So can I just jar up my few class files, put it out
on the server in a /lib directory and point the CLASSPATH to that jar file (in the
starWeblogic.sh script) and call it quits? Or do I need to do the whole .war file
thing even though I just have a couple of simple classes? Oh, I'm using WebLogic
6.1, by the way.
Thanks a ton!
RockyHello Rocky,
In fact, with WLS 6.1, you have to use a web application to access to the
ressources you created ( ie servlets, jsps, beans, EJB ... ).
If you don't want to create a .war file, you can place these ressources in
the DefaultWebApp directory.
Ludovic.
Developer Relations Engineer
BEA Customer Support
"Rocky Angelini" <[email protected]> a écrit dans le message
news: 3d110231$[email protected]..
>
Hey All,
I'm deploying some VERY BASIC functionality, really just 1 servlet, maybea bean
or two, and some jsp pages - no EJBs. We're using WebLogic because theContent Management
System we're using uses it. So can I just jar up my few class files, putit out
on the server in a /lib directory and point the CLASSPATH to that jar file(in the
starWeblogic.sh script) and call it quits? Or do I need to do the whole.war file
thing even though I just have a couple of simple classes? Oh, I'm usingWebLogic
6.1, by the way.
Thanks a ton!
Rocky -
Problem configuring TassieDB database to work with JBoss Servlets + EJB app
Hi everybody
I have been unable to get Budi Kurniawan's Tassie Onine Bookstore example (
http://benmira.free.fr/en/j2ee/sessionEJB.htm#ch29lev1sec4) application to read anything from the database TassieDB . I am not sure what is wrong. I downloaded the database from the CD. Then since this was an older version of Access, I had to let my Access convert it to the newer form.
I then configured the Database the way I thought I should in order for it to work. I created a Data Source Name called TassieDB, by following the procedure to create a System DSN on Windows. I selected the Microsoft Access Driver and associated my Database which I named TassieDB1, which I deposited under C:\budibookstore which also contains the package com.brainysoftware.tassie.servlet.ejb
When I access the SearchServlet page and type in "Computer" in the search box nothing turns up. I wonder what is going on?
The following errors are spewed out by Apache in this process:
May 18, 2005 8:27:24 PM org.apache.coyote.http11.Http11Protocol init
INFO: Initializing Coyote HTTP/1.1 on http-8080
Starting service Tomcat-Standalone
Apache Tomcat/4.1.31
May 18, 2005 8:27:28 PM org.apache.struts.util.PropertyMessageResources
INFO: Initializing, config='org.apache.struts.util.LocalStrings', returnNull=tru
e
May 18, 2005 8:27:28 PM org.apache.struts.util.PropertyMessageResources
INFO: Initializing, config='org.apache.struts.action.ActionResources', returnNul
l=true
May 18, 2005 8:27:29 PM org.apache.struts.util.PropertyMessageResources
INFO: Initializing, config='org.apache.webapp.admin.ApplicationResources', retur
nNull=true
May 18, 2005 8:27:33 PM org.apache.coyote.http11.Http11Protocol start
INFO: Starting Coyote HTTP/1.1 on http-8080
May 18, 2005 8:27:33 PM org.apache.jk.common.ChannelSocket init
INFO: JK2: ajp13 listening on /0.0.0.0:8009
May 18, 2005 8:27:33 PM org.apache.jk.server.JkMain start
INFO: Jk running ID=0 time=10/150 config=C:\tomcatj\conf\jk2.properties
javax.naming.NoInitialContextException: Cannot instantiate class: org.jnp.interf
aces.NamingContextFactory [Root exception is java.lang.ClassNotFoundException: o
rg.jnp.interfaces.NamingContextFactory]
javax.naming.NoInitialContextException: Cannot instantiate class: org.jnp.interf
aces.NamingContextFactory [Root exception is java.lang.ClassNotFoundException: o
rg.jnp.interfaces.NamingContextFactory]
All help is gratefully acknowledged and accepted. Thanks in advanceHi
Did you notyfy the Exception ?
class not found Exception "org.jnp.interfaces.NamingContextFactory"
add these packages to your class path.
Vinoth -
Defining server specific properties for EJB app
I need to define some properties for my app which have different values depending on the server to which I deploy. Eg. the LDAP server name and port.
When I deploy to my development server it should find the local values of the properties, when I deploy to the live server it needs a different set of values.
What is the simplest way to do this? I obviously don't want the properties to be part of my deployment.
RobEJBs are not allowed to read or write files. But they are allowed to read from the JNDI context. The idea is to provide a symbolic name, ie <resource-env-ref>, which contains the value you need.
The startup-classes which could set this value in the JNDI context are best documented in the OC4J User's Guide.
--olaf -
Detailed differences between javabeans and ejb2.0?
Any reusable java classes could be a javabean. EJB is special javabean that can be managed by EJB container which will be able to manage, saying EJB fields to map to database fields. Ofcaurse you can manage this just like regular javabeans. In EJB, it is called bean managed, instead of container managed.
You can find a short tutorial on sun site. -
How can i Migrate from EJB Application to Hibernate
Hi ,
i have developed web services using EJBs. can i create web services for my hybernate application. can anybody please help me for that??
please advice me how can i Migrate from my EJB Apps to Hibernate.
thanks & Regards,
nagalaxmiHi
Check this link
http://www.devx.com/Java/Article/27954
Sameer
Maybe you are looking for
-
PROBLEM WITH MY CLA- DEPRECATED CODE
Hi all, I really need some help to sort out my small class which generates a random string. Here is the code: package project_gui; import java.util.Random; //Random string generator class public class randomString { private st
-
Exception condition "INVALID_POS"
Hi, I am getting the error while monitoring the outbound queue in SMQ1 very rarely as FM-------"BBP_NOTIFY_FOLLOWON_INBOUND" with exception condition "INVALID_POS". Kindly assit me what could be the reason for this error. regards, Kannan B
-
HT5096 What about the permission errors from ACLs when you try this?
I followed the instructions for using Finder to copy the Backups.backupdb directory and get permission errors. Another post says to use DiskUtility restore. I guess I'll try that after wasting a day.
-
Adobe Forms and Allowing to Sign using Adobe Reader
Dear, i am testing some scenario's with Adobe Interactive Forms. I have a Topaz Digital Signature Pad, which can be used to create a Signature inside a PDF file. This has been tested and works. This does not use a certificate, but puts a handwritte
-
Hi Friends, am working on JNI interface in netbeans, i included the code below in this code if am including the Pakage xxxx; The system throws Unsatisfied Error, if comment that line it works fine, In netbeans environment i want to use this package n