Sunday, January 31, 2016

if you suffer of "slow favorites menu" in IE

if you suffer of "slow favorites menu" when you pass the mouse over, in IE, this fixed my problem:

In Control Panel, Folder Options, View tab, scroll to the bottom and uncheck “Show pop-up description for folders and desktop items”.
IE is a 1800 pound pig like this one http://weeklyworldnews.com/headlines/25815/1800-pound-pig/ , but please don't kill pigs, just use Firefox instead!


Tuesday, January 19, 2016

WebLogic deployment fails with java.lang.ArrayIndexOutOfBoundsException in com.bea.objectweb.asm.ClassReader.readClass

BEA-149205 Failed to initialize the application "BLA" due to error weblogic.application.ModuleException: 26
26
weblogic.application.ModuleException: 26
26
 at weblogic.servlet.internal.WebAppModule.createModuleException(WebAppModule.java:1824)
 at weblogic.servlet.internal.WebAppModule.init(WebAppModule.java:270)
 at weblogic.servlet.internal.WebAppModule.init(WebAppModule.java:682)
 at weblogic.application.internal.flow.ScopedModuleDriver.init(ScopedModuleDriver.java:162)
 at weblogic.application.internal.ExtensibleModuleWrapper.init(ExtensibleModuleWrapper.java:98)
 at weblogic.application.internal.flow.ModuleListenerInvoker.init(ModuleListenerInvoker.java:84)
 at weblogic.application.internal.flow.InitModulesFlow.initModule(InitModulesFlow.java:288)
 at weblogic.application.internal.flow.InitModulesFlow.initModules(InitModulesFlow.java:301)
 at weblogic.application.internal.flow.InitModulesFlow.prepare(InitModulesFlow.java:329)
 at weblogic.application.internal.BaseDeployment$1.next(BaseDeployment.java:706)
 at weblogic.application.utils.StateMachineDriver.nextState(StateMachineDriver.java:42)
 at weblogic.application.internal.BaseDeployment.prepare(BaseDeployment.java:237)
 at weblogic.application.internal.EarDeployment.prepare(EarDeployment.java:61)
 at weblogic.application.internal.DeploymentStateChecker.prepare(DeploymentStateChecker.java:158)
 at weblogic.deploy.internal.targetserver.AppContainerInvoker.prepare(AppContainerInvoker.java:61)
 at weblogic.deploy.internal.targetserver.AppDeployment.prepare(AppDeployment.java:155)
 at weblogic.management.deploy.internal.DeploymentAdapter$1.doPrepare(DeploymentAdapter.java:39)
 at weblogic.management.deploy.internal.DeploymentAdapter.prepare(DeploymentAdapter.java:191)
 at weblogic.management.deploy.internal.AppTransition$1.transitionApp(AppTransition.java:21)
 at weblogic.management.deploy.internal.ConfiguredDeployments.transitionApps(ConfiguredDeployments.java:240)
 at weblogic.management.deploy.internal.ConfiguredDeployments.prepare(ConfiguredDeployments.java:165)
 at weblogic.management.deploy.internal.ConfiguredDeployments.deploy(ConfiguredDeployments.java:122)
 at weblogic.management.deploy.internal.DeploymentServerService.resume(DeploymentServerService.java:210)
 at weblogic.management.deploy.internal.DeploymentServerService.start(DeploymentServerService.java:118)
 at weblogic.server.AbstractServerService.postConstruct(AbstractServerService.java:78)
 at sun.reflect.GeneratedMethodAccessor6.invoke(Unknown Source)
 at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
 at java.lang.reflect.Method.invoke(Method.java:606)
 at org.glassfish.hk2.utilities.reflection.ReflectionHelper.invoke(ReflectionHelper.java:1017)
 at org.jvnet.hk2.internal.ClazzCreator.postConstructMe(ClazzCreator.java:388)
 at org.jvnet.hk2.internal.ClazzCreator.create(ClazzCreator.java:430)
 at org.jvnet.hk2.internal.SystemDescriptor.create(SystemDescriptor.java:456)
 at org.glassfish.hk2.runlevel.internal.AsyncRunLevelContext.findOrCreate(AsyncRunLevelContext.java:225)
 at org.glassfish.hk2.runlevel.RunLevelContext.findOrCreate(RunLevelContext.java:82)
 at org.jvnet.hk2.internal.Utilities.createService(Utilities.java:2488)
 at org.jvnet.hk2.internal.ServiceHandleImpl.getService(ServiceHandleImpl.java:98)
 at org.jvnet.hk2.internal.ServiceLocatorImpl.getService(ServiceLocatorImpl.java:606)
 at org.jvnet.hk2.internal.ThreeThirtyResolver.resolve(ThreeThirtyResolver.java:77)
 at org.jvnet.hk2.internal.ClazzCreator.resolve(ClazzCreator.java:231)
 at org.jvnet.hk2.internal.ClazzCreator.resolveAllDependencies(ClazzCreator.java:254)
 at org.jvnet.hk2.internal.ClazzCreator.create(ClazzCreator.java:413)
 at org.jvnet.hk2.internal.SystemDescriptor.create(SystemDescriptor.java:456)
 at org.glassfish.hk2.runlevel.internal.AsyncRunLevelContext.findOrCreate(AsyncRunLevelContext.java:225)
 at org.glassfish.hk2.runlevel.RunLevelContext.findOrCreate(RunLevelContext.java:82)
 at org.jvnet.hk2.internal.Utilities.createService(Utilities.java:2488)
 at org.jvnet.hk2.internal.ServiceHandleImpl.getService(ServiceHandleImpl.java:98)
 at org.jvnet.hk2.internal.ServiceHandleImpl.getService(ServiceHandleImpl.java:87)
 at org.glassfish.hk2.runlevel.internal.CurrentTaskFuture$QueueRunner.oneJob(CurrentTaskFuture.java:1162)
 at org.glassfish.hk2.runlevel.internal.CurrentTaskFuture$QueueRunner.run(CurrentTaskFuture.java:1147)
 at weblogic.work.SelfTuningWorkManagerImpl$WorkAdapterImpl.run(SelfTuningWorkManagerImpl.java:548)
 at weblogic.work.ExecuteThread.execute(ExecuteThread.java:311)
 at weblogic.work.ExecuteThread.run(ExecuteThread.java:263)
