Mishaal Khan

Ranch Hand
+ Follow
since Aug 21, 2008
Merit badge: grant badges
For More
Cows and Likes
Cows
Total received
In last 30 days
0
Forums and Threads

Recent posts by Mishaal Khan

Hello,

I have a JSF project in which I want to use apache trinidad , richfaces and icefaces components.
I am using facelets as viewhandler . I have used tomahawk components and they are displaying in JSF page.
But with trinidad and richfaces I need to make changes in web.xml and faces-config and when I make those
changes the page does not displayed and give errors.

Any suggestions to setup faces-config and web.xml file ?

Thanks.
14 years ago
JSF
Hi,

In a jsf I am using tomahawk datatable and datascroller to display a list of customers.The list is long so I am using pagination to display the next list.
The page works fine and display customers on next page or list .But when I include this jsf inside another jsf ,it only displays the fisrt
list of customers and when I select the page number from paginator it does not display the rest of the customers in list.
The backingbean with which datatable is bind has a session scope in faces-config.

Any idea what is wrong or missing?

Thanks.

14 years ago
JSF
Thanks for your reply Sunil.

I also read the same description in a book that EJB can be injected in registered component in server.But
I am confused with this tutorial which is injecting EJB in a client program.

http://java.sun.com/javaee/5/docs/tutorial/doc/bnbnj.html


Do you think this application client can be registered in server?
Please verify how come it is possible.

Thanks.
Hi,

I have a sample EJB3 project that has one Stateless session bean and an Application Client (main method) is calling its
method using JNDI lookup and its working fine.

But when I change the code and instead of JNDI lookup I inject EJB3 using @EJB annotation
its not able to find the bean and giving NullPointerException .

Just wondering is there any other setting requires to inject an EJB3 component.

Thanks.
So removing those lines from persistence.xml makes Hibernate disable ?

What is the persistence provider then ?
Thank you for your reply Jeanne ,your suggestion worked .

One more question as you said you are assuming , I am using Hiberante for schema generation , I am quite new in this area so just wondering in my code i.e Entity beans or Session bean where I am inserting records I am not importing any Hibernate packages or using Session Object to store my data ,I am using EntityManager
for data persistence , so how come I know I am using using Hibernate ?

I just removed these lines from persistence.xml

<properties>
<property name="hibernate.hbm2ddl.auto" value="create-drop"/>

</properties>

and it worked , so just inserting or deleting these lines in persistence.xml makes Hibernate enable?


Thanks.
Hi,

I am trying an example to learn JPA .It has 2 Entity beans which has one to one relationship.Database is MySql.
The records are being inserted inside the method of EJB 3(session bean) .The example is working fine and records
are being persisted.The application server is Jboss.

My question is whenever I restart the server the previous inserted records are deleted and an empty table is created.
Also when server is stopped the tables are not listed in Mysql ,and as soon as I start the server it shows tables but empty.

1) Is my assumption right that every time server is started it reads the Entity beans and create tables itself and drop the previous one?

2) what can I do to make the records permanent i.e it is not depndent on server to create or drop the table.

Thanks.



I totally agree that OnttoOne relationaship b/w Publisher to Book is not a good example.Actually
I am trying to learn entities relationship and I am very confused about sequence of DML operations
b/w entities. For example if we have two entities

1. Order
2. Invoice
and they both have bidirectional onetoone relationship and both have reference to each other i.e

Order entity :

@OneToOne(optional=false,cascade=CascadeType.ALL, mappedBy="order",targetEntity=Invoice.class)
private Invoice invoice;

Invoice

@OneToOne(optional=false)
@JoinColumn(name = "ORDER_ID")
private Order order;

As invoice cannot exist withiout Order ,so first we will save record in Order but
what value will be saved in invoice field as Invoice is yet not saved?
I assume when Invoice will be persisted it will update the corresponding order's invoice field
with newly generated invoice number?
Also when Invoice will be persisted how it will get the value for Order id?






I have 2 entities i.e Book and Publisher ,which |I am persisting in corresponding tables.
I have joined Book with Publisher entity with onetoone relationship like this:

@OneToOne
@JoinColumn(name = "pubId")
private Publisher publisher;

When I am trying to retrieve and display publisher name using this statement :

Book book = em.find(Book.class, 1)

OR

List <Book> pb = em.createQuery("from Book").getResultList().setParameter("pubid", 1).getResultList();

I'm getting this error:

javax.ejb.EJBException: java.lang.IllegalStateException: Illegal to call this method from injected, managed EntityManager

I am using the same entitymanager to persist and view book and publisher entities in other methods and its working fine,
but for this query its giving error , Any Clue?

Thanks.






Is it OK to assume :

PersistenceContext as set of entities mapped with tables inside datasource
defined in persistence.xml ?

Thanks.
Thanks both of you ,thats all I wanted to confirm !

Thanks for your reply Marco.

As you mentioned we always need to include required jars in classpath , but I am confused
that I tried a jpa tutorial from laliluna website which is using jboss and I did not include the hibernate jar files in classpath
and the application works fine without those jars ,how come ?

Thanks in advance.
Hi,

I am little confused about JPA services and its implementation. In EJB3 in Action , it says JPA standardizes the
ORM framework so that you can run your code with any persistence provider.I am not clear yet that :

1) does JPA not provide implemention for its services i.e EntityManager and cannot be used without persistence provider
i.e (Hibernate or Toplink) ?

2) It also says JPA can be used without container ,so it means if we are using container or app server for example
jboss , then hibernate jars are already included in jboss and we need not to include hibernate jars in classpath ?

3) If we are using JPA without container i.e in a desktop application,then we need to include hibernate jars in classpath
to get the persistence privider or get the implementation of JPA ?

Please clearify.

Thanks.


I found the answere of my question on Jboss community documentation :

Chapter 18. Binding your beans in JNDI

By default, when the application is deployed in a jar, session beans will bind to JNDI in the form ejbName/remote for remote interfaces
and ejbName/local in the case of local interfaces. When the EJBs are deployed in an .ear file, the default jndi binding will be prepended
by the name of the .ear file. So if the ear file name is foo.ear the default jndi names would be foo/EJB-NAME/remote and foo/EJB-NAME/local.

You can override this behavior by defining your own @org.jboss.ejb3.annotation.LocalBinding and/or @org.jboss.ejb3.annotation.RemoteBinding.

I got no replies for this question and I thought it was a stupid question , but it wasn't

I am using following tutorial to learn ejb3 ,

http://www.laliluna.de/download/first-ejb3-tutorial-en.pdf

In this tutorial the the remote interface for a session bean is BookTestBeanRemote and implementing class name
is BookTestBean. This class has a variable

public static final String RemoteJNDIName = BookTestBean.class.getSimpleName() + "/remote";

The client program look for this name in context.lookup i.e

BookTestBeanRemote beanRemote = (BookTestBeanRemote) context.lookup(BookTestBean.RemoteJNDIName);

I am confused as in JNDI namespace the bean is registered as BookTestBean ,so why author has added /remote in front of
bean name to create the RemoteJNDIName?
How and why the server is able to find the ejb BookTestBean/remote whereas the bean is registered as BookTestBean.

Thanks.