[JBossWS] - Marshall Object List
by bsisson
I'm trying to marshall a list containing objects into an XML string. I was able to marshall a single object into an XML string but am struggling on what is needed to do a list?
I am including an example using JBoss Tools Web Services. It will query the database and receive a back a list of WebCalendar objects. If I create a single object and marshall it will work. However, I need to marshall the list so that it creates multiple entries for each object in the marshalled XML. If you can advise I would appreciate it.
Here is an example code:
This is the class that will query the database which returns a list of WebPayCalendar objects I then try to marshall the list into an XML string:
@WebMethod
public String retrievePsWebPayCalendar()
{
try
{
/**************************************************************************
* The following example marshals an object class into an XML string which
* is returned to the caller. The object is an entity representing a
* row on the database.
**************************************************************************/
WebPayCalendarList selectCalendar = (WebPayCalendarList) Component.getInstance("webPayCalendarList");
// Retrieve the entire list of web pay calendar dates
List pc = selectCalendar.getResultList();
// For a test retrieve only the first web calendar date object
WebPayCalendar wpc = pc.get(0);
// Marshal the calendar information into an XML string and return it
JAXBContext context = JAXBContext.newInstance(WebPayCalendar.class);
Marshaller marshaller = context.createMarshaller();
marshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, true);
marshaller.marshal(pc, System.out);
return result.getWriter().toString();
}
catch (Exception e)
{
return "Error: " + e.getMessage();
}
}
This is the object Class:
package org.domain.PSWebService.entity;
import java.io.Serializable;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.Table;
import javax.persistence.UniqueConstraint;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlType;
import org.hibernate.validator.Length;
@Entity
@Table(name="WEB_PAY_CALENDAR", uniqueConstraints = {@UniqueConstraint(columnNames={"RUN_ID"})})
@XmlRootElement
public class WebPayCalendar implements Serializable
{
//WEB_PAY_CALENDAR Data Columns
@Length(max=3)
private String payGroup;
@Id
@Length(max=10)
@Column(name="RUN_ID")
private String runId;
@Column(name="CHECK_DT")
private java.util.Date checkDt;
@Column(name="PAY_BEGIN_DT")
private java.util.Date payBeginDt;
@Column(name="PAY_END_DT")
private java.util.Date payEndDt;
@Length(max=1)
@Column(name="PAY_CONFIRM_RUN")
private String payConfirmRun;
public String getPayGroup()
{
return payGroup;
}
public void setPayGroup(String payGroup)
{
this.payGroup = payGroup;
}
public String getRunId()
{
return runId;
}
public void setRunId(String runId)
{
this.runId = runId;
}
public java.util.Date getCheckDt()
{
return checkDt;
}
public void setCheckDt(java.util.Date checkDt)
{
this.checkDt = checkDt;
}
public java.util.Date getPayBeginDt()
{
return payBeginDt;
}
public void setPayBeginDt(java.util.Date payBeginDt)
{
this.payBeginDt = payBeginDt;
}
public java.util.Date getPayEndDt()
{
return payEndDt;
}
public void setPayEndDt(java.util.Date payEndDt)
{
this.payEndDt = payEndDt;
}
public String getPayConfirmRun()
{
return payConfirmRun;
}
public void setPayConfirmRun(String payConfirmRun)
{
this.payConfirmRun = payConfirmRun;
}
}
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4152353#4152353
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4152353
17 years, 11 months
Automatically rejected mail
by Mail Delivery Subsystem
Your message was automatically rejected by Dovecot Mail Delivery Agent.
The following reason was given:
Quota exceeded
17 years, 11 months
[Clustering/JBoss] - Re: HA-JNDI server side problem
by wecucho
Thanks for your reply, i test what you say but that does not work :(, still respond the same node which is running the method, i think are a kind of "affinity" that make the InitialContext to use the local or something.
Im gonna to explain the problem better but i think that its difficult to see yet, i create a simple method to determine which exactly node is the master node of a cluster give a node of it or several nodes using the HA-JNDI port of course (does not mather IF i use Round Robin Balance *), and it works great OUTSIDE the cluster, the method start to lookup and the nodes start to respond in the round robin way, so, in my test enviroment that tooks 2 iteration tops.. for instance, i start looking for the master and..
1.- respond the master: thats it, i have the master at first time
2.- respond the other node: upps i have the MasterNode in false and return, my method is gonna lookup again and for the balance (Round Robin) the master will respond...
As my program is a kind of Queue manager, he needs to dynamically creates and delete queues, so it needs the "jboss.mq:service=DestinationManager" who lives only in the MASTER node, so i can execute operations like:
anonymous wrote :
| mbsMaster.invoke(destinationManager, "createQueue", new Object[] { name, name }, new String[] {
| String.class.getName(), String.class.getName() });
|
and
anonymous wrote :
| mbsMaster.invoke(destinationManager, "destroyQueue", new Object[] { name}, new String[] {
| String.class.getName()});
|
When i try your suggestion this was my result...
anonymous wrote :
| 2008-05-21 08:11:10,899 INFO [STDOUT] trying with 192.168.5.63:1099
| 2008-05-21 08:11:10,952 INFO [STDOUT] obtained 192.168.5.52
| 2008-05-21 08:11:10,953 INFO [STDOUT] trying with 192.168.5.63:1099
| 2008-05-21 08:11:10,955 INFO [STDOUT] obtained 192.168.5.52
| 2008-05-21 08:11:10,955 INFO [STDOUT] trying with 192.168.5.63:1099
| 2008-05-21 08:11:10,957 INFO [STDOUT] obtained 192.168.5.52
| 2008-05-21 08:11:10,957 INFO [STDOUT] trying with 192.168.5.63:1099
| 2008-05-21 08:11:10,959 INFO [STDOUT] obtained 192.168.5.52
| 2008-05-21 08:11:10,959 INFO [STDOUT] trying with 192.168.5.63:1099
| 2008-05-21 08:11:10,961 INFO [STDOUT] obtained 192.168.5.52
| 2008-05-21 08:11:10,961 INFO [STDOUT] trying with 192.168.5.63:1099
| 2008-05-21 08:11:10,963 INFO [STDOUT] obtained 192.168.5.52
| 2008-05-21 08:11:10,964 INFO [STDOUT] trying with 192.168.5.63:1099
| 2008-05-21 08:11:10,965 INFO [STDOUT] obtained 192.168.5.52
| 2008-05-21 08:11:10,966 INFO [STDOUT] trying with 192.168.5.63:1099
| 2008-05-21 08:11:10,968 INFO [STDOUT] obtained 192.168.5.52
| 2008-05-21 08:11:10,972 INFO [STDOUT] trying with 192.168.5.63:1099
| 2008-05-21 08:11:10,973 INFO [STDOUT] obtained 192.168.5.52
| 2008-05-21 08:11:10,974 INFO [STDOUT] trying with 192.168.5.63:1099
| 2008-05-21 08:11:10,975 INFO [STDOUT] obtained 192.168.5.52
| 2008-05-21 08:11:10,976 INFO [STDOUT] not found
|
He was trying to look directly in the master node but for some mysterious and divine reason that only god is able to answer that lookup obtain the local Context, if i run the same test in the master node directly i get:
anonymous wrote :
| 2008-05-21 08:15:11,499 INFO [STDOUT] trying with 192.168.5.63:1099
| 2008-05-21 08:15:11,552 INFO [STDOUT] obtained 192.168.5.63
| 2008-05-21 08:15:11,632 INFO [STDOUT] MASTER found!
|
There has to be some kind of affinity as i said before that make this happend, and my best guest is that have to be a way to disable this behavior in the jboss, or mabye there have to be a different way to ask for the master..
Thanks for your time :)
Maybe with this additional info your or anyone can see my problem better.
* If my balance is Round Robin the only thing i have to do is ask for a resource (lookup --> ctx.lookup("jmx/invoker/RMIAdaptor")) and get the MasterNode variable and if TRIES is bigger than the number of the nodes in the cluster ill gonna get the master node in some point.
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4152335#4152335
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4152335
17 years, 11 months
[Clustering/JBoss] - WAR redeployment requires restart
by rajeshchande
JBOss : 4.2.2GA
JDK : 1.5.0_12
SunOS hubudweb02 5.10 Generic_118822-18 sun4u sparc SUNW,Sun-Fire-V240
I have 2 clustered instances working perfectly fine. I have around 20 applications deployed on this cluster. When I re-deploy one of the application the cluster, I get the following errors:
####################
| | INFO [TomcatDeployer] deploy, ctxPath=/, warUrl=.../tmp/deploy/tmp65116ssa-exp.war/
| | ERROR [BaseModelMBean] Exception invoking method destroy
| | java.lang.NullPointerException
| | at org.jboss.mx.loading.RepositoryClassLoader.findClass(RepositoryClassLoader.java:630)
| | at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
| | at org.jboss.mx.loading.RepositoryClassLoader.loadClassImpl(RepositoryClassLoader.java:474)
| | at org.jboss.mx.loading.RepositoryClassLoader.loadClass(RepositoryClassLoader.java:415)
| | at java.lang.ClassLoader.loadClass(ClassLoader.java:299)
| | at java.net.FactoryURLClassLoader.loadClass(URLClassLoader.java:579)
| | at java.lang.ClassLoader.loadClass(ClassLoader.java:251)
| | at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1345)
| | at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1204)
| | at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:319)
| | at org.apache.struts2.dispatcher.Dispatcher.cleanup(Dispatcher.java:257)
| | at org.apache.struts2.dispatcher.FilterDispatcher.destroy(FilterDispatcher.java:221)
|
|
|
| | at org.jboss.deployment.scanner.AbstractDeploymentScanner$ScannerThread.run(AbstractDeploymentScanner.java:225)
| WARN [ServiceController] Problem starting service jboss.web.deployment:war=ssa.war,id=181
| 9396930
| | org.jboss.deployment.DeploymentException: Error during deploy; - nested throwable: (javax.management.Ru
| ntimeOperationsException: Exception invoking method destroy)
| | at org.jboss.web.AbstractWebDeployer.start(AbstractWebDeployer.java:384)
| | at org.jboss.web.WebModule.startModule(WebModule.java:83)
| | at org.jboss.web.WebModule.startService(WebModule.java:61)
| | at org.jboss.system.ServiceMBeanSupport.jbossInternalStart(ServiceMBeanSupport.java:289)
| | at org.jboss.system.ServiceMBeanSupport.jbossInternalLifecycle(ServiceMBeanSupport.java:245)
| | at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
| | at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
| | at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
| | at java.lang.reflect.Method.invoke(Method.java:585)
| | at org.jboss.mx.interceptor.ReflectedDispatcher.invoke(ReflectedDispatcher.java:155)
| | at org.jboss.mx.server.Invocation.dispatch(Invocation.java:94)
| | at org.jboss.mx.server.Invocation.invoke(Invocation.java:86)
| | at org.jboss.mx.server.AbstractMBeanInvoker.invoke(AbstractMBeanInvoker.java:264)
| | at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:659)
| | at org.jboss.system.ServiceController$ServiceProxy.invoke(ServiceController.java:978)
| | at $Proxy0.start(Unknown Source)
| ####################
This WAR file has following jar files in WEB-INF/lib
##########################
| commons-beanutils-bean-collections.jar
| commons-beanutils-core.jar
| commons-beanutils.jar
| commons-digester.jar
| commons-lang-2.3.jar
| displaytag-1.1.1.jar
| displaytag-export-poi-1.1.1.jar
| freemarker-2.3.8.jar
| itext-1.3.jar
| jstl-1.1.2.jar
| ognl-2.6.11.jar
| saxon7.jar
| standard-1.0.6.jar
| struts2-core-2.0.11.jar
| struts2-tiles-plugin-2.0.11.jar
| tiles-api-2.0.4.jar
| tiles-core-2.0.4.jar
| tiles-jsp-2.0.4.jar
| xwork-2.0.4.jar
| ##########################
The only solution that works is RESTART of both JBoss clustered instances. At that time, everything works fine till the next redeployment of this WAR files.
All other WAR seem to suuccessfully redeploy. There is NO need of restart of the JBoss instances required except this particular WAR file.
Why the redeployment fails for this WAR file? Is this a struts issue OR a JBoss bug? I could see below struts issue on net but not sure if this is the culprit here.
https://issues.apache.org/struts/browse/WW-2523
https://issues.apache.org/struts/browse/WW-2509
http://forums.bea.com/thread.jspa?threadID=300000385
Can someone help me conclude whats the exact issue?
Regards,
Rajesh.
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4152329#4152329
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4152329
17 years, 11 months