Mail Archive Home | exoplatform List | April 2008 Index
| <-- Date Index --> | <-- Thread Index --> |
|
Hi Alexey, Alexey Zavizionov a écrit : I have got same on WAS with ibm jdk 5? solved with jaxp jars.My modified files are attached. So, I must try to understand this QuartzScheduler error to solve my deployment ? that would be fine. I'll work on this tomorrow...headache tonight... thanks ;) Cheers Alexey Zavizionov a écrit : Hi Steph, |
/*
* Copyright (C) 2003-2007 eXo Platform SAS.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU Affero General Public License
* as published by the Free Software Foundation; either version 3
* of the License, or (at your option) any later version.
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* You should have received a copy of the GNU General Public License
* along with this program; if not, see<http://www.gnu.org/licenses/>.
*/
package org.exoplatform.services.portletcontainer.impl.servlet;
import java.io.IOException;
import java.io.InputStream;
import java.net.URL;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.Iterator;
import javax.servlet.ServletContext;
import javax.servlet.ServletContextEvent;
import javax.servlet.ServletContextListener;
import javax.xml.transform.stream.StreamSource;
import javax.xml.validation.Schema;
import javax.xml.validation.SchemaFactory;
import javax.xml.validation.Validator;
import org.apache.commons.logging.Log;
import org.exoplatform.commons.xml.ExoXPPParser;
import org.exoplatform.container.ExoContainer;
import org.exoplatform.container.ExoContainerContext;
import org.exoplatform.services.log.ExoLogger;
import org.exoplatform.services.portletcontainer.PortletApplicationRegister;
import org.exoplatform.services.portletcontainer.pci.model.PortletApp;
import org.exoplatform.services.portletcontainer.pci.model.XMLParser;
import org.w3c.dom.ls.LSInput;
import org.w3c.dom.ls.LSResourceResolver;
import org.xml.sax.SAXException;
import org.xmlpull.v1.XmlPullParser;
import org.apache.xerces.dom.DOMInputImpl;
/**
* Created by the Exo Development team.
* Author : Mestrallet Benjamin
* benjmestrallet@xxxxxxxxxxxxxxxxxxxxx
* Date: 10 nov. 2003
* Time: 12:58:52
*/
public class PortletApplicationListener implements ServletContextListener {
/**
* Logger.
*/
private static Log log = ExoLogger.getLogger("org.exoplatform.services.portletcontainer");
/**
* WebXML.
*/
private static String fileWebXML = "/WEB-INF/web.xml";
/**
* PortletXML.
*/
private static String filePortletXML = "/WEB-INF/portlet.xml";
/**
* XMLXSD.
*/
private static String fileXMLXSD = "javax/servlet/resources/" + "xml.xsd";
/**
* XMLSchemaDTD.
*/
private static String fileXMLSchemaDTD = "javax/servlet/resources/" + "XMLSchema.dtd";
/**
* DatatypesDTD.
*/
private static String fileDatatypesDTD = "javax/servlet/resources/" + "datatypes.dtd";
/**
* Servlet context.
*/
protected ServletContext hServletContext;
/**
* Overridden method.
*
* @param servletContextEvent servlet context event
* @see javax.servlet.ServletContextListener#contextInitialized(javax.servlet.ServletContextEvent)
*/
public final void contextInitialized(final ServletContextEvent servletContextEvent) {
ExoContainer manager = ExoContainerContext.getTopContainer();
if (log.isDebugEnabled())
log.debug("Getting context path");
String portletAppName = getContextPath(servletContextEvent);
if (log.isDebugEnabled())
log.debug("Context path:" + portletAppName);
ServletContext servletContext = servletContextEvent.getServletContext();
hServletContext = servletContextEvent.getServletContext();
log.info("DEPLOY PORTLET APPLICATION: " + portletAppName);
if (log.isDebugEnabled())
log.debug("Real path : " + servletContext.getRealPath(""));
InputStream is = null;
String oldParser = System.getProperty("javax.xml.parsers.DocumentBuilderFactory");
try {
String spec = validationPortletXML(servletContext);
if (spec == null)
return;
is = servletContext.getResourceAsStream(filePortletXML);
log.info("The portlet.xml file valid portlet spec " + spec);
PortletApp portletApp = XMLParser.parse(is, spec.equalsIgnoreCase("2") ? Boolean.TRUE
: Boolean.FALSE);
is = servletContext.getResourceAsStream(fileWebXML);
Collection<String> roles = new ArrayList<String>();
ExoXPPParser xpp = ExoXPPParser.getInstance();
xpp.setInput(is, "UTF8");
xpp.mandatoryNode("web-app");
while (!xpp.node("security-role")) {
if (xpp.getEventType() == XmlPullParser.END_DOCUMENT)
break;
xpp.next();
}
if (xpp.node("role-name")) {
roles.add(xpp.getContent());
while (xpp.node("security-role"))
roles.add(xpp.mandatoryNodeContent("role-name"));
}
log.info(" -- read: " + portletApp.getPortlet().size() + " portlets");
PortletApplicationRegister service = (PortletApplicationRegister) manager
.getComponentInstanceOfType(PortletApplicationRegister.class);
service.registerPortletApplication(servletContext, portletApp, roles, portletAppName);
} catch (Exception e) {
log.error("Cannot deploy " + portletAppName, e);
} finally {
if (oldParser != null)
System.setProperty("javax.xml.parsers.DocumentBuilderFactory", oldParser);
}
}
/**
* Overridden method.
*
* @param servletContextEvent servlet context event
* @see javax.servlet.ServletContextListener#contextDestroyed(javax.servlet.ServletContextEvent)
*/
public final void contextDestroyed(final ServletContextEvent servletContextEvent) {
ServletContext servletContext = servletContextEvent.getServletContext();
String portletAppName = getContextPath(servletContextEvent);
ExoContainer manager = ExoContainerContext.getTopContainer();
log.info("UNDEPLOY PORTLET APPLICATION: " + portletAppName);
try {
PortletApplicationRegister service = (PortletApplicationRegister) manager
.getComponentInstanceOfType(PortletApplicationRegister.class);
service.removePortletApplication(servletContext, portletAppName);
} catch (Exception e) {
log.error("UNDEPLOY PORTLET APPLICATION: " + e);
}
}
/**
* @param servletContextEvent servlet context event
* @return context path
*/
private String getContextPath(final ServletContextEvent servletContextEvent) {
String portletAppName = null;
try {
portletAppName = (String) ServletContext.class.getMethod("getContextPath", new Class[0])
.invoke(servletContextEvent.getServletContext(), new Class[0]);
portletAppName = portletAppName.substring(portletAppName.lastIndexOf("/") + 1);
return portletAppName;
} catch (Exception e) {
log
.warn("Servlet api 2.4 or below detected. Unable to find method getContextPath on ServletContext.");
//e.printStackTrace();
}
if (portletAppName == null)
try {
java.net.URL webXmlUrl = servletContextEvent.getServletContext().getResource(fileWebXML);
portletAppName = webXmlUrl.toExternalForm();
portletAppName = portletAppName.substring(0, portletAppName.indexOf(fileWebXML));
int id = portletAppName.indexOf(".war");
if (id > 0)
portletAppName = portletAppName.substring(0, id);
portletAppName = portletAppName.substring(portletAppName.lastIndexOf("/") + 1);
return portletAppName;
} catch (java.net.MalformedURLException e) {
log.error("Erorr getting web.xml from ServletContext.");
//e.printStackTrace();
}
return portletAppName;
}
/**
* @param servletContext servlet context
* @return version of portlet app
*/
private String validationPortletXML(final ServletContext servletContext) {
InputStream is = servletContext.getResourceAsStream(filePortletXML);
if (is == null) {
log.info("PORTLET CONFIGURATION IS NOT FOUND, IGNORE THE PACKAGE");
return null;
}
try {
is.close();
} catch (IOException e) {
log.error(e.getCause());
}
String specErr1 = null;
String specErr2 = null;
if (log.isDebugEnabled())
log.debug("Defining portlet specification");
ClassLoader cl = Thread.currentThread().getContextClassLoader();
StreamSource source = null;
// long time = java.lang.System.currentTimeMillis();
try {
if (log.isDebugEnabled())
log.debug("validation 1-st portlet spec");
source = new StreamSource(servletContext.getResourceAsStream(filePortletXML));
SchemaFactory factory = SchemaFactory
.newInstance(javax.xml.XMLConstants.W3C_XML_SCHEMA_NS_URI);
StreamSource schemaFile = new StreamSource(cl.getResourceAsStream("portlet-app_1_0.xsd"));
factory.setResourceResolver(new PCResourceResolverImpl());
Schema schema = factory.newSchema(schemaFile);
Validator validator = schema.newValidator();
validator.validate(source);
return "1";
} catch (SAXException e) {
specErr1 = e.getMessage();
} catch (IOException e) {
specErr1 = e.getMessage();
}
// System.out.println(java.lang.System.currentTimeMillis()-time + " - time 1-st portlet spec validation");
// time = java.lang.System.currentTimeMillis();
try {
if (log.isDebugEnabled())
log.debug("validation 2-nd portlet spec");
source = new StreamSource(servletContext.getResourceAsStream(filePortletXML));
SchemaFactory factory = SchemaFactory
.newInstance(javax.xml.XMLConstants.W3C_XML_SCHEMA_NS_URI);
StreamSource schemaFile = new StreamSource(cl.getResourceAsStream("portlet-app_2_0.xsd"));
factory.setResourceResolver(new PCResourceResolverImpl());
Schema schema = factory.newSchema(schemaFile);
Validator validator = schema.newValidator();
validator.validate(source);
return "2";
} catch (SAXException e) {
specErr2 = e.getMessage();
} catch (IOException e) {
specErr2 = e.getMessage();
}
// System.out.println(java.lang.System.currentTimeMillis()-time + " - time 2-nd portlet spec validation");
if (log.isDebugEnabled())
log.debug("Checking that was the error reason internet connection problem.");
String errWithoutInet = "src-resolve: Cannot resolve the name 'xml:lang' to a(n) 'attribute declaration' component.";
if (specErr1.contains(errWithoutInet) && specErr2.contains(errWithoutInet)) {
log.info("Validation portlet.xml warning: please check your internet connection.");
StringBuffer out = new StringBuffer();
byte[] b = new byte[4096];
try {
is = servletContext.getResourceAsStream(filePortletXML);
for (int n; (n = is.read(b)) != -1;)
out.append(new String(b, 0, n));
is.close();
} catch (IOException e) {
e.printStackTrace();
}
String str = out.toString();
int i1 = str.indexOf("portlet-app");
int i2 = str.indexOf(">", i1);
String s = str.substring(i1, i2);
int res1 = s.indexOf("portlet-app_1_0.xsd");
if (res1 > 0)
return "1";
int res2 = s.indexOf("portlet-app_2_0.xsd");
if (res2 > 0)
return "2";
}
log.error("The portlet.xml doesn't valid portlet spec 1 and 2");
if (specErr1 != null)
log.error("Validation 1-st portlet spec: " + specErr1);
if (specErr2 != null)
log.error("Validation 2-nd portlet spec: " + specErr2);
return null;
}
/**
* Class to resolve resources.
*/
class PCResourceResolverImpl implements LSResourceResolver {
/**
* Logger.
*/
private final Log log = ExoLogger.getLogger("org.exoplatform.services.portletcontainer");
/**
* Simple constructor.
*/
public PCResourceResolverImpl() {
}
/**
* Overridden method.
*
* @param type type
* @param namespaceURI namespace uri
* @param publicId public id
* @param systemId system id
* @param baseURI base uri
* @return ls input
* @see org.w3c.dom.ls.LSResourceResolver#resolveResource(java.lang.String, java.lang.String, java.lang.String, java.lang.String, java.lang.String)
*/
public final LSInput resolveResource(final String type, // 'http://www.w3.org/2001/XMLSchema'
final String namespaceURI, // 'http://www.w3.org/XML/1998/namespace'
final String publicId, // 'null'
final String systemId, // 'http://www.w3.org/2001/xml.xsd' <- this one require for us
final String baseURI) // 'null'
{
try {
if (systemId.equals("http://www.w3.org/2001/xml.xsd")) {
// return a special input source for http://www.w3.org/2001/xml.xsd
LSInput lsInput = new DOMInputImpl();
InputStream is = null;
ClassLoader cl = Thread.currentThread().getContextClassLoader();
Collection c = Collections.list(cl.getResources(fileXMLXSD));
Iterator i = c.iterator();
while (i.hasNext()) {
URL url = (URL) i.next();
is = url.openStream();
if (is != null) {
if (log.isDebugEnabled())
log.debug("Have got the : " + fileXMLXSD + ", url = " + url + ", key = "
+ url.toString());
break;
}
}
lsInput.setByteStream(is);
return lsInput;
}
if (systemId.equals("XMLSchema.dtd")) {
// return a special input source for XMLSchema.dtd
LSInput lsInput = new DOMInputImpl();
InputStream is = null;
ClassLoader cl = Thread.currentThread().getContextClassLoader();
Collection c = Collections.list(cl.getResources(fileXMLSchemaDTD));
Iterator i = c.iterator();
while (i.hasNext()) {
URL url = (URL) i.next();
is = url.openStream();
if (is != null) {
if (log.isDebugEnabled())
log.debug("Have got the : " + fileXMLSchemaDTD + ", url = " + url + ", key = "
+ url.toString());
break;
}
}
lsInput.setByteStream(is);
return lsInput;
}
if (systemId.equals("datatypes.dtd")) {
// return a special input source for datatypes.dtd
LSInput lsInput = new DOMInputImpl();
InputStream is = null;
ClassLoader cl = Thread.currentThread().getContextClassLoader();
Collection c = Collections.list(cl.getResources(fileDatatypesDTD));
Iterator i = c.iterator();
while (i.hasNext()) {
URL url = (URL) i.next();
is = url.openStream();
if (is != null) {
if (log.isDebugEnabled())
log.debug("Have got the : " + fileDatatypesDTD + ", url = " + url + ", key = "
+ url.toString());
break;
}
}
lsInput.setByteStream(is);
return lsInput;
}
} catch (Exception e) {
System.out.println(e.getCause());
}
return null;
}
}
}
<project>
<parent>
<groupId>org.exoplatform.portletcontainer</groupId>
<artifactId>config</artifactId>
<version>trunk</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>exo.pc.component.plugins.pc</artifactId>
<packaging>jar</packaging>
<name>eXo Portlet Container 2 Plugins PC (actual impl)</name>
<description>eXo Portlet Container 2 plugins.pc (actual impl)</description>
<dependencies>
<dependency>
<groupId>org.exoplatform.portletcontainer</groupId>
<artifactId>exo.pc.component.core</artifactId>
<version>${org.exoplatform.pc.version}</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.exoplatform.kernel</groupId>
<artifactId>exo.kernel.commons</artifactId>
<version>${org.exoplatform.kernel.version}</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.exoplatform.kernel</groupId>
<artifactId>exo.kernel.container</artifactId>
<version>${org.exoplatform.kernel.version}</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.exoplatform.core</groupId>
<artifactId>exo.core.component.xml-processing</artifactId>
<version>${org.exoplatform.core.version}</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.exoplatform.kernel</groupId>
<artifactId>exo.kernel.component.cache</artifactId>
<version>${org.exoplatform.kernel.version}</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.exoplatform.core</groupId>
<artifactId>exo.core.component.resources.api</artifactId>
<version>${org.exoplatform.core.version}</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.exoplatform.core</groupId>
<artifactId>exo.core.component.organization.api</artifactId>
<version>${org.exoplatform.core.version}</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.exoplatform.core</groupId>
<artifactId>exo.core.component.organization.jdbc</artifactId>
<version>${org.exoplatform.core.version}</version>
<scope>compile</scope>
</dependency>
<!-- *************************** -->
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>jsp-api</artifactId>
<version>2.0</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>xerces</groupId>
<artifactId>xercesImpl</artifactId>
<version>2.8.1</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>javax.portlet</groupId>
<artifactId>portlet-api</artifactId>
<version>2.0</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>javax.ccpp</groupId>
<artifactId>ccpp</artifactId>
<version>1.0</version>
<scope>compile</scope>
</dependency>
<!-- for javax.xml.bind.JAXBContext; -->
<dependency>
<groupId>javax.xml.bind</groupId>
<artifactId>jaxb-api</artifactId>
<version>2.0</version>
</dependency>
<dependency>
<groupId>com.sun.xml.bind</groupId>
<artifactId>jaxb-impl</artifactId>
<version>2.0.2</version>
</dependency>
<dependency>
<groupId>commons-pool</groupId>
<artifactId>commons-pool</artifactId>
<version>1.2</version>
<scope>compile</scope>
<exclusions>
<exclusion>
<groupId>xml-apis</groupId>
<artifactId>xml-apis</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>xml-apis</groupId>
<artifactId>xml-apis</artifactId>
<version>1.0.b2</version>
<scope>test</scope>
</dependency>
</dependencies>
<properties>
<war.dir>${basedir}/war_template</war.dir>
</properties>
<build>
<plugins>
<plugin>
<artifactId>maven-antrun-plugin</artifactId>
<version>1.2-SNAPSHOT</version>
<executions>
<execution>
<phase>generate-test-sources</phase>
<configuration>
<tasks>
<!-- JSR 168 portlets -->
<mkdir dir="${basedir}/target/test-classes/" />
<copy todir="${basedir}/target/test-classes/">
<fileset dir="${basedir}/war_template/src">
<include name="**/*.properties" />
</fileset>
</copy>
<javac
fork="true"
srcdir="${basedir}/war_template/src"
destdir="${basedir}/target/test-classes/"
debug="${maven.compile.debug}"
deprecation="${maven.compile.deprecation}"
optimize="${maven.compile.optimize}">
<classpath>
<path refid="maven.dependency.classpath" />
<pathelement path="${maven.build.dest}" />
</classpath>
</javac>
<!-- JSR 286 portlets -->
<mkdir dir="${basedir}/target/test-classes/" />
<copy todir="${basedir}/target/test-classes/">
<fileset dir="${basedir}/war_template2/src">
<include name="**/*.properties" />
</fileset>
</copy>
<javac
fork="true"
srcdir="${basedir}/war_template2/src"
destdir="${basedir}/target/test-classes/"
debug="${maven.compile.debug}"
deprecation="${maven.compile.deprecation}"
optimize="${maven.compile.optimize}">
<classpath>
<path refid="maven.dependency.classpath" />
<pathelement path="${maven.build.dest}" />
</classpath>
</javac>
</tasks>
</configuration>
<goals>
<goal>run</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
<systemProperties>
<property>
<name>testPath</name>
<value>${basedir}</value>
</property>
<property>
<name>mock.portal.dir</name>
<value></value>
</property>
<property>
<name>maven.exoplatform.dir</name>
<value></value>
</property>
<property>
<name>emma.coverage.out.file</name>
<value>target/emma/coverage.ec</value>
</property>
</systemProperties>
<includes>
<include>**/AllTestsPortlet.java</include>
<!-- include>**/TestFilters.java</include -->
<!-- include>**/Test*.java</include -->
</includes>
<skip>false</skip>
</configuration>
</plugin>
</plugins>
</build>
</project>
| <-- Date Index --> | <-- Thread Index --> |
Powered by MHonArc.
Copyright © 2006-2007, OW2 Consortium | contact | webmaster.