Win a copy of Rust Web Development this week in the Other Languages forum!

Gaurav Saxena

Greenhorn
+ Follow
since May 28, 2002
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
0
Received in last 30 days
0
Total given
0
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Gaurav Saxena

Ok I got it running.It took a while to figure out what the issue was....
The Verion of javaassist.jar that i was using was an old one. Downloaded the latest version from this url and replaced the old one with the new one lib directory and it started working.

download javaassist url : http://www.java2s.com/Code/Jar/jboss-5.0.0.Beta2/Downloadjavassistjar.htm

Cheers!
Gaurav
I am on the basics itself. I have no idea what this file does, but without it it was throwing some other runtime exception. And in some forum it was suggested to put this file in the classpath. SO that exception was gone, and this new exception was thrown at runtime.
I guess javassist is required for using Java Persistence API with Annotated classes.
I am trying that helloworld example in 2nd chapter of Java Persistence with Hibernate book. Finished of the basic helloworld thing using hibernate.
Moved on to trying the same helloworld thing using Java Persistence and hibernate using annotations . Thats where I am stuck for a long long time.
.
thanks for the reply! Yeah I think I got too many jars in my lib and probably JVM is picking up one that it is not supposed to pick up. Anyways, I am doing this hibernate thing for the first time and did'nt have no idea about the jars to be used so put a lot of jar files in lib. Here is a list
ant-1.6.5.jar
ant-antlr-1.6.5.jar
ant-junit-1.6.5.jar
ant-launcher-1.6.5.jar
antlr.license.txt
antlr-2.7.6.jar
ant-swing-1.6.5.jar
apache.license.txt
apache.license-2.0.txt
asm.jar
asm-attrs.jar
c3p0.license.txt
c3p0-0.9.1.jar
cglib-2.1.3.jar
checkstyle-all.jar
classes12.zip
cleanimports.jar
commons-collections-2.1.1.jar
commons-logging-1.0.4.jar
concurrent-1.3.2.jar
connector.jar
connector.licence.txt
dom4j-1.6.1.jar
ehcache-1.2.3.jar
ejb3-persistence.jar
hibernate3.jar
hibernate-annotations.jar
hibernate-commons-annotations.jar
hibernate-entitymanager.jar
hibernate-tools.jar
hsqldb.jar
javassist.jar
jboss-common.jar
jta.jar
log4j-1.2.11.jar
mysql-connector-java-5.1.5-bin.jar
xml-apis.jar

I dont know which ones are the required ones and which ones are redundant. Using eclipse 3.2.2 and Ant to build and run the helloworld example.
Can you please let me know which jar files can be removed from the above list?
And thanks a tonne for the response Cameron!
Hi All
I am new to hibernate and EJB 3.0 persistence. Getting following error when i try to run the example from 2nd chapter of book EJB 3.0 persistence with hibernate

Exception in thread "main" java.lang.NoSuchMethodError: javassist.bytecode.AnnotationsAttribute.getAnnotation(Ljava/lang/String Ljavassist/bytecode/annotation/Annotation;
[java] at org.hibernate.ejb.packaging.JarVisitor.checkAnnotationMatching(JarVisitor.java:342)
[java] at org.hibernate.ejb.packaging.JarVisitor.executeJavaElementFilter(JarVisitor.java:298)
[java] at org.hibernate.ejb.packaging.JarVisitor.addElement(JarVisitor.java:259)
[java] at org.hibernate.ejb.packaging.ExplodedJarVisitor.getClassNamesInTree(ExplodedJarVisitor.java:54)
[java] at org.hibernate.ejb.packaging.ExplodedJarVisitor.getClassNamesInTree(ExplodedJarVisitor.java:62)
[java] at org.hibernate.ejb.packaging.ExplodedJarVisitor.doProcessElements(ExplodedJarVisitor.java:45)
[java] at org.hibernate.ejb.packaging.JarVisitor.getMatchingEntries(JarVisitor.java:241)
[java] at org.hibernate.ejb.Ejb3Configuration.addMetadataFromVisitor(Ejb3Configuration.java:271)
[java] at org.hibernate.ejb.Ejb3Configuration.configure(Ejb3Configuration.java:240)
[java] at org.hibernate.ejb.HibernatePersistence.createEntityManagerFactory(HibernatePersistence.java:120)
[java] at javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:51)
[java] at javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:33)
[java] at hello.HelloWorld.session1(Unknown Source)
[java] at hello.HelloWorld.main(Unknown Source)
[java] Java Result: 1

