netbeans no library found for this namespace - java

I've searched around but cannot fine a definitive solution. I'm using netbeans+Maven and am trying to upgrade from Primefaces 2.2.1 to 3.0.M3 - when I change the index.xhtml taglib to xmlns:p="http://primefaces.org/ui" netbeans throws the 'no library found for this namespace' error.
The index.xhtml file is:
<?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:f="http://java.sun.com/jsf/core"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:p="http://primefaces.org/ui" >
<f:view contentType="text/html">
<h:head>
</h:head>
<h:body>
<h:form>
<h:commandButton value="Run Test" action="selecttype" />
<h:commandButton value="Manage Methods" action="addmethod" />
<h:commandButton value="Manage Data" action="managedata" />
<p:tagCloud model="#{tagCloudBean.model}" />
</h:form>
</h:body>
</f:view>
</html>
So the new taglib and p:tagCloud line are what netbeans says are not working - when I run the program I see the 3 buttons above the message "Warning: This page calls for XML namespace http://primefaces.org/ui declared with prefix p but no taglibrary exists for that namespace.".
For Maven I've updated these parts of the pom.xml:
<dependency>
<groupId>org.primefaces</groupId>
<artifactId>primefaces</artifactId>
<version>3.0.M3</version>
</dependency>
<repositories>
<repository>
<id>java.net.m2</id>
<name>java.net m2 repo</name>
<url>http://download.java.net/maven/2</url>
</repository>
<repository>
<id>prime-repo</id>
<name>PrimeFaces Maven Repository</name>
<url>http://repository.primefaces.org</url>
<layout>default</layout>
</repository>
</repositories>
and commented out the old prime-repo repository info.
I have got primefaces-3.0.M3.jar as a local dependency - this seems to be ok as all java class files using the library are referencing it ok. The primefaces-3.0.M3.jar binary is also in my WEB-INF/lin folder. I've seen a lot of people having weird issues with netbeans and am not sure if I'm simply missing something or if its the IDE. Any ideas would be greatly appreciated.

Actually if you are using Primefaces 3.0 M4 then the xmlns changed to:
xmlns:p="http://primefaces.org/ui"

This is the solution:
Right click on the EE project.
Click on Frameworks.
Click on JavaServer Faces.
Click on Components
Check PrimeFaces
Click OK
This solves the problem. However, the error icon will still appear in the left panel of our project. (Not in the code). So you must copy all your code (whatever) .xhtml and recreate it, paste the code you wrote and run.
In other words, you must recreate the file that is giving you problems.

The xmlns is wrong for the Primefaces component. Try changing the url to http://primefaces.prime.com.tr/ui as per the Primefaces Getting Started guide.
UPDATE 08-08-2013:
As of this moment the correct namespace as listed in the following link is:
xmlns:p="http://primefaces.org/ui"

in case of anyone still looking for an answer for this,
just right click your EE project -> select project properties -> Frameworks -> components and select primefaces.
works on Netbeans 8.1

Related

Cannot resolve taglib with uri in Intellij IDEA

By looking at the tutorial series JSP, Servlets and JDBC for Beginners: Build a Database App on Udemy done by Chad Darby and with the help of BalusC answer I wrote the following code in Intellij IDEA
<%# taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%--To use JSTL core tags we need to import the following URL with prefix--%>
<%# page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
<title>Title</title>
</head>
<%
// need to define a sample array
String cities[]={"City1","City2","City3","City4"};
// to use JSTL tags they have a to be a part of an attribute, either in the scope of the pageContext, session or application
pageContext.setAttribute("myCities",cities);
%>
<body>
<%-- for printing them in for each loop--%>
<c:forEach var="cityName" items="${myCities}" >
<%-- here we are using JSP expression language as ${...}}--%>
${cityName} <br/>
</c:forEach>
</body>
</html>
and add the JSTL libs under WEB-INF/lib as suggested by both the author of the tutorial (note: tutorial is done on Eclipse IDE) and BalusC answer. The code works fine, but IDEA editor give me
cannot resolve taglib with uri http://java.sun.com/jsp/jstl/core
and
cannot resolve symbol 'c:forEach'
and those lines are in red color as seen in the image
Why is this happening?. Is there any other place to add those libraries in IDEA? Thanks in advance
I got similar kind of message while working with spring based project. I resolved it by adding following dependencies inside pom.xml
<dependency>
<groupId>org.apache.tomcat.embed</groupId>
<artifactId>tomcat-embed-jasper</artifactId>
<scope>provided</scope>
</dependency>
<!-- https://mvnrepository.com/artifact/javax.servlet/jstl -->
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>jstl</artifactId>
<version>1.2</version>
</dependency>
next open terminal and then do maven clean install
mvn -U clean install

