Problem with WildcardTypeImpl

I just upgraded to 7.0 (beta 9) and I’m running into a problem executing DMI calls. I get this exception in the log:

=== 2009-06-15 16:07:46,843 [or25] WARN RequestContext - rpcRequest.execute() failed:
java.lang.ClassCastException: sun.reflect.generics.reflectiveObjects.WildcardTypeImpl
at com.isomorphic.base.VersionSafeChecker.buildGenericParameterTree(VersionSafeChecker.java:156)
at com.isomorphic.base.VersionSafeChecker.getGenericParameterTypes(VersionSafeChecker.java:106)
at com.isomorphic.base.Reflection.adaptArgsAndInvoke(Reflection.java:741)
at com.isomorphic.base.Reflection.adaptArgsAndInvoke(Reflection.java:720)
at com.isomorphic.rpc.RPCDMI.execute(RPCDMI.java:222)
at com.isomorphic.rpc.RPCDMI.execute(RPCDMI.java:54)
at com.isomorphic.rpc.RPCRequest.execute(RPCRequest.java:221)
at com.isomorphic.servlet.IDACall.handleRPCRequest(IDACall.java:198)
at com.isomorphic.servlet.IDACall.processRequest(IDACall.java:102)
at com.isomorphic.servlet.IDACall.doPost(IDACall.java:54)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:710)
at com.isomorphic.servlet.BaseServlet.service(BaseServlet.java:152)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:269)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:188)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:213)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:174)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:117)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:108)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:174)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:874)
at org.apache.coyote.http11.Http11BaseProtocol$Http11ConnectionHandler.processConnection(Http11BaseProtocol.java:665)
at org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:528)
at org.apache.tomcat.util.net.LeaderFollowerWorkerThread.runIt(LeaderFollowerWorkerThread.java:81)
at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:689)
at java.lang.Thread.run(Unknown Source)

Is this a problem with conflicting jars?

Hi Paul,

Yes that’s a possible explanation. A few .jars we depend on were upgraded to more recent versions and the naming conventions changed. Try wiping out all .jars that you are using solely because of SmartClient and replacing them with copies from 7.0, and make sure there aren’t two .jars of the same base name.

I went back and made sure there were no overlapping .jar files and I’m still getting the exception. Here is an ‘ls’ of the /lib directory just FYI:

commons-cli-1.1.jar
commons-codec-1.3.jar
commons-collections-3.2.1.jar
commons-fileupload-1.2.1.jar
commons-httpclient-3.1.jar
commons-jxpath-1.3.jar
commons-lang-2.4.jar
commons-pool-1.4.jar
commons-vfs-1.0.jar
daylight.jar
dayport.jar
dom4j-full.jar
dt_java.jar
isc-jakarta-oro-2.0.6.jar
isomorphic_assembly.jar
isomorphic_core_rpc.jar
javaee.jar
log4j-1.2.15.jar
metasys.jar
ojdbc14.jar
velocity-1.6.1.jar
xercesImpl.jar
xml-apis.jar
xmlwriter-2.2.jar

Does anything jump out here as a potential problem. Since this is happening deep within the DMI call structure it’s a little hard for me to debug. The ClassCastException is occurring on sun.reflect.generics.reflectiveObjects.WildcardTypeImpl found in rt.jar.

BTW - This is also happening in the enterprise evaulation version (70rc_2).

If you are using an IDE such as Eclipse, we’d suggest doing a clean build, manually inspecting the deployment directory in your servlet engine/application server, manually checking the .classpath file (or similar artifact for another tool) and perhaps checking out the project from scratch. Clearly the DMI samples work in the SDK so there is likely so part of your environment that is holding onto old files.

Other than that, we’d need the information necessary to try out a test case, basics like what servlet engine you’re using, what JDK version, what the DMI declaration looks like and the code for the target class and it’s key imports.

Hi Paul,

After a closer look this is a problem with Java generics and wildcard types (such as List<? extends BaseClass>). Can you show the type declarations that lead to this crash? That way we can ensure we’re handling that case.

Yes, I have provide you with the type declarations below. I also have more information regarding the test case I used.

First, I wiped out my deployment directory and reverted to SmartClient 6 to make sure the system still worked properly on the older release and it did.

Second, I wiped clean the deployment directory a second time and redeployed the necessary artifacts from rel 7. I manually deployed the lib files straight out of the 7rc release candidate (smartClientRuntime//WEB-INF/lib/).

I then deployed only the lib files necessary to run my application and was able to repeat the problem.

Here is one of the method signatures for a DMI call that fails:

public class ProjectTreeDMI {
protected Logger log = Logger.getLogger(ProjectTreeDMI.class);

public List&lt;Map&lt;String,Object&gt;&gt; fetch(HttpSession session, Map&lt;?,?&gt; criteria) throws Exception { ...}

The fetch method is an example of a DMI target that fails.

The methods that fail all seem to share the argument type Map<?,?>. While there are several possible explanations for the crash, one explanation may have to do with a change in sun’s implementation (package) of the WilcardTypeImpl class within the rt.jar file from one java release to the next. Also, I believe there are other implementations of this class with certain apache projects although I haven’t verfied that those projects are related to .jar files SmartClient requires.

Hope this helps.

Paul

Hi Paul,

It’s almost certain that you can workaround this problem for now by switching from Map<?,?> to just Map. We’re fixing the underlying problem, but obviously that declaration has no functional impact.

Switching from Map<?,?> to Map works.

Thanks,

BTW, when this problem is fixed will it be possible to have method signatures with a non-wildcard types (e.g. Map<String,Object>) ?

I find that when representing objects as associative arrays/Maps, the keys are always strings.

-p

That’s already safe. It’s just the “?” type where there’s currently a problem.