0 Replies Latest reply on May 24, 2010 7:39 AM by RicardoFressa

    Flex 3 + Java + Blazeds + SqlServer

    RicardoFressa

      Hello, how are you?
      I have a big problem for my flex interconnect with the database using BlazeDS. Can anyone help me?

      Console server is showing these messages:

       

      May 24, 2010 11:33:57 AM org.apache.catalina.core.AprLifecycleListener init

      INFO: The APR based Apache Tomcat Native library which allows optimal performance in production environments was not found on the java.library.path: C:\Program Files\Java\jre6\bin;.;C:\Windows\Sun\Java\bin;C:\Windows\system32;C:\Windows;C:/Program Files/Java/jre6/bin/client;C:/Program Files/Java/jre6/bin;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\Sy stem32\WindowsPowerShell\v1.0\;C:\Program Files\QuickTime\QTSystem\;C:\Program Files\Microsoft SQL Server\100\Tools\Binn\;C:\Program Files\Microsoft SQL Server\100\DTS\Binn\;c:\Program Files\Microsoft SQL Server\100\Tools\Binn\VSShell\Common7\IDE\;C:\Program Files\Common Files\Ahead\Lib\

      May 24, 2010 11:33:57 AM org.apache.tomcat.util.digester.SetPropertiesRule begin

      WARNING: [SetPropertiesRule]{Server/Service/Engine/Host/Context} Setting property 'source' to 'org.eclipse.jst.j2ee.server:BancoJavaFlexBlazeds' did not find a matching property.

      May 24, 2010 11:33:57 AM org.apache.tomcat.util.digester.SetPropertiesRule begin

      WARNING: [SetPropertiesRule]{Server/Service/Engine/Host/Context} Setting property 'source' to 'org.eclipse.jst.j2ee.server:Integra_java_flex_blazeds' did not find a matching property.

      May 24, 2010 11:33:57 AM org.apache.coyote.http11.Http11Protocol init

      INFO: Initializing Coyote HTTP/1.1 on http-8080

      May 24, 2010 11:33:57 AM org.apache.catalina.startup.Catalina load

      INFO: Initialization processed in 785 ms

      May 24, 2010 11:33:57 AM org.apache.catalina.core.StandardService start

      INFO: Starting service Catalina

      May 24, 2010 11:33:57 AM org.apache.catalina.core.StandardEngine start

      INFO: Starting Servlet Engine: Apache Tomcat/6.0.26

      May 24, 2010 11:33:58 AM org.apache.catalina.loader.WebappClassLoader validateJarFile

      INFO: validateJarFile(C:\eclipse\workspace\.metadata\.plugins\org.eclipse.wst.server.core\tmp0\ wtpwebapps\Integra_java_flex_blazeds\WEB-INF\lib\servlet.jar) - jar not loaded. See Servlet Spec 2.3, section 9.7.2. Offending class: javax/servlet/Servlet.class

      May 24, 2010 11:33:59 AM org.apache.catalina.loader.WebappClassLoader validateJarFile

      INFO: validateJarFile(C:\eclipse\workspace\.metadata\.plugins\org.eclipse.wst.server.core\tmp0\ wtpwebapps\BancoJavaFlexBlazeds\WEB-INF\lib\servlet.jar) - jar not loaded. See Servlet Spec 2.3, section 9.7.2. Offending class: javax/servlet/Servlet.class

      May 24, 2010 11:34:00 AM org.apache.coyote.http11.Http11Protocol start

      INFO: Starting Coyote HTTP/1.1 on http-8080

      May 24, 2010 11:34:00 AM org.apache.jk.common.ChannelSocket init

      INFO: JK: ajp13 listening on /0.0.0.0:8009

      May 24, 2010 11:34:00 AM org.apache.jk.server.JkMain start

      INFO: Jk running ID=0 time=0/45  config=null

      May 24, 2010 11:34:00 AM org.apache.catalina.startup.Catalina start

      INFO: Server startup in 2790 ms


      So did my class to list people like this:

       

      package br.com.ricardo.bancojavaflexblazeds;

       

      import java.sql.*;

       

      import javax.swing.JOptionPane;

       

      public class ServicoJavaPessoa {

       

      public void listar_pessoas(){

       

      String driver = "com.microsoft.jdbc.sqlserver.SQLServerDriver";

      String url = "jdbc:microsoft:sqlserver://localhost:1433;DatabaseName=flex";

      String usuario = "Ricardo-PC\\Ricardo";

      String senha = "";

      Connection conexao;

      Statement statement;

      ResultSet resultset;

       

      try

      {

      Class.forName(driver);

      conexao = DriverManager.getConnection(url, usuario, senha);

      JOptionPane.showMessageDialog(null, "Conexão efetuada com sucesso!");

      }

      catch(ClassNotFoundException Driver)

      {

      JOptionPane.showMessageDialog(null, "Classe do banco de dados não encontrada "+Driver);

      }

      catch(SQLException Banco)

      {

      JOptionPane.showMessageDialog(null, "Erro ao manipular o banco de dados "+Banco);

      }

      }

       

       

      }


      My remoting-config.xml file looks like this:

       

      <?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="ServicoJavaPessoa">

          <properties>

          <source>br.com.ricardo.bancojavaflexblazeds.ServicoJavaPessoa</source>

          </properties>

          </destination>

       

      </service>


      And the error message so when I try to call the java class through the BlazeDS:
      Error: [MessagingError message = 'Destination' ServicoJavaPessoa 'either does not exist for the destination has no channels defined (and the application does not define any default channels.)']

      And my application is like this:

       

      <?xml version="1.0" encoding="utf-8"?>

      <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute">

       

      <mx:RemoteObject id="ServicoJavaPessoa" destination="ServicoJavaPessoa" fault="faultServicoPessoa(event)">

      <mx:method name="listar_pessoas" fault="faultServicoPessoa(event)"/>

      </mx:RemoteObject>

       

      <mx:Script>

      <![CDATA[

      import mx.rpc.events.FaultEvent;

      import mx.controls.Alert;

       

       

      public function chama_lista_pessoa():void{

      ServicoJavaPessoa.listar_pessoas();

      }

       

      public function faultServicoPessoa(event:FaultEvent):void{

       

      Alert.show("Erro: "+event.fault.faultString);

      }

      ]]>

      </mx:Script>

      <mx:Panel x="10" y="10" width="566" height="352" layout="absolute">

      <mx:Button x="10" y="10" label="Popular" width="89" click="{chama_lista_pessoa();}"/>

      <mx:DataGrid x="10" y="56" width="526" height="246">

      <mx:columns>

      <mx:DataGridColumn headerText="Column 1" dataField="col1"/>

      <mx:DataGridColumn headerText="Column 2" dataField="col2"/>

      <mx:DataGridColumn headerText="Column 3" dataField="col3"/>

      </mx:columns>

      </mx:DataGrid>

      </mx:Panel>

       

      </mx:Application>

      Can someone please help me?