Akshay Sahu

Greenhorn
+ Follow
since Sep 04, 2009
Akshay likes ...
Netbeans IDE Java
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
5
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 Akshay Sahu

Hello All,

I wrote a shell script to move files from one folder to other. (Say folder1 to folder2 and say I am trying to move 2000 files)

Now when I am executing the shell script directly, I am able to move all the files from folder1 to folder2.
When I am executing the same shell script from a standalone Java Program (Runtime.getRuntime().exec()), even then I am able to move all the files from folder1 to folder2.

But whenever I am executing the same java program from within a servlet, I am able to move only 500-688 files at one stretch.

Can anyone help me with this ? Does any process, getting executed from JVM will have a default timeout period.

Thanks and Regards,
Akshay Sahu
8 years ago
Encapsulation: Encapsulation is defined as a process of wrapping methods and variables as a single entity or unit (whatever you prefer calling it ... )
In simpler terms:

Imagine around 1000 classes using the above class. Now what if I rename the variable value to integerValue, The code will surely not break because the only way to access the value of the variable value is via the method getValue and thus any changes made to the variable will not break the code. This thus defines encapsulation as a process of wrapping methods and variables as a single unit (I prefer calling it a UNIT).This actually is an example of Strong Encapsulation.

Now coming to
Abstraction: Abstraction is defined as a process of hiding implementation data from the usage area.

I have written Class A above and after its compilation I'll get a .class file (Please correct me if I am wrong !!!).I'll jar the .class file and will use the jar for application development.

After some years, I resign from my organization and a new employee joins and he is now been made to work on the same application. Somewhere in his code, he wants to use Class A's getValue() method. And without hesitating a bit, he imports Class A and calls its getValue() method.
This new developer is now using the getValue() method without actually knowing its implementation code.

Thus exemplifiring the concept of Abstraction.
Generally an API is used for Abstraction.
9 years ago
Hi,

If I write
Class TestGeneric<E extends String> {}

The compiler allows me to compile this. This shouldn't be allowed as final classes can neither be extended nor can be implemented.

I just want to know why is the compiler allowing that syntax to be valid.


Thanks and Regards,
Akshay Sahu
10 years ago
Hi Prateek Garodia ,

Please look into https://coderanch.com/t/536756/EJB-JEE/java/SOA-EJB this for information on EJB 3 and SOA.



Regards,
Akshay Sahu
Hi,

1. EJB 3 Interceptors can have method annotated @PostConstruct (Applicable for Stateless and Stateful Session Beans).

2. Write your observer update code into the post construct method that automatically updates the value at your desired location.
Hi,

Injection of an enterprise bean in a non-managed POJO is not possible.

If you're trying for something say

@EJB
private SampleSessionLocal sessionLocal;


in a simple java class, which comes after your servlet takes the input from the client,
then the container would obviously throw a Null Pointer Exception.

As far as I know, an enterprise bean can be injected into the following managed java objects:
1. Another Enterprise Bean ( EJB 2 or EJB 3 compatible).
2. A Servlet
3. JSF class.

I am not sure about the JSF thing, but the first two things are for sure.

Regards,
Akshay Sahu
Hi Raj Parthas,

EJB 3 has internal support for Java Web Services.

Following is the way to expose your EJB 3 compatible enterprise bean as a web service:

import javax.jws.*;
import javax.ejb.Stateless;

@WebService
@Stateless
class SampleRemoteInterface {
@WebMethod
public void sample(String str) {
// Something good should be done here.
}
}


1. Just build your EAR file and deploy it into any of the container available.
2. According to EJB 3 Specification, every container should take the definition from the class file and create a wsdl file for it.
3. The container will generate a wsdl URL for you, which can be accessed either from Axis2 or Java 6 SDK.
4. To know more about EJB 3 SOA, just search for @WebService and @WebMethod support on EJB3.

Regards,
Akshay Sahu
Hi Tomasz Wolak,

In EJB 3.0, except for the enterprise bean type value, every annotation enabled configuration is overriden by ejb-jar.xml file configurations.

Example:
An enterprise bean annotated stateless cannot be overriden as Stateful at ejb-jar.xml file.


Your query, code and question looks ambigious to me.

I request you to be more clear in your question so that I can help you out ... !!!

Senthil Kumar Sekar wrote:Please clarify my below points

1) What is Glass Fish,Sun application server?
2) When i download sdk for jee from Sun site,i get any of these depending on the version of jee i download.
3) So,Its enough to install any app server like Sun App. Server,JBoss etc., to get sdk for jee to be installed.
4) After installing any app. server, i just need to add the server in eclipse which will take care of the sdk and run time.Is it?



1. JEE SDK is nothing more than an app server which contains jar files for supporting the execution of servlets, jsps and ejbs.
2. The same support will be provided by any container like Tomcat (Only JSP, Servlets, Struts), JBOSS, BEA Weblogic, IBM Websphere.
3. Just install those servers or if portable version is available, then keep them somewhere and pass that location to eclipse.
4. After configuring the server at eclipse, whenever you create a new web, ejb project, just use your app server as your execution server.
5. Eclipse will deploy your projects in that server and you can use it without installing JEE SDK.
6. So finally it is clear that for executing JEE projects, it is not mandatory to install Sun JEE SDK.

Regards,
Akshay Sahu

