All denjenigen, die, wie ich, nur selten mit purem PHP entwickeln und sich jedesmal am Kopf kratzen, wenn es darum geht zu wissen, wie der verdammte Befehl heißt, mit dem man einen REDIRECT ausführen kann, soll geholfen werden:
HEADER(“location:http://www.mensch-und-maschine.de”);
zu beachten ist:
Vor dem Aufruf darf nichts ausgegeben werden. also kein echo, kein print_r etc. verwenden.
Dasselbe bekommt man per HTML mittels META Refresh hin:
<html>
<head>
<meta http-equiv="refresh" content="2;url=http://www.yoursite.com/newpage.htm" />
<title>Page has moved</title>
</head>
<body>
</body>
</html>
Mal wieder eien Erkenntnis aus der Eclipse-Welt:
Wer unter Linux den JAVA-Debugger anwirft und sich wundert, dass im Variablen-Fenster keien Variablen angezeigt werden bzw. nicht aufgeklappt werden können, der sollte im Dialog Windows-> Preferences unter Java->Installed JREs die “gjc” Variante von JAVA deaktivieren bzw zu einer anderen wechseln. Sollte keine weitere verfügbar sein, kann per sudo apt-get install sun-java6-jdk der sudo apt-get install sun-java5-jdk eine passende Version installieren.
Viele Grüße,
–kdot
Wer glaubt, des Gute könne nicht existieren, ohne dass es das Böse gibt, irrt: Es genügt zu wissen, wie sich Böses definiert um einen Maßstab zu erhalten.
–kdot
Wer sich mit Shrew zu ein VPN verbinden will, aber im connect-fenster die meldung “failed to attach to key deamon” bekommt, startet am besten windows neu anstatt 30 min lang zu versuchen, die configuration zu korrigieren!
–kdot
Hallo SAP-Jünger,
Um einen SAP Webservice zu betreiben, ist Tomcat offensichtlich nicht die richtige Wahl. Der SAP JAVA Conenctor liefert nach einiger Zeit nur noch Fehlermeldungen im Zusammenhang mit dem Verbinden zum SAP System. Vermutlich liegt das an einem Bug in den Binaries der Datei libsapjco3.so. Vielleicht habe ich die SAP.-Verbindung auch nur nicht richtig Konfiguriert. Jedenfalls haben mich die Probleme mit Tomcat dann doch etwas frustriert und ich habe IBM WebSphere ausprobiert.
Erstmal musste ich mich daran gewöhnen, dass Websphere ein wenig Zeit braucht, um zu starten. Doch wenn es einmal steht, ist es auch performant.
Deployment:
- auf http://localhost:8080 gehen und dort oben links “Administrative Console” anklicken.
- Einloggen mit User=’System’, passwort=’password’
- unter Applications auf ‘Deploy new’ klicken, im oberen Feld die WAR file auswählen und install anklicken
Nachdem das Archiv installiert ist, erscheint es in der Liste der installierten Servlets/JSPs unter Applications->Web App WARs und kann im Browser unter http://<server>:<port>/<application web path>/<servletMapping> erreicht werden.
Viele Grüße,
nK
Hallo to you!
previously it was all about deploying java applications to Tomcat. Today I’ll explain how to use JAVA-Connector JCo 3.0 on a tomcat webserver.
while JCo 2.0 is pretty good covered, JCo 3.0 is not.
requirements:
jco lib: libsapjco3.so
jco jar: sapjco3.jar
libsapjco3.so must be copied into the JDK folder.
under ubuntu thi is:
/usr/lib/jvm/java-1.5.0-sun/jre/lib/i386
sapjco3.jar must be copied into to classpath of the application that shall be deployed on tomcat. Additionally, sapjco3.jar must be copied in the lib folder of your tomcat6 server installation.
After this you can deploy the app like stated in the previous article.
for questions regarding SAP/JCo you can write me an email or leave a comment
I’ve got one solution for all who want to run jco on tomcat but run into two problems:
1. you can register the DestinationDataProvider only once
2. the method Environment.isDestinationDataProviderRegistered() produces the following exception after several runs
java.lang.ExceptionInInitializerError: Error getting the version of the native layer: java.lang.UnsatisfiedLinkError: com/sap/conn/rfc/driver/CpicDriver.nativeCpicGetVersion
The error is probably caused by a bug in JCo itself. Also possible is that i just have wrong configuration settings. Regardless of that,a solution is regisrtering the DataProvider within an empty try catch block and with that not calling the erroneous jco method..
Code with isDestinationDataProviderSet():
public SAPConnection(SAPServerData serverData){
this.serverConnectionProperties = new Properties();
this.serverConnectionProperties.setProperty(DestinationDataProvider.JCO_ASHOST, serverData.getHost());
this.serverConnectionProperties.setProperty(DestinationDataProvider.JCO_SYSNR, serverData.getSystemNr());
this.serverConnectionProperties.setProperty(DestinationDataProvider.JCO_CLIENT, serverData.getClient());
this.serverConnectionProperties.setProperty(DestinationDataProvider.JCO_USER, serverData.getUser());
this.serverConnectionProperties.setProperty(DestinationDataProvider.JCO_PASSWD, serverData.getPassword());
this.serverConnectionProperties.setProperty(DestinationDataProvider.JCO_LANG, serverData.getLanguage());
this.serverConnectionProperties.setProperty(DestinationDataProvider.JCO_PEAK_LIMIT, "10");
this.serverConnectionProperties.setProperty(DestinationDataProvider.JCO_POOL_CAPACITY, "5");
//this.serverConnectionProperties.setProperty(DestinationDataProvider.JCO_EXPIRATION_PERIOD, Integer.toString(serverData.getTimeout()));
//set properties of testsystem provider
provider.changePropertiesForABAP_AS(serverConnectionProperties);
//avoid multiple provider loading, which would lead to an exception
if(!Environment.isDestinationDataProviderRegistered()){
//register provider
Environment.registerDestinationDataProvider(provider);
}
//try to establish connection
try{
this.destination = JCoDestinationManager.getDestination(SAP_SERVER);
this.repository=this.destination.getRepository();
}
catch( JCoException e){
e.printStackTrace();
return;
}
}
Code without isDestinationDataProviderRegistered():
public SAPConnection(SAPServerData serverData){
this.serverConnectionProperties = new Properties();
this.serverConnectionProperties.setProperty(DestinationDataProvider.JCO_ASHOST, serverData.getHost());
this.serverConnectionProperties.setProperty(DestinationDataProvider.JCO_SYSNR, serverData.getSystemNr());
this.serverConnectionProperties.setProperty(DestinationDataProvider.JCO_CLIENT, serverData.getClient());
this.serverConnectionProperties.setProperty(DestinationDataProvider.JCO_USER, serverData.getUser());
this.serverConnectionProperties.setProperty(DestinationDataProvider.JCO_PASSWD, serverData.getPassword());
this.serverConnectionProperties.setProperty(DestinationDataProvider.JCO_LANG, serverData.getLanguage());
this.serverConnectionProperties.setProperty(DestinationDataProvider.JCO_PEAK_LIMIT, "10");
this.serverConnectionProperties.setProperty(DestinationDataProvider.JCO_POOL_CAPACITY, "5");
//this.serverConnectionProperties.setProperty(DestinationDataProvider.JCO_EXPIRATION_PERIOD, Integer.toString(serverData.getTimeout()));
//set properties of testsystem provider
provider.changePropertiesForABAP_AS(serverConnectionProperties);
//avoid multiple provider loading, which would lead to an exception.
try {
//register provider
Environment.registerDestinationDataProvider(provider);
} catch (Exception e1) {}
//try to establish connection
try{
this.destination = JCoDestinationManager.getDestination(SAP_SERVER);
this.repository=this.destination.getRepository();
}
catch( JCoException e){
e.printStackTrace();
return;
}
}
Hallo an Dich!
Zuletzt ging es an dieser Stelle um das Deployen von Java Anwendungen auf Tomcat. Heute wird das Ganze erweitert um das erfolgreiche Einbinden von SAP’s JAVA-Connector JCo 3.0
JCo 2.0 wird relativ gut im Netz behandelt, doch mit JCo3 sieht es nicht so gut aus.
Was du brauchst:
jco lib: libsapjco3.so
jco jar: sapjco3.jar
libsapjco3.so kommt ins JDK-Verzeichnis.
unter ubuntu ist das:
/usr/lib/jvm/java-1.5.0-sun/jre/lib/i386
Die sapjco3.jar muss in den classpath der Anwendung, die auf tomcat deployed werden soll.
Weiterhin muss die sapjco3.jar im tomcat 6 unter lib kopiert werden. bei mir: (/usr/local/share/tomcat6/lib)
danach kann wie im tomcat deployment text vorgegangen werden, um zu deployen.
Eine Lösung habe ich für alle die, die JCo auf Tomcat6 betreiben wollen, jedoch auf zwei probleme stoßen.
1. Man kann den DestinationDataProvider nur einmal registrieren
2. die Abfrage Environment.isDestinationDataProviderRegistered() produziert nach einigen Durchläufen folgende Exception:
java.lang.ExceptionInInitializerError: Error getting the version of the native layer: java.lang.UnsatisfiedLinkError: com/sap/conn/rfc/driver/CpicDriver.nativeCpicGetVersion
Der Fehler wird vermutlich durch einen Bug in JCo hervorgerufen. Möglich ist auch, dass es an falschen Einstellungen des Dataproviders liegt. Wie auch immer: eine Lösung ist, das setzen dees Dataproviders in einen leeren Try Catch Block zu schreiben und somit die fehlerhafte isDestinationDataProviderSet() methode nicht aufzurufen.
Code mit isDestinationDataProviderSet():
public SAPConnection(SAPServerData serverData){
this.serverConnectionProperties = new Properties();
this.serverConnectionProperties.setProperty(DestinationDataProvider.JCO_ASHOST, serverData.getHost());
this.serverConnectionProperties.setProperty(DestinationDataProvider.JCO_SYSNR, serverData.getSystemNr());
this.serverConnectionProperties.setProperty(DestinationDataProvider.JCO_CLIENT, serverData.getClient());
this.serverConnectionProperties.setProperty(DestinationDataProvider.JCO_USER, serverData.getUser());
this.serverConnectionProperties.setProperty(DestinationDataProvider.JCO_PASSWD, serverData.getPassword());
this.serverConnectionProperties.setProperty(DestinationDataProvider.JCO_LANG, serverData.getLanguage());
this.serverConnectionProperties.setProperty(DestinationDataProvider.JCO_PEAK_LIMIT, "10");
this.serverConnectionProperties.setProperty(DestinationDataProvider.JCO_POOL_CAPACITY, "5");
//this.serverConnectionProperties.setProperty(DestinationDataProvider.JCO_EXPIRATION_PERIOD, Integer.toString(serverData.getTimeout()));
//set properties of testsystem provider
provider.changePropertiesForABAP_AS(serverConnectionProperties);
//avoid multiple provider loading, which would lead to an exception
if(!Environment.isDestinationDataProviderRegistered()){
//register provider
Environment.registerDestinationDataProvider(provider);
}
//try to establish connection
try{
this.destination = JCoDestinationManager.getDestination(SAP_SERVER);
this.repository=this.destination.getRepository();
}
catch( JCoException e){
e.printStackTrace();
return;
}
}
Code ohne isDestinationDataProviderRegistered():
public SAPConnection(SAPServerData serverData){
this.serverConnectionProperties = new Properties();
this.serverConnectionProperties.setProperty(DestinationDataProvider.JCO_ASHOST, serverData.getHost());
this.serverConnectionProperties.setProperty(DestinationDataProvider.JCO_SYSNR, serverData.getSystemNr());
this.serverConnectionProperties.setProperty(DestinationDataProvider.JCO_CLIENT, serverData.getClient());
this.serverConnectionProperties.setProperty(DestinationDataProvider.JCO_USER, serverData.getUser());
this.serverConnectionProperties.setProperty(DestinationDataProvider.JCO_PASSWD, serverData.getPassword());
this.serverConnectionProperties.setProperty(DestinationDataProvider.JCO_LANG, serverData.getLanguage());
this.serverConnectionProperties.setProperty(DestinationDataProvider.JCO_PEAK_LIMIT, "10");
this.serverConnectionProperties.setProperty(DestinationDataProvider.JCO_POOL_CAPACITY, "5");
//this.serverConnectionProperties.setProperty(DestinationDataProvider.JCO_EXPIRATION_PERIOD, Integer.toString(serverData.getTimeout()));
//set properties of testsystem provider
provider.changePropertiesForABAP_AS(serverConnectionProperties);
//avoid multiple provider loading, which would lead to an exception.
try {
//register provider
Environment.registerDestinationDataProvider(provider);
} catch (Exception e1) {}
//try to establish connection
try{
this.destination = JCoDestinationManager.getDestination(SAP_SERVER);
this.repository=this.destination.getRepository();
}
catch( JCoException e){
e.printStackTrace();
return;
}
}
Grog ist DAS Modegetränk, wie der u.g. Artikel bestätigt. Jeder sollte Grog trinken!
Wir sehen uns also in der SCUMM Bar wieder
Frohes Plündern und Brandschatzen sei euch gewünscht!
Link: Grog im aller welt
Hallo Freunde des Java-Codes.
Da die Anleitungen auf der Apache Tomcat Seite sehr sehr ausschweifend sind, möchte ich hier ene enorm kurze Anleitung bringen, wie man mittels Eclipse 3.4 und Apache Tomcat Servlets schnell udn sicher verfügbar machen kann.
Vorraussetzungen: Du hast im Eclipse (JAVA EE mit Web Tools) ein funktionierendes Programm und ein Servlet, was als Webservice dienen und auf die restlichen Klassen zugreifen soll. Ihr habt einen lokalen Tomcat 6.0 Server laufen und der kann per Eclipse gestartet werden. Per Browser könnt ihr lokal bereits auf das Servlet zugreifen.
Schritt 1: Erstellen eines WAR-Files (Das ist beinahe ein JAR File, doch enthält es zusätzliche Dateien, um Tomcat zu konfigurieren)
WAR ezeugen: File->Export->WAR File
Schritt 2: War File auf Tomcat ‘deployen’: kopiere das WAR file auf den Server, auf dem das Live-System letztendlich laufen soll. Der Pfad ist dabei uninteressant.
Schritt 3: Öffne einen Browser (ich nehme dazu Links, weil die Live-Server ja meist nicht zugreifbar sind) und gehe auf http://localhost:8080 (das ist die Standard Einstellung von Tomcat. Solltest du das geändert haben, so musst du das an der URL natürlich auch ändern!)
Schritt 4: Klicke links im Menü auf ‘Tomcat Manager’ und log dich als ein Benutzer ein, der in der ‘manager’-Gruppe ist.
Schritt 5: Im Vorletzten Feld ‘Deploy’ musst du nun unter ‘WAR file to deploy’ und dort unter ‘Select WAR file to upload’ dein soeben hochgeladenes WAR-File auswählen und dann auf ‘Deploy’ klicken.
Schritt 6: Starte den Tomcat Server neu und du kannst dein Servlet nutzen.
–kdot
