Hallo,
Muss mich zur Zeit für ein Projekt in EJB3.0 einarbeiten. Ich benutze dafür den JBoss App. Server und die JBoss Eclipse IDE. Arbeite mit dem Buch "Enterprise JavaBeans 3.0 - 5th Edition" von O'Reilly.
Hab mir in Eclipse ein EJB 3.0 Projekt angelet und darin folgende Klassen erstellt:
CabinBean (meine Entity Bean Klasse)
TravelAgentBean & TravelAgentRemote
(Session Bean + Remote Interface)
TravelAgentRemote:
TravelAgentBean:
dann hab ich noch eine Client Klasse mit der main:
Wen man alle Klassen erstellt hat sollte man eine persistence.xml anlegen mit dem folgenden inhalt:
Nun sollte man die Klassen: CabinBean, TravelAgentRemote und TravelAgentBean zusammen mit der persistence.xml zu einem jar Archiv zusammenfassen.
Wen ich jetzt die Jar Datei zu meinem JBoss Server Deploye bekomm ich folgende Fehlermeldung in der Konsole vom Server:
Wen ich die Client Klasse ausführe bekomm ich immer diese Fehlermeldung:
Spiel jetzt schon 2 Tage damit rum und komm einfach auf keinen grünen Zweig. Wäre nett wen mir jemand helfen könnte.
grüsse
Germu
Muss mich zur Zeit für ein Projekt in EJB3.0 einarbeiten. Ich benutze dafür den JBoss App. Server und die JBoss Eclipse IDE. Arbeite mit dem Buch "Enterprise JavaBeans 3.0 - 5th Edition" von O'Reilly.
Hab mir in Eclipse ein EJB 3.0 Projekt angelet und darin folgende Klassen erstellt:
CabinBean (meine Entity Bean Klasse)
Code:
package com.titan.domain;
import javax.persistence.*;
@Entity
@Table(name="Cabin")
public class CabinBean implements java.io.Serializable{
private static final long serialVersionUID = 1L;
private int id;
private String name;
private int deckLevel;
private int shipId;
private int bedCount;
@Id
@Column(name="ID")
public int getId() {return this.id;}
public void setId(int id) {this.id = id;}
@Column(name="NAME")
public String getName() { return this.name; }
public void setName(String name) {this.name = name; }
@Column(name="DECK_LEVEL")
public int getDeckLevel() { return this.deckLevel; }
public void setDeckLevel(int deckLevel) { this.deckLevel = deckLevel; }
@Column(name="SHIP_ID")
public int getShipId() { return this.shipId; }
public void setShipId(int shipId) {this.shipId = shipId; }
@Column(name="BED_COUNT")
public int getBedCount() { return this.bedCount; }
public void setBedCount(int bedCount) { this.bedCount = bedCount; }
}
TravelAgentBean & TravelAgentRemote
(Session Bean + Remote Interface)
TravelAgentRemote:
Code:
package com.titan.travelagent;
import javax.ejb.Remote;
import com.titan.domain.CabinBean;
@Remote
public interface TravelAgentRemote {
public void CreateCabin(CabinBean cabin);
public CabinBean findCabin(int id);
}
Code:
package com.titan.travelagent;
import javax.ejb.Stateless;
import javax.persistence.*;
import com.titan.domain.CabinBean;
@Stateless
public class TravelAgentBean implements TravelAgentRemote{
@PersistenceContext(unitName="titan")
private EntityManager manager;
public void CreateCabin(CabinBean cabin) {
manager.persist(cabin);
}
public CabinBean findCabin(int id) {
return manager.find(CabinBean.class, id);
}
}
dann hab ich noch eine Client Klasse mit der main:
Code:
package com.titan.client;
import java.awt.GridLayout;
import java.util.Properties;
import javax.naming.Context;
import javax.naming.NamingException;
import javax.rmi.PortableRemoteObject;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;
import com.titan.domain.CabinBean;
import com.titan.travelagent.TravelAgentRemote;
public class Client extends JFrame{
private static final long serialVersionUID = 1L;
public static void main(String [] args) {
try
{
Context jndiContext = getInitialContex();
Object ref = jndiContext.lookup("TravelAgentBean/remote");
TravelAgentRemote dao = (TravelAgentRemote)
PortableRemoteObject.narrow(ref, TravelAgentRemote.class);
CabinBean cabin_1 = new CabinBean();
cabin_1.setId(1);
cabin_1.setName("Master Suite");
cabin_1.setDeckLevel(1);
cabin_1.setShipId(1);
cabin_1.setBedCount(3);
dao.CreateCabin(cabin_1);
CabinBean cabin_2 = dao.findCabin(1);
System.out.println(cabin_2.getName());
System.out.println(cabin_2.getDeckLevel());
System.out.println(cabin_2.getShipId());
System.out.println(cabin_2.getBedCount());
}
catch (javax.naming.NamingException ne)
{
ne.printStackTrace();
}
}
private static Context getInitialContex()
throws javax.naming.NamingException
{
return new javax.naming.InitialContext();
}
}
Wen man alle Klassen erstellt hat sollte man eine persistence.xml anlegen mit dem folgenden inhalt:
Code:
<?xml version="1.0" encoding="UTF-8"?>
<persistence>
<persistence-unit name="titan">
<jta-data-source>java:/Titan/DB</jta-data-source>
</persistence-unit>
</persistence>
Nun sollte man die Klassen: CabinBean, TravelAgentRemote und TravelAgentBean zusammen mit der persistence.xml zu einem jar Archiv zusammenfassen.
Wen ich jetzt die Jar Datei zu meinem JBoss Server Deploye bekomm ich folgende Fehlermeldung in der Konsole vom Server:
Code:
11:00:20,469 ERROR [PersistenceXmlLoader] Error parsing XML: XML InputStream(8) The processing instruction target matching "[xX][mM][lL]" is not allowed.
11:00:20,484 WARN [ServiceController] Problem creating service jboss.j2ee:service=EJB3,module=titan.jar
org.xml.sax.SAXParseException: The processing instruction target matching "[xX][mM][lL]" is not allowed.
at org.apache.xerces.parsers.DOMParser.parse(Unknown Source)
at org.apache.xerces.jaxp.DocumentBuilderImpl.parse(Unknown Source)
at org.hibernate.ejb.packaging.PersistenceXmlLoader.loadURL(PersistenceXmlLoader.java:64)
at org.hibernate.ejb.packaging.PersistenceXmlLoader.deploy(PersistenceXmlLoader.java:73)
at org.jboss.ejb3.Ejb3Deployment.initializePersistenceUnits(Ejb3Deployment.java:444)
at org.jboss.ejb3.Ejb3Deployment.create(Ejb3Deployment.java:307)
at org.jboss.ejb3.Ejb3Module.createService(Ejb3Module.java:77)
at org.jboss.system.ServiceMBeanSupport.jbossInternalCreate(ServiceMBeanSupport.java:260)
at org.jboss.system.ServiceMBeanSupport.jbossInternalLifecycle(ServiceMBeanSupport.java:243)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
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.create(Unknown Source)
at org.jboss.system.ServiceController.create(ServiceController.java:330)
at org.jboss.system.ServiceController.create(ServiceController.java:273)
at sun.reflect.GeneratedMethodAccessor4.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
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.mx.util.MBeanProxyExt.invoke(MBeanProxyExt.java:210)
at $Proxy46.create(Unknown Source)
at org.jboss.ejb3.EJB3Deployer.create(EJB3Deployer.java:429)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.jboss.mx.interceptor.ReflectedDispatcher.invoke(ReflectedDispatcher.java:155)
at org.jboss.mx.server.Invocation.dispatch(Invocation.java:94)
at org.jboss.mx.interceptor.AbstractInterceptor.invoke(AbstractInterceptor.java:133)
at org.jboss.mx.server.Invocation.invoke(Invocation.java:88)
at org.jboss.mx.interceptor.ModelMBeanOperationInterceptor.invoke(ModelMBeanOperationInterceptor.java:142)
at org.jboss.mx.interceptor.DynamicInterceptor.invoke(DynamicInterceptor.java:97)
at org.jboss.system.InterceptorServiceMBeanSupport.invokeNext(InterceptorServiceMBeanSupport.java:238)
at org.jboss.ws.server.WebServiceDeployer.create(WebServiceDeployer.java:99)
at org.jboss.deployment.SubDeployerInterceptorSupport$XMBeanInterceptor.create(SubDeployerInterceptorSupport.java:180)
at org.jboss.deployment.SubDeployerInterceptor.invoke(SubDeployerInterceptor.java:91)
at org.jboss.mx.server.Invocation.invoke(Invocation.java:88)
at org.jboss.mx.server.AbstractMBeanInvoker.invoke(AbstractMBeanInvoker.java:264)
at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:659)
at org.jboss.mx.util.MBeanProxyExt.invoke(MBeanProxyExt.java:210)
at $Proxy47.create(Unknown Source)
at org.jboss.deployment.MainDeployer.create(MainDeployer.java:953)
at org.jboss.deployment.MainDeployer.deploy(MainDeployer.java:807)
at org.jboss.deployment.MainDeployer.deploy(MainDeployer.java:771)
at sun.reflect.GeneratedMethodAccessor12.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.jboss.mx.interceptor.ReflectedDispatcher.invoke(ReflectedDispatcher.java:155)
at org.jboss.mx.server.Invocation.dispatch(Invocation.java:94)
at org.jboss.mx.interceptor.AbstractInterceptor.invoke(AbstractInterceptor.java:133)
at org.jboss.mx.server.Invocation.invoke(Invocation.java:88)
at org.jboss.mx.interceptor.ModelMBeanOperationInterceptor.invoke(ModelMBeanOperationInterceptor.java:142)
at org.jboss.mx.server.Invocation.invoke(Invocation.java:88)
at org.jboss.mx.server.AbstractMBeanInvoker.invoke(AbstractMBeanInvoker.java:264)
at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:659)
at org.jboss.mx.util.MBeanProxyExt.invoke(MBeanProxyExt.java:210)
at $Proxy6.deploy(Unknown Source)
at org.jboss.deployment.scanner.URLDeploymentScanner.deploy(URLDeploymentScanner.java:421)
at org.jboss.deployment.scanner.URLDeploymentScanner.scan(URLDeploymentScanner.java:610)
at org.jboss.deployment.scanner.AbstractDeploymentScanner$ScannerThread.doScan(AbstractDeploymentScanner.java:263)
at org.jboss.deployment.scanner.AbstractDeploymentScanner$ScannerThread.loop(AbstractDeploymentScanner.java:274)
at org.jboss.deployment.scanner.AbstractDeploymentScanner$ScannerThread.run(AbstractDeploymentScanner.java:225)
11:00:20,484 INFO [EJB3Deployer] Deployed: file:/C:/Programme/jboss-4.0.4.GA/server/default/deploy/titan.jar
11:00:20,484 ERROR [URLDeploymentScanner] Incomplete Deployment listing:
--- MBeans waiting for other MBeans ---
ObjectName: jboss.j2ee:service=EJB3,module=titan.jar
State: FAILED
Reason: org.xml.sax.SAXParseException: The processing instruction target matching "[xX][mM][lL]" is not allowed.
--- MBEANS THAT ARE THE ROOT CAUSE OF THE PROBLEM ---
ObjectName: jboss.j2ee:service=EJB3,module=titan.jar
State: FAILED
Reason: org.xml.sax.SAXParseException: The processing instruction target matching "[xX][mM][lL]" is not allowed.
Wen ich die Client Klasse ausführe bekomm ich immer diese Fehlermeldung:
Code:
javax.naming.NameNotFoundException: remote not bound
at org.jnp.server.NamingServer.getBinding(NamingServer.java:529)
at org.jnp.server.NamingServer.getBinding(NamingServer.java:537)
at org.jnp.server.NamingServer.getObject(NamingServer.java:543)
at org.jnp.server.NamingServer.lookup(NamingServer.java:296)
at org.jnp.server.NamingServer.lookup(NamingServer.java:270)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at sun.rmi.server.UnicastServerRef.dispatch(Unknown Source)
at sun.rmi.transport.Transport$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at sun.rmi.transport.Transport.serviceCall(Unknown Source)
at sun.rmi.transport.tcp.TCPTransport.handleMessages(Unknown Source)
at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
at sun.rmi.transport.StreamRemoteCall.exceptionReceivedFromServer(Unknown Source)
at sun.rmi.transport.StreamRemoteCall.executeCall(Unknown Source)
at sun.rmi.server.UnicastRef.invoke(Unknown Source)
at org.jnp.server.NamingServer_Stub.lookup(Unknown Source)
at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:625)
at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:587)
at javax.naming.InitialContext.lookup(Unknown Source)
at com.titan.client.Client.main(Client.java:27)
Spiel jetzt schon 2 Tage damit rum und komm einfach auf keinen grünen Zweig. Wäre nett wen mir jemand helfen könnte.
grüsse
Germu