Senthil Kumar Sekar wrote:Hi All,
Iam new to J2EE.
I have a basic question.Iam aware that jdk is required to compile,run etc., the java classes.
I have a basic question.What is the purpose of installing j2ee sdk.Is this mandatory if i have Eclipse installed in my pc for the development?

Thanks.

Regards
Senthil Kumar Sekar



J2EE requires a separate environment for Servlets, JSPs, EJBs, as their API is not recognized by JSE JDK.
If you do not have the runtime environment for these frameworks, then you cannot execute them.

Installation of JEE would mean installation of Sun Servers on your system.
Instead of that, you can also download any vendor-specific server and place it in your system. And pass the location of it to eclipse.
Eclipse will then take care of all the JEE requirements for you.
I am a new guy to Dependency injection and I have tried something different. Can anyone please help me out...!!!

I have a web application with following requirements:

1. People will write the name of the class in an xml file.
2. They will also write their variable name in the same xml, for which you have to load a string value.

I have done something like this:

1. I have written a startup servlet, where I am loading the xml file location as a stream.
2. Using DOM, I am parsing the xml file and fetching all the required data.
3. In my dependency injection class, I am first loading the class as follows:

Class actualClass = Class.forName(classValueInXML):
Object actualObject = actualClass.newInstance();
Field acutalField = actualClass.getDeclaredField("Stranger");
actualField.set(actualObject, "I am an stranger");


4. The above code is running absolutely fine.
5. Now when I am trying to execute the same file by calling it from some other place, then it says, Stranger not initialized. NullPointerException.

I am new to this. Please anyone, help me !!!

Thanks in Advance !!!

Akshay Sahu





10 years ago
Yes guys, I have solved it for myself.


The solution is:


1. The default name of mapping file in EJB 3 is orm.xml. So in persistence.xml file, if I provide the <mapping-file> name as orm.xml, then the container deploys the same orm.xml twice. So I renamed my orm.xml file to mapping.xml file. The error is gone now.


2. Instead of renaming it to some other name, remove <mapping-file> element from persistence.xml file, then also it will work as the container treats orm.xml as the default mapping file, and even though you do not make an entry of that in persistence.xml file, the container loads it.


Thanks 2 my self
Hi,

My Persistence.xml file:

<persistence-unit name="CSP" transaction-type="JTA">
<provider>org.hibernate.ejb.HibernatePersistence</provider>
<jta-data-source>java:/CSP</jta-data-source>
<mapping-file>/META-INF/orm.xml</mapping-file>
<properties>
<property name="hibernate.hbm2ddl.auto" value="update"/>
<property name="toplink.logging.level" value="FINE" />
<property name="hibernate.show-sql" value="true" />
</properties>
</persistence-unit>

My orm.xml file:

<entity class="com.entity.CustomerDetails" name="CustomerProfile">
<table name="CUSTOMER_DETAILS" schema="dbo" />
<attributes>
<id name="CustomerId">
<column name="CUSTOMER_ID" insertable="true" />
<generated-value strategy="IDENTITY" />
</id>
<basic name="PartnerId" optional="true" fetch="LAZY">
<column name="PARTNER_ID" nullable="true" insertable="true" />
</basic>
<basic name="activationStatus" optional="false" fetch="EAGER">
<column name="ACTIVATION_STATUS" nullable="false" insertable="true" length="10" />
</basic>
<basic name="customerType" optional="false" fetch="EAGER">
<column name="CUSTOMER_TYPE" nullable="false" insertable="true" length="10" />
</basic>
<basic name="notes" optional="true" fetch="LAZY">
<column name="NOTES" nullable="true" insertable="true" length="300"/>
</basic>
<basic name="createdDate" optional="true" fetch="LAZY">
<column name="CREATED_DATE" nullable="true" insertable="true" />
</basic>
<basic name="updatedDate" optional="true" fetch="LAZY">
<column name="UPDATED_DATE" nullable="true" insertable="true" />
</basic>
<basic name="createdByUserId" optional="true" fetch="LAZY">
<column name="CREATED_BY_USER_ID" nullable="true" insertable="true" />
</basic>
<basic name="updatedByUserId" optional="true" fetch="LAZY">
<column name="UPDATED_BY_USER_ID" nullable="true" insertable="true" />
</basic>
</attributes>
</entity>

Even though I am not deploying it twice, JBoss 5 throws an exception stating
that

java.lang.IllegalStateException: Duplicate XML entry for com.entity.CustomerDetails

I don't know, where am I going wrong.

Any help, highly appreciated. !!!

Thank You,
Akshay Sahu
Mikalai Zaikin,

Your book was awesome. I can't see any question in the exam, coming from some other book. I have given the book to all my colleagues at my office. And even they have praised the book.

I have a request for you, please add explanation for Session Beans - web service technology. Which is currently not available in your book. And please make Message Driven Beans explanation more elaborative.

Other than these, your book was mind blowing.

Thank you very much for creating this book. I don't know how many more will get BCD certified, because of your book.


CHeers,
Akshay Sahu
Hi guys,

Yesterday I became Oracle Certified on EJB 3. I was able to secure 93% score. Majority of my marks went off due to Message Driven Beans.

First I wanna thank God for bestowing his blessings on to me.

Secondly, I wanna thank Milkian Mikalai Zaikin.

The book what he wrote was very helpful. His study guide was superb and I recommend this book to all the BCD aspirants.

Thank you all once again for providing me with improtant inputs at the right time.

Cheers,
Akshay Sahu