Apache tomcat error (no from eclipse or xampp tomcat)

I have a problem converting from .docx to .pdf with the Documents4j library, which only happens when I run the application from apache tomcat installation.
However, if the application is executed with Eclipse or XAMPP apache tomcat works correctly.
I have tried Windows 10, Windows 7 and Windows Server 2012 with apache tomcat 8 and 8.5 but the problem persist.
Eclipse or XAMPP do "something" when running apache tomcat that makes it work correctly
jsp:
<%# page language="java" contentType="text/html; charset=ISO-8859-1" pageEncoding="ISO-8859-1"%>
<%# page import="com.documents4j.api.IConverter,
com.documents4j.job.LocalConverter,
com.documents4j.api.DocumentType,
java.io.File" %>
<!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=ISO-8859-1">
<title>Insert title here</title>
</head>
<%
IConverter converter = LocalConverter.make();
converter.convert(new File("C:\\test\\test.docx")).as(DocumentType.DOCX).to(new File("C:\\test\\test.pdf")).as(DocumentType.PDF).execute();
%>
</body>
</html>
Dependencies:
<dependencies>
<!-- Local dependencies -->
<!-- https://mvnrepository.com/artifact/com.documents4j/documents4j-local -->
<dependency>
<groupId>com.documents4j</groupId>
<artifactId>documents4j-local</artifactId>
<version>1.0.2</version>
</dependency>
<!-- https://mvnrepository.com/artifact/com.documents4j/documents4j-transformer-msoffice-word -->
<dependency>
<groupId>com.documents4j</groupId>
<artifactId>documents4j-transformer-msoffice-word</artifactId>
<version>1.0.2</version>
</dependency>
</dependencies>
Error:
org.apache.jasper.JasperException: com.documents4j.throwables.ConverterException: Conversion failed for an unknown reason
org.apache.jasper.servlet.JspServletWrapper.handleJspException(JspServletWrapper.java:565)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:481)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:385)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:329)
javax.servlet.http.HttpServlet.service(HttpServlet.java:729)
org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
com.documents4j.throwables.ConverterException: Conversion failed for an unknown reason
com.documents4j.job.AbstractFutureWrappingPriorityFuture.run(AbstractFutureWrappingPriorityFuture.java:90)
java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
java.lang.Thread.run(Unknown Source)
You can try to specify an explicit base folder for the converter. Application containers often define an implicit temporary folder that is different from the default temporary folder, maybe your setup forbids execution of scripts from within this folder what might cause your troubles. You can check the temporary folder by checking the java.io.tmpdir property at runtime.
As another problem, make sure that your base folder does not contain any spaces. Please update to 1.0.3, too, where the update contains improved handling of such spaces. Maye Tomcat is installed in "Program Files" which might be the problem.

Struts 2 could not find a result for success returned from an action

