Play Framework [2.2.0-Java] Custom 404 page - playframework-2.2

Hi Everyone I'm using play 2.2.0 built with scala 2.10.2 (running java 1.7.0_45)
I'm trying to make a custom Not Found Page but I don't have any success.
This is the code:
#Override
public Promise<SimpleResult> onHandlerNotFound(RequestHeader request) {
return Promise.<SimpleResult>pure(notFound(
views.html.myerrors.page404.render()
));
}
But I get this error
[error] path\app\Global.java:80: error: cannot find symbol
[error] return Promise.<SimpleResult>pure(notFound(
[error] ^
[error] symbol: method notFound(Html)
[error] location: class Global
[error] 1 error
[error] (compile:compile) javac returned nonzero exit code
Does somebody know the reason why and the solution?
Thank you in advance.

notFound is a static method of the play.mvc.Results class.
It is probably not imported in your code. You can try to import it at the beginning of your file :
import static play.mvc.Results.notFound;
...
or import just the Results class if you don't want a static import :
import play.mvc.Results;
...
return Promise.<SimpleResult>pure(Results.notFound(
views.html.myerrors.page404.render()));
...

Related

Migrating ADAL Filter to MSAL on Linux running Java 11 (maven) - AuthenticationResponseParser.parse() throws exception

in AuthenticationResponseParser.parse(new URI(fullUrl), params);
where params is
Map<String, List<String>>
and is created as
for (String key : httpRequest.getParameterMap().keySet()) {
params.put(key, Collections.singletonList(httpRequest.getParameterMap().get(key)[0]));
}
throws exception
Error: class java.util.Collections$SingletonList cannot be cast to class java.lang.String (java.util.Collections$SingletonList and java.lang.String are in module java.base of loader 'bootstrap')
What could be going wrong?
I am using MSALJ maven dependency com.microsoft.azure, msal4j, 1.13.2
Tried to pass String as params but it is expecting List of strings

Android studio JavaDoc error throws a NullPointerException

Android studio cannot create JavaDoc. It throws a null pointer exception and cannot identify any of the android packed items.
...
/home/<user>/AndroidStudioProjects/<project>/app/src/main/java/com/example/simpleparadox/listycity/MainActivity.java:14: error: cannot access ViewGroup
public class MainActivity extends AppCompatActivity {
^
class file for android.view.ViewGroup not found
javadoc: error - fatal error encountered: java.lang.NullPointerException
javadoc: error - Please file a bug against the javadoc tool via the Java bug reporting page
(http://bugreport.java.com) after checking the Bug Database (http://bugs.java.com)
for duplicates. Include error messages and the following diagnostic in your report. Thank you.
java.lang.NullPointerException
at jdk.compiler/com.sun.tools.javac.comp.TypeEnter$MembersPhase.runPhase(TypeEnter.java:934)
at jdk.compiler/com.sun.tools.javac.comp.TypeEnter$Phase.doCompleteEnvs(TypeEnter.java:282)
at jdk.compiler/com.sun.tools.javac.comp.TypeEnter$MembersPhase.doCompleteEnvs(TypeEnter.java:877)
at jdk.compiler/com.sun.tools.javac.comp.TypeEnter$Phase.completeEnvs(TypeEnter.java:251)
at jdk.compiler/com.sun.tools.javac.comp.TypeEnter$Phase.completeEnvs(TypeEnter.java:266)
at jdk.compiler/com.sun.tools.javac.comp.TypeEnter$Phase.completeEnvs(TypeEnter.java:266)
at jdk.compiler/com.sun.tools.javac.comp.TypeEnter$Phase.completeEnvs(TypeEnter.java:266)
at jdk.compiler/com.sun.tools.javac.comp.TypeEnter.complete(TypeEnter.java:198)
at jdk.compiler/com.sun.tools.javac.code.Symbol.complete(Symbol.java:642)
at jdk.compiler/com.sun.tools.javac.code.Symbol$ClassSymbol.complete(Symbol.java:1326)
at jdk.compiler/com.sun.tools.javac.comp.Enter.complete(Enter.java:583)
at jdk.compiler/com.sun.tools.javac.comp.Enter.main(Enter.java:560)
at jdk.javadoc/jdk.javadoc.internal.tool.JavadocEnter.main(JavadocEnter.java:79)
at jdk.javadoc/jdk.javadoc.internal.tool.JavadocTool.getEnvironment(JavadocTool.java:206)
at jdk.javadoc/jdk.javadoc.internal.tool.Start.parseAndExecute(Start.java:576)
at jdk.javadoc/jdk.javadoc.internal.tool.Start.begin(Start.java:432)
at jdk.javadoc/jdk.javadoc.internal.tool.Start.begin(Start.java:345)
at jdk.javadoc/jdk.javadoc.internal.tool.Main.execute(Main.java:63)
at jdk.javadoc/jdk.javadoc.internal.tool.Main.main(Main.java:52)
7 errors
Then I found a work around which add -bootclasspath path_to_sdk_android_jar_file in the other command-line argument text box in the JavaDoc dialog.
However, newer Java deprecated -bootclasspath. It throws another error as follows:
error: option --boot-class-path not allowed with target 11
So I used -sourcepath instead. That brought the old error (NullPointerException).
I am pretty much lost at this point.
By the way, if I choose a class with only Java elements (no-android) and create JavaDoc to that specific file only, it creates JavaDoc nicely. But this is not a good workaround for a project with a lot of classes.
I've faced the same issue as yours with several imports errors..
The following solution worked for me ( I got it from mike192's answer, see the link here )
task javadoc(type: Javadoc) {
doFirst {
configurations.implementation
.filter { it.name.endsWith('.aar') }
.each { aar ->
copy {
from zipTree(aar)
include "**/classes.jar"
into "$buildDir/tmp/aarsToJars/${aar.name.replace('.aar', '')}/"
}
}
}
configurations.implementation.setCanBeResolved(true)
source = android.sourceSets.main.java.srcDirs
classpath += project.files(android.getBootClasspath().join(File.pathSeparator))
classpath += configurations.implementation
classpath += fileTree(dir: "$buildDir/tmp/aarsToJars/")
destinationDir = file("${project.buildDir}/outputs/javadoc/")
failOnError false
exclude '**/BuildConfig.java'
exclude '**/R.java'
}
All you need to do is to add the code to your build.gradle file right before your dependencies {}
Then, double click on your Ctrl button and execute the following command :
gradle javadoc
The result of the javadoc can be then found in your project's directory \app\build\outputs\javadoc
I hope this works for you

How to add JavaCard packages to JavaCard applet?

I am trying to build a simple Hello world JavaCard applet.I am using NetBeans IDE.
I am following this tutorial.
Here is my code:
package classicapplet1;
import javacard.framework.*;
import java.rmi.Remote;
import javacard.framework.service.Dispatcher;
import javacard.framework.service.RMIService;
import javacard.framework.service.Service;
public class JavaCardApplet extends Applet {
HelloWorld hello;
Dispatcher disp;
Service svc;
public static void install(byte[] bArray, short bOffset, byte bLength) {
new JavaCardApplet();
}
private JavaCardApplet() {
// register();
hello = new HelloWorld();
svc=new RMIService((Remote) hello);
disp = new Dispatcher((short)1);
disp.addService(svc, Dispatcher.PROCESS_COMMAND);
}
public static void install(byte[] buf, short ofs, short len){
(new JavaCardApplet()).register();
}
public void process(APDU apdu) {
//Insert your code here
disp.process(apdu);
}
}
The IDE doesnt show any error or warning on the editor, but WHen I try to build the code: The foloowing things display in the debug console:
ant -f "C:\\Users\\Tera\\Documents\\NetBeansProjects\\JavaCardApplet" run
__reset_for_debug__:
init-platform-properties:
Using JavaCard Platform Definition at C:\Users\Tera\AppData\Roaming\NetBeans\8.1\config\Services\Platforms\org-netbeans-api-java-Platform\javacard_default.jcplatform
Java Card Home is C:\Program Files\NetBeans 8.1\javacard\JCDK3.0.2_ConnectedEdition (Java Card Platform)
init-ri-properties:
init-device-properties:
Platform device property name is jcplatform.javacard_default.devicespath
Computed device folder path is C:\Users\Tera\AppData\Roaming\NetBeans\8.1\config\org-netbeans-modules-javacard\servers\javacard_default
Platform device file path property name is C:\Users\Tera\AppData\Roaming\NetBeans\8.1\config\org-netbeans-modules-javacard\servers\javacard_default\Default Device.jcard
Deploying to device Default Device http port 8019
init-keystore:
Keystore is C:\Program Files\NetBeans 8.1\javacard\JCDK3.0.2_ConnectedEdition/samples/keystore/a.keystore
build-dependencies:
unpack-dependencies:
compile:
Compiling 2 source files to
C:\Users\Tera\Documents\NetBeansProjects\JavaCardApplet\build\APPLET-INF\classes
C:\Users\Tera\Documents\NetBeansProjects\JavaCardApplet\src\classicapplet1\JavaCardApplet.java:11: error: package javacard.framework.service does not exist
import javacard.framework.service.Dispatcher;
C:\Users\Tera\Documents\NetBeansProjects\JavaCardApplet\src\classicapplet1\JavaCardApplet.java:12: error: package javacard.framework.service does not exist
import javacard.framework.service.RMIService;
C:\Users\Tera\Documents\NetBeansProjects\JavaCardApplet\src\classicapplet1\JavaCardApplet.java:13: error: package javacard.framework.service does not exist
import javacard.framework.service.Service;
C:\Users\Tera\Documents\NetBeansProjects\JavaCardApplet\src\classicapplet1\JavaCardApplet.java:22: error: cannot find symbol
Dispatcher disp;
symbol: class Dispatcher
location: class JavaCardApplet
C:\Users\Tera\Documents\NetBeansProjects\JavaCardApplet\src\classicapplet1\JavaCardApplet.java:23: error: cannot find symbol
Service svc;
symbol: class Service
location: class JavaCardApplet
C:\Users\Tera\Documents\NetBeansProjects\JavaCardApplet\src\classicapplet1\JavaCardApplet.java:48: error: cannot find symbol
svc=new RMIService((Remote) hello);
symbol: class RMIService
location: class JavaCardApplet
C:\Users\Tera\Documents\NetBeansProjects\JavaCardApplet\src\classicapplet1\JavaCardApplet.java:49: error: cannot find symbol
disp = new Dispatcher((short)1);
symbol: class Dispatcher
location: class JavaCardApplet
C:\Users\Tera\Documents\NetBeansProjects\JavaCardApplet\src\classicapplet1\JavaCardApplet.java:50: error: cannot find symbol
disp.addService(svc, Dispatcher.PROCESS_COMMAND);
symbol: variable Dispatcher
location: class JavaCardApplet
8 errors
C:\Users\Tera\Documents\NetBeansProjects\JavaCardApplet\nbproject\build-impl.xml:301: Compile failed; see the compiler error output for details.
BUILD FAILED (total time: 1 second)
Note:NetBEans IDE has the JavaCard Plugin Installed.
Add the api_classic.jar library and its export path to the libraries of your project manually. This file is exist under this path:
<NetbeansInstalledDirectory>\javacard\JCDK3.0.2_ConnectedEdition\lib
Step by step for beginners:
And now, try to build it again.

How to btrace JBoss AS 7

I'm trying to instrument JBoss AS 7 using btrace but can't get it to work. I'm using visualvm 1.3.7 and the btrace workbench 0.6.7 (right click -> "Trace applicaiton..."). I'm always setting the following non-descriptive error.
!!! Error occured
!!! Error occured
What I tried is setting the following VM options
-Djboss.modules.system.pkgs=com.sun.btrace,com.sun.btrace.annotations
-Xbootclasspath/a:/path/to/btrace-boot-1.2.3.jar
but no avail. I am running on Java 8.
Even simple scripts like this don't work:
import static com.sun.btrace.BTraceUtils.println;
import com.sun.btrace.annotations.BTrace;
import com.sun.btrace.annotations.Kind;
import com.sun.btrace.annotations.Location;
import com.sun.btrace.annotations.OnMethod;
#BTrace
public class Simple {
#OnMethod(
clazz = "com.acme.Main",
method = "main",
location = #Location(Kind.ENTRY)
)
public static void mainEjbCall() {
println("enter");
}
}
* Update *
Yes, I assume it's a JBoss AS classloader issue but I don't know how to fix it.
I can profile normal Java 8 applications (even though I get an exception from the ASM ClassReader).

Red5 Application fails to connect

I am attempting to run a basic application on Red5 that just makes an attempt to connect to the red5 server (on localhost). The source for this application is below:
import org.red5.server.adapter.ApplicationAdapter;
import org.red5.server.api.IConnection;
import org.red5.server.api.scope.IScope;
// import org.red5.server.api.service.ServiceUtils;
/**
* Sample application that uses the client manager.
*
* #author The Red5 Project (red5#osflash.org)
*/
public class Application extends ApplicationAdapter {
/** {#inheritDoc} */
#Override
public boolean connect(IConnection conn, IScope scope, Object[] params) {
return true;
}
/** {#inheritDoc} */
#Override
public void disconnect(IConnection conn, IScope scope) {
super.disconnect(conn, scope);
}
}
My client code is also pretty basic. For brevity, the snippet is below:
public function onCreationComplete(event:FlexEvent) : void {
// setup connection code
connection = new NetConnection();
connection.connect("rtmp://localhost/Player");
connection.addEventListener(NetStatusEvent.NET_STATUS, onConnectionNetStatus);
connection.client = this;
}
public function onConnectionNetStatus(event:NetStatusEvent) : void {
// did we successfully connect
if(event.info.code == "NetConnection.Connect.Success") {
Alert.show("Successful Connection", "Information");
} else {
Alert.show("Unsuccessful Connection "+event.info.code, "Information");
}
Note that I make the alert box show the error code so I can see what happens.
On the client side, when I attempt to connect, I get two failure messages:
Unsuccessful Connection NetConnection.Connect.Closed
Unsuccessful Connection NetConnection.Connect.Rejected
And on the server side I am seeing the following:
[INFO] [NioProcessor-10]
org.red5.server.net.rtmp.codec.RTMPProtocolDecoder - Action connect
[INFO] [NioProcessor-10] org.red5.server.net.rtmp.RTMPConnection -
Setting object encoding to AMF3
[INFO] [NioProcessor-10] org.red5.server.net.rtmp.RTMPHandler - Scope
Player not found on localhost
[WARN] [Red5_Scheduler_Worker-3]
org.red5.server.net.rtmp.RTMPConnection - Closing RTMPMinaConnection
from 127.0.0.1 : 50051 to localhost (in: 3334 out 3256 ), with id 9
due to long handshake
It seems clear that something is wrong due to some kind of mis- configuration. Unfortunately, I have no idea where to look for the problem.
Could someone please give some idea of what is going wrong and how I can fix this? Thank you...
ADDITION: Startup Exception that occurs when running Red5 v1 RC2:
Exception in thread "Launcher:/Player" org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with
name 'web.context' defined in ServletContext resource [/WEB-INF/red5-web.xml]:
Unsatisfied dependency expressed through bean property 'clientRegistry': : Cannot find class [org.red5.server.WebScope] for bean with name 'web.scope' defined in ServletContext resource [/WEB-INF/red5-web.xml];
nested exception is java.lang.ClassNotFoundException: org.red5.server.WebScope; nested exception is org.springframework.beans.factory.CannotLoadBeanClassException: Cannot find class [org.red5.server.WebScope] for bean with name 'web.scope' defined in ServletContext resource [/WEB-INF/red5-web.xml]; nested exception is java.lang.ClassNotFoundException: org.red5.server.WebScope
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.autowireByType(AbstractAutowireCapableBeanFactory.java:1199)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1091)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:517)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:456)
at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:294)
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:225)
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:291)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:193)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:585)
at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:913)
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:464)
at org.red5.server.tomcat.TomcatLoader$1.run(TomcatLoader.java:593)
Caused by: org.springframework.beans.factory.CannotLoadBeanClassException: Cannot find class [org.red5.server.WebScope] for bean with name 'web.scope' defined in ServletContext resource [/WEB-INF/red5-web.xml]; nested exception is java.lang.ClassNotFoundException: org.red5.server.WebScope
at org.springframework.beans.factory.support.AbstractBeanFactory.resolveBeanClass(AbstractBeanFactory.java:1262)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.predictBeanType(AbstractAutowireCapableBeanFactory.java:576)
at org.springframework.beans.factory.support.AbstractBeanFactory.isFactoryBean(AbstractBeanFactory.java:1331)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.getBeanNamesForType(DefaultListableBeanFactory.java:317)
at org.springframework.beans.factory.BeanFactoryUtils.beanNamesForTypeIncludingAncestors(BeanFactoryUtils.java:185)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.findAutowireCandidates(DefaultListableBeanFactory.java:833)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.doResolveDependency(DefaultListableBeanFactory.java:790)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveDependency(DefaultListableBeanFactory.java:707)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.autowireByType(AbstractAutowireCapableBeanFactory.java:1184)
... 11 more
Caused by: java.lang.ClassNotFoundException: org.red5.server.WebScope
at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1680)
at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1526)
at org.springframework.util.ClassUtils.forName(ClassUtils.java:258)
at org.springframework.beans.factory.support.AbstractBeanDefinition.resolveBeanClass(AbstractBeanDefinition.java:417)
at org.springframework.beans.factory.support.AbstractBeanFactory.doResolveBeanClass(AbstractBeanFactory.java:1283)
at org.springframework.beans.factory.support.AbstractBeanFactory.resolveBeanClass(AbstractBeanFactory.java:1254)
... 19 more
Another Fact could be that u have 2 Red5.jars so u have to delete one. In my case it worked rly good.
Big Ty for this post
Change org.red5.server.WebScope to org.red5.server.scope.WebScope in your red5-web.xml file.
what version of Red5 is that?
Are there any exceptions when you startup your custom webapp? There might be already an error in the startup of the server that consequently leads to your issue.
Sebastian
The application scope that you are attempting to connect to "Player" does not exist on the server; the log notes this as "Scope Player not found on localhost". What this means in general is that your application didn't load. The reason that it didn't load looks like class package error for WebScope. Change the beans class attribute to org.red5.server.scope.WebScope and try again.