title: How can I use the Scala REPL to test java code - java and scala REPL giving different outputs
body: <p>I am trying to use the REPL for testing my java code. I had set my class path and launched the REPL and I could access my application classes inside REPL.</p>
  
  <p>I launched a method which makes a webservice call and it is throwing a java.lang.ClassCastException. I wrote a java program which does the same thing as the series of commands entered in the REPL and ran it with the same classpath, it is running without issues and giving the result.</p>
  
  <p>Any clues on why it is not running under scala?
  Does the rules of casting is strict in scala?, and if I am using an API on which I have no control how can I tell Scala to be behave like java so, that I can test my methods which makes a lot of API calls and code written by others.</p>
  
  <pre><code>java.lang.ClassCastException: weblogic.webservice.encoding.ImageCodec cannot be cast to weblogic.xml.schema.binding.Serializer
          at weblogic.xml.schema.binding.internal.XSDTypeMapping.addOptionalEntries(XSDTypeMapping.java:762)
          at weblogic.xml.schema.binding.internal.XSDTypeMapping.createOptionalMapping(XSDTypeMapping.java:665)
          at weblogic.xml.schema.binding.internal.XSDTypeMapping.createPrimaryMapping(XSDTypeMapping.java:655)
          at weblogic.xml.schema.binding.internal.XSDTypeMapping.createInstance(XSDTypeMapping.java:138)
          at weblogic.xml.schema.binding.internal.XSDTypeMapping.&lt;clinit&gt;(XSDTypeMapping.java:118)
          at weblogic.xml.schema.binding.internal.TypeMappingFactoryBase.createDefaultMapping(TypeMappingFactoryBase.java:18)
          at weblogic.webservice.core.encoding.DefaultRegistry.&lt;init&gt;(DefaultRegistry.java:110)
          at weblogic.webservice.core.encoding.DefaultRegistry.&lt;init&gt;(DefaultRegistry.java:37)
          at weblogic.webservice.core.rpc.ServiceImpl.&lt;init&gt;(ServiceImpl.java:91)
  </code></pre>
  
  <p>Since many are asking for the source code to answer this, here is the snippet I entered in the scala REPL. It makes API calls which are copyrighted and cannot be shared here, I can answer to questions to provide more info on this issue without violating the norms.</p>
  
  <pre><code>val clientManager=new ClientManager()
  val client=clientManager.getClient(&lt;clientId&gt;)
  /*client location is stored in another system which exposes its data as a webservice.
   We use weblogic tools to compile the WSDL to create client (Web service client, not to
   be confused with the client object which represent a customer) to access the system
   hosting the data*/
  val res=client.getLocation //exception is thrown at this line where a web-service call is made
  </code></pre>
  
  <p>I did something different and I got a completely different exception this time
  instead of using <code>val res=client.getLocation</code> I used <code>client.getLocation</code> without assigning it to a variable and this time the exception thrown is</p>
  
  <pre><code>java.lang.NoClassDefFoundError: Could not initialize class weblogic.xml.schema.binding.internal.XSDTypeMapping
          at weblogic.xml.schema.binding.internal.TypeMappingFactoryBase.createDefaultMapping(TypeMappingFactoryBase.java:18)
          at weblogic.webservice.core.encoding.DefaultRegistry.&lt;init&gt;(DefaultRegistry.java:110)
          at weblogic.webservice.core.encoding.DefaultRegistry.&lt;init&gt;(DefaultRegistry.java:37)
          at weblogic.webservice.core.rpc.ServiceImpl.&lt;init&gt;(ServiceImpl.java:91)
  </code></pre>
  
  <p>I ran the interpreted with the <code>-nobootcp</code> option and it ran without throwing any exception which are above but the result I got is null in both the cases</p>
  
  <p>Anyone using Scala REPL to test client written from stubs generated by weblogic 10.3 and were successful in using it?</p>