I'm not a native English speaker, so my apologizes if I made some idiomatic mistake. I'm completely new on Struts2.
I developed a web project that contains 3 JSP pages, a deployment descriptor (web.xml), a struts configuration file (struts.xml) with 2 actions configured inside (an action named index and an action named welcome) and 1 class that implements the action logic for welcome action. When I try the index action it works perfectly but if I call the welcome action in the URL (welcome.action) I get the following error
Struts Problem Report
Struts has detected an unhandled exception:
Messages:
No result defined for action actions.WelcomeAction and result success
com.opensymphony.xwork2.DefaultActionInvocation.executeResult(DefaultActionInvocation.java:373)
com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:275)
...
Now I give you more information about the project and environment:
Development Environment
OS: Mac OS X 10.10.3
JRE: 1.8.0_20
IDE: NetBeans 7.4
App Server: GlassFish 4.0
Server Location: localhost:8080
Context Path: /AppStruts2Example
URL Project: http://localhost:8080/AppStruts2Example/
Web Project Development Information
Java EE Version: 7
Struts2 Version: 2.3.15
Code is described below
web.xml
<?xml version="1.0" encoding="UTF-8"?>
<web-app version="3.1" xmlns="http://xmlns.jcp.org/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd">
<filter>
<filter-name>struts2</filter-name>
<filter-class>org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter</filter-class>
</filter>
<filter-mapping>
<filter-name>struts2</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
<session-config>
<session-timeout>
30
</session-timeout>
</session-config>
<welcome-file-list>
<welcome-file>index.jsp</welcome-file>
</welcome-file-list>
</web-app>
struts.xml
<!DOCTYPE struts PUBLIC
"-//Apache Software Foundation//DTD Struts Configuration 2.0//EN"
"http://struts.apache.org/dtds/struts-2.3.dtd">
<struts>
<constant name="struts.devMode" value="true" />
<constant name="struts.configuration.xml.reload" value="true" />
<!-- Configuration for the default package. -->
<package name="default" extends="struts-default">
<action name="index">
<result>/WelcomeFromIndexAction.jsp</result>
</action>
<action name="welcome" class="actions.WelcomeAction">
<result name="success">/WelcomeFromWelcomeAction.jsp</result>
</action>
</package>
</struts>
actions.WelcomeAction.java
package actions;
import com.opensymphony.xwork2.ActionSupport;
public class WelcomeAction extends ActionSupport{
#Override
public String execute(){
System.out.println("Inside of execute method in WelcomeAction.");
System.out.println("Result: " + SUCCESS);
return SUCCESS;
}
}
index.jsp
<%#page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Index JSP</title>
</head>
<body>
<h1>Welcome to index.jsp!</h1>
</body>
</html>
WelcomeFromIndexAction.jsp
<%#page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Index Action</title>
</head>
<body>
<h1>Welcome From Index Action</h1>
<br />
<h3>Current Page: WelcomeFromIndexAction.jsp</h3>
</body>
</html>
WelcomeFromWelcomeAction.jsp
<%#page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Welcome Action</title>
</head>
<body>
<h1>Welcome From Welcome Action</h1>
<br />
<h3>Current Page: WelcomeFromWelcomeAction.jsp</h3>
</body>
</html>
Project works fine when:
I write directly the URL of anyone JSP on the browser
I invoke the index action as you can see below: /index.action or /index -> both redirect me to WelcomeFromIndexAction.jsp
Project fails when:
I invoke the welcome action as you can see below: /welcome.action or /welcome -> both shows me a web page with Struts Problem Report like described above
I thought it could be a problem with GlassFish Server, so I mounted a Debian on a VM and I installed a Tomcat 7 there. My next step was deploy the web application whit "Clean and Build" from NetBeans. It generated me a WAR file that I deployed into Tomcat 7 but I got the same problem. After this disappointing I disabled the Debian VM (Tomcat 7) and I come back to work with GlassFish 4.0
As you can see in WelcomeAction.java, it has a println statement within execute method. When I invoke welcome action on the browser, I can see that Struts effectively calls that method, the lines are printed on the output and after this call, when Struts2 has to process the Result then show me the error. This confirm me that Struts2 is not finding the result not the action, but I don't know why.
I tried configuring the filter dispatcher with old and new version of filter (FilterDispatcher/StrutsPrepareAndExecuteFilter). With both i get same problem.
I tried configuring the welcome action in struts.xml exactly the same index action (practically by default) but doesn't work too. Only index action run fine.
I tried configuring the welcome action in struts.xml of many many ways, but nothing works.
So, here i am, needing someone help me. I appreciate your answers.
Note: Stackoverflow doesn't allow me post image because i'm new. So, I uploaded an important print screen to my dropbox. https://dl.dropboxusercontent.com/u/101502868/NetBeans%20Struts2%20Error.png
At this print screen you can see the libraries added, execution of execute method, the customized print lines and start of Struts error's.
Thank's.
make entry in struts.xml with custom method in action class named editUser so that control dirctly goes to that perticuler method and handle the result accordingly your logic
<action method="editUser" name="editUser" class="com.action.EditUserAction">
<result name="true">/jsp/editUser.jsp</result>
<result name="false">jsp/index.jsp</result>
</action>
And add custom method in your class instead of override execute method
class EditUserAction extendes ActionSupport{
public String editUser(){
String status = "false";
/**
do your buisness logic
*/
return status;
}
}
After doing same if still the issues is persist then check your configuration carefully
The best way to fix this issue is using Maven to create your project and manage all dependencies you could need. That was the only solution that works to me.
Here is an official guide to create a Struts 2 Web Application using Maven (very simple example): http://struts.apache.org/docs/create-struts-2-web-application-using-maven-to-manage-artifacts-and-to-build-the-application.html
If you don't have installed Maven is OS X and you don't know how to install it, then follow the next steps to install it:
Download Maven (This example uses Maven 3.3.3. The name of the compressed file is apache-maven-3.3.3-bin.tar.gz): http://maven.apache.org/download.cgi
Unpack the downloaded file (This example assumes that the downloaded file is located in /Users/YourUser/Downloads/). After unpack, a new directory will be created with the same name and path of your maven file downloaded. (In this example: /Users/YourUser/Downloads/apache-maven-3.3.3/)
Open a Terminal
Move your maven directory to your home directory using this command:
mv ~/Downloads/apache-maven-3.3.3/ ~/
Now, you have to edit the file .bash_profile located on your home directory (~/.bash_profile). To edit it, we'll use vi commando as you can see below:
vi ~/.bash_profile
Once opened you must press i to edit it
Now you can edit the file, so you have to write the following:
export JAVA_HOME=$(/usr/libexec/java_home)
export MAVEN=$HOME/apache-maven-3.3.3/bin
Close the terminal and open it again. That's all, Maven should be already installed. Use the following command to verify that Maven is working:
mvn -version
If you see the information about Maven, Java and OS X that you are using it's because Maven is working fine.

