Constructor in EJB
Can anybody explain me role of default parameterless constructor in EJB bean classes(session+entity).
is it compulsory to provide these constructors?
according to 2.0 spec (7.10.2) -
The session bean class must have one default pareterless constructor.
but, I have created a entity bean component( infact, using the JBuilder generated beans) which is not having any constructor, and still working fine.
Please help me clear this constructor concept for both entity and session bean.
Thanks.
I may not be complete but here is my explanation
Default constructor is required because container uses reflection to create the instances of bean classes(class.newInstance()).
In java if you dont provide the default constructor , one is generated by compiler. That is why you are not getting any error.
But I dont know why this point is explicitly mentioned in specs.
May be somebody has more better explanation?
--Ashwani
Similar Messages
-
Webservice initialized on every method-call.
Hello!
I have written two webservices. One containing a EJB and a SOAP-Webservice and one with just a SOAP-Webservice.
If I call the EJB-Version the webservice gets inizialized by glassfish on the first call and then stays running (Constructor is not called any more) but if I call the SOAP-only service constructor is called on every method-call.
Therefore I have a deployment-problem with the EJB-Version: I use SQL-Server-JDBC-Libs in my Netbeans-Project. The get deployed to the server but are not used by the application. Instead I have to copy them to the servers lib-directory. If I deploy them with my Soap-only-service they work...For the Webservice-only I create a web-application in Netbeans (File - New Project - Java Web - Web Application) and run this code:
package com.service;
import javax.jws.WebMethod;
import javax.jws.WebParam;
import javax.jws.WebService;
@WebService(serviceName = "Service")
public class Service {
public Service() {
System.out.println("Constructor called!");
@WebMethod(operationName = "hello")
public String hello(@WebParam(name = "name") String txt) {
return "Hello " + txt + " !";
}Everytime i call the hello-method through the Tester (http://ip:port/URI?Tester) the webservice get initialized ("Constructor called").
On the other hand I create a Java EE - EJB-Module in Netbeans and add the webservice.
I remove the EJB-Annotations from the module and use it as a POJO for the code.
EJB:
package com.slan.ejb;
import javax.ejb.Stateless;
@Stateless
public class EJBSlan {
public EJBSlan(){
System.out.println("Constructor of EJB called!");
public String getHello(String name) {
return "Hello " + name;
}Service:
package com.slan.service;
import com.slan.ejb.EJBSlan;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import javax.ejb.Stateless;
import javax.jws.WebMethod;
import javax.jws.WebParam;
import javax.jws.WebService;
@WebService(serviceName = "EJBService")
@Stateless()
public class EJBService {
private EJBSlan ejbRef;
public EJBService(){
ejbRef = new EJBSlan();
System.out.println("Constructor of Service called!");
@WebMethod(operationName = "getHello")
public String getHello(@WebParam(name = "name") String name) {
return ejbRef.getHello(name);
@WebMethod(operationName = "getMachines")
public String getMachines() {
String machines = "";
try {
DriverManager.registerDriver(new com.mysql.jdbc.Driver());
Connection c = DriverManager.getConnection("jdbc:mysql://ip/cm","user","password");
Statement s = c.createStatement();
ResultSet r = s.executeQuery("select from machines");
while(r.next()){
machines += r.getString("comment");
s.close();
c.close();
} catch (SQLException e) {
System.out.println(e.toString());
return machines;
}As you can see I already tried to add the sql-code to query the database. I added the mysql.jar to the project and deployed it. Using the tester the Service- and POJO-Object gets initialized only once but I cant use the mysql-driver cause it is not used on the server. But it gets deployed to the server... I think it's just not included in the class-path... -
How am I able to use an injected EJB in a Managed Bean Constructor?
JSF 1.2
EJB 3.0
Glassfish v1
Summary:
Managed bean injected EJB is null when referencing EJB var in constructor.
Details:
In my managed bean, I have a constructor that tries to reference an injected EJB, such as:
public class CustomerBean implements Serializable {
@EJB private CustomerSessionRemote customerSessionRemote;
public CustomerBean() {
List<CustomerRow> results = customerSessionRemote.getCustomerList();
}The call within the constructor to customerSessionRemote is null - I've double checked this in Netbeans 5.5.
How am I able to use an injected EJB in a Managed Bean Constructor?
Thanks,
--ToddOK, I was reading the article Web Tier to Go With Java EE 5: A Look at Resource Injection and I understand your statement too.
Is there any way possible to Inject the EJB prior to the bean instance creation at all?
Maybe, I need to approach it with the old fashion Java EE 1.4 route and using JNDI in the PostConstruct annotated method to reference the EJB in the managed bean.
This had to been thought out before, I don't understand why a manged bean's life cycle places any injections at the end of the bean creation.
Also, now that I understand that the @PostConstruct annotated method will be called by the container after the bean has been constructed and before any business methods of the bean are executed.
I am trying to reference my EJB as part of the creation of the managed bean.
What happens: the JSF page loads the managed bean and I need to populate a listbox component with data from an EJB.
When I try to make the call to the EJB in the listbox setter method, the EJB reference is null.
Now, I'm not for sure if the @PostConstruct annotation is going to work... hmmmm.
** Figured it out. ** I just needed to move the EJB logic that was still in the setter of the component I wanted to populate into the annotated PostConstruct method. -
Ejb constructor - BMPEntityBase
It is sayed in the entity bean example that the create takes the place of the constructor should the normal constructor should do nothing. But in the ebjCreate() method there is no code like super(BMPExample.getHelper().getTopLinkSessionName()) ; then I'm wondering how it can works, where is the BMPEntityBase constructed? and so is the toplink session initialized ?
Does the ebjCreate() call the constructor of the ejb class?
ThxShould it also be done in the constructor and must I also call the super(...getTopLinkSessionName()) in the ejbCreate()?
Thx -
Error while building a Webservice in Netbeans EJB Module
I have copied the java code of a JCD doing xml to cobol copybook transformation in JCAPS, to a new webservice created in the Netbeans EJB module. There were no compilation errors. But while trying to build, I am getting errors like "java.io.printStream does not have a no-arg default Constructor" , "IllegalAnnotation Exception", "Unable to create jaxb context" etc..
I am not able to find out why this happened... Someone please help me in resolving this issue......Guys,
I am able to solve the problem. I think the problem is Language settings difference between Database and OWB repository. -
Ejb QL 3.0 group by / return type issues
Hello all. I have a question regarding ejb query language 3.0. I have a query that works and looks like the following:
select e.objectId, count(distinct s1.objectId), count(distinct s2.objectId)
from Engagement e JOIN e.surveys s1 JOIN e.surveys s2
where s2.scope is not null
and s2.schedule is not null
and s2.quality is not null
and s2.expertise is not null
and s2.overallExperience is not null
group by e.objectId
While this query "works" I am unhappy with the result. What is returned by this query is an Object array of size 3. The first element is the objectId, the second the count of "sent surveys" and the third the count of "completed surveys". While this is correct for the query i want to execute a query selecting out an actual engagement object, not just the objectId. To accomplish this now, I would have to manually select out every column in engagement growing my Object array to n + 2 where n is the number of columns in Engagement. I find this unreasonable and not object oriented and would like to get an object array back that contains an Engagement object as the first element, and then the counts. However I am unaware of how to write this in ejb QL. If anyone has more experience than me please let me know if this is possible. The following code is incorrect but represents what I want to do:
select e, count(distinct s1.objectId), count(distinct s2.objectId)
from Engagement e JOIN e.surveys s1 JOIN e.surveys s2
where s2.scope is not null
and s2.schedule is not null
and s2.quality is not null
and s2.expertise is not null
and s2.overallExperience is not null
group by e /* alternatively 'group by e.objectId' or something of the like */
For anyone else having trouble with ejb QL the best resource I have found is the BNF grammar on suns site. If you are trying to do anything complex, chances are there isn't an example out for you :(
http://java.sun.com/javaee/5/docs/tutorial/doc/bnbuf.html#bnbuiI realized what I wanted to the QL to do wasn't really fair. I was thinking if you wanted to do something like the above it could automatically group by first whatever the pk is on the entity and then who cares what order is next, just pick something so the SQL group by is satisfied. After more thought I realized this wasn't really a fair assumption the query engine could make and went about coding the specific items I wanted back in the select and made a corresponding entity object that acutely defined my result and used a constructor expression to create a list of these new objects. Hopefully someone else finds this useful and I appreciate the above response as well. Marking as answered.
-
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 -
EJB 3.0 and jndi lookup (simple question)
hi all,
i am newbie on Weblogic Application Server and i have some issues,
i have weblogic application server 10.0, also i have oracle timesten in-memory database, i have configured datasource and deploy my ejb 3.0 application, but i could not done jndi lookup?
here is my example:
1. one stateless session bean :
import javax.ejb.Remote;
@Remote
public interface InsertSubscriber {
public void insertSubscriber(SubscriberT subscriberT);
} 2. here is it's implementation :
@Remote(InsertSubscriber.class)
@Stateless
public class InsertSubscriberBean implements InsertSubscriber {
@PersistenceContext(unitName = "TimesTenDS")
private EntityManager oracleManager;
public void insertSubscriber(SubscriberT subscriber)
try {
System.out.println("started");
oracleManager.persist(subscriber);
System.out.println("end");
} catch (Exception e) {
e.printStackTrace();
}3 and my test client :
public class Client {
public static void main(String[] args) {
Context ctx = null;
Hashtable ht = new Hashtable();
ht.put(Context.INITIAL_CONTEXT_FACTORY,
"weblogic.jndi.WLInitialContextFactory");
ht.put(Context.PROVIDER_URL, "t3://192.9.200.222:7001");
try {
ctx = new InitialContext(ht);
InsertSubscriber usagefasade = (InsertSubscriber) ctx
.lookup("ejb.InsertSubscriberBean");
} catch (NamingException e) {
e.printStackTrace();
} finally {
try {
ctx.close();
} catch (Exception e) {
e.printStackTrace();
}what i did incorrect ???
i got error like this : Name not fount exception
when i tried to view jndi tree on weblogic server application console i found this :
Binding Name:
TimestenExampleTimestenExample_jarInsertSubscriberBean_InsertSubscriber
Class:
test.InsertSubscriberBean_o7jk9u_InsertSubscriberImpl_1000_WLStub
Hash Code:
286
toString Results:
weblogic.rmi.internal.CollocatedRemoteRef - hostID: '2929168367193491522S::billing_domain:AdminServer', oid: '286', channel: 'null'what does it mean how i can done lookup to jndi ?
Regards,
Paata Lominadze,
Magticom LTD.
Georgia.Hi All,
I am using the weblogic cluster with session replication and EJB 2.0 with Local entity beans.
for fail-over session should be replicated to another server so we can achive the same session if 1st server fails.
Suppose i m using two managed server(server1,server2) in the cluster.I am storing the object of class ABC into session and object contains the instance of Local-EntityBean home but i put that as a transient.I have also override the readObject and write object method.
when write object is called on 1st server,readObject method should be called on second server so we will be sure that session is replicating properly.
pleaase find the code below : -
public IssuerPageBean() {
initEJB();
private void readObject(java.io.ObjectInputStream stream) throws IOException, ClassNotFoundException {
stream.defaultReadObject();
initEJB();
initializeCommonObject();
private void writeObject(java.io.ObjectOutputStream stream) throws IOException {
stream.defaultWriteObject();
private void initEJB() {
try {
ic = new InitialContext();
issuerHome = (LocalIssuerHome) ic.lookup("java:comp/env/Issuer");
} catch (NamingException e) {
e.printStackTrace();
in my case if i am calling the constructor IssuerPageBean(),it calls the initEJB() method and lookeup the entity local home properly but when readObject method is called on another server only initEJB() method is called directly and getting the exception below :
WARNING: Error during create -
javax.naming.NameNotFoundException: remaining name: env/ejb/Client
at weblogic.j2eeclient.SimpleContext.resolve(Ljavax/naming/Name;Z)Ljavax/naming/Context;(SimpleContext.java:35)
at weblogic.j2eeclient.SimpleContext.resolve(Ljavax/naming/Name;)Ljavax/naming/Context;(SimpleContext.java:39)
at weblogic.j2eeclient.SimpleContext.lookup(Ljavax/naming/Name;)Ljava/lang/Object;(SimpleContext.java:57)
at weblogic.j2eeclient.SimpleContext.lookup(Ljavax/naming/Name;)Ljava/lang/Object;(SimpleContext.java:57)
at weblogic.j2eeclient.SimpleContext.lookup(Ljava/lang/String;)Ljava/lang/Object;(SimpleContext.java:62)
at weblogic.jndi.factories.java.ReadOnlyContextWrapper.lookup(Ljava/lang/String;)Ljava/lang/Object;(ReadOnlyCont
extWrapper.java:45)
at weblogic.jndi.internal.AbstractURLContext.lookup(Ljava/lang/String;)Ljava/lang/Object;(AbstractURLContext.jav
a:130)
at javax.naming.InitialContext.lookup(Ljava/lang/String;)Ljava/lang/Object;(InitialContext.java:347)
at com.lb.equities.veda.tools.salesvault.jsp.ClientPageBean.initEJB()V(ClientPageBean.java:218)
at com.lb.equities.veda.tools.salesvault.jsp.ClientPageBean.readObject(Ljava/io/ObjectInputStream;)V(ClientPageB
ean.java:191)
at java.lang.LangAccessImpl.readObject(Ljava/lang/Class;Ljava/lang/Object;Ljava/io/ObjectInputStream;)V(Unknown
Source)
at java.io.ObjectStreamClass.invokeReadObject(Ljava/lang/Object;Ljava/io/ObjectInputStream;)V(Unknown Source)
at java.io.ObjectInputStream.readSerialData(Ljava/lang/Object;Ljava/io/ObjectStreamClass;)V(Unknown Source)
at java.io.ObjectInputStream.readOrdinaryObject(Z)Ljava/lang/Object;(Unknown Source)
at java.io.ObjectInputStream.readObject0(Z)Ljava/lang/Object;(Unknown Source)
at java.io.ObjectInputStream.readObject()Ljava/lang/Object;(Unknown Source)
at java.util.HashMap.readObject(Ljava/io/ObjectInputStream;)V(Unknown Source)
at java.lang.LangAccessImpl.readObject(Ljava/lang/Class;Ljava/lang/Object;Ljava/io/ObjectInputStream;)V(Unknown
Source)
at java.io.ObjectStreamClass.invokeReadObject(Ljava/lang/Object;Ljava/io/ObjectInputStream;)V(Unknown Source)
at java.io.ObjectInputStream.readSerialData(Ljava/lang/Object;Ljava/io/ObjectStreamClass;)V(Unknown Source)
at java.io.ObjectInputStream.readOrdinaryObject(Z)Ljava/lang/Object;(Unknown Source)
at java.io.ObjectInputStream.readObject0(Z)Ljava/lang/Object;(Unknown Source)
at java.io.ObjectInputStream.defaultReadFields(Ljava/lang/Object;Ljava/io/ObjectStreamClass;)V(Unknown Source)
at java.io.ObjectInputStream.readSerialData(Ljava/lang/Object;Ljava/io/ObjectStreamClass;)V(Unknown Source)
at java.io.ObjectInputStream.readOrdinaryObject(Z)Ljava/lang/Object;(Unknown Source)
at java.io.ObjectInputStream.readObject0(Z)Ljava/lang/Object;(Unknown Source)
at java.io.ObjectInputStream.readObject()Ljava/lang/Object;(Unknown Source)
at weblogic.common.internal.ChunkedObjectInputStream.readObject()Ljava/lang/Object;(ChunkedObjectInputStream.jav
a:120)
at weblogic.rjvm.MsgAbbrevInputStream.readObject(Ljava/lang/Class;)Ljava/lang/Object;(MsgAbbrevInputStream.java:
121)
at weblogic.cluster.replication.ReplicationManager_WLSkel.invoke(ILweblogic/rmi/spi/InboundRequest;Lweblogic/rmi
/spi/OutboundResponse;Ljava/lang/Object;)Lweblogic/rmi/spi/OutboundResponse;(Unknown Source)
at weblogic.rmi.internal.BasicServerRef.invoke(Lweblogic/rmi/extensions/server/RuntimeMethodDescriptor;Lweblogic
/rmi/spi/InboundRequest;Lweblogic/rmi/spi/OutboundResponse;)V(BasicServerRef.java:492)
Please help .
Thanks in Advance.
Edited by hforever at 03/04/2008 7:28 AM -
Problem with ejbs in Netweaver 2004s-Class not found exception
Hello,
I have a webdynpro project(Newtweaver 2004s) referring to a stateless session bean. I created an ejb and defined two public parts - part 1 contains EJB components and part 2 contains some Exception classes I refer to in my webdynpro project. I added these parts to my webdynpro project as dependencies for compile and runtime. I am able to compile and deploy the webdynpro project without any issue but I get runtime errors saying the following:
com.sap.tc.webdynpro.services.exceptions.WDRuntimeException: Failed to create delegate for component com.test.techops.ccf.data.Data. (Hint: Is the corresponding DC deployed correctly? Does the DC contain the component?)
at com.sap.tc.webdynpro.progmodel.generation.ControllerHelper.createDelegate(ControllerHelper.java:110)
at com.sap.tc.webdynpro.progmodel.generation.DelegatingComponent.<init>(DelegatingComponent.java:51)
at com.sap.tc.webdynpro.clientserver.cal.ClientComponent.init(ClientComponent.java:382)
at com.sap.tc.webdynpro.clientserver.cal.ClientApplication.init(ClientApplication.java:362)
at com.sap.tc.webdynpro.clientserver.session.ApplicationSession.initApplication(ApplicationSession.java:707)
at com.sap.tc.webdynpro.clientserver.session.ApplicationSession.doProcessing(ApplicationSession.java:269)
at com.sap.tc.webdynpro.clientserver.session.ClientSession.doApplicationProcessingStandalone(ClientSession.java:759)
at com.sap.tc.webdynpro.clientserver.session.ClientSession.doApplicationProcessing(ClientSession.java:712)
at com.sap.tc.webdynpro.clientserver.session.ClientSession.doProcessing(ClientSession.java:261)
at com.sap.tc.webdynpro.clientserver.session.RequestManager.doProcessing(RequestManager.java:149)
at com.sap.tc.webdynpro.serverimpl.defaultimpl.DispatcherServlet.doContent(DispatcherServlet.java:62)
at com.sap.tc.webdynpro.serverimpl.defaultimpl.DispatcherServlet.doPost(DispatcherServlet.java:53)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:760)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
at com.sap.engine.services.servlets_jsp.server.HttpHandlerImpl.runServlet(HttpHandlerImpl.java:401)
at com.sap.engine.services.servlets_jsp.server.HttpHandlerImpl.handleRequest(HttpHandlerImpl.java:266)
at com.sap.engine.services.httpserver.server.RequestAnalizer.startServlet(RequestAnalizer.java:387)
at com.sap.engine.services.httpserver.server.RequestAnalizer.startServlet(RequestAnalizer.java:365)
at com.sap.engine.services.httpserver.server.RequestAnalizer.invokeWebContainer(RequestAnalizer.java:944)
at com.sap.engine.services.httpserver.server.RequestAnalizer.handle(RequestAnalizer.java:266)
at com.sap.engine.services.httpserver.server.Client.handle(Client.java:95)
at com.sap.engine.services.httpserver.server.Processor.request(Processor.java:174)
at com.sap.engine.core.service630.context.cluster.session.ApplicationSessionMessageListener.process(ApplicationSessionMessageListener.java:33)
at com.sap.engine.core.cluster.impl6.session.MessageRunner.run(MessageRunner.java:41)
at com.sap.engine.core.thread.impl3.ActionObject.run(ActionObject.java:37)
at java.security.AccessController.doPrivileged(Native Method)
at com.sap.engine.core.thread.impl3.SingleThread.execute(SingleThread.java:100)
at com.sap.engine.core.thread.impl3.SingleThread.run(SingleThread.java:170)
Caused by: java.lang.reflect.InvocationTargetException
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)
at java.lang.reflect.Constructor.newInstance(Constructor.java:274)
at com.sap.tc.webdynpro.progmodel.generation.ControllerHelper.createDelegate(ControllerHelper.java:74)
... 27 more
Caused by: java.lang.NoClassDefFoundError: com/test/techops/ccfejb/util/CCFException --> Defined in my ejb (public part)
at com.test.techops.ccf.data.wdp.InternalData.<init>(InternalData.java:240)
... 32 more
I did not have any issues when the code was running on Netweaver 2004 but now it does not seem to work when I migrated to 2004s. Can anyone please advice me on what the problem might be ?
Thanks,
RamaHi Harsha,
Thanks for your quick reply.
Trying to figure it out by comparing JRE versions but still no result. I have found one problem is that
when Gantt is loaded , Java in control panel loads all the Applets requried in to its Resources.
These Resources are missing for the user for whom the Gantt error is produced.
Loaded Resources can be found in the below Path :
ControlPanel -> Java-> General Tab -> View Button -> select Resources in Show .
So, How to load these resources ??? . Is there any setting to do that ???
Regards,
Ravikiran.K -
How to access an EJB from a web application deployed in the same server
Hey All,
I deployed an EJB named EventServerBean to Sun Application Server 9.0, and put the client side jar file (named eventserver.jar which is generated by Sun Application Server) to C:\Sun\AppServer\lib. Now, I have a web application which is a simple jave file -- lookup EventServer EJB and invoke a remote method in this EJB. However, the web application always throws an exception "java.lang.NoClassDefFoundError: eventserver/EventServerRemoteHome"
Here is my java class that access the ejb:
public class Post_Event {
public HashMap<String, String> getEventInfo(String event_name, String site) {
System.out.println("Post_Event, the class path: " + System.getProperty("java.class.path"));
System.out.println("Post_Event, user.dir: " + System.getProperty("user.dir"));
System.out.println("Post_Event, java.library.path: " + System.getProperty("java.library.path"));
HashMap<String, String> result = null;
EventServerRemote remote = null;
StringTokenizer st, st2;
// here get the event information from host
try {
String lookupStr = "corbaname:iiop:" + site + ":3700#ejb/EventServerBean";
InitialContext initialContext = new InitialContext();
EventServerRemoteHome remoteHome = (EventServerRemoteHome) javax.rmi.PortableRemoteObject.narrow(initialContext.lookup(lookupStr), EventServerRemoteHome.class);
if (remoteHome != null) {
remote = remoteHome.create();
} catch (javax.naming.NamingException ne) {
ne.printStackTrace();
return null;
} catch (javax.ejb.CreateException ce) {
ce.printStackTrace();
return null;
} catch (java.rmi.RemoteException re) {
re.printStackTrace();
return null;
} catch (java.io.IOException ioe) {
ioe.printStackTrace();
return null;
System.out.println("look up remote event server successfully.");
result = remote.getEvent(event_name);
return result;
} I output the class path in this java file, and the class path DOES include the path C:\Sun\AppServer\lib where eventserver\EventServerRemoteHome.class is.
Does anyone know why it happens? Why a java class can't find a class that is in its class path?
appreciate any help!<BLOCKQUOTE><font size="1" face="Verdana, Arial">quote:</font><HR>Originally posted by Wael Abbas ([email protected]):
Thank you for your great topic.
I think you need to copy the snippet code and past it to every application, applet, servlet or JSP every time you need to use your EJB.
Its better to include this snippet code in a simple JavaBean and use this bean as a bridge to your EJB, you may include a connect method in your JavaBean or but the connection code in the constructor and include a setters, getters and other methods to encapsulate your EJB methods.
You can use your JavaBean in any application, applet, servlet or JSP just create an object form it and call its methods.
Its just an idea
I hope it will be useful.
<HR></BLOCKQUOTE>
null -
Hi!
I have deal with EJB 2.0 CMP bean.
I have a composite PK so use the java class to store it. And there is a corresponding field in the Entity Bean with its primary key class type.
The problem is: when deployment tool creates sql query for the findByPrimaryKey(PKClass ck)
where ck is an object with 3 fielde : a_id, b_id, c_id.
it says:
<sql>SELECT "ck" FROM "MyTable" WHERE "ck" = ? </sql>
And it means by the "ck" simple a column in DB but NOT the composite key which has to be splited into 3 different fields. So the container can't do the proper mapping.
Does anyone know solutions?I was wrong about primary key class fields, take a look at Ejb2.0 Specification (10.8.2):
The primary key class must be public, and must have a public constructor with no parameters.
All fields in the primary key class must be declared as public.
The names of the fields in the primary key class must be a subset of the names of the container-managed
fields. (This allows the container to extract the primary key fields from an instance�s container-managed
fields, and vice versa.)
Right now I'm using BMP and I don't have this problems. Primary keys, calculated fields and types not supported by the DB can be easily achieved. But I understand your interest on CMP, is clearly evolving! -
Getting Tomcat 4.1 to call EJBs in WLS 8.1
I know this is not necessarily a new topic, but we're upgrading our Tomcat
4.1 -> WLS 5.1 to a Tomcat 4.1 -> WLS 8.1 configuration.
Firstly, has ANYONE got Tomcat 4.1.x to work with a post 5.1 container at
all? Ever?
We are using the T3 protocol to talk to our beans, and the goal, of course,
is that our Tomcat based client code will ideally not have to change.
Our beans are all EJB 1.1, and I have them loaded into a running WLS 8.1
container. They appear to work.
The way I tested to see if I could talk to WLS was by using a simple client
that I had that gets an InitialContext, and then grabs a bean.
I now have a simple JSP that essentially does the same thing. I've bundled
this jsp into a properly formatted WAR file.
Within this WAR file in the WEB-INF/classes directory are the Session bean
Home and the Session Bean Remote interface classes.
Within the WEB-INF/lib directory is the
c:\bea\weblogic81\server\lib\weblogic.jar, slightly modified.
After the first attempt to load this, Tomcat would complain because the
weblogic.jar contains the javax.servlet package, so I exploded the
weblogic.jar file, renamed javax/servlet to javax/servlet.x, and then
rejarred the file. This file was placed into the WEB-INF/lib directory.
This is otherwise a default Tomcat 4.1.18 binary package.
Here's the WAR file contents:
./META-INF/MANIFEST.MF
./WEB-INF/classes/com/pfizer/ecms/as/CustomizationSession.class
./WEB-INF/classes/com/pfizer/ecms/as/CustomizationSessionHome.class
./WEB-INF/lib/wlsx.jar <-- Edited weblogic.jar
./WEB-INF/web.xml
./test.jsp
This is the contents of the test.jsp:
<%@ page language="java" %>
<%@ page import="javax.naming.*" %>
<%@ page import="com.pfizer.ecms.as.*" %>
<%
try{
System.setProperty(Context.INITIAL_CONTEXT_FACTORY,
"weblogic.jndi.WLInitialContextFactory");
System.setProperty(Context.PROVIDER_URL, "t3://localhost:7001");
InitialContext ctx = new InitialContext();
CustomizationSessionHome csth = (CustomizationSessionHome)
ctx.lookup("CustomizationSession");
CustomizationSession cst = csth.create();
catch (Throwable t) {
System.out.println(">>>t = " + t);
t.printStackTrace(System.out);
%>
<HTML>
<BODY>
This is the jsp.
</BODY>
</HTML>
Similar code to this has been working for us for 3 years so far.
When I try and load the JSP, it dumps a stack trace. Here's the relevant
bits up to the Tomcat container:
t = java.lang.NoClassDefFoundError: weblogic/rmi/extensions/server/Stubjava.lang.NoClassDefFoundError: weblogic/rmi/extensions/server/Stub
at java.lang.ClassLoader.defineClass0(Native Method)
at java.lang.ClassLoader.defineClass(ClassLoader.java:502)
at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:123)
at
weblogic.utils.classloaders.GenericClassLoader.findLocalClass(GenericClassLo
ader.java:431)
at
weblogic.utils.classloaders.GenericClassLoader.findClass(GenericClassLoader.
java:169)
at java.lang.ClassLoader.loadClass(ClassLoader.java:299)
at java.lang.ClassLoader.loadClass(ClassLoader.java:255)
at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:315)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:217)
at
weblogic.utils.classfile.utils.CodeGenerator.generateClass(CodeGenerator.jav
a:71)
at weblogic.rmi.internal.StubGenerator.getStubClass(StubGenerator.java:672)
at weblogic.rmi.internal.StubGenerator.generateStub(StubGenerator.java:712)
at weblogic.rmi.internal.StubGenerator.generateStub(StubGenerator.java:699)
at weblogic.rmi.extensions.StubFactory.getStub(StubFactory.java:76)
at
weblogic.jndi.WLInitialContextFactoryDelegate.newRootNamingNodeStub(WLInitia
lContextFactoryDelegate.java:486)
at
weblogic.jndi.WLInitialContextFactoryDelegate.newRemoteContext(WLInitialCont
extFactoryDelegate.java:449)
at
weblogic.jndi.WLInitialContextFactoryDelegate.newContext(WLInitialContextFac
toryDelegate.java:345)
at
weblogic.jndi.WLInitialContextFactoryDelegate.getInitialContext(WLInitialCon
textFactoryDelegate.java:308)
at
weblogic.jndi.WLInitialContextFactoryDelegate.getInitialContext(WLInitialCon
textFactoryDelegate.java:234)
at
weblogic.jndi.WLInitialContextFactory.getInitialContext(WLInitialContextFact
ory.java:135)
at javax.naming.spi.NamingManager.getInitialContext(NamingManager.java:662)
at javax.naming.InitialContext.getDefaultInitCtx(InitialContext.java:243)
at javax.naming.InitialContext.init(InitialContext.java:219)
at javax.naming.InitialContext.<init>(InitialContext.java:175)
at org.apache.jsp.test_jsp._jspService(test_jsp.java:51)
What is interesting about this is that the system could "see"
weblogic.utils.classloaders.GenericClassLoader, but THAT class could not
find weblogic.rmi.extension.server.Stub, even though they are, ideally, at
the same level within the Tomcat imposed hierarchy of classloaders.
Unfortunately, we don't quite know where in that hierarchy each class is
placed.
Now, the culprit may well be java.security.SecureClassLoader (or, actually,
the java.lang.ClassLoader.defineClass0), which is very high up in the
hierarchy trying to load a the result of the StubGenerator, only to find
that an associated class, weblogic.rmi.extensions.server.Stub, was "not
found" because it only existed deep in the Tomcat hierarchy.
One way that I tried to get around this was to start taking selective bits
of of weblogic.jar and put them on the system CLASSPATH used by Tomcat when
it starts up.
This gets us farther along, in that more classes seem to load without
getting the ClassDefNotFound error, but it finally leads us into this
exception:
The error is, with a small bit of stack dump:
weblogic.utils.AssertionError: ***** ASSERTION FAILED *****[ Environment not
found on thread ]
at
weblogic.jndi.internal.NamingNodeReplicaHandler.<init>(NamingNodeReplicaHand
ler.java:150)
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at
sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAcces
sorImpl.java:39)
at
sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstruc
torAccessorImpl.java:27)
at java.lang.reflect.Constructor.newInstance(Constructor.java:274)
at java.lang.Class.newInstance0(Class.java:306)
at java.lang.Class.newInstance(Class.java:259)
at
weblogic.common.internal.ChunkedObjectInputStream.readObject(ChunkedObjectIn
putStream.java:90)
snip
The relevant starting point is toward the middle of the stack trace:
at
weblogic.rjvm.BasicOutboundRequest.sendReceive(BasicOutboundRequest.java:106
at weblogic.rmi.internal.BasicRemoteRef.invoke(BasicRemoteRef.java:125)
at
com.pfizer.ecms.as.DataImporterSession_aiw0oz_HomeImpl_810_WLStub.create(Unk
nown Source)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39
at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl
.java:25)
at java.lang.reflect.Method.invoke(Method.java:324)
at com.pfizer.ecms.com.AppServer.createInstance(AppServer.java:163)
at com.pfizer.ecms.com.AppServer.getDataImporterSession(AppServer.java:231)
at
com.pfizer.ecms.ws.ECMSActionServlet.testBeans(ECMSActionServlet.java:1662)
at
com.pfizer.ecms.ws.ECMSActionServlet.initOther(ECMSActionServlet.java:62)
at org.apache.struts.action.ActionServlet.init(ActionServlet.java:472)
Now, according to the Weblogic documentation, the AssertionError exception
"is impossible". Well, that's my job they say, doing the impossible.
Minimally, it's a meaningless message to me and pretty much stops me cold.
I have seen other discussions about Tomcat and how it's not J2EE, etc, and
perhaps my expectations that this will work are too high. My concern with
that is simply that in our case, Tomcat is a Fat Client no different from
"any other Java application". We just use Tomcat to talk to beans rather
than a custom client. The difficulty, it seems, is in the complexities of
the Tomcat class loaders interoperating with the expectations of Weblogics
classes et al.
I've got a small application that does exactly what Tomcat wants to do, so
"weblogic works", except of course, in Tomcat.
So, in the end, I'm curious if others have some data on getting these two
system cooperating. If anyone has any other ideas on how to use Tomcat as a
client of Weblogic 8 that utilizes techniques besides replacing Tomcat
(which is not an option at the moment) I'd like to hear those as well. I
have been fighting this for days, and tried several things, but nothing
"obvious" seems to help.
Weblogic 8 has a "thin client" jar, but it's only useful for RMI rather than
T3, plus it's still not clear how we'd go about rewriting the interfaces to
support that versus the standard EJB interfaces already created for the
beans.
Any assistance greatly appreciated.
Regards,
Will Hartung
([email protected])Of course I feel obliged to first recommend that you run your webapps
and EJBs in WLS. There's significant performance advantages and it
greatly simpifies your life since you don't have to deal with another
remote failure case.
That being said, I believe it should be possible especially with 8.1 to
make Tomcat a WLS client.
Answers inline.
Will Hartung wrote:
I know this is not necessarily a new topic, but we're upgrading our Tomcat
4.1 -> WLS 5.1 to a Tomcat 4.1 -> WLS 8.1 configuration.
Firstly, has ANYONE got Tomcat 4.1.x to work with a post 5.1 container at
all? Ever?
We are using the T3 protocol to talk to our beans, and the goal, of course,
is that our Tomcat based client code will ideally not have to change.
Our beans are all EJB 1.1, and I have them loaded into a running WLS 8.1
container. They appear to work.
The way I tested to see if I could talk to WLS was by using a simple client
that I had that gets an InitialContext, and then grabs a bean.
I now have a simple JSP that essentially does the same thing. I've bundled
this jsp into a properly formatted WAR file.
Within this WAR file in the WEB-INF/classes directory are the Session bean
Home and the Session Bean Remote interface classes.
Within the WEB-INF/lib directory is the
c:\bea\weblogic81\server\lib\weblogic.jar, slightly modified.My suggestion is to ditch the weblogic.jar and the joys of trying to
modify it. I'd instead check out 8.1's thin client support:
http://e-docs.bea.com/wls/docs81/rmi_iiop/rmiiiop2.html#1071450
>
After the first attempt to load this, Tomcat would complain because the
weblogic.jar contains the javax.servlet package, so I exploded the
weblogic.jar file, renamed javax/servlet to javax/servlet.x, and then
rejarred the file. This file was placed into the WEB-INF/lib directory.
This is otherwise a default Tomcat 4.1.18 binary package.
Here's the WAR file contents:
./META-INF/MANIFEST.MF
./WEB-INF/classes/com/pfizer/ecms/as/CustomizationSession.class
./WEB-INF/classes/com/pfizer/ecms/as/CustomizationSessionHome.class
./WEB-INF/lib/wlsx.jar <-- Edited weblogic.jar
./WEB-INF/web.xml
./test.jsp
This is the contents of the test.jsp:
<%@ page language="java" %>
<%@ page import="javax.naming.*" %>
<%@ page import="com.pfizer.ecms.as.*" %>
<%
try{
System.setProperty(Context.INITIAL_CONTEXT_FACTORY,
"weblogic.jndi.WLInitialContextFactory");
System.setProperty(Context.PROVIDER_URL, "t3://localhost:7001");
InitialContext ctx = new InitialContext();
CustomizationSessionHome csth = (CustomizationSessionHome)
ctx.lookup("CustomizationSession");
CustomizationSession cst = csth.create();
catch (Throwable t) {
System.out.println(">>>t = " + t);
t.printStackTrace(System.out);
%>
<HTML>
<BODY>
This is the jsp.
</BODY>
</HTML>
Similar code to this has been working for us for 3 years so far.
When I try and load the JSP, it dumps a stack trace. Here's the relevant
bits up to the Tomcat container:
t = java.lang.NoClassDefFoundError: weblogic/rmi/extensions/server/Stubjava.lang.NoClassDefFoundError: weblogic/rmi/extensions/server/Stub
at java.lang.ClassLoader.defineClass0(Native Method)
at java.lang.ClassLoader.defineClass(ClassLoader.java:502)
at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:123)
at
weblogic.utils.classloaders.GenericClassLoader.findLocalClass(GenericClassLo
ader.java:431)
at
weblogic.utils.classloaders.GenericClassLoader.findClass(GenericClassLoader.
java:169)
at java.lang.ClassLoader.loadClass(ClassLoader.java:299)
at java.lang.ClassLoader.loadClass(ClassLoader.java:255)
at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:315)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:217)
at
weblogic.utils.classfile.utils.CodeGenerator.generateClass(CodeGenerator.jav
a:71)
at weblogic.rmi.internal.StubGenerator.getStubClass(StubGenerator.java:672)
at weblogic.rmi.internal.StubGenerator.generateStub(StubGenerator.java:712)
at weblogic.rmi.internal.StubGenerator.generateStub(StubGenerator.java:699)
at weblogic.rmi.extensions.StubFactory.getStub(StubFactory.java:76)
at
weblogic.jndi.WLInitialContextFactoryDelegate.newRootNamingNodeStub(WLInitia
lContextFactoryDelegate.java:486)
at
weblogic.jndi.WLInitialContextFactoryDelegate.newRemoteContext(WLInitialCont
extFactoryDelegate.java:449)
at
weblogic.jndi.WLInitialContextFactoryDelegate.newContext(WLInitialContextFac
toryDelegate.java:345)
at
weblogic.jndi.WLInitialContextFactoryDelegate.getInitialContext(WLInitialCon
textFactoryDelegate.java:308)
at
weblogic.jndi.WLInitialContextFactoryDelegate.getInitialContext(WLInitialCon
textFactoryDelegate.java:234)
at
weblogic.jndi.WLInitialContextFactory.getInitialContext(WLInitialContextFact
ory.java:135)
at javax.naming.spi.NamingManager.getInitialContext(NamingManager.java:662)
at javax.naming.InitialContext.getDefaultInitCtx(InitialContext.java:243)
at javax.naming.InitialContext.init(InitialContext.java:219)
at javax.naming.InitialContext.<init>(InitialContext.java:175)
at org.apache.jsp.test_jsp._jspService(test_jsp.java:51)
What is interesting about this is that the system could "see"
weblogic.utils.classloaders.GenericClassLoader, but THAT class could not
find weblogic.rmi.extension.server.Stub, even though they are, ideally, at
the same level within the Tomcat imposed hierarchy of classloaders.
Unfortunately, we don't quite know where in that hierarchy each class is
placed.
Now, the culprit may well be java.security.SecureClassLoader (or, actually,
the java.lang.ClassLoader.defineClass0), which is very high up in the
hierarchy trying to load a the result of the StubGenerator, only to find
that an associated class, weblogic.rmi.extensions.server.Stub, was "not
found" because it only existed deep in the Tomcat hierarchy.
One way that I tried to get around this was to start taking selective bits
of of weblogic.jar and put them on the system CLASSPATH used by Tomcat when
it starts up.
This gets us farther along, in that more classes seem to load without
getting the ClassDefNotFound error, but it finally leads us into this
exception:
The error is, with a small bit of stack dump:
weblogic.utils.AssertionError: ***** ASSERTION FAILED *****[ Environment not
found on thread ]
at
weblogic.jndi.internal.NamingNodeReplicaHandler.<init>(NamingNodeReplicaHand
ler.java:150)
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at
sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAcces
sorImpl.java:39)
at
sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstruc
torAccessorImpl.java:27)
at java.lang.reflect.Constructor.newInstance(Constructor.java:274)
at java.lang.Class.newInstance0(Class.java:306)
at java.lang.Class.newInstance(Class.java:259)
at
weblogic.common.internal.ChunkedObjectInputStream.readObject(ChunkedObjectIn
putStream.java:90)
snip
The relevant starting point is toward the middle of the stack trace:
at
weblogic.rjvm.BasicOutboundRequest.sendReceive(BasicOutboundRequest.java:106
at weblogic.rmi.internal.BasicRemoteRef.invoke(BasicRemoteRef.java:125)
at
com.pfizer.ecms.as.DataImporterSession_aiw0oz_HomeImpl_810_WLStub.create(Unk
nown Source)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39
at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl
.java:25)
at java.lang.reflect.Method.invoke(Method.java:324)
at com.pfizer.ecms.com.AppServer.createInstance(AppServer.java:163)
at com.pfizer.ecms.com.AppServer.getDataImporterSession(AppServer.java:231)
at
com.pfizer.ecms.ws.ECMSActionServlet.testBeans(ECMSActionServlet.java:1662)
at
com.pfizer.ecms.ws.ECMSActionServlet.initOther(ECMSActionServlet.java:62)
at org.apache.struts.action.ActionServlet.init(ActionServlet.java:472)
Now, according to the Weblogic documentation, the AssertionError exception
"is impossible". Well, that's my job they say, doing the impossible.
Minimally, it's a meaningless message to me and pretty much stops me cold.
Right, it's not really meant to be meaningful because customers "should"
never see these assertions.
I have seen other discussions about Tomcat and how it's not J2EE, etc, and
perhaps my expectations that this will work are too high. My concern with
that is simply that in our case, Tomcat is a Fat Client no different from
"any other Java application". We just use Tomcat to talk to beans rather
than a custom client. The difficulty, it seems, is in the complexities of
the Tomcat class loaders interoperating with the expectations of Weblogics
classes et al.
I've got a small application that does exactly what Tomcat wants to do, so
"weblogic works", except of course, in Tomcat.
So, in the end, I'm curious if others have some data on getting these two
system cooperating. If anyone has any other ideas on how to use Tomcat as a
client of Weblogic 8 that utilizes techniques besides replacing Tomcat
(which is not an option at the moment) I'd like to hear those as well. I
have been fighting this for days, and tried several things, but nothing
"obvious" seems to help.
Weblogic 8 has a "thin client" jar, but it's only useful for RMI rather than
T3, plus it's still not clear how we'd go about rewriting the interfaces to
support that versus the standard EJB interfaces already created for the
beans.I'm not sure I follow you here. You always write to RMI interfaces.
The question is what protocol (eg T3, JRMP, IIOP) will actually run RMI.
By default WLS uses its own protocol (t3), but most customer apps
should run without change over IIOP.
I'd really recommend going the thin client route. Otherwise I fear
you'll end up with a heavily modified weblogic.jar and headaches when
you try to install a service pack etc.
-- Rob
>
Any assistance greatly appreciated.
Regards,
Will Hartung
([email protected]) -
Error while running a EJB client
Hi All,
I am trying to execute a Hello World Prgram using EJB's. I have Deployed a Stateless Session bean in J2EE 1.3 deploytool.I am also able to compile my Client, but when i a executing the Client i am getting this error.
=========================
java.rmi.RemoteException: CORBA BAD_OPERATION 0 No; nested exception is: org.omg.CORBA.BAD_OPERATION: vmcid: 0x0 minor code: 0 completed: No at com.sun.corba.ee.internal.iiop.ShutdownUtilDelegate.mapSystemException(ShutdownUtilDeleg ate.java:137) at javax.rmi.CORBA.Util.mapSystemException(Util.java:65) at headfirst._Advice_Stub.getAdvice(Unknown Source) at AdviceClient.go(AdviceClient.java:21) at AdviceClient.main(AdviceClient.java:11) Caused by: org.omg.CORBA.BAD_OPERATION: vmcid: 0x0 minor code: 0 completed: No at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java :39) at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorI mpl.java:27) at java.lang.reflect.Constructor.newInstance(Constructor.java:274) at java.lang.Class.newInstance0(Class.java:296) at java.lang.Class.newInstance(Class.java:249) at com.sun.corba.ee.internal.iiop.messages.ReplyMessage_1_2.getSystemException(ReplyMessage _1_2.java:93) at com.sun.corba.ee.internal.iiop.ClientResponseImpl.getSystemException(ClientResponseImpl. java:108) at com.sun.corba.ee.internal.POA.GenericPOAClientSC.invoke(GenericPOAClientSC.java:132) at org.omg.CORBA.portable.ObjectImpl._invoke(ObjectImpl.java:457) at headfirst._Advice_Stub.getAdvice(Unknown Source) ... 2 more ===============================
I have undeployed and redeployed couple of time but i am still getting the same problem. I am using J2EE 1.3 deploytool for deploying the EJB.
Can anyone please help me in figuring out the problem.
Thanks in Advance.
~Ravi.You are having network-related errors to the client.
Let me see your Remote interface -
Error while deploy a simple EJB
Hi , I'm having a problem while trying to deploy a ear [witch only contains a EJB ] in weblogic 10.01 AKA 10mp1 ,
java.lang.NoClassDefFoundError
at org.apache.log4j.Logger.getLogger(Logger.java:104)
at MyClass.<clinit>(MyClass.java:62)
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)
at java.lang.reflect.Constructor.newInstance(Constructor.java:494)
at java.lang.Class.newInstance0(Class.java:354)
at java.lang.Class.newInstance(Class.java:307)
at weblogic.ejb.container.manager.BaseEJBManager.createNewBeanInstance(BaseEJBManager.java:222)
A little more info
MyClass.java:62 = private static Logger log = Logger.getLogger(MyClass.class);
I also have try
MyClass.java:62 = private static Logger log = Logger.getRootLogger();
Both with the same result.
My Log4j properties are simple
#==================================================================
#std-out Logger Configuration
#==================================================================
log4j.appender.std-out=org.apache.log4j.ConsoleAppender
log4j.appender.std-out.target=System.out
log4j.appender.std-out.layout=org.apache.log4j.PatternLayout
log4j.appender.std-out.layout.ConversionPattern=%d{dd MMM yyyy HH:mm:ss,SSS} [%t] %-5p %c %x - %m\n
log4j.rootCategory=${root.log}, std-out
Also have Try Hard Code Properties , but having the same error.
static {
PatternLayout out=new PatternLayout("%d{dd MMM yyyy HH:mm:ss,SSS} [%t] %-5p %c %x - %m\n");
ConsoleAppender appender=new ConsoleAppender(out);
appender.setTarget(ConsoleAppender.SYSTEM_OUT);
Logger.getRootLogger().addAppender(appender);
I'm aware of a "bug" of Weblogic 9.2 to 10.02 that weblogic adds first his jars instead the web-inf\lib jars I have added this xml's to the weblogic-application.xml
<wls:prefer-application-packages>
<wls:package-name>org.apache.log4j.*</wls:package-name>
</wls:prefer-application-packages>
Please note a add the weblogic-application.xml in ejb META-INF folder , as well in the EAR META-INF folder
That doesn't resolve my problem has you can imagine already
I'm using log4j 1.2.15 and log4j extras both download from maven repository
I'll really appreciate some sort of guide since this problem is really annoying me
Regards
Carlos Ortiz
PS. If you need more info , please ask I will facilitate as much as I canYes I Have double check
Edited by: khrono on Jul 20, 2009 8:32 AM -
EJB 3.0 Constraints Problem
Hi everybody !
Hope someone can help me !! Im really go crazy with this stuff :s...
Im Using jdeveloper .... I have 2 Entity Bean called Jiverating and Jiveuser, I creadte them using "Create Entity Bean from Table".... also a Session Bean called ForumFacadeBean I created using a EJB diagram as EJB Sesion Bean ....
I can execute query without any problem but when I want to sotre a new Jiverating the aplication thows an exception... I just call the following metold of ForumFacadeBean
public Jiverating persistJiverating(Jiverating jiverating) {
em.persist(jiverating);
return jiverating;
The exception I got is:
<Jan 13, 2012 8:42:48 PM PET> <Warning> <EclipseLink> <BEA-2005000> <2012-01-13 20:42:48.125--UnitOfWork(317933487)--Exception [EclipseLink-4002] (Eclipse Persistence Services - 2.1.3.v20110304-r9073): org.eclipse.persistence.exceptions.DatabaseException
Internal Exception: java.sql.SQLTransactionRollbackException: ORA-02091: transaction rolled back
ORA-02291: integrity constraint (DEV_DISCUSSIONS.JIVERATE_SCR_FK) violated - parent key not found
Error Code: 2091
Call: INSERT INTO JIVERATING (SCORE, OBJECTTYPE, USERID, OBJECTID) VALUES (?, ?, ?, ?)
bind => [2, 0, 2, 11]
Query: InsertObjectQuery(pe.com.bcts.gart.ejb.entities.Jiverating@12f3242c)>
<Jan 13, 2012 8:42:48 PM PET> <Warning> <EclipseLink> <BEA-2005000> <2012-01-13 20:42:48.126--UnitOfWork(317933487)--Exception [EclipseLink-4002] (Eclipse Persistence Services - 2.1.3.v20110304-r9073): org.eclipse.persistence.exceptions.DatabaseException
Internal Exception: java.sql.SQLTransactionRollbackException: ORA-02091: transaction rolled back
ORA-02291: integrity constraint (DEV_DISCUSSIONS.JIVERATE_SCR_FK) violated - parent key not found
Error Code: 2091
Call: INSERT INTO JIVERATING (SCORE, OBJECTTYPE, USERID, OBJECTID) VALUES (?, ?, ?, ?)
bind => [2, 0, 2, 11]
Query: InsertObjectQuery(pe.com.bcts.gart.ejb.entities.Jiverating@12f3242c)>
<Jan 13, 2012 8:42:48 PM PET> <Error> <EJB> <BEA-010026> <Exception occurred during commit of transaction Name=[EJB pe.com.gart.ejb.entities.ForumFacadeBean.persistJiverating(pe.com.bcts.gart.ejb.entities.Jiverating)],Xid=BEA1-001B5FB5B4DB06A00B5F(317932956),Status=Rolled back. [Reason=Exception [EclipseLink-4002] (Eclipse Persistence Services - 2.1.3.v20110304-r9073): org.eclipse.persistence.exceptions.DatabaseException
Internal Exception: java.sql.SQLTransactionRollbackException: ORA-02091: transaction rolled back
ORA-02291: integrity constraint (DEV_DISCUSSIONS.JIVERATE_SCR_FK) violated - parent key not found
Error Code: 2091
Call: INSERT INTO JIVERATING (SCORE, OBJECTTYPE, USERID, OBJECTID) VALUES (?, ?, ?, ?)
bind => [2, 0, 2, 11]
Query: InsertObjectQuery(pe.com.bcts.gart.ejb.entities.Jiverating@12f3242c)],numRepliesOwedMe=0,numRepliesOwedOthers=0,seconds since begin=0,seconds left=30,SCInfo[osinergminWebPortalDesa+WC_Spaces]=(state=rolledback),properties=({weblogic.transaction.name=[EJB pe.com.gart.ejb.entities.ForumFacadeBean.persistJiverating(pe.com.bcts.gart.ejb.entities.Jiverating)]}),OwnerTransactionManager=ServerTM[ServerCoordinatorDescriptor=(CoordinatorURL=WC_Spaces+192.168.101.124:9000+osinergminWebPortalDesa+t3+, XAResources={WSATGatewayRM_WC_Spaces_osinergminWebPortalDesa, CustomPortalServicesEJB@Portal@Portal_osinergminWebPortalDesa, webapp@Portal@Portal_osinergminWebPortalDesa},NonXAResources={})],CoordinatorURL=WC_Spaces+192.168.101.124:9000+osinergminWebPortalDesa+t3+): weblogic.transaction.RollbackException: Unexpected exception in beforeCompletion: sync=[email protected]f34805
Internal Exception: java.sql.SQLTransactionRollbackException: ORA-02091: transaction rolled back
ORA-02291: integrity constraint (DEV_DISCUSSIONS.JIVERATE_SCR_FK) violated - parent key not found
Error Code: 2091
Call: INSERT INTO JIVERATING (SCORE, OBJECTTYPE, USERID, OBJECTID) VALUES (?, ?, ?, ?)
* bind => [2, 0, 2, 11]*Query: InsertObjectQuery(pe.com.bcts.gart.ejb.entities.Jiverating@12f3242c)
at weblogic.transaction.internal.TransactionImpl.throwRollbackException(TransactionImpl.java:1881)
at weblogic.transaction.internal.ServerTransactionImpl.internalCommit(ServerTransactionImpl.java:345)
at weblogic.transaction.internal.ServerTransactionImpl.commit(ServerTransactionImpl.java:240)
at weblogic.ejb.container.internal.BaseRemoteObject.postInvoke1(BaseRemoteObject.java:627)
at weblogic.ejb.container.internal.StatelessRemoteObject.postInvoke1(StatelessRemoteObject.java:49)
at weblogic.ejb.container.internal.BaseRemoteObject.__WL_postInvokeTxRetry(BaseRemoteObject.java:444)
at weblogic.ejb.container.internal.SessionRemoteMethodInvoker.invoke(SessionRemoteMethodInvoker.java:53)
at pe.com.gart.ejb.entities.ForumFacade_xgr9io_ForumFacadeImpl.persistJiverating(Unknown Source)
at pe.com.gart.ejb.entities.ForumFacade_xgr9io_ForumFacadeImpl_WLSkel.invoke(Unknown Source)
at weblogic.rmi.internal.ServerRequest.sendReceive(ServerRequest.java:174)
at weblogic.rmi.cluster.ClusterableRemoteRef.invoke(ClusterableRemoteRef.java:345)
at weblogic.rmi.cluster.ClusterableRemoteRef.invoke(ClusterableRemoteRef.java:259)
at pe.com.gart.ejb.entities.ForumFacade_xgr9io_ForumFacadeImpl_1035_WLStub.persistJiverating(Unknown Source)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at weblogic.ejb.container.internal.RemoteBusinessIntfProxy.invoke(RemoteBusinessIntfProxy.java:85)
at $Proxy247.persistJiverating(Unknown Source)
at customdiscussions.backing.AddRating.<init>(AddRating.java:51)
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)
at java.lang.reflect.Constructor.newInstance(Constructor.java:513)
at java.lang.Class.newInstance0(Class.java:355)
at java.lang.Class.newInstance(Class.java:308)
at oracle.adfinternal.controller.beans.ManagedBeanFactory.newInstance(ManagedBeanFactory.java:187)
at oracle.adfinternal.controller.beans.ManagedBeanFactory.instantiateBean(ManagedBeanFactory.java:874)
at oracle.adfinternal.controller.state.ScopeMap.get(ScopeMap.java:83)
at javax.el.MapELResolver.getValue(MapELResolver.java:164)
at com.sun.faces.el.DemuxCompositeELResolver._getValue(DemuxCompositeELResolver.java:173)
at com.sun.faces.el.DemuxCompositeELResolver.getValue(DemuxCompositeELResolver.java:200)
at com.sun.el.parser.AstValue.getValue(Unknown Source)
at com.sun.el.ValueExpressionImpl.getValue(Unknown Source)
at com.sun.faces.application.ApplicationImpl.createComponent(ApplicationImpl.java:250)
at javax.faces.webapp.UIComponentELTag.createComponent(UIComponentELTag.java:222)
at javax.faces.webapp.UIComponentClassicTagBase.createChild(UIComponentClassicTagBase.java:513)
at javax.faces.webapp.UIComponentClassicTagBase.findComponent(UIComponentClassicTagBase.java:782)
at javax.faces.webapp.UIComponentClassicTagBase.doStartTag(UIComponentClassicTagBase.java:1354)
at org.apache.myfaces.trinidad.webapp.UIXComponentELTag.doStartTag(UIXComponentELTag.java:75)
at oracle.adfinternal.view.faces.unified.taglib.UnifiedDocumentTag.doStartTag(UnifiedDocumentTag.java:50)
at jsp_servlet.__addrating_jspx._jspx___tag1(__addrating_jspx.java:154)
at jsp_servlet.__addrating_jspx._jspx___tag0(__addrating_jspx.java:113)
at jsp_servlet.__addrating_jspx._jspService(__addrating_jspx.java:74)
at weblogic.servlet.jsp.JspBase.service(JspBase.java:35)
at weblogic.servlet.internal.StubSecurityHelper$ServletServiceAction.run(StubSecurityHelper.java:227)
at weblogic.servlet.internal.StubSecurityHelper.invokeServlet(StubSecurityHelper.java:125)
at weblogic.servlet.internal.ServletStubImpl.execute(ServletStubImpl.java:300)
at weblogic.servlet.internal.ServletStubImpl.onAddToMapException(ServletStubImpl.java:417)
at weblogic.servlet.internal.ServletStubImpl.execute(ServletStubImpl.java:326)
at weblogic.servlet.internal.ServletStubImpl.execute(ServletStubImpl.java:184)
at weblogic.servlet.internal.RequestDispatcherImpl.invokeServlet(RequestDispatcherImpl.java:523)
at weblogic.servlet.internal.RequestDispatcherImpl.forward(RequestDispatcherImpl.java:253)
at com.sun.faces.context.ExternalContextImpl.dispatch(ExternalContextImpl.java:410)
at org.apache.myfaces.trinidad.context.ExternalContextDecorator.dispatch(ExternalContextDecorator.java:45)
at org.apache.myfaces.trinidad.context.ExternalContextDecorator.dispatch(ExternalContextDecorator.java:45)
at oracle.adfinternal.view.faces.config.rich.RecordRequestAttributesDuringDispatch.dispatch(RecordRequestAttributesDuringDispatch.java:45)
at org.apache.myfaces.trinidad.context.ExternalContextDecorator.dispatch(ExternalContextDecorator.java:45)
at org.apache.myfaces.trinidad.context.ExternalContextDecorator.dispatch(ExternalContextDecorator.java:45)
at org.apache.myfaces.trinidad.context.ExternalContextDecorator.dispatch(ExternalContextDecorator.java:45)
at org.apache.myfaces.trinidadinternal.context.FacesContextFactoryImpl$OverrideDispatch.dispatch(FacesContextFactoryImpl.java:268)
at com.sun.faces.application.ViewHandlerImpl.executePageToBuildView(ViewHandlerImpl.java:471)
at com.sun.faces.application.ViewHandlerImpl.renderView(ViewHandlerImpl.java:140)
at javax.faces.application.ViewHandlerWrapper.renderView(ViewHandlerWrapper.java:191)
at org.apache.myfaces.trinidadinternal.application.ViewHandlerImpl.renderView(ViewHandlerImpl.java:193)
at oracle.adfinternal.view.faces.lifecycle.LifecycleImpl._renderResponse(LifecycleImpl.java:800)
at oracle.adfinternal.view.faces.lifecycle.LifecycleImpl._executePhase(LifecycleImpl.java:294)
at oracle.adfinternal.view.faces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:214)
at javax.faces.webapp.FacesServlet.service(FacesServlet.java:266)
at weblogic.servlet.internal.StubSecurityHelper$ServletServiceAction.run(StubSecurityHelper.java:227)
at weblogic.servlet.internal.StubSecurityHelper.invokeServlet(StubSecurityHelper.java:125)
at weblogic.servlet.internal.ServletStubImpl.execute(ServletStubImpl.java:300)
at weblogic.servlet.internal.TailFilter.doFilter(TailFilter.java:27)
at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:57)
at oracle.security.jps.ee.http.JpsAbsFilter$1.run(JpsAbsFilter.java:111)
at oracle.security.jps.util.JpsSubject.doAsPrivileged(JpsSubject.java:313)
at oracle.security.jps.ee.util.JpsPlatformUtil.runJaasMode(JpsPlatformUtil.java:413)
at oracle.security.jps.ee.http.JpsAbsFilter.runJaasMode(JpsAbsFilter.java:94)
at oracle.security.jps.ee.http.JpsAbsFilter.doFilter(JpsAbsFilter.java:161)
at oracle.security.jps.ee.http.JpsFilter.doFilter(JpsFilter.java:71)
at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:57)
at oracle.dms.servlet.DMSServletFilter.doFilter(DMSServletFilter.java:136)
at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:57)
at weblogic.servlet.internal.RequestEventsFilter.doFilter(RequestEventsFilter.java:27)
at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:57)
at weblogic.servlet.internal.WebAppServletContext$ServletInvocationAction.wrapRun(WebAppServletContext.java:3715)
at weblogic.servlet.internal.WebAppServletContext$ServletInvocationAction.run(WebAppServletContext.java:3681)
at weblogic.security.acl.internal.AuthenticatedSubject.doAs(AuthenticatedSubject.java:321)
at weblogic.security.service.SecurityManager.runAs(SecurityManager.java:120)
at weblogic.servlet.internal.WebAppServletContext.securedExecute(WebAppServletContext.java:2277)
at weblogic.servlet.internal.WebAppServletContext.execute(WebAppServletContext.java:2183)
at weblogic.servlet.internal.ServletRequestImpl.run(ServletRequestImpl.java:1454)
at weblogic.work.ExecuteThread.execute(ExecuteThread.java:209)
at weblogic.work.ExecuteThread.run(ExecuteThread.java:178)
Caused by: Exception [EclipseLink-4002] (Eclipse Persistence Services - 2.1.3.v20110304-r9073): org.eclipse.persistence.exceptions.DatabaseException
Internal Exception: java.sql.SQLTransactionRollbackException: ORA-02091: transaction rolled back
ORA-02291: integrity constraint (DEV_DISCUSSIONS.JIVERATE_SCR_FK) violated - parent key not found
I dont underestand this error beacuse when I execute INSERT INTO JIVERATING (SCORE, OBJECTTYPE, USERID, OBJECTID) VALUES (2, 0, 2, 11) directly on the database I got no error !
please help me !!!!!ORA-02291: integrity constraint (DEV_DISCUSSIONS.JIVERATE_SCR_FK) violated - parent key not foundWell it is a database constraint, so it is the database that is blocking the insertion of the record.
I dont underestand this error beacuse when I execute INSERT INTO JIVERATING (SCORE, OBJECTTYPE, USERID, OBJECTID) VALUES (2, 0, 2, 11) directly on the database I got no error !And did you actually attempt to -commit- the transaction? If you did then I can only conclude one thing: you are using two different databases. One has a constraint, the other does not. Constraints do not magically appear out of thin air, especially ones that generate an ORA error.
Maybe you are looking for
-
Business Event Appraisal in Training and event management
Hi I am facing issue releated to Business Event Appraisal Functionality in ESS. I have maintained value as blank in field HAP00 REPLA switch. We have created I View of transacion PV7I in ESS. When i am selecting "APPRAISAL" button for attended event
-
CD or DVD Disc does not appear on desk top ...
When I insert a blank CD it comes up on the desktop. When I insert any CD or DVD that contains data the CD or DVD does not come up on the desktop. I have looked at "troubleshooting a cd-rom " from Apple. I've tried a number different brands of CDs an
-
What happened to my itunes library it disappeared except for the purchased songs?
-
Hi, i need urgent help. I did back up from Iphone 4s , and i wanted to upload into iphone 5. All applications where updated into Iphone 5, but I lost all contacts.So how to restore contacts to the new Iphone5 ?
-
I am installing UPK client developer license (admin) for a multi user environment and getting the following error: An unexpected error occured while installing Microsoft XML Core Services (MSXML) 4.0. The installation will now be cancelled. Return Co