tutorials.de Buch-Aktion 05/2012
ERLEDIGT
NEIN
ANTWORTEN
3
ZUGRIFFE
381
EMPFEHLEN
  • An Twitter übertragen
  • An Facebook übertragen
AUF DIESES THEMA
ANTWORTEN
  1. #1
    ceene ceene ist offline Mitglied Gold
    Registriert seit
    Sep 2007
    Beiträge
    200
    Hallo Leute

    Ich habe ein kleines Problem mit meiner Web-Anwendung.
    Ich arbeite mit dem JBoss 4.2.3, Seam 2.1
    Ich möchte in meinem Web-Projekt ein Bean aufrufen, und es dann in meinem Projekt verwenden. Leider bekomme ich immer den Fehler "$Proxy294 cannot be cast to src.interfaces.DataProtectionInterface"

    Hier die Klasse in dem ich das Versuche das Bean aufzurufen:
    Code :
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    
    package src.ejb;
     
    import java.util.List;
     
    import javax.naming.Context;
    import javax.naming.InitialContext;
    import javax.naming.NamingException;
     
    import src.entity.RecipientData;
    import src.interfaces.DataProtectionInterface;
    import src.klassen.AdressIdType;
     
    public class DataProtectionService implements DataProtectionInterface {
        
        private DataProtectionInterface manager;
        
        public DataProtectionService() throws NamingException
        {
            Context context = new InitialContext();
           /*Hier tritt der Fehler auf*/
            manager = (DataProtectionInterface) context.lookup("DataProtectionBean/remote");
        }
        
        @Override
        public List<RecipientData> getRecipients(String country, AdressIdType type,
                long id) {
            // TODO Auto-generated method stub
            return (manager.getRecipients(country, type, id));
        }
     
    }

    Hier das Interface dazu:
    Code :
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    
    package src.interfaces;
     
    import java.util.List;
     
    import src.entity.RecipientData;
    import src.klassen.AdressIdType;
     
    public interface DataProtectionInterface {
     
        List<RecipientData> getRecipients(String country,
                                          AdressIdType type,
                                          long id);
    }

    Hier noch das RemoteInterface vom Bean:
    Code :
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    
    package com;
     
    import java.util.List;
     
    import javax.ejb.Remote;
     
    @Remote
    public interface DataProtection {
     
        List<RecipientData> getRecipients(String country, AdressIdType type, long id);
     
    }

    und das Bean:
    Code :
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    
    package com;
     
    import java.util.ArrayList;
    import java.util.List;
     
    import javax.ejb.Remote;
    import javax.ejb.Stateless;
     
    @Stateless
    @Remote(DataProtection.class)
    public class DataProtectionBean implements DataProtection {
     
        public List<RecipientData> getRecipients(String country, AdressIdType type, long id)
        {
            RecipientData data;
            List<RecipientData> result = new ArrayList<RecipientData>();
            
            for(int i = 0; i<=4; i++)
            {
                data = new RecipientData();
                data.setId(new Integer(i).toString());
                data.setAdrLine1("Name" + new Integer(i).toString());
                data.setAdrLine2("Strasse" + new Integer(i).toString());
                data.setAdrLine3("Zip" + new Integer(i).toString() + " " + "City");
                data.setAdrLine4("Country" + new Integer(i).toString());
                result.add(data);
            }
            
            return result;
        }
        
    }

    Ich kann einfach nicht nachvollziehen wo das Problem liegt. Ich hoffe hier kann mir jemand helfen.
     

  2. #2
    ceene ceene ist offline Mitglied Gold
    Registriert seit
    Sep 2007
    Beiträge
    200
    Hat keiner ne Idee?
     

  3. #3
    ceene ceene ist offline Mitglied Gold
    Registriert seit
    Sep 2007
    Beiträge
    200
    Mmmhhhh....so wie es aussieht müssen die Interface-Namen gleich sein. Aber gehen tut es immer noch nicht
    Geändert von ceene (11.10.10 um 13:30 Uhr)
     

  4. #4
    Registriert seit
    Jun 2002
    Ort
    Saarbrücken (Saarland)
    Beiträge
    9.886
    Blog-Einträge
    29
     
    Java rocks!
    How to become a good Java Programmer?
    Does IT in Java and .Net
    The only valid measurement of code quality: WTFs / minute
    Blog
    Xing
    Twitter

Ähnliche Themen

  1. Interfaces in anderen Interfaces implementieren
    Von mueslirocker im Forum Algorithmen & Datenstrukturen mit Java
    Antworten: 0
    Letzter Beitrag: 12.09.10, 18:12
  2. Antworten: 8
    Letzter Beitrag: 03.06.10, 22:09
  3. [C] cast: INT zu CHAR
    Von myhonor im Forum C/C++
    Antworten: 3
    Letzter Beitrag: 14.12.09, 13:43
  4. Reflection + Cast
    Von meinereiner85 im Forum Java
    Antworten: 13
    Letzter Beitrag: 02.10.08, 13:00
  5. cast
    Von masterjcl im Forum C/C++
    Antworten: 3
    Letzter Beitrag: 25.11.04, 20:20