Cannot find theme.css resource of AdminFaces - primefaces

I'm using PrimeFaces 6.0 to develop a business application. Now my UI looks very primitive. I just want to re-design it by using AdminFaces templates (1.0.0-RC18).
I don't have any idea about this, can anyone can help me to solve my issue. How I can implement this template in to my project.
When I add the AdminFaces theme to my project by using following code, I get an error.
pom.xml:
<dependency>
<groupId>com.github.adminfaces</groupId>
<artifactId>admin-template</artifactId>
<version>1.0.0-RC18</version>
</dependency>
<dependency>
<groupId>com.github.adminfaces</groupId>
<artifactId>admin-theme</artifactId>
<version>1.0.0-RC18</version>
</dependency>
web.xml:
<context-param>
<param-name>primefaces.THEME</param-name>
<param-value>admin</param-value>
</context-param>
the error:
cannot find "theme.css" resource of "primefaces-admin-1.0.0-rc18" library

Related

Generated protoc file creates a target source with error

I have tried to make a project that connects to a DB and takes information and outputes them in a desktop application through grpc.
But, when I compile it I get "Error:(20,18) java: cannot find symbol" in a target file( which is auto-generated by protoc.
I can't understand the issue with this. I have tried to change the compiler of mvn, to change the version on protoc, to setup a different JDK, everything just gets worse that it already is.
My project can be viewed here : https://github.com/Diana-Ioana/grpc
My db and error with the generated target files that crashes is : https://imgur.com/a/T6taLXF
I have no idea what to do now. Any help would be greate, thank you!
It looks like the "cannot find symbol" is referring to javax.annotation.Generated. In that case you can add a dependency on annotations-api:
<dependency>
<groupId>org.apache.tomcat</groupId>
<artifactId>annotations-api</artifactId>
<version>6.0.53</version>
<!-- Generated has #Retention(SOURCE), so not needed at runtime -->
<scope>provided</scope>
</dependency>
Originally this answer suggested javax.annotation-api, but that library is licensed CDDL so gRPC changed its recommendation.
<!-- The old suggestion. Uses CDDL-licensed library -->
<dependency>
<groupId>javax.annotation</groupId>
<artifactId>javax.annotation-api</artifactId>
<version>1.2</version>
</dependency>

error: package com.google.appengine.labs.repackaged.org.json does not exist

I want to return JSON object back to the client side.I add dependencies and it is not working again.What is the purpose of 'repackaged'?I can not find any documentation of this pacakge to add in pom.xml.It allows me to create a JSONObject but in my console appear this error?!
pom.xml
<dependency>
<groupId>org.apache.struts</groupId>
<artifactId>struts2-json-plugin</artifactId>
<version>${struts.version}</version>
</dependency>
<dependency>
<groupId>com.google.appengine</groupId>
<artifactId>appengine-api-labs</artifactId>
<version>${appengine.app.version}</version>
<scope>test</scope>
</dependency>
I used Gson and works for me.It is easy to implement and convert Java object to JSON and vice versa!Here is GSON dependency:
<dependency>
<groupId>com.google.code.gson</groupId>
<artifactId>gson</artifactId>
<version>2.3.1</version>
</dependency>
Treat the 'repackaged' package as internal GAE implementation choices that may change. Such classes have their package path surgically altered to include repackaged so that they won't conflict with your choices.
I've had problems with Eclipse offering repackaged classes up as viable options. How to hide some Eclipse autocomplete results shows a way to fix that.
Just a follow up on this for IntelliJ users. You can tell the IDE to not offer repackaged classes in:
(for IntelliJ 2016.1)
Settings > Editor > General > Auto Import > Exclude from Import and
Completion
Enter there the following and you are done.
com.google.appengine.labs.repackaged
com.google.appengine.repackaged

Thymeleaf - Strict HTML parsing issue

HTML5 allows some tags to be written more liberally i.e without corresponding END tags. e.g. input need not be closed </input>.However if choose template mode HTML5 in Thymeleaf the Thymeleaf engine complains about this and does not parse the HTML template. I want to override this default Strict tag checking behavior. i.e Thymeleaf should parse an HTML template with meta and input (AND ALIKE) tags WITHOUT THEIR RESP. CLOSING TAGS. Pl. guide.
It also complains when you have something like this
<a href="/home/pic/image.png" download="/path/to/file" data-gallery></a>
It throws an exception when it encounters the data-gallery throws "should be followed by '=' " which is kind of annoying as it takes the flexibility out of HTML5.
All you have to do is run Thymeleaf in "LEGACYHTML5" mode and it works like a charm. Thanks to this and this post, I found the solution and am documenting in SO so others do not have to go through the same trouble in finding this answer.
To set the legacy mode you can define the bean in your Spring XML file:
<!-- View TemplateResolver -->
<bean id="templateResolver" class="org.thymeleaf.templateresolver.ServletContextTemplateResolver">
<property name="templateMode" value="LEGACYHTML5"/>
<property name="cacheable" value="false"/>
</bean>
or add the properties to the application.properties file:
spring.thymeleaf.mode=LEGACYHTML5
spring.thymeleaf.cache=false
And in both cases you have to add the nekohtml jar to your project or, if you are running maven, you can add its dependency to your pom.xml
<dependency>
<groupId>net.sourceforge.nekohtml</groupId>
<artifactId>nekohtml</artifactId>
<version>1.9.21</version>
</dependency>
Gradle
'net.sourceforge.nekohtml:nekohtml:1.9.21'
Here is how you can do it in a neat way
Step 1: Add thymeleaf mode to your application.properties file.
resources/application.properties
spring.thymeleaf.mode=LEGACYHTML5
Step 2: Add nekohtml dependency to your pom.xml file.
pom.xml
<dependency>
<groupId>net.sourceforge.nekohtml</groupId>
<artifactId>nekohtml</artifactId>
</dependency>
Using LEGACYHTML5 worked for me as well.
Also it is necessary to add
<dependency>
<groupId>net.sourceforge.nekohtml</groupId>
<artifactId>nekohtml</artifactId>
</dependency>
to pom.xml as stated above. But there is one more step which might occur. After doing those two steps I was getting:
java.lang.NoClassDefFoundError: org/w3c/dom/ElementTraversal
To avoid this it is necessary to add
<dependency>
<groupId>xml-apis</groupId>
<artifactId>xml-apis</artifactId>
<version>1.4.01</version>
</dependency>
to pom.xml

Jersey No WebApplication provider is present when jersey-* dependency added

I have a simple Spring & Jersey application, which works perfectly well for consuming requests through a simple Resource. However, I'd like to return a JSON response - containing a simple JSON serialization of an object. To achieve this, I've added a maven dependency for jersey-json. As soon as I add this dependency, however, I get this error at server startup:
com.sun.jersey.api.container.ContainerException: No WebApplication provider is present at
com.sun.jersey.spi.container.WebApplicationFactory.createWebApplication(WebApplicationFactory.java:69) at
com.sun.jersey.spi.container.servlet.ServletContainer.create(ServletContainer.java:391)
I'm not totally clear upon exactly what a provider is, but I'm pretty certain that there should be a default one found.
For completeness, here's my Resource:
#Path("/scan")
#Resource
#Component
public class ScanResource {
#GET
#Produces(MediaType.APPLICATION_JSON)
#Path("/{barcode}")
public List<Scan> getScansForBarcode(#PathParam("barcode") Long barcode){
..snip..
return results;
}
}
A Scan object is a simple Entity Bean object.
The mvn dependency is:
<dependency>
<groupId>com.sun.jersey</groupId>
<artifactId>jersey-json</artifactId>
<version>1.11</version>
</dependency>
Does anyone know why I might be getting the No WebApplication provider is present Exception? Any thoughts on how I might resolve it?
Thanks
You need to have jersey-server jar on your classpath as well. And you need to make sure that all your jars are from the same version, Jersey runtime won't be able to use provided classes otherwise.
Additionally (most likely not relevant here, but..) there is a recent change in module structure - servlet dependencies were separated to new modules. So if you are using servlets, you might want to depend on jersey-servlet (which depends on jersey-server).
I am also had this issue. The issue was resolved by having same version for "jersey-json" and "jersey-servlet"maven dependencies.
EX:
<dependency>
<groupId>com.sun.jersey</groupId>
<artifactId>jersey-json</artifactId>
<version>1.13</version>
</dependency>
<dependency>
<groupId>com.sun.jersey</groupId>
<artifactId>jersey-servlet</artifactId>
<version>1.13</version>
</dependency>

Spring Webflow , Primefaces with Comet (Atmosphere)

Thinking to start a project using Spring Web Flow with Primefaces. I need to use comet so i figured Primefaces uses Atmosphere. I'm not really experienced with the Atmosphere / Comet business so any pointers about where to start is welcomed.
Thanks in Advance
a very basic example can be found in the primefaces showcase: https://www.primefaces.org/showcase/push/chat.xhtml
This is the old example for the ajax push component and is NOT officially included in the show case right now because it will be redone in primefaces 3 if I know right. In addition to that you have to configure the comet servlet within your web.xml:
<servlet>
<servlet-name>Comet Servlet</servlet-name>
<servlet-class>org.primefaces.comet.PrimeFacesCometServlet</servlet-class>
<init-param>
<param-name>org.atmosphere.useBlocking</param-name>
<param-value>true</param-value>
</init-param>
<load-on-startup>0</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>Comet Servlet</servlet-name>
<url-pattern>/primefaces_comet/*</url-pattern>
</servlet-mapping>
If you use primefaces 2.2 you cannot use the newest version of atmosphere/comet I think. I got it running with the following dependencies:
<dependency>
<groupId>org.atmosphere</groupId>
<artifactId>atmosphere-runtime</artifactId>
<version>0.5</version>
</dependency>
<dependency>
<groupId>org.atmosphere</groupId>
<artifactId>atmosphere-compat-tomcat</artifactId>
<version>0.5</version>
</dependency>
The last step is to add a file named "atmosphere.xml" within your META-INF directory with the following content:
<?xml version="1.0" encoding="UTF-8"?>
<atmosphere-handlers>
<atmosphere-handler context-root="/primefaces_comet/*" class- name="org.primefaces.comet.PrimeFacesCometHandler" />
</atmosphere-handlers>
Jens