Why isn't my GWT web application running properly?

I'm going through the book: GWT in Action. On chapter I'm working through the very first hello world application. It's all in development mode.
My issue is that the label in my .java file is not showing up when I open the URL webpage. There is nothing being displayed versus the Label("Hello World!") appearing.
EDIT: When at the displayed webpage, I pressed F12 in google chrome to see if I could find anything weird. Got the error: Failed to load resource: the server responded with a status of 404 (Not Found)
HelloWorld.gwt.xml
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE module PUBLIC "-//Google Inc.//DTD Google Web Toolkit 2.6.0//EN" "http://google-web-toolkit.googlecode.com/svn/tags/2.6.0/distro-source/core/src/gwt-module.dtd">
<module>
<inherits name="com.google.gwt.user.User" />
<source path="client" />
<entry-point class="com.example.gwt.client.HelloWorld"></entry-point>
</module>
HelloWorld.java
package com.example.gwt.client;
import com.google.gwt.core.client.EntryPoint;
import com.google.gwt.user.client.ui.Label;
import com.google.gwt.user.client.ui.RootPanel;
public class HelloWorld implements EntryPoint {
#Override
public void onModuleLoad() {
RootPanel.get().add(new Label("Hello World!"));
}
}
HelloWorld.html
<!doctype html>
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<title>HelloWorld</title>
<script type="text/javascript" language="javascript" src=".nocache.js"></script>
</head>
<body>
<iframe src="javascript:''" id="__gwt_historyFrame" tabIndex='-1' style="position:absolute;width:0;height:0;border:0"></iframe>
</body>
</html>
My console is displaying this after I run it as a web application:
[WARN] Server class 'org.eclipse.jetty.servlet.listener.ELContextCleaner' could not be found in the web app, but was found on the system classpath
[WARN] Adding classpath entry 'file:/C:/Users/Qs/Desktop/eclipse/plugins/com.google.gwt.eclipse.sdkbundle_2.6.0/gwt-2.6.0/gwt-dev.jar' to the web app classpath for this session
For additional info see: file:/C:/Users/Qs/Desktop/eclipse/plugins/com.google.gwt.eclipse.sdkbundle_2.6.0/gwt-2.6.0/doc/helpInfo/webAppClassPath.html
If you don't specify the rename-to in your gwt.xml as shown below then by default GWT places the generated nocache.js under war directory by the name of location of gwt.xml followed by its name as shown in below snapshot.
<module rename-to="xyz">
For more info have a look at gwt-module dtd.
Please have a look Defining a module and Renaming modules
There are two ways to solve this issue:
define rename-to in gwt.xml that is more preferable over second solution
gwt.xml
<module rename-to="hello">
html
<script type="text/javascript" language="javascript" src="hello/hello.nocache.js"></script>
use default way
html
<script type="text/javascript" language="javascript" src="com.example.gwt.HelloWorld/com.example.gwt.HelloWorld.nocache.js"></script>
Here is a snapshot to make it more clear
Change the src attribute of the script tag in HelloWorld.html to
src="com.example.gwt.client.HelloWorld/com.example.gwt.client.HelloWorld.nocache.js"
If that still doesn't work, run the GWT compiler and look at the files it generates to determine the exact name of the *.nocache.js file.

Jsf 2.0 Custom Tag

I get the following error on every page of my project when I am removing the MyFaces-2.0 entry from web.xml. My project is created using JSF 2.0.
Error:
One or more resources have the target of 'head', but no 'head'
component has been defined within the view.
web.xml:
<context-param>
<param-name>org.jboss.jbossfaces.JSF_CONFIG_NAME</param-name>
<param-value>MyFaces-2.0</param-value>
</context-param>
After removing that entry my custom tag runs. If I put this in web.xml again, then the compiler doesn't go to the component class.
As the message you got says, you have no head component in your view (on your Facelet). Such a component is needed for other components that e.g. want to inject scripts and css resources into the head.
The remedy is to simply add this component on your Facelet, e.g.:
<!DOCTYPE html>
<html lang="en"
xmlns="http://www.w3.org/1999/xhtml"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:h="http://java.sun.com/jsf/html"
>
<!-- The head component that was missing -->
<h:head/>
<h:body>
<!-- Other components here -->
</h:body>
</html>

Categories

Resources