Caused By: java.lang.ArrayIndexOutOfBoundsException: 26
 at com.bea.objectweb.asm.ClassReader.readClass(Unknown Source)
 at com.bea.objectweb.asm.ClassReader.accept(Unknown Source)
 at com.bea.objectweb.asm.ClassReader.accept(Unknown Source)
 at weblogic.application.utils.annotation.ClassInfoImpl.(ClassInfoImpl.java:42)
 at weblogic.application.utils.annotation.ClassfinderClassInfos.polulateOneClassInfo(ClassfinderClassInfos.java:240)
 at weblogic.application.utils.annotation.ClassfinderClassInfos.populateClassInfos(ClassfinderClassInfos.java:193)
 at weblogic.application.utils.annotation.ClassfinderClassInfos.(ClassfinderClassInfos.java:44)
 at weblogic.servlet.internal.War.initializeClassInfosIfNecessary(War.java:446)
 at weblogic.servlet.internal.War.getAnnotatedClasses(War.java:376)
 at weblogic.servlet.utils.WarUtils.isJsfApplication(WarUtils.java:258)
 at weblogic.servlet.internal.WebAppModule.detectJsfApplication(WebAppModule.java:277)
 at weblogic.servlet.internal.WebAppModule.init(WebAppModule.java:262)
 at weblogic.servlet.internal.WebAppModule.init(WebAppModule.java:682)
 at weblogic.application.internal.flow.ScopedModuleDriver.init(ScopedModuleDriver.java:162)
 at weblogic.application.internal.ExtensibleModuleWrapper.init(ExtensibleModuleWrapper.java:98)
 at weblogic.application.internal.flow.ModuleListenerInvoker.init(ModuleListenerInvoker.java:84)
 at weblogic.application.internal.flow.InitModulesFlow.initModule(InitModulesFlow.java:288)
 at weblogic.application.internal.flow.InitModulesFlow.initModules(InitModulesFlow.java:301)
 at weblogic.application.internal.flow.InitModulesFlow.prepare(InitModulesFlow.java:329)
 at weblogic.application.internal.BaseDeployment$1.next(BaseDeployment.java:706)
 at weblogic.application.utils.StateMachineDriver.nextState(StateMachineDriver.java:42)
 at weblogic.application.internal.BaseDeployment.prepare(BaseDeployment.java:237)
 at weblogic.application.internal.EarDeployment.prepare(EarDeployment.java:61)
 at weblogic.application.internal.DeploymentStateChecker.prepare(DeploymentStateChecker.java:158)
 at weblogic.deploy.internal.targetserver.AppContainerInvoker.prepare(AppContainerInvoker.java:61)
 at weblogic.deploy.internal.targetserver.AppDeployment.prepare(AppDeployment.java:155)
 at weblogic.management.deploy.internal.DeploymentAdapter$1.doPrepare(DeploymentAdapter.java:39)
 at weblogic.management.deploy.internal.DeploymentAdapter.prepare(DeploymentAdapter.java:191)
 at weblogic.management.deploy.internal.AppTransition$1.transitionApp(AppTransition.java:21)
 at weblogic.management.deploy.internal.ConfiguredDeployments.transitionApps(ConfiguredDeployments.java:240)
 at weblogic.management.deploy.internal.ConfiguredDeployments.prepare(ConfiguredDeployments.java:165)
 at weblogic.management.deploy.internal.ConfiguredDeployments.deploy(ConfiguredDeployments.java:122)
 at weblogic.management.deploy.internal.DeploymentServerService.resume(DeploymentServerService.java:210)
 at weblogic.management.deploy.internal.DeploymentServerService.start(DeploymentServerService.java:118)
 at weblogic.server.AbstractServerService.postConstruct(AbstractServerService.java:78)
 at sun.reflect.GeneratedMethodAccessor6.invoke(Unknown Source)
 at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
 at java.lang.reflect.Method.invoke(Method.java:606)
 at org.glassfish.hk2.utilities.reflection.ReflectionHelper.invoke(ReflectionHelper.java:1017)
 at org.jvnet.hk2.internal.ClazzCreator.postConstructMe(ClazzCreator.java:388)
 at org.jvnet.hk2.internal.ClazzCreator.create(ClazzCreator.java:430)
 at org.jvnet.hk2.internal.SystemDescriptor.create(SystemDescriptor.java:456)
 at org.glassfish.hk2.runlevel.internal.AsyncRunLevelContext.findOrCreate(AsyncRunLevelContext.java:225)
 at org.glassfish.hk2.runlevel.RunLevelContext.findOrCreate(RunLevelContext.java:82)
 at org.jvnet.hk2.internal.Utilities.createService(Utilities.java:2488)
 at org.jvnet.hk2.internal.ServiceHandleImpl.getService(ServiceHandleImpl.java:98)
 at org.jvnet.hk2.internal.ServiceLocatorImpl.getService(ServiceLocatorImpl.java:606)
 at org.jvnet.hk2.internal.ThreeThirtyResolver.resolve(ThreeThirtyResolver.java:77)
 at org.jvnet.hk2.internal.ClazzCreator.resolve(ClazzCreator.java:231)
 at org.jvnet.hk2.internal.ClazzCreator.resolveAllDependencies(ClazzCreator.java:254)
 at org.jvnet.hk2.internal.ClazzCreator.create(ClazzCreator.java:413)
 at org.jvnet.hk2.internal.SystemDescriptor.create(SystemDescriptor.java:456)
 at org.glassfish.hk2.runlevel.internal.AsyncRunLevelContext.findOrCreate(AsyncRunLevelContext.java:225)
 at org.glassfish.hk2.runlevel.RunLevelContext.findOrCreate(RunLevelContext.java:82)
 at org.jvnet.hk2.internal.Utilities.createService(Utilities.java:2488)
 at org.jvnet.hk2.internal.ServiceHandleImpl.getService(ServiceHandleImpl.java:98)
 at org.jvnet.hk2.internal.ServiceHandleImpl.getService(ServiceHandleImpl.java:87)
 at org.glassfish.hk2.runlevel.internal.CurrentTaskFuture$QueueRunner.oneJob(CurrentTaskFuture.java:1162)
 at org.glassfish.hk2.runlevel.internal.CurrentTaskFuture$QueueRunner.run(CurrentTaskFuture.java:1147)
 at weblogic.work.SelfTuningWorkManagerImpl$WorkAdapterImpl.run(SelfTuningWorkManagerImpl.java:548)
 at weblogic.work.ExecuteThread.execute(ExecuteThread.java:311)
 at weblogic.work.ExecuteThread.run(ExecuteThread.java:263)




