# Probleme mit ApplikationClient mit Sicherheitsanmeldung!



## th.weigand (13. Jan 2008)

Hallo,

ich habe ein OnlineBankingSystem als J2EE Anwendung erzeugt. Dazu habe ich auch eine Weboberfläche für die Anwendung implementiert. Nun möchte ich noch einen Client schreiben der mir ein paar Beispiel Daten für das OnlineBanking erzeugt. So sieht mein ClientCode aus:

```
package ob.client;

import java.util.Properties;

import javax.naming.Context;
import javax.naming.InitialContext;
import javax.rmi.PortableRemoteObject;
import javax.security.auth.login.LoginContext;
import java.util.*;
import ob.client.OnlineBankingClientCallbackHandler;
import ob.session.BankVerwaltungRemote;
import ob.entity.BankBean;
public class OnlineBankingClient {

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		// TODO Auto-generated method stub
	    BankVerwaltungRemote bankverw = null;
	    try
	    {
	      //System.setProperty("java.security.auth.login.config", "C:/temp/workspace/SecurityClient/appClientModule/META-INF/auth.conf");
	      //System.setProperty("java.security.auth.login.config", "appClientModule/META-INF/auth.conf");
	      
	      //Properties für den JNDI-Zugriff initialisieren:
	      Properties props = new Properties();
	      props.setProperty(Context.INITIAL_CONTEXT_FACTORY, "org.jnp.interfaces.NamingContextFactory");
	      props.setProperty(Context.URL_PKG_PREFIXES, "org.jboss.naming.client");
	      props.setProperty(Context.PROVIDER_URL, "jnp://localhost:1099");
	      props.setProperty("j2ee.clientName", "OnlineBankingClient");
	      
	      InitialContext initialContext = new InitialContext(props);
	      
	      //Login initialisieren:
	      OnlineBankingClientCallbackHandler callbackHandler = new OnlineBankingClientCallbackHandler();
	      LoginContext loginContext = new LoginContext ("adminsecurity", callbackHandler);
	      loginContext.login();
	      
	      
	      Object bankverwRef = initialContext.lookup("java:comp/env/ejb/BankVerwaltungRemote");
	      bankverw = (BankVerwaltungRemote) PortableRemoteObject.narrow(bankverwRef, BankVerwaltungRemote.class);
	    }
	    catch (Exception ex)
	    {
	      System.out.println("INIT Failed (" + ex.getClass().getName() + "): " + ex.getMessage() + " ");
	      ex.printStackTrace();
	      return;
	    }
	    try {
	    if (bankverw != null) {	         
	    		bankverw.neueBankAnlegen(55090500,"Sparda-Bank Südwest eG", "Robert-Koch-Straße 45", "Mainz", "55129", "info@sparda-sw.de","01805915550", "06131915949");
	    		bankverw.neueBankAnlegen(56261073, "Volksbank Kirn-Sobernheim eG", "August-Bebel-Platz 4", "Kirn", "55606", "info@vbkiso.de", "067529393-0", "067529393-33");
	    		bankverw.neueBankAnlegen(51080060, "Dresdner Bank AG", "Salinenstraße 32", "Bad Kreuznach", "55543", "info@dr-ba.de", "06712560", "0671256291");
	    		bankverw.neueBankAnlegen(56050180, "Sparkasse Rhein-Nahe", "Kornmarkt 5", "Bad Kreuznach", "55543", "info@sk-rhein-nahe.de", "0671940", "06719615555");
	    		bankverw.neueBankAnlegen(12070000, "Deutsche Bank AG", "Theodor-Heuss-Allee 70", "Frankfurt", "60262", "deutsche.bank@db.com", "06991000", "06991034255");
	    	}

	    	
	        else {
	        System.out.println("SessionFacade ist nicht da");
	        }
	        System.out.println("Eine Bank erzeugt!");
	        List<BankBean> liste = bankverw.listeallerBanken();
	        System.out.println("Wir haben " + liste.size() + " Banken!");
	        for (Iterator iterator = liste.iterator(); iterator.hasNext();) {
	        BankBean bank = (BankBean) iterator.next();
	        System.out.println(bank.getBlz() + ": " +
	        bank.getName() + " " + bank.getOrt() + " " +
	        bank.getUsers().size() + " Benutzer");
	        }
		}
		catch (Exception e) {
			System.err.println("Die Bank konnte nicht angelegt werden!");
		}

	}

}
```

