Friday, April 5, 2013

Solution for De-serialization problem in EJB entity from a remote client!

In my previous post , I had a problem in calling remote EJB entity from a remote client. The problem was, when retrieving an object from a data base and return to the client CORBA MARSHALING exception is being thrown. Because, may be the entity retrieved and returned to client can't be de-serialized in the same way as the server.  For overcoming this problem, I spent many hours. There are many posts available in web just mentioning the problem and suggesting their idea, but not really a solution.
Finally, I just separate the entity class as java application and add to all EJB session beans, Interfaces, and Client application (web application). With this, it works perfectly. Nevertheless, I don't think this is better solution. This gives access to entity beans for the client.
I am still searching for a better solution.:) 

Wednesday, April 3, 2013

De-Serialization problem in EJB remote client and server using JPA

When I try to retrieve an object passed as a list or so from session bean to a client side application say action class in struts 2 concept, De-Serialization problem occurred. I googled a lot, but no one has came with tangible solution.

Here below the full stack trace of the glass fish server.
WARNING: IOP00810011: Exception from readValue on ValueHandler in CDRInputStream
org.omg.CORBA.MARSHAL: WARNING: IOP00810011: Exception from readValue on ValueHandler in CDRInputStream  vmcid: OMG  minor code: 11 completed: Maybe
 at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
 at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:57)
 at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
 at java.lang.reflect.Constructor.newInstance(Constructor.java:525)
 at com.sun.corba.ee.spi.orbutil.logex.corba.CorbaExtension.makeException(CorbaExtension.java:248)
 ......
 at org.mk.rc.intf.__PublicationBeanRemote_Remote_DynamicStub.searchPublication(org/mk/rc/intf/__PublicationBeanRemote_Remote_DynamicStub.java)
 at org.mk.rc.intf._PublicationBeanRemote_Wrapper.searchPublication(org/mk/rc/intf/_PublicationBeanRemote_Wrapper.java)
 at org.mk.rc.actions.PublicatonAction.searchPublication(PublicatonAction.java:43)
 at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
 at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
 at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
......
 at com.opensymphony.xwork2.interceptor.ModelDrivenInterceptor.intercept(ModelDrivenInterceptor.java:100)
 at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:249)
 ......
atThreadPool$Worker.run(AbstractThreadPool.java:513)
 at java.lang.Thread.run(Thread.java:722)
Caused by: java.lang.NullPointerException
 at com.sun.corba.ee.impl.orbutil.ClassInfoCache$ClassInfo.(ClassInfoCache.java:156)
.....
 at com.sun.corba.ee.impl.io.ValueHandlerImpl.readValue(ValueHandlerImpl.java:274)
 at com.sun.corba.ee.impl.encoding.CDRInputStream_1_0.readRMIIIOPValueType(CDRInputStream_1_0.java:1015)
 ... 96 more

I don't solved it yet. I hope soon :)

Tuesday, March 26, 2013

An annotation processor threw an uncaught exception.

When compiling a EJB project there might be a case in which the java EE API comes before eclipseLink API in the class path. Hence the following error may be generated.

An annotation processor threw an uncaught exception.
Consult the following stack trace for details.
java.lang.ClassFormatError: Absent Code attribute in method that is not native or abstract in class file javax/persistence/PersistenceException
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClassCond(ClassLoader.java:632)
.....
at org.netbeans.core.execution.RunClassThread.run(RunClassThread.java:153)
../..//nbproject/build-impl.xml:839: The following error occurred while executing this line:
../../nbproject/build-impl.xml:258: Compile failed; see the compiler error output for details.
BUILD FAILED (total time: 1 second)

The solution is simple:-) Just make the eclipseLink API first in the project libraries configuration. 

Monday, March 25, 2013

javax.naming.NameNotFoundException: org.mk.rc.intf.StaffsBeanRemote

When calling an EJB, I got an error like the following....