In Oracle support I find that

Unable To Deploy An Application In WebLogic 12C That Works In WebLogic 10 (Doc ID 1565172.1)

WebLogic Server 12c (12.1.1 and higher) does a complete scan of all *.class files in an application when it is deployed. This is an enhancement over previous versions which prevents invalid Java classes being deployed with an application. However, in a few cases where there is an unused invalid class packaged with the application, deployment which succeeded in WLS 11g or earlier could fail in WebLogic 12c. See Note 1504269.1 for more information about a similar case. In that case, there was an invalid class file in the application being deployed. The problem wasn't caught by the previous JVM, but was caught in WLS 12.1.1. In the customer's case, there were files in the customer application which were not Java class files, but which were named with the .class extension. These files were scanned and validated on deployment of the application, and failed validation since they were not Java classes. This caused the deployment failure.


I restart the WLS server with -verbose:class, to find out that weblogic.application.utils.annotation.ClassfinderClassInfos is loaded from wlserver/modules/features/weblogic.server.merged.jar

I patch this class adding this println:
  private void polulateOneClassInfo(Source source)
    throws AnnotationProcessingException
  {
    if (source == null) {
      return;
    }
    System.out.println("polulateOneClassInfo: source=" + source.getURL().toString());



and I find out that the offending class is loaded from a JAR compiled with Java 1.4 (check the manifest.mf)

See also http://stackoverflow.com/questions/19152655/java-lang-arrayindexoutofboundsexception-while-deploying-app-in-wls-12



Sunday, January 17, 2016

EJB and JNDI, or how to lookup a EJB from a JSP


package ejb3.bean;

import javax.ejb.LocalBean;
import javax.ejb.Stateless;

@Stateless(mappedName = "HelloEjb")
@LocalBean
public class HelloEjb implements HelloEjbRemote, HelloEjbLocal {

 public HelloEjb() {
 }

 public String printHello(String name) {
  return "Hello " + name;
 }

}



package ejb3.bean;

import javax.ejb.Remote;

@Remote
public interface HelloEjbRemote {
 String printHello(String name);
}


package ejb3.bean;

import javax.ejb.Local;

@Local
public interface HelloEjbLocal {
 String printHello(String name);
}




The LocalBean means a no-interface view .

This is what I find in JNDI tree:

Binding Name: HelloEjb#ejb3.bean.HelloEjbRemote (this is from @Remote)
Class: com.sun.proxy.$Proxy208


Binding Name: java:global.PVHelloEJBEAR.PVHelloEJB.HelloEjb!ejb3.bean.HelloEjb (this is from @LocalBean )
Class: ejb3.bean.HelloEjb_n3seu_NoIntfViewImpl


Binding Name: java:global.PVHelloEJBEAR.PVHelloEJB.HelloEjb!ejb3.bean.HelloEjbLocal (this is from @Local)
Class: ejb3.bean.HelloEjb_n3seu_HelloEjbLocalImpl


Binding Name: java:global.PVHelloEJBEAR.PVHelloEJB.HelloEjb!ejb3.bean.HelloEjbRemote (this is from @Remote again)
Class: com.sun.proxy.$Proxy208



where PVHelloEJBEAR.PVHelloEJB.HelloEjb are respectively: application name (from application.xml), ejb module name (from application.xml), ejb name (mappedName)
To lookup the EJB interface from a JSP:
HelloEjbRemote helloEjb = (HelloEjbRemote) context.lookup("HelloEjb#ejb3.bean.HelloEjbRemote");

or (it works also in a servlet) if the JSP is in a WAR the same EAR as the EJB module you can use the no-interface @LocalBean trick :
@EJB
private HelloEjb helloEjb;


If you provide a @EJB in the JSP/Servlet without having a @LocalBean annotation, you get this error:
Module named 'PVHelloEJBEAR' failed to redeploy. See Error Log view for more detail.
weblogic.management.DeploymentException: weblogic.application.naming.ReferenceResolutionException: [J2EE:160200]Error resolving ejb-ref "ejb3.bean.HelloEjb3Servlet/helloEjb" from module "PVHelloWAR.war" of application "PVHelloEJBEAR". The ejb-ref does not have an ejb-link and the JNDI name of the target bean has not been specified. Attempts to automatically link the ejb-ref to its target bean failed because no EJBs in the application were found to implement the "ejb3.bean.HelloEjb" interface. Link or map this ejb-ref to its target EJB and ensure the interfaces declared in the ejb-ref are correct.
Exception received from deployment driver. See Error Log view for more detail.



This is the documentation of @EJB : https://docs.oracle.com/javaee/6/api/javax/ejb/EJB.html

So if from your Servlet/JSP you want to access a REMOTE EJB (i.e. without LocalBean) you must change your @EJB lookup to:
@EJB(lookup="HelloEjb#ejb3.bean.HelloEjbRemote")
private HelloEjbRemote helloEjb;


or using the @Local interface:
@EJB
private HelloEjbLocal helloEjb;


Sample project available:
git clone https://github.com/vernetto/JavaMonAmour
cd JavaMonAmour\jeesamples\HelloEJB


If you wonder about Portable JNDI Syntax, have a look here.