dieser llässt sich zwar ausführen, aber er bringt mir folgende Fehlermeldung die mir nicht weiterhilft. Ich kann mit dieser Fehlermeldung nichts anfangen. Fehlermeldung:
13:07:20,890 WARN  [JDBCExceptionReporter] SQL Error: 0, SQLState: null
13:07:20,890 ERROR [JDBCExceptionReporter] failed batch
13:07:20,890 ERROR [AbstractFlushingEventListener] Could not synchronize database state with session
org.hibernate.exception.GenericJDBCException: Could not execute JDBC batch update
	at org.hibernate.exception.SQLStateConverter.handledNonSpecificException(SQLStateConverter.java:103)
	at org.hibernate.exception.SQLStateConverter.convert(SQLStateConverter.java:91)
	at org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:43)
	at org.hibernate.jdbc.AbstractBatcher.executeBatch(AbstractBatcher.java:253)
	at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:235)
	at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:139)
	at org.hibernate.event.def.AbstractFlushingEventListener.performExecutions(AbstractFlushingEventListener.java:298)
	at org.hibernate.event.def.DefaultFlushEventListener.onFlush(DefaultFlushEventListener.java:27)
	at org.hibernate.impl.SessionImpl.flush(SessionImpl.java:1000)
	at org.hibernate.ejb.AbstractEntityManagerImpl.flush(AbstractEntityManagerImpl.java:296)
	at org.jboss.ejb3.entity.TransactionScopedEntityManager.flush(TransactionScopedEntityManager.java:211)
	at ob.session.BankVerwaltungBean.neueBankAnlegen(BankVerwaltungBean.java:271)
	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.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:112)
	at org.jboss.ejb3.interceptor.InvocationContextImpl.proceed(InvocationContextImpl.java:166)
	at org.jboss.ejb3.interceptor.EJB3InterceptorsInterceptor.invoke(EJB3InterceptorsInterceptor.java:63)
	at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
	at org.jboss.ejb3.entity.TransactionScopedEntityManagerInterceptor.invoke(TransactionScopedEntityManagerInterceptor.java:54)
	at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
	at org.jboss.ejb3.AllowedOperationsInterceptor.invoke(AllowedOperationsInterceptor.java:47)
	at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
	at org.jboss.aspects.tx.TxPolicy.invokeInOurTx(TxPolicy.java:79)
	at org.jboss.aspects.tx.TxInterceptor$Required.invoke(TxInterceptor.java:191)
	at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
	at org.jboss.aspects.tx.TxPropagationInterceptor.invoke(TxPropagationInterceptor.java:76)
	at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
	at org.jboss.ejb3.stateless.StatelessInstanceInterceptor.invoke(StatelessInstanceInterceptor.java:62)
	at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
	at org.jboss.aspects.security.RoleBasedAuthorizationInterceptor.invoke(RoleBasedAuthorizationInterceptor.java:166)
	at org.jboss.ejb3.security.RoleBasedAuthorizationInterceptor.invoke(RoleBasedAuthorizationInterceptor.java:108)
	at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
	at org.jboss.aspects.security.AuthenticationInterceptor.invoke(AuthenticationInterceptor.java:77)
	at org.jboss.ejb3.security.Ejb3AuthenticationInterceptor.invoke(Ejb3AuthenticationInterceptor.java:106)
	at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
	at org.jboss.ejb3.ENCPropagationInterceptor.invoke(ENCPropagationInterceptor.java:46)
	at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
	at org.jboss.ejb3.asynchronous.AsynchronousInterceptor.invoke(AsynchronousInterceptor.java:106)
	at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
	at org.jboss.ejb3.stateless.StatelessContainer.dynamicInvoke(StatelessContainer.java:278)
	at org.jboss.aop.Dispatcher.invoke(Dispatcher.java:106)
	at org.jboss.aspects.remoting.AOPRemotingInvocationHandler.invoke(AOPRemotingInvocationHandler.java:82)
	at org.jboss.remoting.ServerInvoker.invoke(ServerInvoker.java:734)
	at org.jboss.remoting.transport.socket.ServerThread.processInvocation(ServerThread.java:560)
	at org.jboss.remoting.transport.socket.ServerThread.dorun(ServerThread.java:369)
	at org.jboss.remoting.transport.socket.ServerThread.run(ServerThread.java:165)
Caused by: java.sql.BatchUpdateException: failed batch
	at org.hsqldb.jdbc.jdbcStatement.executeBatch(Unknown Source)
	at org.hsqldb.jdbc.jdbcPreparedStatement.executeBatch(Unknown Source)
	at org.jboss.resource.adapter.jdbc.CachedPreparedStatement.executeBatch(CachedPreparedStatement.java:478)
	at org.jboss.resource.adapter.jdbc.WrappedStatement.executeBatch(WrappedStatement.java:519)
	at org.hibernate.jdbc.BatchingBatcher.doExecuteBatch(BatchingBatcher.java:48)
	at org.hibernate.jdbc.AbstractBatcher.executeBatch(AbstractBatcher.java:246)
	... 44 more

ich hoffe es kann mir hier jemand weiterhelfen.

thanks
Thomas


----------



## Guest (13. Jan 2008)

In einer simiplen Anwendung hast du kein NamingService. Diese Fehlermeldung sagt einfach, dass keine Datenbank erreichbar ist.


----------



## th.weigand (14. Jan 2008)

Hallo

ich will nur kurz bescheid geben das sich dieses Problem gelöst hat.

danke
Thomas


----------

