[Javassist user questions] - Re: Best Practice for 'Wrapping' a Method
by parkinm
So here's what I'm doing to achieve the above. Assume that m is the original CtMethod, c is the class it's declared in, pool is a ClassPool and that we're adding a new parameter of type String.
| // Add a new parameter of type string to the list of parameters
| CtClass[] parameters = m.getParameterTypes();
| CtClass[] newParameters = new CtClass[parameters.length + 1];
| System.arraycopy(parameters, 0, newParameters, 0, parameters.length);
| newParameters[parameters.length] = pool.get("java.lang.String");
|
| // Create and configure method
| CtClass returnType = m.getReturnType();
| CtMethod newM = new CtMethod(returnType, m.getName(), newParameters, c);
| newM.setExceptionTypes(m.getExceptionTypes());
| newM.setModifiers(m.getModifiers());
|
| // Add and configure method body
| newM.setBody(m, null);
| newM.insertBefore("// string parameter is $args[$args.length-1]");
|
| // Add new method to class
| c.addMethod(newM);
|
Is this the best way to do this?
Thanks,
Michael.
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4146141#4146141
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4146141
18 years
[Installation, Configuration & DEPLOYMENT] - Re: Can not get connection to server. Problem establishing s
by alexsbe
Thanks for your help,
The client is on windows (for test). It will be on a linux System for production.
When I don't specify the option -Djava.rmi.server.hostname=serverIp adress here is the trace I have from the client
javax.naming.CommunicationException [Root exception is java.rmi.ConnectException: Connection refused to host: fedora.sbe-online.com; nested exception is:
| java.net.ConnectException: Connection refused: connect]
| at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:780)
| at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:627)
| at javax.naming.InitialContext.lookup(InitialContext.java:351)
| at com.sbe.test.Client.main(Client.java:23)
| Caused by: java.rmi.ConnectException: Connection refused to host: fedora.sbe-online.com; nested exception is:
| java.net.ConnectException: Connection refused: connect
| at sun.rmi.transport.tcp.TCPEndpoint.newSocket(TCPEndpoint.java:574)
| at sun.rmi.transport.tcp.TCPChannel.createConnection(TCPChannel.java:185)
| at sun.rmi.transport.tcp.TCPChannel.newConnection(TCPChannel.java:171)
| at sun.rmi.server.UnicastRef.invoke(UnicastRef.java:94)
| at org.jnp.server.NamingServer_Stub.lookup(Unknown Source)
| at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:667)
| ... 3 more
| Caused by: java.net.ConnectException: Connection refused: connect
| at java.net.PlainSocketImpl.socketConnect(Native Method)
| at java.net.PlainSocketImpl.doConnect(PlainSocketImpl.java:333)
| at java.net.PlainSocketImpl.connectToAddress(PlainSocketImpl.java:193)
| at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:182)
| at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:364)
| at java.net.Socket.connect(Socket.java:507)
| at java.net.Socket.connect(Socket.java:457)
| at java.net.Socket.<init>(Socket.java:365)
| at java.net.Socket.<init>(Socket.java:207)
| at org.jboss.net.sockets.DefaultClientSocketFactory.createSocket(DefaultClientSocketFactory.java:77)
| at sun.rmi.transport.tcp.TCPEndpoint.newSocket(TCPEndpoint.java:569)
| ... 8 more
and with this option I have the other error. I read from a forum that putting this option solve my issue. It did not solve it. I had an other one.
here is the information I have typing the netstat -a command
anonymous wrote : Connexions Internet actives (serveurs et ÃÂÃÂÃÂétablies)
| Proto Recv-Q Send-Q Local Address Foreign Address State
| tcp 0 0 fedora.sbe-online.:fagordnc *:* LISTEN
| tcp 0 0 *:36008 *:* LISTEN
| tcp 0 0 *:8009 *:* LISTEN
| tcp 0 0 *:rmiactivation *:* LISTEN
| tcp 0 0 *:rmiregistry *:* LISTEN
| tcp 0 0 *:sunrpc *:* LISTEN
| tcp 0 0 *:webcache *:* LISTEN
| tcp 0 0 *:us-srv *:* LISTEN
| tcp 0 0 *:48915 *:* LISTEN
| tcp 0 0 *:40344 *:* LISTEN
| tcp 0 0 fedora.sbe-online.com:smtp *:* LISTEN
| tcp 0 0 *:krb524 *:* LISTEN
| tcp 0 0 *:8093 *:* LISTEN
| tcp 0 0 *:upnotifyp *:* LISTEN
| tcp 0 0 *:59613 *:* LISTEN
| tcp 0 0 *:n1-fwp *:* LISTEN
| tcp 0 0 10.107.70.70:51503 10.107.1.10:ncube-lm ESTABLISHED
| tcp 0 0 *:ssh *:* LISTEN
| tcp 0 0 ::ffff:10.107.70.70:ssh ::ffff:10.107:dbcontrol-oms ESTABLISHED
| tcp 0 132 ::ffff:10.107.70.70:ssh ::ffff:10.107:sercomm-wlink ESTABLISHED
| tcp 0 0 ::ffff:10.107.70.70:ssh ::ffff:10.107.20.5:olsv ESTABLISHED
| udp 0 0 *:43907 *:*
| udp 0 0 *:59557 *:*
| udp 0 0 *:940 *:*
| udp 0 0 *:961 *:*
| udp 0 0 *:mdns *:*
| udp 0 0 *:sunrpc *:*
| Sockets du domaine UNIX actives(serveurs et ÃÂÃÂÃÂétablies)
| Proto RefCpt Indicatrs Type Etat I-Node Chemin
| unix 2 [ ACC ] STREAM LISTENING 4476 @/var/run/hald/dbus-hAUCEFLem5
| unix 2 [ ACC ] STREAM LISTENING 4041 /var/run/dbus/system_bus_socket
| unix 2 [ ACC ] STREAM LISTENING 4173 /var/run/acpid.socket
| unix 2 [ ACC ] STREAM LISTENING 4473 @/var/run/hald/dbus-CwaPn6jAVh
| unix 2 [ ACC ] STREAM LISTENING 6060 @/tmp/.X11-unix/X0
| unix 2 [ ] DGRAM 512 @/org/kernel/udev/udevd
| unix 13 [ ] DGRAM 3965 /dev/log
| unix 2 [ ] DGRAM 4498 @/org/freedesktop/hal/udev_event
| unix 2 [ ACC ] STREAM LISTENING 3641 /var/run/rpcbind.sock
| unix 2 [ ACC ] STREAM LISTENING 6008 /var/run/gdm_socket
| unix 2 [ ACC ] STREAM LISTENING 3945 /var/run/pcscd.comm
| unix 2 [ ACC ] STREAM LISTENING 4446 /var/run/avahi-daemon/socket
| unix 2 [ ACC ] STREAM LISTENING 6061 /tmp/.X11-unix/X0
| unix 2 [ ACC ] STREAM LISTENING 4013 /var/run/audispd_events
| unix 2 [ ACC ] STREAM LISTENING 6194 /tmp/orbit-gdm/linc-8d1-0-260b868bdfaac
| unix 2 [ ACC ] STREAM LISTENING 6199 /tmp/orbit-gdm/linc-8cf-0-73485901dff43
| unix 2 [ ACC ] STREAM LISTENING 6210 /tmp/orbit-gdm/linc-8cd-0-1c2d188aeb267
| unix 2 [ ] STREAM CONNECTE 29854
| unix 2 [ ] DGRAM 28814
| unix 3 [ ] STREAM CONNECTE 25936
| unix 3 [ ] STREAM CONNECTE 25935
| unix 3 [ ] STREAM CONNECTE 25934
| unix 3 [ ] STREAM CONNECTE 25933
| unix 3 [ ] STREAM CONNECTE 24660
| unix 3 [ ] STREAM CONNECTE 24659
| unix 3 [ ] STREAM CONNECTE 24658
| unix 3 [ ] STREAM CONNECTE 24657
| unix 3 [ ] STREAM CONNECTE 6223 @/tmp/.X11-unix/X0
| unix 3 [ ] STREAM CONNECTE 6222
| unix 3 [ ] STREAM CONNECTE 6219 /tmp/orbit-gdm/linc-8cd-0-1c2d188aeb267
| unix 3 [ ] STREAM CONNECTE 6212
| unix 3 [ ] STREAM CONNECTE 6209 /tmp/orbit-gdm/linc-8cf-0-73485901dff43
| unix 3 [ ] STREAM CONNECTE 6208
| unix 3 [ ] STREAM CONNECTE 6207 @/tmp/.X11-unix/X0
| unix 3 [ ] STREAM CONNECTE 6206
| unix 3 [ ] STREAM CONNECTE 6202 /tmp/orbit-gdm/linc-8cf-0-73485901dff43
| unix 3 [ ] STREAM CONNECTE 6201
| unix 3 [ ] STREAM CONNECTE 6198 /tmp/orbit-gdm/linc-8d1-0-260b868bdfaac
| unix 3 [ ] STREAM CONNECTE 6197
| unix 3 [ ] STREAM CONNECTE 6158 @/tmp/.X11-unix/X0
| unix 3 [ ] STREAM CONNECTE 6157
| unix 3 [ ] STREAM CONNECTE 6156 @/tmp/.X11-unix/X0
| unix 3 [ ] STREAM CONNECTE 6155
| unix 3 [ ] STREAM CONNECTE 6133 @/tmp/.X11-unix/X0
| unix 3 [ ] STREAM CONNECTE 6132
| unix 3 [ ] STREAM CONNECTE 6097 @/tmp/.X11-unix/X0
| unix 3 [ ] STREAM CONNECTE 6096
| unix 3 [ ] STREAM CONNECTE 6064 /var/run/acpid.socket
| unix 3 [ ] STREAM CONNECTE 6063
| unix 2 [ ] DGRAM 6028
| unix 3 [ ] STREAM CONNECTE 6027 /var/run/pcscd.comm
| unix 3 [ ] STREAM CONNECTE 6026
| unix 3 [ ] STREAM CONNECTE 5196 @/var/run/hald/dbus-CwaPn6jAVh
| unix 3 [ ] STREAM CONNECTE 5195
| unix 3 [ ] STREAM CONNECTE 5194 /var/run/dbus/system_bus_socket
| unix 3 [ ] STREAM CONNECTE 5193
| unix 3 [ ] STREAM CONNECTE 5169 @/var/run/hald/dbus-CwaPn6jAVh
| unix 3 [ ] STREAM CONNECTE 5168
| unix 3 [ ] STREAM CONNECTE 5156 /var/run/dbus/system_bus_socket
| unix 3 [ ] STREAM CONNECTE 5155
| unix 3 [ ] STREAM CONNECTE 4998 /var/run/acpid.socket
| unix 3 [ ] STREAM CONNECTE 4997
| unix 3 [ ] STREAM CONNECTE 4981 @/var/run/hald/dbus-CwaPn6jAVh
| unix 3 [ ] STREAM CONNECTE 4980
| unix 3 [ ] STREAM CONNECTE 4638 @/var/run/hald/dbus-CwaPn6jAVh
| unix 3 [ ] STREAM CONNECTE 4626
| unix 3 [ ] STREAM CONNECTE 4493 @/var/run/hald/dbus-hAUCEFLem5
| unix 3 [ ] STREAM CONNECTE 4492
| unix 3 [ ] STREAM CONNECTE 4475 /var/run/dbus/system_bus_socket
| unix 3 [ ] STREAM CONNECTE 4474
| unix 3 [ ] STREAM CONNECTE 4449 /var/run/dbus/system_bus_socket
| unix 3 [ ] STREAM CONNECTE 4448
| unix 3 [ ] STREAM CONNECTE 4443
| unix 3 [ ] STREAM CONNECTE 4442
| unix 2 [ ] DGRAM 4439
| unix 2 [ ] DGRAM 4389
| unix 3 [ ] STREAM CONNECTE 4367 /var/run/dbus/system_bus_socket
| unix 3 [ ] STREAM CONNECTE 4366
| unix 2 [ ] DGRAM 4346
| unix 2 [ ] DGRAM 4323
| unix 2 [ ] DGRAM 4175
| unix 2 [ ] DGRAM 4107
| unix 3 [ ] STREAM CONNECTE 4045
| unix 3 [ ] STREAM CONNECTE 4044
| unix 2 [ ] DGRAM 4015
| unix 2 [ ] DGRAM 4009
| unix 3 [ ] STREAM CONNECTE 4008
| unix 3 [ ] STREAM CONNECTE 4007
| unix 2 [ ] DGRAM 3978
| unix 3 [ ] STREAM CONNECTE 3826
| unix 3 [ ] STREAM CONNECTE 3825
|
and finally the content of the /etc/hosts file
anonymous wrote : # Do not remove the following line, or various programs
| # that require network functionality will fail.
| 127.0.0.1 fedora.domain fedora localhost.localdomain localhost fedora
| myIp myname
| ::1 localhost6.localdomain6 localhost6
|
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4146140#4146140
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4146140
18 years
[EJB 3.0] - Why can't existing Remote Interface of a deployed session be
by baumar
Hi,
I'm trying a basic example with an entity bean Person
and a stateless bean PersonFeederBean that is getting a list of persons and to persist them, print them and maybe remove them.
The PersonFeederBean is called by ClientPersonFeeder creating the list of person to store.
The code compiles in eclipse 3.2 with java compliance level 5, the jar can is deployed (on JBoss 404), the PersonFeederBean can be looked up and narrowed; to make sure it is not empty I added a test retrieving the methods; they are there.
But when I want to call one of these methods I get the error:
"$Proxy0.testInstanceAlive(Unknown Source)" as listed at the end of the code section.
Can anybody tell me, what went wrong?
I also wonder, what I might do to get rid of the java.lang.reflect.UndeclaredThrowableException, is there a strategy or documentation about it?
Thanks for help
Markus
code:
import java.io.Serializable;
@Entity
@NamedQueries({
@NamedQuery(name="Person.findall_sortlastname", query="SELECT p FROM Person p")
})
@Table(name="PERSON")
public class Person implements Serializable{
private static final long serialVersionUID = 1L;
public Person() {};
public Person(String firstName, String lastName) {
setTechnicalId(technicalId);
setFirstName(firstName);
setLastName(lastName);
};
@Id
@Column(name="TECHNICALID")
@GeneratedValue(strategy=GenerationType.AUTO)
private int technicalId;
public int getTechnicalId() {
return technicalId;
}
public void setTechnicalId(int technicalId) {
this.technicalId = technicalId;
}
@Column(name="FIRSTNAME")
private String firstName;
public String getFirstName() {
return firstName;
}
public void setFirstName(String firstName) {
this.firstName = firstName;
}
@Column(name="LASTNAME")
private String lastName;
public String getLastName() {
return lastName;
}
public void setLastName(String lastName) {
this.lastName = lastName;
}
public String toString() {
return "firstname: "+getFirstName()+"; lastname: "+getLastName()+"; id: "+getTechnicalId();
}
}
@Remote
public interface PersonFeederRemote {
public void feedPersonList(Vector personList);
public void deletePersonList(Vector personList);
public void listAllPerson();
public void testInstanceAlive();
}
@Stateless
public class PersonFeederBean implements PersonFeederRemote {
@PersistenceUnit(unitName="ForumorganizerTest")
EntityManager manager;
public void feedPersonList(Vector personList) {
for (Person person: personList) {
manager.persist(person);
System.out.println("added "+person.toString());
}
}
}
public void deletePersonList(Vector personList) {
for (Person person: personList) {
manager.remove(person);
System.out.println("added "+person.toString());
}
}
public void listAllPerson() {
List resultList = manager.createNamedQuery("Person.findAll_sortlastname").getResultList();
for( Object o: resultList) {
System.out.println(o.toString());
}
}
public void testInstanceAlive() {
System.out.println("PersonFeederBean is alive");
}
}
14:14:28,109 INFO [JmxKernelAbstraction] installing MBean: jboss.j2ee:jar=person.jar,name=PersonFeederBean,service=EJB3 with dependencies:
14:14:28,109 INFO [JmxKernelAbstraction] persistence.units:jar=person.jar,unitName=ForumorganizerTest
14:14:28,140 INFO [EJBContainer] STARTED EJB: com.informationcontrol.forumorganizer.persistence.PersonFeederBean ejbName: PersonFeederBean
14:14:28,250 INFO [EJB3Deployer] Deployed: file:/C:/Programme/JBoss/JBoss404/server/default/deploy/person.jar
public class ClientPersonFeeder {
/**
* @param args
*/
public static void main(String[] args) {
Context ctx =null;
Object ref = null;
try {
ctx = new InitialContext();
ref = ctx.lookup("PersonFeederBean/remote");
} catch (NamingException e) {
System.out.println("could not find PersonFeederBean/remote");
e.printStackTrace();
}
try {
NamingEnumeration nameList = ctx.listBindings("");
while (nameList.hasMore()) {
Binding binding = (Binding) nameList.next();
System.out.println(binding.getName()+"; "+binding.getObject());
}
} catch (NamingException e) {
System.out.println("Could not find root directory");
e.printStackTrace();
}
PersonFeederRemote pfr = (PersonFeederRemote) PortableRemoteObject.narrow(ref, PersonFeederRemote.class);
if (pfr == null) {
System.out.println("PersonFeederRemote is null");
} else {
Method[] methods = pfr.getClass().getMethods();
for (Method method: methods) { System.out.println(method.getName());}
}
Vector personList = new Vector();
Person person = new Person("First", "Last");
personList.add(person);
person = new Person("Peter", "Muster");
personList.add(person);
// !!!!!!!!!!! the first call to a method of the bean causes the error: !!!!!!
pfr.testInstanceAlive();
pfr.feedPersonList(personList);
pfr.listAllPerson();
pfr.deletePersonList(personList);
pfr.listAllPerson();
}
Exception in thread "main" java.lang.reflect.UndeclaredThrowableException
at $Proxy0.testInstanceAlive(Unknown Source)
at com.informationcontrol.forumorganizer.clientfortest.ClientPersonFeeder.main(ClientPersonFeeder.java:67)
Caused by: java.lang.ClassNotFoundException: [Ljava.lang.StackTraceElement;
at java.net.URLClassLoader$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at org.jboss.remoting.loading.RemotingClassLoader.loadClass(RemotingClassLoader.java:50)
...
ERROR: JDWP Unable to get JNI 1.2 environment, jvm->GetEnv() return code = -2
JDWP exit error AGENT_ERROR_NO_JNI_ENV(183): [../../../src/share/back/util.c:820]
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4146138#4146138
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4146138
18 years
[JBossWS] - Re: No tests for @SchemaValidation annotation in 3.0.1 ?
by ljgp
Hi,
> The question about where the annotation is tested remains.
And still remains...maybe I should repeat what the question was, so people do'nt have to search for it by looking through all previous posts.
The question was:
I am probably overlooking something, because I cannot find a proper test for the @SchemaValidation annotation.
There are two endpoint classes, org.jboss.test.ws.jaxws.jbws1172.ValidatingEndpoint.java and NonValidatingEndpoint.java
The annotation processor processes the @SchemaValidation annotation by adding the relevant feature to the endpoint.
However, in JBWS1172TestCase.java, the testcases ignore the defined endpoints, and instead add the validating feature to endpoints defined in the testcode. So, to me it seems the handling of the @SchemaValidation annotation is not tested here. Is there another test for this maybe ?
If I cannot get this to work, I am considering switching to the metro implementation, which should have support for this (added november last year I think).
Cheers, Luc.
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4146132#4146132
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4146132
18 years