3/6/08


English Learning: Dictionary + Trainer

Today I shown my Top Dictionary (also known as Top Editor) to Thor:


So I think it is time to show my product here also. It was long way from my first simple HTML-based english trainer. I have made it on c++, php and C#. But always idea was prety identical - if you want to study English - you need partner. Exactly such e-partner I have been trying to implements a lot of years. May be name "partner" is too loude but anyway it is prety usefull tool. I hope it will be better in future.
Main futures:
- usefull editing studied words;
- management by samples for those words;
- ability to record sound for a words and samples;
- presence of trainer;
- easy printing all wards in paper;
- easy play sounds in any mp3-player;

BEA forever

Yesterday I posted request to BEA customer support. Today I have received full description of the possble decision. Thanks a lot. It was my first request to official support and successfull. Also I have respond on BEA forum. Great

3/4/08


There is xsd inheritance!

Look into two classes:

package com;
public class SomeBase {
}


package com;
public class SomeChild extends SomeBase {
}


and result conversion into xsd:

<xs:complexType name="SomeChild">
<xs:complexContent>
<xs:extension base="java:SomeBase" xmlns:java="java:com"/>
</xs:complexContent>
</xs:complexType>
<xs:complexType name="SomeBase"/>

Some incomprehension

I have found some xsd definition:

<xs:schema targetNamespace="java:java.lang" xmlns:xs=http://www.w3.org/2001/XMLSchema>
<xs:complexType name="NullPointerException">
<xs:complexContent>
<xs:extension base="java:RuntimeException" xmlns:java="java:java.lang"/>
</xs:complexContent>

</xs:complexType>
<xs:complexType name="RuntimeException"/>

</xs:schema>

My attention is attracted by line <xs:extension base="... Is there inheritance in XML Schema?

-------------------------------------------------------------

Another strange issue. Let's look into my MyException src:

package com;
public class MyException extends java.lang.Exception {
private static final long serialVersionUID = 6543L;
private java.lang.String myException;

public java.lang.String getMyException() { return this.myException; }
public MyException() { }

public MyException(java.lang.String myException) { this.myException = myException; }

// public MyException(Throwable ex) {

// super(ex);
// }
}

In WSDL for my service it appears as:

<xs:complexType name="MyException">
<xs:sequence>

<xs:element minOccurs="1" name="MyException" nillable="true" type="xs:string"/>
</xs:sequence>

</xs:complexType>
<xs:element name="MyException" type="java:MyException" xmlns:java="java:com"/>


But clientgen generates right definition for class MyException (with extends). From where it know about if in WSDL information is absence?

-------------------------------------------------------------

Next incomprehension tied with comment code in my Exception class. If uncomment those lines then web service invocation will be accompanied with:

weblogic.wsee.codec.CodecException: Failed to encode
at weblogic.wsee.codec.soap11.SoapCodec.encodeFault(SoapCodec.java:362)...

-----------------------------------------------------

JNDI
I have deployed EJB on the WebLogic server. It has jndi:

EJB is allocated in EAR project:First question:
I looked up that EJB via:

context.lookup("ejb.ScfBeanRemoteHome");

EAR project name not needs while jndi lookup???

Second:
I listed all context containig by:

NamingEnumeration en = context.list("");

while(en.hasMore())
{
System.out.println(en.next().toString());
}


and did not find "ejb.ScfBeanRemoteHome" name.. Why? Where is that name?

List:
com_bea_wli_monitoring_alert_AlertLogService: com.bea.wli.monitoring.alert.AlertLoggerImpl
mejbmejb_jarMejb_EO: weblogic.rmi.cluster.ClusterableRemoteObject
ejb: weblogic.jndi.internal.ServerNamingNode
ALSB Test FrameworksbTestFwkEjb_jarTestService_EO: weblogic.rmi.cluster.ClusterableRemoteObject
com_bea_wli_monitoring_Aggregator: com.bea.wli.monitoring.statistics.prototype.ClusterAggregatorImpl
QueueIn: weblogic.jms.common.WrappedDestinationImpl
javax: weblogic.jndi.internal.ServerNamingNode
wli: weblogic.jndi.internal.ServerNamingNode
ScfEjbMediator_ear: weblogic.jndi.internal.ServerNamingNode
wlsbjmsrpDataSource: weblogic.rmi.cluster.ClusterableRemoteObject
AdminServer_clusterTimerAuthority: com.bea.wli.timer.ClusterTimerAuthorityImpl
weblogic: weblogic.jndi.internal.ServerNamingNode
bea_wls_remote_deployerbea_wls_remote_deployer_jarDeployerBean_EO: weblogic.rmi.cluster.ClusterableRemoteObject
ScfEjbMediator_earScfEjbMediator_ejb_jarScfBean_EO: weblogic.rmi.cluster.ClusterableRemoteObject
ScfEjbMediator_earScfEjbMediator_ejb_jarUtiliteBean_EO: weblogic.rmi.cluster.ClusterableRemoteObject
wlsb: weblogic.jndi.internal.ServerNamingNode
ServiceBus_Console: weblogic.jndi.internal.ServerNamingNode
com: weblogic.jndi.internal.ServerNamingNode
WebLogicEJB_ejbWebLogicEJB_ejbSomeEjb_EO: weblogic.rmi.cluster.ClusterableRemoteObject

Weblogic Service Bus service generation


Some unexpected behaviour was trailed when business Transport Typed Service generated. My EJB looks like:


@RemoteMethod
public String someMethod(String arg) {

return "Hello " + arg;
}
@RemoteMethod
public String someMethod2(String arg) throws MyException {
throw new MyException("ERR");
//return "Hello " + arg;
}


