i am developing a portlet struts 2 ejb3
i configured project ejb and in the portlet project i confugured the action class and struts.xml
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE struts PUBLIC
"-//Apache Software Foundation//DTD Struts Configuration 2.0//EN"
"http://struts.apache.org/dtds/struts-2.0.dtd">
<struts>
<package namespace="/view" extends="struts-portlet-default" name="view">
<!-- If no class attribute is specified the framework will assume success and
render the result index.jsp -->
<!-- If no name value for the result node is specified the success value is the default -->
<action name="index">
<result>/html/view/index.jsp</result>
</action>
<action name="create" method="ajouterOUmodifier" class="com.esprit.action.AdressAction">
<result name="success" type="redirect">index</result>
<result name="input">/html/view/ajoutAdress.jsp</result>
</action>
</package>
</struts>
and the jsp file
<%# page contentType="text/html; charset=UTF-8"%>
<%# taglib prefix="s" uri="/struts-tags"%>
<%# taglib prefix="sx" uri="/struts-dojo-tags" %>
<html>
<head>
<link href="<s:url value="/resources/main.css"/>" rel="stylesheet" type="text/css"/>
</head>
<body>
<s:form action="create" method="post">
<s:textfield name="adress.nom" label="Firstname"/>
<s:textfield name="adress.prenom" label="Lastname"/>
<s:submit value="ok" />
</s:form>
</body>
</html>
but when i execute the project an error is display:
ERROR [jsp:154] java.lang.ClassNotFoundException: com.esprit.metier.AdressDao from BaseClassLoader#33b2c7a8{VFSClassLoaderPolicy#1e52011c{name=vfsfile:/D:/android/jboss-5.1.0.GA/server/default/deploy/DepartmentWEB-portlet.war/ domain=ClassLoaderDomain#69ac5f83{name=vfsfile:/D:/android/jboss-5.1.0.GA/server/default/deploy/DepartmentWEB-portlet.war/ parentPolicy=AFTER_BUT_JAVA_BEFORE parent=ClassLoaderDomain#5183a17c{DefaultDomain}} roots=[MemoryContextHandler#432465105[path= context=vfsmemory://5c4o13m-e9nqdk-h49ogxti-1-h49ohbp5-2a
can you help me ?
The ClassNotFound condition can result from two issues:
The class that the classloader complains about is not on the classpath
The class that the classloader complains about references another class that cannot be loaded for some reason (e.g. it's not on the classpath or references something else that is not...)
So: Check your classpath: Is com.esprit.metier.AdressDao on there? Its superclasses (the whole hierarchy) and all interfaces it implements? All members and referenced classes (see method signatures as well).
Further, if this really is a portlet's jsp, it shouldn't contain <html>, <head> and <body> as this is the business of the portal to add these to the page. You'll also probably need to include your css either in the theme or in liferay-portlet.xml in the <header-css> section (but this shouldn't influence your class-not-found experiences, it's just general portal advice)
Related
I am working on an eclipse RCP application. In the main (app) plugin I have defined a welcome or intro page. This is an XHTML file containing links to interesting resources.
There is a separate help plugin which contains the help in html and also as a PDF.
Is it possible to link from the welcome page in the app plugin to the PDF in the help plugin? I was thinking of something like this (but it didn't work)
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Welcome</title>
<link rel="stylesheet" href="shared.css" type="text/css" />
<link rel="stylesheet" href="root.css" type="text/css" />
</head>
<body>
<h1>Welcome to the Test Framework</h1>
<div class="page-style">
<div id="content">
<!-- app plugin -->
<a href="presentation.pdf">
<img border="0" src="file_powerpoint.png" alt="Presentation" />Präsentation</a>
<!-- help plugin -->
<a href="platform:/com.acme.atf.help/pdf/handbook_de.pdf">
<img border="0" src="file_pdf.png" alt="Handbuch" />Handbuch</a>
</div>
</div>
</body>
You need to register your XHTML page as a config extension at your plugin.
Add the extension at the plugin.xml:
<extension point="org.eclipse.ui.intro.configExtension">
<configExtension
configId="org.eclipse.ui.intro.universalConfig"
content="path/yourFile.xhtml" />
</extension>
Then, add it to the welcome page (via editing configuration, or using the Help/Welcome/Customize menu).
Link: A short tutorial on this topic
You can also use command to open some resource (you will implement opening of the resource in handler):
<extension
point="org.eclipse.ui.commands">
<command
defaultHandler="yourHandler"
id="openResource">
</command>
</extension>
and then execute the command in xml file where you have welcome page content:
<introContent>
<extensionContent id="openPdf" style="css/welcome.css"
name="SomeName" path="overview/#">
<group style-id="content-group" id="overview-default-group">
<link label="Open PDF"
url='http://org.eclipse.ui.intro/execute?command=openResource'
id="introLink" style-id="content-link">
<text>Open PDF resource</text>
</link>
</group>
</extensionContent>
I have a jar file that contains some tag-files.
My *.tag files are inside /META-INF/tags/ folder (jar)
I also have a mytags.tld inside /META-INF/ folder (jar)
After pack all war project (with mytags.jar inside WEB-INF/lib folder), it works fine in JBoss. But Eclipse still cannot recognize the tag, getting the error Can not find the tag library descriptor for "http://www.mycompany.com"
Is there a way to Eclipse recognize my tags?
follow the sources:
block.tag
<%#tag description="Item do block" pageEncoding="UTF-8"%>
<%#taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%#attribute name="id" required="true" %>
<%#attribute name="label" required="true" %>
<%#attribute name="description" required="false" %>
<%#attribute name="icon" required="false" %>
<div id="${id}" class="block">
<div class="block-box ${icon}">
<div class="label">
<span>${label}</span>
</div>
<div class="description">
${description}
<jsp:doBody></jsp:doBody>
</div>
</div>
</div>
mytags.tld
<?xml version="1.0" encoding="UTF-8" ?>
<taglib xmlns="http://java.sun.com/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-jsptaglibrary_2_1.xsd"
version="2.1">
<description>My Tags</description>
<display-name>MyTags</display-name>
<tlib-version>1.0</tlib-version>
<short-name>mytags</short-name>
<uri>http://www.mycompany.com</uri>
<tag-file>
<name>block</name>
<path>/META-INF/tags/block.tag</path>
</tag-file>
</taglib>
some.jsp
<%#page contentType="text/html; charset=ISO-8859-1" pageEncoding="UTF-8" %>
<%#taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%#taglib uri="http://www.mycompany.com" prefix="mytags" %> <-- ECLIPSE MARKS ERROR HERE
<!DOCTYPE html>
<html>
<head>
<title>Test</title>
</head>
<body>
<mytags:block id="users" label="Users" icon="user">
<!-- some content -->
</mytags:block>
</body>
</html>
But everything works fine in JBoss. Only eclipse accuses error.
Thanks
An existing bug report https://bugs.eclipse.org/bugs/show_bug.cgi?id=330405 suggests correcting the error message to point to the JSP version 1.1 detected from web.xml as a reason for the outdated interpretation of the taglib URI.
This is confirmed by a JSP Tag Libraries document, http://docs.oracle.com/cd/B14099_19/web.1012/b14014/taglibs.htm#i1014427:
As first defined in the JSP 1.1 specification, the taglib directive of a JSP page can fully specify the name and physical location, within a WAR file structure, of the TLD file that defines a particular tag library, as in the following example:
<%# taglib uri="/WEB-INF/oracustomtags/tlds/mytld.tld" prefix="oracust" %>
[..] Alternatively, as also defined since the JSP 1.1 specification, the taglib directive can specify the name and application-relative physical location of a JAR file instead of a TLD file
Both of the above 2 conventions retired to a fallback mechanism since JSP 1.2 which introduced mapping tag definitions and uses through the arbitrary taglib uri strings, http://docs.oracle.com/cd/B14099_19/web.1012/b14014/taglibs.htm#i1013109.
A recent JSP 2.1 spec documents the URI mapping in section JSP.7.3.2:
The URI describing a tag library is mapped to a TLD resource path though a
taglib map, and a fallback interpretation that is to be used if the map does not
contain the URI. The taglib map is built from an explicit taglib map in web.xml
(described in Section JSP.7.3.3) that is extended with implicit entries deduced
from packaged tag libraries in the web application (described in
Section JSP.7.3.4), and implicit entries known to the JSP container. The fallback
interpretation is targetted to a casual use of the mechanism, as in the development
cycle of theWeb Application; in that case the URI is interpreted as a direct path to
the TLD (see Section JSP.7.3.6.2).
I am trying to use JSF Facelet template/Facelet template client first time. I am creating template and template client with Netbeans 7.2.1. When I run that created JSF project and call http://localhost:8080/jpaweb/template.xhtml I can see template style, but when I call client template http://localhost:8080/jpaweb/client.xhtml I see plain text without style. Both files are in the same directory and created by Netbeans wizard. Please, help me with this issue.
template.xhtml
<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:h="http://java.sun.com/jsf/html">
<h:head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<link href="./resources/css/default.css" rel="stylesheet" type="text/css" />
<link href="./resources/css/cssLayout.css" rel="stylesheet" type="text/css" />
<title>Facelets Template</title>
</h:head>
<h:body>
<div id="top" class="top">
<ui:insert name="top">Top</ui:insert>
</div>
<div>
<div id="left">
<ui:insert name="left">Left</ui:insert>
</div>
<div id="content" class="left_content">
<ui:insert name="content">Content</ui:insert>
</div>
</div>
</h:body>
</html>
client.xhtml
<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:ui="http://java.sun.com/jsf/facelets">
<body>
<ui:composition template="./template.xhtml">
<ui:define name="top">
Welcome, to my website
</ui:define>
<ui:define name="left">
My links
</ui:define>
<ui:define name="content">
This page is created for testing
</ui:define>
</ui:composition>
</body>
</html>
If you have Netbeans creating JSF project and JSF template and template client will get you this result. I tried in Netbeans 1.7.0 also. Same problem.
Edit: I run page not like http://localhost:8080/jpaweb/client.xhtml but likehttp://localhost:8080/jpaweb/faces/client.xhtml it worked. There is no "faces" directory in my project. Do we have to add "faces" to all JSF links?
Edit 2: I think netbeans auto-configures that all jsf files are kept in faces directory even there is no such directory in my project. And in Project properties -> Frameworks -> JavaServer Faces -> Configuration there is field JSF Servlet URL Pattern with value assigned /faces/*. I think that means one must call jsf files as if it is in faces directory. Trying to force it work as it appears in my project was a mistake :)
Solved. Changed value of Project properties -> Frameworks -> JavaServer Faces -> Configuration -> JSF Servlet URL Pattern from /faces/* to *.xhtml, and that worked OK.
Your client.xhtml content file is not properly composed. Don't include html tags, as JSF doesn't parse anything out from ui:composition tags here.
<ui:composition xmlns="http://www.w3.org/1999/xhtml"
xmlns:ui="http://java.sun.com/jsf/facelets"
template="./template.xhtml">
<ui:define name="top">
Welcome, to my website
</ui:define>
<ui:define name="left">
My links
</ui:define>
<ui:define name="content">
This page is created for testing
</ui:define>
</ui:composition>
I tested with your template and it works.
I just created a new IceFaces application and I'm trying to include a navigation bar in all of the pages. When I use the jsp:directive.include tag the file is included, but when I use jsp:include it does not seem to be loaded. In fact, when I check the HTML source code in my browser, it's like the included file was completely empty. I do not want to use jsp:directive.include because it will not automatically show any updates to the included file.
My environment: Eclipse 3.5, Tomcat 6, JSF 1.2, IceFaces 1.8.
Steps to reproduce the problem and pieces of code:
create a new Dynamic Web Project with the following options:
Target runtime: Apache tomcat v6.0
Dynamic web module version: 2.5
Configuration: ICEfaces project
create a new ICEFaces JSPX file -- the home file. Some code:
<jsp:directive.page contentType="text/html;charset=ISO-8859-1" />
<f:view >
<ice:outputDeclaration doctypeRoot="HTML"
doctypePublic="-//W3C//DTD HTML 4.01 Transitional//EN"
doctypeSystem="http://www.w3.org/TR/html4/loose.dtd" />
<html>
<head>
<title>test file</title>
<link rel="stylesheet" type="text/css"
href="./xmlhttp/css/rime/rime.css" />
</head>
<body>
<jsp:directive.include file="./vertical_navigation.jsp" /> <!-- working -->
<jsp:include page="./vertical_navigation.jsp" /> <!-- not working, no error though -->
</body>
</html>
</f:view>
create the file to be included, also as a new ICEFaces JSPX file. Simplified code:
<ice:form>
<ice:panelGrid columns="1" width="152">
<ice:graphicImage url="./img/image.jpg"></ice:graphicImage>
<ice:panelCollapsible expanded="true">
<f:facet name="header">
<ice:panelGroup>
<ice:outputText value="Customer"/>
</ice:panelGroup>
</f:facet>
<ice:panelGrid columns="1">
<ice:commandLink action="customer"><ice:outputText value="Customer name" /></ice:commandLink>
</ice:panelGrid>
</ice:panelCollapsible>
</ice:panelGrid>
</ice:form>
</body>
</html>
</f:view>
Some remarks:
I'm completely new to JSF, so forgive me for any obvious mistake.
In the home file (the first one) I'm not using both tags at the same time. I pasted both here just to show that I am trying both options.
I created both files as "ICEFaces JSPX file", but the second one was assigned the .jsp extension.
When I use the directive.include tag, the included file is loaded. But if I change it, it's not automatically republished.
To start, you have to separate and distinguish several technologies:
JSP is a Java based view technology which allows you to write HTML/CSS/JS in and use taglibs to call backend Java code and/or control the output flow.
JSPX is the same as JSP, but forces you to write code in XML format. JSP-specific tags are replaced by tags in XML format. JSPX is also called "JSP Document". Here is a basic tutorial which outlines the differences in tags.
JSF is a component based MVC framework which provides components in flavor of taglibs which outputs HTML/CSS/JS.
You cannot use <jsp:include> in a JSPX page. You have to transform the JSPX page into a JSP page. You need to rename the file .jspx to .jsp and replace JSPX specific tags by JSP tags. Here's a kickoff example for JSP with JSF/IceFaces:
<%# page pageEncoding="ISO-8859-1" %>
<%# taglib uri="http://java.sun.com/jsf/core" prefix="f"%>
<%# taglib uri="http://java.sun.com/jsf/html" prefix="h"%>
<%# taglib uri="http://www.icesoft.com/icefaces/component" prefix="ice"%>
<!DOCTYPE html>
<f:view>
<html lang="en">
<head>
<title>Title</title>
</head>
<body>
<jsp:include page="include.jsp" />
</body>
</html>
</f:view>
I am using Eclipse with GAE on a MacBook Pro with GChart. My problem is that I cant get any chart to show when I am developing, but when I use regular tools such as Buttons or Labels with GAE they work just fine. The code doesn't give me any errors, so I am assuming that I have the right code:
public class TestingTesting implements EntryPoint {
public void onModuleLoad() {
GChart graf = new GChart();
graf.setTitle("testing");
graf.setChartSize(200, 200);
graf.addCurve();
graf.getCurve().getSymbol().setFillThickness(2);
for (int i = 0; i < 10; i++)
graf.getCurve().addPoint(i,i*i);
Button btnOk = new Button("Ok");
RootPanel.get("chartdiv").add(graf);
RootPanel.get("button").add(btnOk);
}
}
and my TestingTesting.gwt.xml file looks like this:
<?xml version="1.0" encoding="UTF-8"?>
<module rename-to='testingtesting'>
<!-- Inherit the core Web Toolkit stuff. -->
<inherits name='com.google.gwt.user.User' />
<!-- Inherit the default GWT style sheet. You can change -->
<!-- the theme of your GWT application by uncommenting -->
<!-- any one of the following lines. -->
<inherits name='com.google.gwt.user.theme.standard.Standard' />
<!-- <inherits name='com.google.gwt.user.theme.chrome.Chrome'/> -->
<!-- <inherits name='com.google.gwt.user.theme.dark.Dark'/> -->
<!-- Other module inherits -->
<inherits name='com.googlecode.gchart.GChart' />
<!-- Specify the app entry point class. -->
<entry-point class='test.gchart.sollution.client.TestingTesting' />
<!-- Specify the paths for translatable code -->
<source path='client' />
<source path='shared' />
</module>
My TestingTesting.html looks like this:
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<title>Chart Example</title>
<script type="text/javascript" language="javascript"
src="testingtesting/testingtesting.nocache.js"></script>
</head>
<body>
<div id="chartdiv"></div>
<div id="button"></div>
</body>
</html>
other than that, my structure of the project in Eclipse is
/
- gchart.jar
- App Engine SDK [App Engine 1.3.5]
- GWT SDK [GWT - 2.0.4]
- JRE System Library
- src
-- test.gchart.sollution
--- TestingTesting.gwt.xml
-- test.gchart.sollution.client
--- TestingTesting.java
-- test.gchart.sollution.server
-- test.gchart.sollution.shared
--- FieldVerifier.java
- META-INF
-- jdoconfig.xml
- log4j.properties
- war
-- TestTest.html
- WEB-INF
-- appengine-web.xml
-- logging.properties
-- web.xml
Can anyone help me to figure out what the problem might be? The button shows without any problem, but the chart doesn't?
I figuered out what I've made wrong.
I forgot on the TestingTesting.java to include
RootPanel.get("chartdiv").add(graf);
graf.update(); // you have to update your graph before it renders