[JBoss Seam] - Update problem with Seam contexts, Bindings, JSF Components
by haikodo
Hello!
I have:
- One LocationBean javabean with session context that holds my current location (I use selectOneMenu on the page to select my location)
- One DDAirportMenu JSF component that I use to dynamically render a richfaces dropdown menu based on the Location defined in the LocationBean (using the binding attribute)
The first time I load the page the DDAirportMenu calls the getAirportmenu and the dropdown menu is created witht the correct location.
However, after this when I change the location from the selectOneMenu, the dropdown menu is not updated. Inside the DDAirportMenu the getAirportmenu method is never called (it was called on the first page load)
The LocationBean value is updated successfully and I also retrieve data from the db.. which is also updated successfuly.
LocationBean:
|
| @Stateful
| @Scope(ScopeType.SESSION)
| @Name("locationBean")
| public class LocationBean implements Location {
|
| @Logger private Log log;
|
| @In FacesMessages facesMessages;
|
| protected String name;
| protected String airport;
| protected String busstation;
| protected String trainstation;
| protected String harbor;
| ArrayList<String> locations = new ArrayList<String>();
| Hashtable<String, ArrayList<String>> airports_cache = new Hashtable<String, ArrayList<String>>();
| Hashtable<String, ArrayList<String>> busstations_cache = new Hashtable<String, ArrayList<String>>();
| Hashtable<String, ArrayList<String>> trainstations_cache = new Hashtable<String, ArrayList<String>>();
| Hashtable<String, ArrayList<String>> harbors_cache = new Hashtable<String, ArrayList<String>>();
|
| public LocationBean() {
| /* Locations */
| locations.add("City1");
| locations.add("City2");
|
| //City1
| l = new ArrayList<String>();
| l.add("City1: Airport 2");
| l.add("City1: Airport 1");
| airports_cache.put("City1", l);
|
| /* City 2 */
| l = new ArrayList<String>();
| l.add("City2: Airport 2");
| l.add("City2: Airport 1");
| airports_cache.put("City2", l);
|
|
| // Set defaults
| name = "city";
| airport = "City2: Airport 1";
|
|
|
| }
|
| public void location()
| {
| //implement your business logic here
| log.info("location.location() action called");
| facesMessages.add("location");
|
| }
|
| @Destroy @Remove
| public void destroy() {}
|
| //add additional action methods
|
| public String getName() {
| System.out.println("----- getting name " + name);
| return name;
| }
|
| public void setName(String name) {
| System.out.println("----- setting name to " + name);
|
|
| this.name = name;
| this.airport = this.getAirports().get(0);
| }
|
| public ArrayList<String> getLocations() {
| System.out.println("Returning locations-------------------");
| return locations;
| }
|
| public ArrayList<String> getAirports() {
| System.out.println("Returning aiports list for city: " + name + " .. size=" + airports_cache.get(name).size());
| return airports_cache.get(name);
| }
|
| public ArrayList<String> getRemainingLocations() {
| System.out.println("Returning locations-------------------");
| java.util.Iterator<String> i = locations.iterator();
| ArrayList<String> l = new ArrayList<String>();
| while (i.hasNext()) {
| String t = i.next();
| if (!t.equals(name)) {
| l.add(t);
| }
| }
|
| return l;
| }
|
| public ArrayList<String> getRemainingAirports() {
| System.out.println("Returning aiports list for city: " + name + " .. size=" + airports_cache.get(name).size());
|
| java.util.Iterator<String> i = airports_cache.get(name).iterator();
| ArrayList<String> l = new ArrayList<String>();
| while (i.hasNext()) {
| String t = i.next();
| if (!t.equals(airport)) {
| l.add(t);
| }
| }
| return l;
| }
|
| public String getAirport() {
| return airport;
| }
|
| public void setAirport(String airport) {
| this.airport = airport;
| }
| }
|
|
JSF-component
| @Name("ddairportmenu")
| @Scope(ScopeType.EVENT)
| @AutoCreate
| public class DDAirportMenu {
|
| private org.richfaces.component.html.HtmlDropDownMenu airportmenu;
| @In(create=true)
| private Location locationBean;
|
| public HtmlDropDownMenu getAirportmenu() {
|
| System.out.println("Pimping out the menu ...");
| airportmenu= new HtmlDropDownMenu();
| HtmlOutputLabel p = new HtmlOutputLabel();
| HtmlOutputText ot = new HtmlOutputText();
| ot.setValue(locationBean.getAirport());
| HtmlGraphicImage og = new HtmlGraphicImage();
| og.setUrl("img/arrow_down.gif");
| og.setStyle("vertical-align: bottom;");
| p.getChildren().add(ot);
| p.getChildren().add(og);
| airportmenu.getFacets().put("label", p);
|
| List<String> l = locationBean.getRemainingAirports();
| Iterator<String> i = l.iterator();
|
| while (i.hasNext()) {
| HtmlMenuItem m = new HtmlMenuItem();
| String tmp = i.next();
| m.setValue(tmp);
| airportmenu.getChildren().add(m);
| }
| return airportmenu;
| }
|
| ......
|
jsf page:
| <h:form>
| <h:selectOneMenu id="test" value="#{locationBean.name}" style="barsearch" onchange="submit();">
| <s:selectItems var="car" value="#{locationBean.locations}">
| </s:selectItems>
| </h:selectOneMenu>
|
|
|
| .....
| <h:column><rich:spacer></rich:spacer></h:column>
| <h:column>
| <rich:dropDownMenu binding="#{ddairportmenu.airportmenu}"></rich:dropDownMenu></h:column>
| <h:column><rich:spacer></rich:spacer></h:column>
|
| .....
| </h:form>
|
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4129826#4129826
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4129826
18 years, 2 months
[EJB 3.0] - Re: Jboss 5 Beta 4 Resource Injection problem in Ejb 3
by jaikiran
Works fine on JBoss5 Beta-4 for me. I have a similar EJB (but without the Spring related stuff):
@Stateless
| @Remote ({UserManager.class})
| @RemoteBinding (jndiBinding = "RemoteUserManagerBean")
| public class UserManagerBean implements UserManager {
|
| /**
| * Instance of logger
| */
| private static Logger logger = Logger.getLogger(UserManagerBean.class);
|
| @PersistenceContext
| private EntityManager entityManager;
|
| @Resource
| private SessionContext sessionContext;
|
| @Resource(name = "jdbc/TestDs", type = DataSource.class, shareable = true, mappedName = "java:DefaultDS")
| private DataSource dataSource;
|
| @PostConstruct
| public void init() {
| setDataSource(dataSource);
| }
|
| private void setDataSource(DataSource ds) {
| System.out.println("Do nothing ---> " + ds);
| }
| }
The application deploys fine and accesing this bean too works fine.
Are you sure that the datasource has been deployed, before this bean is being accessed?
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4129821#4129821
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4129821
18 years, 2 months
[JNDI/Naming/Network] - jndi connecting problem
by SunSpider
I bind jboss to one network interface with ./run.sh -b x.x.x.x command.
When run on the local machine, client using jndi connects correctly to the configured address, and finishes successfully. but on remote machine, exception is thrown. more over, if the code is wrapped inside servlet, though jndi context is correct, the code always connect to localhost.
first one of the following stack trace is shown on remote machine, the second one is inside container.
//========================
{java.naming.factory.initial=org.jnp.interfaces.NamingContextFactory, java.naming.provider.url=192.168.1.101, java.naming.factory.url.pkgs=org.jnp.interfaces:org.jboss.naming}
javax.naming.CommunicationException: Could not obtain connection to any of these urls: 192.168.1.101 and discovery failed with error: javax.naming.CommunicationException: Receive timed out [Root exception is java.net.SocketTimeoutException: Receive timed out] [Root exception is javax.naming.CommunicationException: Failed to connect to server 192.168.1.101:1099 [Root exception is java.lang.ClassNotFoundException: org.jnp.server.NamingServer_Stub]]
at org.jnp.interfaces.NamingContext.checkRef(NamingContext.java:1601)
at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:636)
at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:629)
at javax.naming.InitialContext.lookup(Unknown Source)
at sunspider.jaxws20.tutorial.service.impl.eventing.AnnoucementEntity.(AnnoucementEntity.java:52)
at sunspider.jaxws20.tutorial.service.impl.eventing.AnnoucementEntity.main(AnnoucementEntity.java:121)
Caused by: javax.naming.CommunicationException: Failed to connect to server 192.168.1.101:1099 [Root exception is java.lang.ClassNotFoundException: org.jnp.server.NamingServer_Stub]
at org.jnp.interfaces.NamingContext.getServer(NamingContext.java:276)
at org.jnp.interfaces.NamingContext.checkRef(NamingContext.java:1572)
... 5 more
Caused by: java.lang.ClassNotFoundException: org.jnp.server.NamingServer_Stub
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 java.lang.ClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClassInternal(Unknown Source)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Unknown Source)
at sun.rmi.server.LoaderHandler.loadClass(Unknown Source)
at sun.rmi.server.LoaderHandler.loadClass(Unknown Source)
at java.rmi.server.RMIClassLoader$2.loadClass(Unknown Source)
at java.rmi.server.RMIClassLoader.loadClass(Unknown Source)
at sun.rmi.server.MarshalInputStream.resolveClass(Unknown Source)
at java.io.ObjectInputStream.readNonProxyDesc(Unknown Source)
at java.io.ObjectInputStream.readClassDesc(Unknown Source)
at java.io.ObjectInputStream.readOrdinaryObject(Unknown Source)
at java.io.ObjectInputStream.readObject0(Unknown Source)
at java.io.ObjectInputStream.readObject(Unknown Source)
at java.rmi.MarshalledObject.get(Unknown Source)
at org.jnp.interfaces.NamingContext.getServer(NamingContext.java:259)
... 6 more
//===========================
2008-02-16 19:45:09,834 INFO [STDOUT] thread start
2008-02-16 19:45:09,850 INFO [STDOUT] {java.naming.provider.url=192.168.1.101, java.naming.factory.initial=org.jnp.interfaces.NamingContextFactory, java.naming.factory.url.pkgs=org.jboss.naming:org.jnp.interfaces:org.jboss.naming:org.jnp.interfaces:org.jnp.interfaces:org.jboss.naming:org.jnp.interfaces:org.jboss.naming}
2008-02-16 19:45:15,020 DEBUG [org.jnp.interfaces.NamingContext] Failed to connect to localhost:1099
javax.naming.CommunicationException: Failed to connect to server localhost:1099 [Root exception is javax.naming.ServiceUnavailableException: Failed to connect to server localhost:1099 [Root exception is java.net.ConnectException: Connection refused]]
at org.jnp.interfaces.NamingContext.getServer(NamingContext.java:272)
at org.jnp.interfaces.NamingContext.checkRef(NamingContext.java:1423)
at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:597)
at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:590)
at javax.naming.InitialContext.lookup(InitialContext.java:351)
at org.jboss.ws.extensions.eventing.mgmt.DispatcherDelegate.getServer(DispatcherDelegate.java:84)
at org.jboss.ws.extensions.eventing.mgmt.DispatcherDelegate.getSubscriptionManager(DispatcherDelegate.java:65)
at org.jboss.ws.extensions.eventing.mgmt.DispatcherDelegate.dispatch(DispatcherDelegate.java:44)
at sunspider.jaxws20.tutorial.service.impl.eventing.AnnoucementEntity.run(AnnoucementEntity.java:132)
Caused by: javax.naming.ServiceUnavailableException: Failed to connect to server localhost:1099 [Root exception is java.net.ConnectException: Connection refused]
at org.jnp.interfaces.NamingContext.getServer(NamingContext.java:246)
... 8 more
Caused by: java.net.ConnectException: Connection refused
at java.net.PlainSocketImpl.socketConnect(Native Method)
at java.net.PlainSocketImpl.doConnect(PlainSocketImpl.java:333)
at java.net.PlainSocketImpl.connectToAddress(PlainSocketImpl.java:195)
at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:182)
at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:366)
at java.net.Socket.connect(Socket.java:516)
at java.net.Socket.connect(Socket.java:466)
at java.net.Socket.(Socket.java:366)
at java.net.Socket.(Socket.java:266)
at org.jnp.interfaces.TimedSocketFactory.createSocket(TimedSocketFactory.java:84)
at org.jnp.interfaces.TimedSocketFactory.createSocket(TimedSocketFactory.java:77)
at org.jnp.interfaces.NamingContext.getServer(NamingContext.java:242)
... 8 more
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4129819#4129819
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4129819
18 years, 2 months
[JBossWS] - Re: Cannot obtain java type mapping for {http://business/jaw
by JoPe
What's this type mapping about after all? I'm trying to write my first own webservice and did two tutorials, leading to this client code:
package test.de.laliluna.library;
|
| import java.net.URL;
|
| import javax.xml.namespace.QName;
| import javax.xml.rpc.Service;
| import javax.xml.rpc.ServiceFactory;
|
| import de.laliluna.library.BookTestBean;
|
| public class WebServiceTestClient
| {
|
| /**
| * @param args
| */
| public static void main(String[] args) throws Exception
| {
| URL url = new URL("http://localhost:8080/FirstEjb3Tutorial/BookTestBean?wsdl");
| QName qname = new QName("http://library.laliluna.de/", "BookTestBeanService");
| ServiceFactory factory = ServiceFactory.newInstance();
| Service service = factory.createService(url, qname);
|
| BookTestBean serviceEndpoint = (BookTestBean)service.getPort(BookTestBean.class);
|
| serviceEndpoint.test();
| }
| }
|
leading to this exception:
Exception in thread "main" org.jboss.ws.WSException: Cannot obtain java type mapping for: {http://library.laliluna.de/}test
| at org.jboss.ws.metadata.builder.jaxrpc.JAXRPCMetaDataBuilder.processDocElement(JAXRPCMetaDataBuilder.java:627)
| ...
| at test.de.laliluna.library.WebServiceTestClient.main(WebServiceTestClient.java:22)
The last line refers to the statement "Service service = factory.createService(url, qname);"
I expected not to have to care about XML internals of the web service when using Java Annotations - like this:
@WebMethod
| @Oneway
| public void test()
| {...
So, if you could answer these questions:
1. Where/how can I manually specify a type mapping? Or do I need to extend my Annotations?
2. My web method has neither parameters nor a return value, how can there be any types to map??
I'd really appreciate it.
Also, does anybody know a good webservices tutorial for complete webservice rookies using JBoss?
Thanks in advance!
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4129818#4129818
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4129818
18 years, 2 months