There is no compilation error. Am i missing some jar file?

Regards
Gaurav
Hi JoJo i tried to set the compiler options as indicated in your post but it still does'nt work for me......I m using JDK1.5 on windows XP machine and xmlbeans version 2.2.0......any idea what could be wrong
here is the stack trace..


at java.lang.Runtime.exec(Unknown Source)
at java.lang.Runtime.exec(Unknown Source)
at org.apache.xmlbeans.impl.tool.CodeGenUtil.externalCompile(CodeGenUtil
.java:231)
at org.apache.xmlbeans.impl.tool.SchemaCompiler.compile(SchemaCompiler.j
ava:1126)
at org.apache.xmlbeans.impl.tool.SchemaCompiler.main(SchemaCompiler.java
:368)
BUILD FAILED

Please help!
Hi Sri
The books you have seen were probably written to cater to SCJP 1.2 requirements. As of SCJP 1.4 all these things have been left out.
And anyways information at Sun's site should be trusted more than any thing else when it comes to Java and Java related technologies
Cheers!!
Ok Ernest as you say
---------------------------------------------------------------------------No copies are made of the constants (other than copies that are inlined into code.) When a class implements an interface, the compiler doesn't copy the interface's constants into that class; there's just one set of static values associated with the interface itself.
---------------------------------------------------------------------------
then why is it discouraged to have static Constants in an interface and then let all the required files implement that interface? I believe one of the reasons is that if you modify the value of constants in the interface then all the classes implementing the interface will have to be recompiled in order to access the modified constants. But on the other hand if u place all the static constants in a normal java class then modification of the constants' value will not require the classes using this class to be recompiled. Is that true? Will be of gr8 help if u can throw some more light on what exactly goes on behind the scenes when a class extends another class or implements an interface.
regards
16 years ago
Hi all
Sorry if i've posted this in wrong place(I beleive it shud be posted in advance java ) anyways lets continue....
I know it's a bad practice - to declare Constants in an interface and then implement that interface in the classes using those constants. But thats a different topic for discussion. I've come across a peculiar situation, a framework to be precise which is as follows :-

1. There is a Base Interface Say A - This interface has "n" no. of String Constants used in the application and absolutely no methods at all. Sample code is as follows
public interface A{
String AAA = "abc";
String BBB = "def";
String CCC = "ghi";
....
....
}

2. There are two more interfaces B and C. Both B and C extend interface A and both have different sets of methods.

public interface B extends A{
String method A() throws SomeException;
void method B(ParamA a, ParamB b) throws SomeException;
String method C(ParamC c) throws SomeException;
}

public interface C extends B{
String method D(ParamE e, ParamF f) throws SomeException;
}

The above three interfaces are a part of the basic framework which the application uses for customization according to different situations.

3. now there is a Class say Class X which is required to implement both interfaces as it has to implement both sets of methods.

Class X implements B,C{
.........
.........
}

My question is - "How will the Java Compiler treat all the String variables declared in Interface A, when we compile the Class X?
As Both interfaces B and C extend A, and X implemets both B and C,will the Class X actually be getting each Variable of interface A twice - once thru the inheritance tree A-->B-->X and second time thru the inheritance tree
A-->C-->X"
All i can say is it's bad and Confusing design according to me...
Can some one throw some light on what happens behind the scenes when class X is compiled?
Thanx and Regards
Gaurav
16 years ago
All
I have written a JUnit test client to test my session bean.After deploying the session bean in the Weblogic 8.11 and running the JUnit test client i am getting the following error.

