Glassfish

From no name for this wiki
Jump to: navigation, search

Glassfish stuff

Auf derby sample-db connection

Die sample-db von Glassfish ist eine Netzwerkdatenbank.

URL: jdbc:derby://localhost:1527/sample Driver: org.apache.derby.jdbc.ClientDriver Jar: derbyclient.jar, im Verz. GLASSFISHHOME/javadb/lib

datasource mappen mit glassfish in einer Webapplikation

Folgende Datei mit dem Namen sun-web.xml im WEB-INF Verzeichnis anlegen. Mapped java:comp/env/jdbc/WebLearningPlatform nach jdbc/sample.

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE sun-web-app PUBLIC "-//Sun Microsystems, Inc.//DTD Application Server 9.0 Servlet 2.5//EN" "http://www.sun.com/software/appserver/dtds/sun-web-app_2_5-0.dtd">
<sun-web-app error-url="">
 <context-root>/WebLearingPlatform</context-root>
 <resource-ref>
   <res-ref-name>jdbc/WebLearningPlatform</res-ref-name>
   <jndi-name>jdbc/sample</jndi-name>
 </resource-ref>
 <class-loader delegate="true"/>
 <jsp-config>
   <property name="keepgenerated" value="true">
     <description>Keep a copy of the generated servlet class' java code.</description>
   </property>
 </jsp-config>
</sun-web-app>

Security in webapps

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE sun-web-app PUBLIC "-//Sun Microsystems, Inc.//DTD Application Server 9.0 Servlet 2.5//EN" "http://www.sun.com/software/appserver/dtds/sun-web-app_2_5-0.dtd">
<sun-web-app error-url="">
 <context-root>/SimpleBox</context-root>
 <security-role-mapping>
   <role-name>visitor</role-name>
   <principal-name>claude</principal-name>
 </security-role-mapping>
 <class-loader delegate="true"/>
 <jsp-config>
   <property name="keepgenerated" value="true">
     <description>Keep a copy of the generated servlet class' java code.</description>
   </property>
 </jsp-config>
</sun-web-app>

In der Administrator Konsole kann dann der user claude angelegt werden:

configuration -> security -> realmname -> add user

sun ea descriptor

Die Datei heisst sun-application.xml:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE sun-application PUBLIC "-//Sun Microsystems, Inc.//DTD Application Server 9.0 Java EE Application 5.0//EN" "http://www.sun.com/software/appserver/dtds/sun-application_5_0-0.dtd">
<sun-application/>

sun ejb descriptor

Die Datei heisst sun-ejb-jar.xml

Anbei ein Beispiel, wo der JNDI-Name definiert wird:

<sun-ejb-jar>
 <enterprise-beans>
   <ejb>
     <ejb-name>FooBean</ejb-name>
     <jndi-name>FooEJB</jndi-name>
   </ejb>
 </enterprise-beans>
</sun-ejb-jar>

coded-name zu jndi-name mappen

Zum Beispiel in sun-web.xml:

<ejb-ref>
   <ejb-ref-name>fooejbref</ejb-ref-name>
   <jndi-name>Foo</jndi-name>
</ejb-ref>

clients

properties to set for jndi context

Properties props = new Properties();
props.setProperty("java.naming.factory.initial", "com.sun.enterprise.naming.SerialInitContextFactory");
props.setProperty("java.naming.factory.url.pkgs", "com.sun.enterprise.naming");
props.setProperty("java.naming.factory.state", "com.sun.corba.ee.impl.presentation.rmi.JNDIStateFactoryImpl");
props.setProperty("org.omg.CORBA.ORBInitialHost", "localhost");
props.setProperty("org.omg.CORBA.ORBInitialPort", "3712");
InitialContext ctx = new InitialContext(props);

ejb3 standalone clients classpath

Standalone Applikationen mit Zugriff auf Remote Beans sollten folgende Jars im Classpath haben:

  • lib/appserv-rt.jar
  • lib/javaee.jar
  • lib/appserv-deployment-client.jar
  • lib/appserv-ext.jar

message queue or topic clients classpath

JNDI:

  • lib/appserv-rt.jar
  • lib/javaee.jar
  • lib/appserv-deployment-client.jar
  • lib/appserv-ext.jar

MESSAGE:

  • /imq/lib/jms.jar
  • /imq/lib/imq.jar
  • /imq/lib/imqutil.jar
  • /imq/lib/jms.jar
  • /lib/install/applications/jmsra/imqjmsra.jar