com.sun.enterprise.container.common.spi.util.InjectionException: Exception attempting to inject Remote ejb-ref name=org.mk.rc.client.Client/staffsBean,Remote 3.x interface =org.mk.rc.intf.StaffsBeanRemote,ejb-link=null,lookup=,mappedName=,jndi-name=org.mk.rc.intf.StaffsBeanRemote,refType=Session into class org.mk.rc.client.Client: Lookup failed for 'java:comp/env/org.mk.rc.client.Client/staffsBean' in SerialContext[myEnv={java.naming.factory.initial=com.sun.enterprise.naming.impl.SerialInitContextFactory, java.naming.factory.url.pkgs=com.sun.enterprise.naming, java.naming.factory.state=com.sun.corba.ee.impl.presentation.rmi.JNDIStateFactoryImpl}
at com.sun.enterprise.container.common.impl.util.InjectionManagerImpl._inject(InjectionManagerImpl.java:703)
at com.sun.enterprise.container.common.impl.util.InjectionManagerImpl.inject(InjectionManagerImpl.java:470)
....

Caused by: javax.naming.NameNotFoundException: org.mk.rc.intf.StaffsBeanRemote#org.mk.rc.intf.StaffsBeanRemote not found
at com.sun.enterprise.naming.impl.TransientContext.doLookup(TransientContext.java:248)
at com.sun.enterprise.naming.impl.TransientContext.lookup(TransientContext.java:215)
..... 

The problem is, I didn't add StaffsBeanRemote bean name to application-client.xml file. Just add as follow and works fine. 

<ejb-ref>
    <ejb-ref-name>StaffsBean</ejb-ref-name>
    <ejb-ref-type>Session</ejb-ref-type>
    <remote>org.mk.rc.intf.StaffsBeanRemote</remote>
 </ejb-ref>

Enjoy :-)


Saturday, March 23, 2013

The module has not been deployed.

When I tried to use Hibernate (JPA 2.0) as a persistence provider in glasfish 3.x application server , I encountered the following problem and my EJB application can't be deployed.


Initializing...
deploy?DEFAULT=/home/alemnew/NetBeansProjects/LMS-ejb/build/classes&name=LMS-ejb&libraries=/home/alemnew/NetBeansProjects/LMSRemote/dist/LMSRemote.jar,/home/alemnew/NetBeansProjects/LMS-ejb/lib/ejb3-persistence.jar,/home/alemnew/NetBeansProjects/LMS-ejb/lib/hibernate-annotations.jar,/home/alemnew/NetBeansProjects/LMS-ejb/lib/hibernate-commons-annotations.jar,/home/alemnew/NetBeansProjects/LMS-ejb/lib/hibernate-validator.jar,/home/alemnew/NetBeansProjects/LMS-ejb/lib/hibernate3.jar,/home/alemnew/NetBeansProjects/LMS-ejb/lib/hsqldb.jar&force=true failed on GlassFish Server 3.1.2 
 Error occurred during deployment: Exception while preparing the app : java.lang.ClassNotFoundException: org.hibernate.ejb.HibernatePersistence. Please see server.log for more details.
/home/alemnew/NetBeansProjects/LMS-ejb/nbproject/build-impl.xml:971: The module has not been deployed.
See the server log for details.
BUILD FAILED (total time: 1 second)
=========================================

As a temporary solution I used eclipseLink (JPA 2.0) instead.  The problem seams like, glassfish doesn't have Hibernate as a persistence provider by default. Hence, manual operation is needed, I think. I will try to solve......

Monday, February 18, 2013

Wifi connection failed problem in Ubuntu 12.04

I have been getting "connection failed activation failed" problem for a days while connecting to some WAP. I have been searching a bit on internet and different peoples suggest  different solutions. Finally I got one post in ubuntu forum says re-install : sudo apt-get install  --reinstall bcmwl-kernel-source, then I tried but failed. I removed sudo apt-get remove cmwl-kernel-source and works fine.


Friday, January 4, 2013

File permissions


Setting Permissions

The chmod command uses as an argument a string which describes the permissions for a file. The permission description can be in the form of a number that is exactly three digits. Each digit of this number is a code for the permissions level of three types of people that might access this file:
  1. Owner (you)
  2. Group (a group of other users that you set up)
  3. World (anyone else browsing around on the file system)
The value of each digit is set according to what rights each of the types of people listed above have to manipulate that file.
Permissions are set according to numbers. Read is 4. Write is 2. Execute is 1. The sums of these numbers give combinations of these permissions:
  • 0 = no permissions whatsoever; this person cannot read, write, or execute the file
  • 1 = execute only
  • 2 = write only
  • 3 = write and execute (1+2)
  • 4 = read only
  • 5 = read and execute (4+1)
  • 6 = read and write (4+2)
  • 7 = read and write and execute (4+2+1)
Permissions are given using these digits in a sequence of three: one for owner, one for group, one for world.
Let's look at how I can make it impossible for anyone else to do anything with my apple.txt file but me:
$ chmod 700 apple.txt
$

http://www.december.com/unix/tutor/permissions.html
http://codex.wordpress.org/Changing_File_Permissions