Results 1 to 1 of 1
Thread: jsf+flex integration problem
- 07-03-2011, 01:16 PM #1
Member
- Join Date
- Jul 2011
- Posts
- 1
- Rep Power
- 0
jsf+flex integration problem
Witam,
próbuje zintegrować JSF z Flexem. Niestety z marnym skutkiem. Albo czegoś nie rozumiem albo źle się za to zabieram.
Stworzyłem sobie prostą aplikacje www, dodałem biblioteki flexa oraz frameworka JSF. Web xml:
Hello,
I'm traying integrate JSF and FLEX. I created simple www app with flex(from blazeDS) library and jsf framework in netbeans ide.
My web.xml
Then i wrote simple controler class:Java Code:<?xml version="1.0" encoding="UTF-8"?> <web-app version="2.5" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"> <context-param> <param-name>javax.faces.PROJECT_STAGE</param-name> <param-value>Development</param-value> </context-param> <servlet> <servlet-name>Faces Servlet</servlet-name> <servlet-class>javax.faces.webapp.FacesServlet</servlet-class> <load-on-startup>1</load-on-startup> </servlet> <servlet-mapping> <servlet-name>Faces Servlet</servlet-name> <url-pattern>/faces/*</url-pattern> </servlet-mapping> <listener> <listener-class>flex.messaging.HttpFlexSession</listener-class> </listener> <!-- MessageBroker Servlet --> <servlet> <servlet-name>MessageBrokerServlet</servlet-name> <servlet-class>flex.messaging.MessageBrokerServlet</servlet-class> <init-param> <param-name>services.configuration.file</param-name> <param-value>/WEB-INF/flex/services-config.xml</param-value> </init-param> <load-on-startup>1</load-on-startup> </servlet> <servlet-mapping> <servlet-name>MessageBrokerServlet</servlet-name> <url-pattern>/messagebroker/*</url-pattern> </servlet-mapping> <session-config> <session-timeout> 30 </session-timeout> </session-config> <welcome-file-list> <welcome-file>faces/index.xhtml</welcome-file> </welcome-file-list> </web-app>
For this class i made bean in faces=config.xml:Java Code:public class UsersControler implements Serializable{ public UsersControler(){ users.add("user1"); users.add("user2"); users.add("user2"); } private List<String> users = new ArrayList<String>(); public List getUsers() { return users; } public String getName(){ return users.get(0); } }
And jsf work correct. I can see on my test page user1,user2,user3. Problem is when i am trying acces to this bean via remote objects in flex.Java Code:<?xml version='1.0' encoding='UTF-8'?> <faces-config version="2.0" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-facesconfig_2_0.xsd"> <managed-bean> <managed-bean-name>usersService</managed-bean-name> <managed-bean-class>controlers.UsersControler</managed-bean-class> <managed-bean-scope>session</managed-bean-scope> </managed-bean> </faces-config>
I have done everithing like in this post:
accessing jsf bean from blazeds client - Stack Overflow. My factory class:
My remoting-config.xmlJava Code:public class BeanFactory implements FlexFactory { private static final String SOURCE = "source"; public void initialize(String id, ConfigMap configMap) {} public FactoryInstance createFactoryInstance(String id, ConfigMap properties) { BeanFactoryInstance instance = new BeanFactoryInstance(this, id, properties); instance.setSource(properties.getPropertyAsString(SOURCE, instance.getId())); System.out.println(instance.toString()); return instance; } public Object lookup(FactoryInstance inst) { BeanFactoryInstance factoryInstance = (BeanFactoryInstance) inst; return factoryInstance.lookup(); } static class BeanFactoryInstance extends FactoryInstance { BeanFactoryInstance(BeanFactory factory, String id, ConfigMap properties) { super(factory, id, properties); } @Override public String toString() { return "BeanFactory instance for id=" + getId() + " source=" + getSource() + " scope=" + getScope(); } @Override public Object lookup() { HttpServletRequest hsr = FlexContext.getHttpRequest(); String beanName = getSource(); try { Object o = hsr.getSession().getAttribute(beanName); return o; } catch (Exception e) { ServiceException se = new ServiceException(); String msg = "Java Bean '" + beanName + "' does not exist."; se.setMessage(msg); se.setRootCause(e); se.setDetails(msg); se.setCode("Server.Processing"); throw se; } } }}
And services-config.xmlJava Code:<?xml version="1.0" encoding="UTF-8"?> <service id="remoting-service" class="flex.messaging.services.RemotingService"> <adapters> <adapter-definition id="java-object" class="flex.messaging.services.remoting.adapters.JavaAdapter" default="true"/> </adapters> <default-channels> <channel ref="my-amf"/> </default-channels> <!-- <destination id="usersService"> <properties> <source>controlers.UsersControler</source> <scope>application</scope> </properties> </destination> --> <destination id="usersService"> <properties> <factory>beanFactory</factory> <source>usersService</source> <scope>session</scope> </properties> </destination> </service>
Files proxy-config.xml and messaging-config.xml i get from blazeds sample, i didnt change it. Doring tomcat start i get:Java Code:<?xml version="1.0" encoding="UTF-8"?> <services-config> <services> <service-include file-path="remoting-config.xml" /> <service-include file-path="proxy-config.xml" /> <service-include file-path="messaging-config.xml" /> <!-- Application level default channels. Application level default channels are necessary when a dynamic destination is being used by a service component and no ChannelSet has been defined for the service component. In that case, application level default channels will be used to contact the destination. --> <default-channels> <channel ref="my-amf"/> </default-channels> </services> <security> <security-constraint id="sample-users"> <auth-method>Custom</auth-method> <roles> <role>sampleusers</role> </roles> </security-constraint> <login-command class="flex.messaging.security.TomcatLoginCommand" server="Tomcat"/> <!-- Uncomment the correct app server <login-command class="flex.messaging.security.TomcatLoginCommand" server="JBoss"> <login-command class="flex.messaging.security.JRunLoginCommand" server="JRun"/> <login-command class="flex.messaging.security.WeblogicLoginCommand" server="Weblogic"/> <login-command class="flex.messaging.security.WebSphereLoginCommand" server="WebSphere"/> --> </security> <channels> <channel-definition id="my-streaming-amf" class="mx.messaging.channels.StreamingAMFChannel"> <endpoint url="http://{server.name}:{server.port}/{context.root}/messagebroker/streamingamf" class="flex.messaging.endpoints.StreamingAMFEndpoint"/> </channel-definition> <channel-definition id="my-amf" class="mx.messaging.channels.AMFChannel"> <endpoint url="http://{server.name}:{server.port}/{context.root}/messagebroker/amf" class="flex.messaging.endpoints.AMFEndpoint"/> <properties> <polling-enabled>false</polling-enabled> </properties> </channel-definition> <channel-definition id="my-secure-amf" class="mx.messaging.channels.SecureAMFChannel"> <endpoint url="https://{server.name}:{server.port}/{context.root}/messagebroker/amfsecure" class="flex.messaging.endpoints.SecureAMFEndpoint"/> <properties> <add-no-cache-headers>false</add-no-cache-headers> </properties> </channel-definition> <channel-definition id="my-polling-amf" class="mx.messaging.channels.AMFChannel"> <endpoint url="http://{server.name}:{server.port}/{context.root}/messagebroker/amfpolling" class="flex.messaging.endpoints.AMFEndpoint"/> <properties> <polling-enabled>true</polling-enabled> <polling-interval-seconds>4</polling-interval-seconds> </properties> </channel-definition> <channel-definition id="my-http" class="mx.messaging.channels.HTTPChannel"> <endpoint url="http://{server.name}:{server.port}/{context.root}/messagebroker/http" class="flex.messaging.endpoints.HTTPEndpoint"/> </channel-definition> <channel-definition id="my-secure-http" class="mx.messaging.channels.SecureHTTPChannel"> <endpoint url="https://{server.name}:{server.port}/{context.root}/messagebroker/httpsecure" class="flex.messaging.endpoints.SecureHTTPEndpoint"/> <properties> <add-no-cache-headers>false</add-no-cache-headers> </properties> </channel-definition> <channel-definition id="per-client-qos-polling-amf" class="mx.messaging.channels.AMFChannel"> <endpoint url="http://{server.name}:{server.port}/{context.root}/messagebroker/qosamfpolling" class="flex.messaging.endpoints.AMFEndpoint"/> <properties> <polling-enabled>true</polling-enabled> <polling-interval-millis>500</polling-interval-millis> </properties> </channel-definition> </channels> <logging> <!-- You may also use flex.messaging.log.ServletLogTarget --> <target class="flex.messaging.log.ConsoleTarget" level="Error"> <properties> <prefix>[BlazeDS] </prefix> <includeDate>false</includeDate> <includeTime>false</includeTime> <includeLevel>true</includeLevel> <includeCategory>false</includeCategory> </properties> <filters> <pattern>Endpoint.*</pattern> <pattern>Service.*</pattern> <pattern>Configuration</pattern> </filters> </target> </logging> <system> <redeploy> <enabled>true</enabled> <watch-interval>20</watch-interval> <watch-file>{context.root}/WEB-INF/flex/services-config.xml</watch-file> <watch-file>{context.root}/WEB-INF/flex/proxy-config.xml</watch-file> <watch-file>{context.root}/WEB-INF/flex/remoting-config.xml</watch-file> <watch-file>{context.root}/WEB-INF/flex/messaging-config.xml</watch-file> <touch-file>{context.root}/WEB-INF/web.xml</touch-file> </redeploy> </system> <factories> <factory id="beanFactory" class="factories.BeanFactory"/> </factories> </services-config>
And at last when i run test page with flex app i have this error:Java Code:2011-07-03 10:13:05 org.apache.catalina.core.AprLifecycleListener init INFO: The Apache Tomcat Native library which allows optimal performance in production environments was not found on the java.library.path: /usr/lib/jvm/java-6-sun-1.6.0.25/jre/lib/amd64/server:/usr/lib/jvm/java-6-sun-1.6.0.25/jre/lib/amd64:/usr/lib/jvm/java-6-sun-1.6.0.25/jre/../lib/amd64:/usr/java/packages/lib/amd64:/usr/lib64:/lib64:/lib:/usr/lib 2011-07-03 10:13:05 org.apache.coyote.http11.Http11Protocol init INFO: Initializing Coyote HTTP/1.1 on http-8400 2011-07-03 10:13:05 org.apache.catalina.startup.Catalina load INFO: Initialization processed in 1504 ms 2011-07-03 10:13:05 org.apache.catalina.core.StandardService start INFO: Starting service Catalina 2011-07-03 10:13:05 org.apache.catalina.core.StandardEngine start INFO: Starting Servlet Engine: Apache Tomcat/6.0.14 2011-07-03 10:13:08 com.sun.faces.config.ConfigureListener contextInitialized INFO: Initializing Mojarra 2.0.4 (FCS b09) for context '/WebApplication1' 2011-07-03 10:13:10 com.sun.faces.config.ConfigureListener$WebConfigResourceMonitor$Monitor <init> INFO: Monitoring jndi:/localhost/WebApplication1/WEB-INF/faces-config.xml for modifications BeanFactory instance for id=usersService source=usersService scope=request 2011-07-03 10:13:14 org.apache.coyote.http11.Http11Protocol start INFO: Starting Coyote HTTP/1.1 on http-8400 2011-07-03 10:13:14 org.apache.jk.common.ChannelSocket init INFO: JK: ajp13 listening on /0.0.0.0:8009 2011-07-03 10:13:14 org.apache.jk.server.JkMain start INFO: Jk running ID=0 time=0/90 config=null 2011-07-03 10:13:14 org.apache.catalina.startup.Catalina start INFO: Server startup in 9292 ms 2011-07-03 10:13:17 org.apache.catalina.core.StandardContext reload INFO: Reloading this Context has started 2011-07-03 10:13:19 com.sun.faces.config.ConfigureListener contextInitialized INFO: Initializing Mojarra 2.0.4 (FCS b09) for context '/WebApplication1' 2011-07-03 10:13:20 com.sun.faces.config.ConfigureListener$WebConfigResourceMonitor$Monitor <init> INFO: Monitoring jndi:/localhost/WebApplication1/WEB-INF/faces-config.xml for modifications BeanFactory instance for id=usersService source=usersService scope=request
My flex app:Java Code:[MessagingError message='Destination 'usersService' either does not exist or the destination has no channels defined (and the application does not define any default channels.)'] Couldn't establish a connection to 'usersService'
Someone know what is the problem?Java Code:<?xml version="1.0" encoding="utf-8"?> <s:Application xmlns:fx="http://ns.adobe.com/mxml/2009" xmlns:s="library://ns.adobe.com/flex/spark" xmlns:mx="library://ns.adobe.com/flex/mx" xmlns:valueObjects="valueObjects.*" width="700" height="700" initialize="init()"> <fx:Script> <![CDATA[ import flash.utils.describeType; import mx.controls.Alert; import mx.events.FlexEvent; import mx.rpc.events.FaultEvent; import mx.rpc.events.ResultEvent; protected function user_faultHandler(event:FaultEvent):void { Alert.show(event.fault.faultString + '\n' + event.fault.faultDetail,"Error"); } protected function init():void { getUsersResult.token = usersService.getUsers(); } protected function getUsersResult_resultHandler(event:ResultEvent):void { users=event.result as ArrayCollection; } ]]> </fx:Script> <fx:Declarations> <s:RemoteObject id="usersService" destination="usersService" showBusyCursor="true" fault="user_faultHandler(event)"/> <s:CallResponder id="getUsersResult" result="getUsersResult_resultHandler(event)"/> <s:ArrayCollection id="users"/> </fx:Declarations> <s:Label id="emailLabel" text="{users}"/> </s:Application>
Similar Threads
-
Problem of integration and reading of Arabic
By akkachamid in forum JDBCReplies: 7Last Post: 04-28-2011, 01:13 PM -
Problem In infrared tools integration with weblogic
By siva_vs_siva in forum New To JavaReplies: 3Last Post: 03-28-2011, 02:03 PM -
Problem In infrared tools integration with weblogic
By siva_vs_siva in forum Advanced JavaReplies: 1Last Post: 03-28-2011, 01:34 PM -
Flex + Java crosspolicy send problem
By VasiliyF4 in forum NetworkingReplies: 1Last Post: 08-19-2009, 05:46 PM -
problem with integration of a applet class
By JuliaS85 in forum Java AppletsReplies: 0Last Post: 03-27-2009, 04:32 PM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks