Primitive int[] and Integer[] array type not supported - weblogic.developer.interest.webservices.general(Archived)

Hi there,
I have a stateless ejb exposed as webservice using jax-rpc 1.1 and one of my methods accepts a parameter of int[] array. When I run the wls clientgen ant task and I look at the generated client stub for that webservice the parameter is no longer int[] but this one "com.starcomsoft.ArrayOfJavaLangint_Literal". Below is a snippet of client stub code produced by wls clientgen.
public class CustomerWS_Stub
extends weblogic.wsee.jaxrpc.StubImpl
implements com.starcomsoft.pp.customer.jws.CustomerWS, /**/java.io.Serializable
{
public CustomerWS_Stub(weblogic.wsee.wsdl.WsdlPort port,
weblogic.wsee.jaxrpc.ServiceImpl service)
throws javax.xml.rpc.ServiceException
{
super(port, com.starcomsoft.pp.customer.jws.CustomerWS.class, service);
}
/**
* Operation Name : {http://www.starcomsoft.com}findAddresses1 */
public java.lang.Object[] findAddresses1(com.starcomsoft.ArrayOfint_Literal idSet) throws java.rmi.RemoteException {
java.util.ArrayList _args = new java.util.ArrayList();
_args.add(idSet);
try {
java.lang.Object result = invoke("findAddresses1", _args.toArray());
return (java.lang.Object[])_result;
} catch (javax.xml.rpc.JAXRPCException wlsexception) {
throw new java.rmi.RemoteException(_wls_exception.getMessage(), wlsexception.getLinkedCause());
} catch (javax.xml.rpc.soap.SOAPFaultException wlsexception) {
throw new java.rmi.RemoteException(_soapFault2String(_wls_exception), wlsexception);
} catch (java.lang.Throwable wlsexception) {
throw new java.rmi.RemoteException(_wls_exception.getMessage(), wlsexception);
}
}
And here is my webservice class:
#SOAPBinding(style=SOAPBinding.Style.DOCUMENT, use=SOAPBinding.Use.LITERAL,
     parameterStyle=SOAPBinding.ParameterStyle.WRAPPED)
#Stateless(mappedName = "CustomerBeanWS")
#WebService(name = "CustomerWS",
               serviceName = "CustomerWSService",
               targetNamespace = "http://www.starcomsoft.com")
public class CustomerWSImpl implements CustomerEJBRemote, CustomerEJBLocal {
     #WebMethod()
     #TransactionAttribute(TransactionAttributeType.REQUIRED)
     public List<Address> findAddresses1(int[] idSet) {
          AddressDAO dao = new AddressDAO();
          List<Address> addrList = dao.loadAddresses(idSet);
          return addrList;
     }
}
I also tried using Integer[] type but the same type is produced - that is "com.starcomsoft.ArrayOfJavaLangint_Literal".
I'm stuck and your help is very much appreciated.

Related

#Resource DataSource ds and #EJB injection not working

Hi there,
I'm using wls 10.3 and I'm trying to inject a DataSource and EJB in one of my webservice (jax-rpc) and using the annotation because I'm just using the jwsc ant task to generate all my weblogic descriptor. When I tried to test the DataSource and EJB it is null. I have defined in the admin console a jdbc DataSource jndi named="jdbc/ppDataSource" and also created both SystemEJBRemote and SystemEJBLocal ejb's. Sample code below.
#SoapBinding(style=SOAPBinding.Style.DOCUMENT....)
#Stateless(mappedName="CustomerBeanWS")
#WebService(name="CustomerWS",
serviceName="CustomerWSService")
public class CustomerWSImpl
#EJB private SystemEJBLocal systemLocal;
#Resource DataSource(name="jdbc/DataSource") ds;
public void testInjection() {
// test ejb
if (systemLocal != null) {
systemLocal.hello();
} else {
System.out.println("SystemEJBLocal ref injection is null.");
}
if (ds != null) {
ds.getConnection();
} else {
System.out.println("DataSource ref injection is null.");
}
}
#Stateless
#Local( SystemEJBLocal.class )
#Remote( SystemEJBRemote.class )
public class SystemEJBImpl {
public void hello() {
System.out.println( "Hello EJB3!" );
}
}
Your help is very much appreciated.
Thanks

Invoking weblogic ejb over iiop