but if I generate business service by EJBClientJar of that EJB I do not find fault part in operation description for second method in the its WSDL. Moreover I do not find MyException type definition as well:

<s0:operation name="someMethod2">
<s2:operation soapAction="http://www.openuri.org/someMethod2
" style="document"/>
<s0:input>
<s2:body parts="parameters" use="literal"/>
</s0:input>
<s0:output>
<s2:body parts="parameters" use="literal"/>
</s0:output>
</s0:operation>


http://forums.bea.com/thread.jspa?threadID=300006140

Web services exceptions handling


There are two web methods in previous topic. Each of them throws exception:
RuntimeException and checked exception com.MyException

In second case wsdl description has fault description part:

<s0:operation name="meth2Checked">
<s3:operation soapAction="" style="document"/>
<s0:input>
<s3:body parts="parameters" use="literal"/>
</s0:input>
<s0:output>
<s3:body use="literal"/>
</s0:output>
<s0:fault name="MyException">
<s3:fault name="MyException" use="literal"/>
</s0:fault>


So JAX-RPC stubs has exception description in signature of the correspondent methods.
If involkes such methods:

Exception in thread "main" com.MyException
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)....


In case of throwing RuntimeException we just have in runtime:

Exception in thread "main" java.rmi.RemoteException: SOAPFaultException - FaultCode [{http://schemas.xmlsoap.org/soap/envelope/}Server] FaultString [Failed to invoke end componentFailed to invoke method >> RUN TIME EXCEPTION << ] FaultActor [null] Detail [<detail><bea_fault:stacktrace xmlns:bea_fault=http://www.bea.com/servers/wls70/webservice/fault/1.0.0>java.lang.RuntimeException: >> RUN TIME EXCEPTION <<
at com.ErrWs.meth1RunTime(ErrWs.java:10)
at jrockit.reflect.VirtualNativeMethodInvoker.invoke(Ljava.lang.Object;[Ljava.lang.Object;)Ljava.lang.Object;(Unknown Source)
at java.lang.reflect.Method.invoke(Ljava.lang.Object;[Ljava.lang.Object;I)Ljava.lang.Object;(Unknown Source)
....


In case of some transport problem (e.g. absent WS in the defined location) is gotten:

Exception in thread "main" java.rmi.RemoteException: SOAPFaultException - FaultCode [{http://schemas.xmlsoap.org/soap/envelope/}Server] FaultString [Failed to receive message java.io.IOException: The server at http://localhost:7001/WebService_ws/ErrWs returned a 404 error code (Not Found). Please ensure that your URL is correct, and the web service has deployed without error.The server at http://localhost:7001/WebService_ws/ErrWs returned a 404 error code (Not Found). Please ensure that your URL is correct, and the web service has deployed without error.] FaultActor [null] Detail [java.io.IOException: The server at http://localhost:7001/WebService_ws/ErrWs returned a 404 error code (Not Found). Please ensure that your URL is correct, and the web service has deployed without error....

Webogic Web Services invocation

Let's look into some WebLogic WebService:

import javax.jws.*;
@WebServicepublic class ErrWs {
@WebMethod

public void meth1RunTime() {
throw new RuntimeException(" >> RUN TIME EXCEPTION << ");
}

@WebMethod
public void meth2Checked() throws MyException {
throw new MyException(" >> MyException EXCEPTION << ");
}
}

How we can use that web service in java code? First of all use jwsc ant task to genrate JAX-RPC code for that web service:

<taskdef name="jwsc"
classname="weblogic.wsee.tools.anttasks.JwscTask">
<classpath refid="..." />
</taskdef>

<jwsc srcdir="src" destdir="${somedir-dir}">
<jws file="com/ws/ErrWs.java">
</jws>
</jwsc>

In case of some WebLogic web application we can generate web service control but for standalone application (or non WebLogic web application) we need use ClientGenTask. But there is some strange behaviour I meet with..
Below content of my ant build.xml:

< project
default="wsc_lient_gen"
name="LocalClient">
< path id="wl_cp">
< pathelement path="lib/weblogic.jar">
< pathelement path="lib/xbean.jar">
< pathelement path="lib/apache_xbean.jar">
< pathelement path="lib/webserviceclient.jar">
</path>
<taskdef

name="clientgen"
classpathref="wl_cp"
classname="weblogic.wsee.tools.anttasks.ClientGenTask">
</taskdef >
<target name="wsc_lient_gen">
<clientgen

classpathref="wl_cp"
wsdl=http://localhost:7001/WebService_ws/ErrWs?WSDL
destdir="gen">
</target>
</project>


But there is exception while run that code right in Eclipse environment:

Buildfile: D:\Screwfix\ErrAttempts_java2\Test\build.xml
wsc_lient_gen:
Generating client from http://localhost:7001/WebService_ws/ErrWs?WSDL ...
[clientgen] Package name is com
[clientgen] DestDir is D:\Screwfix\ErrAttempts_java2\Test\gen
[clientgen] class name is ErrWs_Stub
[clientgen] service class name is ErrWsService
[clientgen] Porttype name is ErrWs
[clientgen] service impl name is ErrWsService_Impl
BUILD FAILED
java.lang.AssertionError: java.io.IOException
Total time: 3 seconds


But in CLI, if before invoking set domain environment:

> %SOME_WL_DOMAIN_PATH%\bin\setDomainEnv.cmd
> ant
all artifacts are generated successfully.

After those operation we need some client's code to invoke web service: (and also 4 *.jar in classpath presented in ant's build file)

ErrWsService service = new ErrWsService_Impl();
ErrWs port = service.getErrWsSoapPort();
port.meth1RunTime();