Hello World JSP

Hando84

Grünschnabel
also, ich verwende SAP NetWeaver und einen SAP 7.1 Web-Application-Server.

So sieht das Programm aus, wenn ich es lokal als Java-Programm laufen hab und auf den Server zugreife, was auch funktioniert:

package com.sap.sdn.client;

import java.util.Properties;

import javax.naming.Context;
import javax.naming.InitialContext;
import javax.rmi.PortableRemoteObject;

import com.sap.sdn.ejb.HelloWorldRemote;

public class HelloWorldClient {
public static void main(String[] args) {
Properties props = new Properties();
props.put(Context.INITIAL_CONTEXT_FACTORY,
"com.sap.engine.services.jndi.InitialContextFactoryImpl");
props.put(Context.PROVIDER_URL, "test.de:50204");
props.put(Context.SECURITY_PRINCIPAL, "lala");
props.put(Context.SECURITY_CREDENTIALS, "dipsi");


try {
Context ctx = new InitialContext(props);
Object o = ctx.lookup(
"com.tsi/MS_HelloWorldEAR/REMOTE/HelloWorldBean/com.sap.sdn.ejb.HelloWorldRemote");
HelloWorldRemote helloRef = (HelloWorldRemote)
PortableRemoteObject.narrow(o, HelloWorldRemote.class);
String msg = helloRef.sayHello("World");
System.out.println(msg);

} catch (Exception e) {
e.printStackTrace();
}
}
}


Nun möchte ich das ganze aber als JSP auf dem Web-Server laufen lassen um über den Browser an den gewünschten Text zu kommen. Die Bean und die JSP sollen sich hierbei in 2 verschiedenen EARs befinden.
Da hab ich das ganze ienfach mal so versucht:


<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>

<%@ page import="java.util.Properties", import="javax.naming.Context" import="javax.naming.InitialContext",
import="javax.rmi.PortableRemoteObject", import="com.sap.sdn.ejb.HelloWorldRemote" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Hello World</title>
</head>
<body>

<%

Properties props = new Properties();
props.put(Context.INITIAL_CONTEXT_FACTORY,
"com.sap.engine.services.jndi.InitialContextFactoryImpl");
props.put(Context.PROVIDER_URL, "localhost:50204");
props.put(Context.SECURITY_PRINCIPAL, "lala");
props.put(Context.SECURITY_CREDENTIALS, "dipsi");


try {
Context ctx = new InitialContext(props);
Object o = ctx.lookup(
"com.tsi/MS_HelloWorldEAR/Remote/HelloWorldBean/com.sap.sdn.ejb.HelloWorldRemote");
HelloWorldRemote helloRef = (HelloWorldRemote)
PortableRemoteObject.narrow(o, HelloWorldRemote.class);
String msg = helloRef.sayHello("World");
System.out.println(msg);

} catch (Exception e) {
e.printStackTrace();
}

%>

</body>
</html>

Ich weiß, könnte das ganze jetzt auch übers Local-Interface, anstatt das Remote-Interface versuchen, aber das hat auch net so ganz funktioniert.
Weiß auch garnicht, ob ich das so in ne JSP einbauen darf...
Jedenfalls habe ich in dem EAR mit dem JSP die benötigte Jar eingebunden, jedoch nur die Interfaces ohne die eigentliche Bean


Jedenfalls bekomme ich dann folgende Fehlermeldung:

Runtime error in processing of the JSP file [/usr/sap/EPX/DVEBMGS02/j2ee/cluster/apps/com.tsi/MS_HelloWorldEARClient/servlet_jsp/HelloWorldDynamicWeb/root/HelloWorldJSP.jsp].
The error is: com.sap.engine.services.servlets_jsp.jspparser_api.exception.JspParseException: Expecting [=] instead of [,].
Error in file [/usr/sap/EPX/DVEBMGS02/j2ee/cluster/apps/com.tsi/MS_HelloWorldEARClient/servlet_jsp/HelloWorldDynamicWeb/root/HelloWorldJSP.jsp]; line: [4]; position: [38]001E0B5C3568005700000C44000014E003C3387A2F1E59BB

Processing HTTP request to servlet [jsp] finished with error.
The error is: com.sap.engine.services.servlets_jsp.server.exceptions.WebIOException: Internal error occurred while parsing the jsp page [/usr/sap/EPX/DVEBMGS02/j2ee/cluster/apps/com.tsi/MS_HelloWorldEARClient/servlet_jsp/HelloWorldDynamicWeb/root/HelloWorldJSP.jsp].001E0B5C3568005700000C47000014E003C3387A2F1E59BB

Cannot get aliases for [sap.com/caf~eu~gp~ui~support] application.
The error is: com.sap.engine.services.deploy.exceptions.ServerDeploymentException: [ERROR CODE DPL.DS.5005] Application sap.com/caf~eu~gp~ui~support is not deployed on cluster element get its aliases and it is not possible to {2}.001E0B5C3568005700000C4A000014E003C3387A2F1E59BF

Vielleicht kann mir ja hier wer weiterhelfen, wie ich das richtig einbaue...
 
Zuletzt bearbeitet:

Neue Beiträge

Zurück