Thursday, August 23, 2012

Error invalid LOC header (bad signature) | jar binary


The Jar files custom or out of the box is important to be checked in as binary file into the version control system. If you check them into CVS or SVN as text files. It usually not a problem if your build process is on windows as windows is more forgiving about the file types checked in. If you use Linux or any UNIX based CVS\SVN servers. The build would through up with the error as below. The fix is either to override and check in the jar files as binary files or run some commands to change the type of the JAR files in CVS.


this is the error i am getting
[accessBeanRegeneration] +++ Warning +++:  java.lang.InternalError: jzentry == 0,
[accessBeanRegeneration]      jzfile = 164252568,
[accessBeanRegeneration]      total = 5,
[accessBeanRegeneration]      name = C:\WCToolkitEE60\workspace\WC\lib\custom\trimflt.jar,
[accessBeanRegeneration]      i = 1,
[accessBeanRegeneration]      message = invalid LOC header (bad signature)
[accessBeanRegeneration]      at java.util.zip.ZipFile$2.nextElement(ZipFile.java(Compiled Code))
[accessBeanRegeneration]      at org.eclipse.jdt.internal.core.JarPackageFragmentRoot.computeChildren(JarPackageFragmentRoot.java(Compiled Code))
[accessBeanRegeneration]      at org.eclipse.jdt.internal.core.PackageFragmentRoot.buildStructure(PackageFragmentRoot.java(Compiled Code))
[accessBeanRegeneration]      at org.eclipse.jdt.internal.core.Openable.generateInfos(Openable.java(Compiled Code))
[accessBeanRegeneration]      at org.eclipse.jdt.internal.core.JavaElement.openWhenClosed(JavaElement.java(Compiled Code))

Tuesday, August 7, 2012

When is this file created ***Factory.java during the EJB creation process?

Answer after the access bean is created. If you haven't created entity bean for a while like me and you could almost forget. If you are looking at creating access bean for a session bean. It does not work with copy helper and you have to select the Java bean wrapper. After the access bean is created for session bean using New wizard, and select EJB > Access Bean and click Next.


Select the appropriate bean type for the session bean in this case would be Java bean wrapper.



Once you are done with the wizard, it creates the ****AccessBean.java and ***Factory.java and ibm-ejb-access-bean.xmi is updated.
Sample block from ibm-ejb-access-bean.xmi

If you just need to regenerate access beans, you can do the following and then deploy.

Java EE->AccessBeans --> Regenerate access beans
Java EE->Prepare for Deployment.


Just want to also quickly touch upon why access beans are required?
Access beans provide a simpler interface to clients, caching of the home object, and reduced call traffic to the enterprise bean and also encapsulates all the complex logic.
At run time the access bean caches the enterprise bean home object because look ups to the home object are expensive, in terms of time and resource usage.
The access bean implements a copyHelper object that reduces the number of calls to the enterprise bean when commands get and set enterprise bean attributes. Only a single call to the enterprise bean is required when reading or writing multiple enterprise bean attributes.

Reference:
http://publib.boulder.ibm.com/infocenter/wchelp/v6r0m0/topic/com.ibm.commerce.developer.doc/concepts/csdaccessbeans.htm