Hi,
I am trying to invoke my EJB ( stateless session ) through iiop protocol. My client
code is based on the sample bean provided by weblogic. I have the client code
aatached.
When I run the client I get the following exception ...
Exception in thread "main" java.lang.ClassCastException at com.sun.corba.se.internal.javax.rmi.PortableRemoteObject.narrow(Unknown
Source) at javax.rmi.PortableRemoteObject.narrow(Unknown Source)
at Client.narrow(Client.java:115) at Client.lookupHome(Client.java:131)
at Client.<init>(Client.java:41) at Client.main(Client.java:73)
I am invoking the EJB in the same way as it has been suggested by weblogic. I
reffered to this url
http://e-docs.bea.com/wls/docs61/rmi_iiop/API_rmi_iiop.html#1044525
Can someone tell me what am I doing wrong? My EJB is OK as I can invoke it nicely
from a t3 client. I am using weblogic 6.1 sp 2
--------------------
Shubhrajit
This is the code of the client
import java.rmi.RemoteException;
import java.util.Properties;
import javax.ejb.CreateException;
import javax.ejb.RemoveException;
import javax.naming.Context;
import javax.naming.InitialContext;
import javax.naming.NamingException;
import javax.rmi.PortableRemoteObject;
import shub.ejb.test.*;
public class Client {
private static final String JNDI_NAME = "shub.ejb.test.Far2CentHome";
private String url;
private Far2CentHome home;
private static boolean remote = false;
public Client(String url)
throws NamingException
{
this.url = url;
home = lookupHome();
}
public static void main(String[] args) throws Exception {
log("\nBeginning statelessSession.Client...\n");
String url = "iiop://localhost:7001";
// Parse the argument list
     if(args.length != 1){
          System.out.println("Wrong usage");
          System.exit(1);
     }
     log("\nBeginning statelessSession.FartoCentClient...\n");
     float d = (new Float(args[0])).floatValue();
Client client = null;
try {
client = new Client(url);
} catch (NamingException ne) {
System.exit(1);
}
try {
client.example(d);
} catch (Exception e) {
log("There was an exception while creating and using the Trader.");
log("This indicates that there was a problem communicating with the server:
"+e);
}
log("\nEnd statelessSession.Client...\n");
}
/**
* Runs this example.
*/
public void example(float d)
throws CreateException, RemoteException, RemoveException
{
// create a FartoCent
log("Creating a FartoCent");
Far2Cent fartocent = (Far2Cent)narrow(home.create(), Far2Cent.class);
log("Success");
log("Far= "+d+" Cent="+fartocent.getCent(d));
}
/**
* RMI/IIOP clients should use this narrow function
*/
private Object narrow(Object ref, Class c) {
return PortableRemoteObject.narrow(ref, c);
}
/**
* Lookup the EJBs home in the JNDI tree
*/
private Far2CentHome lookupHome()
throws NamingException
{
// Lookup the beans home using JNDI
Context ctx = getInitialContext();
try {
Object home = ctx.lookup(JNDI_NAME);
System.out.println(home.toString());
return (Far2CentHome) narrow(home, Far2CentHome.class);
} catch (NamingException ne) {
log("The client was unable to lookup the EJBHome. Please make sure ");
log("that you have deployed the ejb with the JNDI name "+JNDI_NAME+" on
the WebLogic server at "+url);
throw ne;
}
}
private Context getInitialContext() throws NamingException {
try {
// Get an InitialContext
Properties h = new Properties();
h.put(Context.INITIAL_CONTEXT_FACTORY,
"com.sun.jndi.cosnaming.CNCtxFactory");
h.put(Context.PROVIDER_URL, url);
return new InitialContext(h);
} catch (NamingException ne) {
log("We were unable to get a connection to the WebLogic server at "+url);
log("Please make sure that the server is running.");
throw ne;
}
}
private static void log(String s) {
System.out.println(s);
}
}
Putting the thread on top again so that it is visible to others

int[] or Integer[] array is not working.

Hi there, I'm using wls 10.3 and some of my web services classes/methods (jax-rpc 1.1) used either an int[] or Integer[] array as both a parameter and return types. When I generate the wls client artifacts using jwsc ant task, the client stub method signature is different. Instead of seeing it as int[] or Integer[] - I'm seeing these class types. Below are the snippet of wls generated client stub classes.
1. public java.lang.Object[] findCustomersByIds(com.starcomsoft.ArrayOfint_Literal ids) throws java.rmi.RemoteExceptionc {..}
2. public java.lang.Object[] findCustomersByIds2(com.starcomsoft.ArrayOfJavaLangint_Literal ids) throws java.rmi.RemoteException {..}
Also below is the wls generated class that replace both the int[] and Integer[] array.
ArrayOfint_Literal.java and
ArrayOfJavaLangint_Literal.java
public class ArrayOfint_Literal implements java.io.Serializable {
private int[] _int;
public int[] getInt() {
return this._int;
}
public void setInt(int[] _int) {
this._int = _int;
}
}
public class ArrayOfJavaLangint_Literal implements java.io.Serializable {
private java.lang.Integer[] javaLangint;
public java.lang.Integer[] getJavaLangint() {
return this.javaLangint;
}
public void setJavaLangint(java.lang.Integer[] javaLangint) {
this.javaLangint = javaLangint;
}
}
This 2 classes seems to wrapped both the int[] and Integer[] array. Is this correct or not? I would expect that they would support this java types, because the old wls 7.2 supported it and we have no problem on our old web service application.
Your help is very much appreciated.

IllegalAccessError for the same package

Hi,
I'm using Workshop 8.1, and I'm trying to implement some WebServices.
I have a small problem.
I put the Web Service (JWS file) in the same package as other classes. These other classes aren't public, but they should be instanciable by classes in the same package, especially by the web service.
I noted that the compiled JWS file is in another directory than the compiled Java files; I don't know why, but i suspect that's the ground of the problem.
Source excerpts :
CDCatalogWS.jws
package com.ft.ws.catalog;
public class CDCatalogWS implements com.bea.jws.WebService, ICDCatalog
{
static final long serialVersionUID = 1L;
CDCatalog catalog;
public CDCatalogWS () {
catalog = new CDCatalog();
}
/**
* #common:operation
*/
public String getCd(String title) throws MyException {
return catalog.getCd(title);
}
}
MyException.java
package com.ft.ws.catalog;
class MyException extends Exception {
     private int nombre;
     MyException (int nombre) {
          this.nombre = nombre;
     }
     public MyException () {
this.nombre = 10;
     }
     public int getNombre () {
          return this.nombre;
     }
     public void setNombre (int nombre) {
          this.nombre = nombre;
     }
}
Is there a solution to be able to reference MyException (or other classes in the same package) without setting it "public" (which indeed solves the problem) ?

Another try, with CR: Error deserializing arguments, xml tag without a recognized type

Sorry, I will try this again. The carriage returns didn't show.
I am trying to run a webservice created using Weblogic Workshop 8.1sp2 that communicates
with an ejb control. When I test in debug mode, I get the above error, specifically:
<detail>
<jwErr:jwErrorDetail xmlns:jwErr="http://www.bea.com/2002/04/jwErrorDetail/">
com.bea.wlw.runtime.core.request.RequestValidationException: Error deserializing
arguments.
Encountered an xml tag without a recognized type: the type must be declared with
an xsi:type attribute.
Caused by: com.bea.xml.marshal.XmlEncodingException: Encountered an xml tag with
out a recognized type: the type must be declared with an xsi:type attribute.
...
</detail>
I am passing a Request object to the jws method (to the ejb) that has a Collection
as an instance member. This Collection references objects of another type, Param
(code for both objects below). Before passing the object, I convert the Collection
to an array of objects. When I call the operation via a java client, I get the
above message.
In Workshop, I've included the Request and Param classes as the parameter xml
and the soap style is rpc. I've tested the ejb by itself and it is working fine.
Request.java:
import java.util.*;
public class Request implements java.io.Serializable
{
protected Collection params=null;
public Collection getParams()
{ return params; }
public void setParams(Collection data)
{ params=data; }
}
Param.java:
public class Param implements java.io.Serializable
{
private String name=null;
private Object value=null;
public String getName()
{ return name; }
public void setName(String data)
{ name = data; }
public Object getValue()
{ return value; }
public void setValue(Object data)
{ value=data; }
}
Here's the code from the jws:
public class MyWS implements com.bea.jws.WebService
{
/**
* #common:control
*/
private control.PSEjbControl psEJB;
static final long serialVersionUID = 1L;
/**
* #common:operation
* #jws:parameter-xml
* include-java-types="mypackage.Request mypackage.Param"
* #jws:protocol soap-style="rpc"
*/
public void addData(mypackage.Request arg0) throws java.rmi.RemoteException
{
System.out.println("arg0 : " + arg0);
psEJB.addData(arg0);
}
}
*Note: in the server console, arg0 comes through as null when called from my client.
Here's the bit from my client:
import weblogic.jws.proxies.*;
import org.openuri.www.encodedTypes.Request;
import org.openuri.www.encodedTypes.Param;
...
public void go(String wsdl) throws Exception {
MyWSSoap mw = null;
mw = new MyWS_Impl().getMyWSSoap();
Request req = new Request();
Collection reqColl = new ArrayList();
Param param1 = new Param();
param1.setName("NAME");
param1.setValue("Joe Tester");
Param param2 = new Param();
param2.setName("ADDRESS");
param2.setValue("345 Test Drive");
reqColl.add(param1);
reqColl.add(param2);
Object[] obs = reqColl.toArray();
req.setParams(obs);
mw.addData(req);
}
Not sure if this enough to go by. Please let me know if you need more information.
Any help is really appreciated. Thanks.

Categories

Resources