java.rmi.RemoteException: EJB Exception: ; nested exception is:
java.lang.NoClassDefFoundError
at weblogic.rjvm.BasicOutboundRequest.sendReceive(BasicOutboundRequest.java:108)
at weblogic.rmi.cluster.ReplicaAwareRemoteRef.invoke(ReplicaAwareRemoteRef.java:284)
at weblogic.rmi.cluster.ReplicaAwareRemoteRef.invoke(ReplicaAwareRemoteRef.java:244)
at tavant.app.asap.stipengine.session.StipulationDelinquencySessionBean_oor940_EOImpl_811_WLStub.prepareListOfStipsinOpe
nState(Unknown Source)
at tavant.app.asap.stipengine.tests.junit.StipulationDelinquencySessionTest.testPrepareListOfStipsinOpenState(Stipulatio
nDelinquencySessionTest.java:117)
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 junit.framework.TestCase.runTest(TestCase.java:154)
at junit.framework.TestCase.runBare(TestCase.java:127)
at junit.framework.TestResult$1.protect(TestResult.java:106)
at junit.framework.TestResult.runProtected(TestResult.java:124)
at junit.framework.TestResult.run(TestResult.java:109)
at junit.framework.TestCase.run(TestCase.java:118)
at junit.framework.TestSuite.runTest(TestSuite.java:208)
at junit.framework.TestSuite.run(TestSuite.java:203)
at junit.textui.TestRunner.doRun(TestRunner.java:116)
at junit.textui.TestRunner.start(TestRunner.java:172)
at junit.textui.TestRunner.main(TestRunner.java:138)
Caused by: java.lang.NoClassDefFoundError
at tavant.app.asap.stipengine.entity.utils.StipulationEntityProxy.getLoanStipSLAHome(StipulationEntityProxy.java:70)
at tavant.app.asap.stipengine.session.StipulationDelinquencySessionBean.prepareListOfStipsinOpenState(StipulationDelinqu
encySessionBean.java:170)
at tavant.app.asap.stipengine.session.StipulationDelinquencySessionBean_oor940_EOImpl.prepareListOfStipsinOpenState(Stip
ulationDelinquencySessionBean_oor940_EOImpl.java:46)
at tavant.app.asap.stipengine.session.StipulationDelinquencySessionBean_oor940_EOImpl_WLSkel.invoke(Unknown Source)
at weblogic.rmi.internal.BasicServerRef.invoke(BasicServerRef.java:466)
at weblogic.rmi.cluster.ReplicaAwareServerRef.invoke(ReplicaAwareServerRef.java:108)
at weblogic.rmi.internal.BasicServerRef$1.run(BasicServerRef.java:409)
at weblogic.security.acl.internal.AuthenticatedSubject.doAs(AuthenticatedSubject.java:353)
at weblogic.security.service.SecurityManager.runAs(SecurityManager.java:144)
at weblogic.rmi.internal.BasicServerRef.handleRequest(BasicServerRef.java:404)
at weblogic.rmi.internal.BasicExecuteRequest.execute(BasicExecuteRequest.java:30)
at weblogic.kernel.ExecuteThread.execute(ExecuteThread.java:197)
at weblogic.kernel.ExecuteThread.run(ExecuteThread.java:170)
[StipulationDelinquencySessionTest:testPrepareListOfStipsinOpenState():End]

Please help
Thanx and Regards
Gaurav
17 years ago
Basic difference between An Application Server and a web erver is that A Web server has no support for running EJBs. It Only provieds support for running web-applications (having JSPs, Servlet, plain Java classes etc.). If at all your application requires Support for Enterprise Java Beans then to host your EJBs you require an Application server.
thats the most basic difference bn. and Appserver and a Web-Server.For more information try a lil bit of googling and browse thru java.sun.com.
17 years ago
hey ashok
First read the Java docs properly. All ur basic doubts will get cleared. If at all you still have doubts you r most welcome here!
17 years ago
Hi Ashok
This is what the definition of transient says -
"Transient instance fields are neither saved nor restored by the standard serialisation mechanism". So if at all u want some field to be serialized dont make it as transient/static in the first place.
Hope it clears ur doubt
Gaurav
17 years ago
A bit more efficient would be
code:
--------------------------------------------------------------------------------

public class MyImmutableClass { private final List data; MyImmutableClass(final List inData) { data = Collections.unmodifiableList(new ArrayList(inData)); } public List getData() { return data; }}

--------------------------------------------------------------------------------

Obviously this is immutable iff the objects you've put in "inData" are...

- Peter

Hi peter
Are you trying to say that if the List <b>inData</b> contains objects that are mutable then MyImmutableClass will not really be immutable?
Please clarify
17 years ago
Hi all
First of all i dont know whether this question shud be posted here or in some other forum. My apologies in advance if this is not the forum for this question.
Coming back to my point. the questions are
1. Why do we need the String objects to be immutable?
2. Can i have a class (say MyClass) and make it immutable? If yea then can any one throw some light on how this can be done?
Thanx in advance
Gaurav
17 years ago