Spring Boot Jetty not supported on GAE, but causes my tests to fail when removed? - spring-mvc

I am building out an API using Spring Boot, which is being deployed to Google App Engine with Travis CI.
I started my code from Google's Starter Project (https://github.com/GoogleCloudPlatform/getting-started-java/tree/master/appengine-standard-java8/springboot-appengine-standard), which doesn't use the spring-boot-starter-jetty dependency. As such, my project also did not not require it, and everything was deploying fine.
That was until I decided to add a test that uses Spring's TestRestTemplate.getForEntity() method to hit a basic endpoint I could assert on, just to give me some peace of mind that the endpoint could be reached end-to-end. However, I got the following error when running the test locally:
java.lang.IllegalStateException: Failed to load ApplicationContext
[stacktrace]
Caused by: org.springframework.context.ApplicationContextException: Unable to start web server; nested exception is org.springframework.context.ApplicationContextException: Unable to start ServletWebServerApplicationContext due to missing ServletWebServerFactory bean.
[stacktrace]
Caused by: org.springframework.context.ApplicationContextException: Unable to start ServletWebServerApplicationContext due to missing ServletWebServerFactory bean.
Looking around, it became apparent that I should add the spring-boot-starter-jetty, and the test started passing! Everything looked fine.
However, after committing and deploying to GAE, I now get a 500 Error when trying to hit the endpoint.
I did some digging in Stackdriver, and this is the error that's thrown:
java.lang.RuntimeException: javax.servlet.ServletException: Not running on Jetty, JSR-356 support unavailable
I presume that JSR-356 support is required by spring-boot-starter-jetty, which I presume GAE doesn't support, hence the error. I have reported this upstream here: https://issuetracker.google.com/issues/79235250
Is there a way I can add the dependency without JSR-356 support, or is there another way I can get some form of HTTP End-To-End test to pass?
You can view my source code here: https://github.com/bytelucas/nohold - the test in question is HTTPRequestTest.java.

Looks like Spring boot defaults the starter jetty to 9.1, can you try overriding the default to earlier versions of jetty by adding it (in POM) which uses JSR-353 to see if that fixes the issue instead.

Related

Error while issuing a state in Postgres Corda 4.6 OS

Following are the error I got when trying to initiate a state in Corda 4.6OS using Postgres:
"net.corda.core.CordaRuntimeException: com.esotericsoftware.kryo.KryoException: java.lang.UnsupportedOperationException: net.corda.nodeapi.internal.persistence.CordaPersistence, which is a closeable resource, has been detected during flow checkpointing. Restoring such resources across node restarts is not supported. Make sure code accessing it is confined to a private method or the reference is nulled out."
unfortunately with just this information it's hard to know what exactly happened.
Here's some examples of what could be happening.
look carefully through the stacktrace, if you're getting an unsupported runtime exception or other exceptions from code that's not in your control look around and make sure you're using packages / resources that line up with the cordapp template.
For example I had something like this for a couple hours because I was using the wrong junit package in my imports and the tests weren't initializing properly so you can get errors like this one and it won't be obvious at all why unfortunately.
Here's a link to the cordapp template, try to carefully check your flow / state to make sure all the imports are reasonable and you're using the right packages / gradle dependencies.
https://github.com/corda/cordapp-template-java
https://github.com/corda/cordapp-template-kotlin
good luck

getting an error on app init() FPWSE0001E: Not Found - Targeted resource 'PushDevice' does not exist

We are getting the following error on application launch.
MobileFirst Platform Foundation version 7.0
error response when calling : WL.Client.connect();
{"status":500,"errorCode":"UNEXPECTED_ERROR","errorMsg":"The server was unable to process the request from the application. Please try again later."}
error on server side
>com.worklight.core.auth.impl.AuthenticationFilter E FWLSE0048E: Unhandled exception caught: FPWSE0001E: Not Found - Targeted resource 'PushDevice' does not exist. Check the '17e57139-b8ff-3d29-b105-ddc44
2147adc' parameter
com.ibm.pushworks.server.exceptions.PushWorksEntityNotFoundException: FPWSE0001E: Not Found - Targeted resource 'PushDevice'
does not exist. Check the '17e57139-b8ff-3d29-b105-ddc442147adc' parameter
at com.ibm.pushworks.server.core.PushServiceImpl.updateDevice(PushServiceImpl.java:461)
at com.worklight.integration.notification.UserSubscriptionData.addSubscriptionDataToResponse(UserSubscriptionData.jav
a:87)
at com.worklight.core.auth.impl.LoginContext.addIdentityToJSONResponse(LoginContext.java:438)
at com.worklight.core.auth.impl.AuthenticationContext.addIdentitiesToResponse(AuthenticationContext.java:522)
at com.worklight.core.auth.impl.AuthenticationFilter.doFilter(AuthenticationFilter.java:225)
at com.ibm.ws.webcontainer.filter.FilterInstanceWrapper.doFilter(FilterInstanceWrapper.java:192)
at com.ibm.ws.webcontainer.filter.WebAppFilterChain.doFilter(WebAppFilterChain.java:86)
at com.ibm.ws.webcontainer.filter.WebAppFilterManager.doFilter(WebAppFilterManager.java:975)
at com.ibm.ws.webcontainer.filter.WebAppFilterManager.invokeFilters(WebAppFilterManager.java:1097)
at com.ibm.ws.webcontainer.servlet.CacheServletWrapper.handleRequest(CacheServletWrapper.java:81)
at com.ibm.ws.webcontainer.WebContainer.handleRequest(WebContainer.java:912)
at com.ibm.ws.webcontainer.osgi.DynamicVirtualHost$2.run(DynamicVirtualHost.java:262)
at com.ibm.ws.http.dispatcher.internal.channel.HttpDispatcherLink$TaskWrapper.run(HttpDispatcherLink.java:938)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1156)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:626)
at java.lang.Thread.run(Thread.java:780)
But there is no issue while I am testing in my development machine.
The error message that you have provided matches the following APAR:
http://www-01.ibm.com/support/docview.wss?uid=swg1PI41837
As noted on the APAR page, this issue occurs when there are multiple versions of the application installed. The fix for this issue is included in build level IF201507012211 and above. I believe that if you check "About" from your MobileFirst console, you will find that the version that you have is earlier. My suggestion would be to apply the latest ifix to your Studio and Server environments, rebuild/redeploy your project war file, and verify that the issue no longer occurs. Ifixes can be downloaded from the IBM Fix Central site.
Please review the following link for information about installing the ifix and updating the server runtime:
https://www.ibm.com/support/knowledgecenter/SSHS8R_7.0.0/com.ibm.worklight.upgrade.doc/devenv/c_upgrade_to_srvr_in_production_env.html?lang=en

What is the best way to debug production error templates?

I am trying to create pretty error pages for my application by following this cookbook article. Sometimes a bug slips in, which causes the application to return a single line: 503 Service Unavailable. It would make my life a whole lot easier if only I could see the underlying error or exception thrown. Switching over to the development environment doesn't help either as the error templates are only used in production.
I figured out that I needed to add TwigBundle to assetic's configuration to use javascript and css assets. Problems like this are really hard to debug in the production environment.
Setting the debug mode to true in my front controller doesn't help, since production error templates get replaced by development templates.
EDIT
Thanks to Mike Purcell I managed to retrieve the errors provided. I got
Uncaught exception 'Symfony\Component\Routing\Exception\ResourceNotFoundException' in /[snip]/app/cache/prod/appprodUrlMatcher.php:669
Turns out the framework should be handling the exception, but in the case of a possible error inside the error Twig template, it just decides to throw a 503 error.
How do I turn on error reporting for the production environment in a Symfony2 application?
I'm tired of guessing what's wrong and clearing the cache. What is the best way to debug Twig's error templates in production?
The best way to see what errors are being thrown in production is to configure Monolog to email the errors too you or alternatively to a file.
Have a look at the Symfony2 Cookbook on emailing logs http://symfony.com/doc/master/cookbook/logging/monolog_email.html
To make the error pages look nicer have a look at this cookbook entry on how to do that http://symfony.com/doc/master/cookbook/controller/error_pages.html
There are open source tools specifically built for error reporting like Sentry, which has a native Symfony client.
disclaimer: I work for Sentry

CDI on GlassFish 3.1.1 b12 generates error "WELD-001408 Unsatisfied dependencies"

I'm trying to evaluate CDI on Glassfish 3.1 and even though I have accomplished to make it work well, when I'm trying to split my code in separate deployment modules I get a weird error. More specifically:
I have two classes bundled in the same utility project (let's say the CommonLib.jar); the classnames are UserDatabase and UserDatabaseEntityManager and their definitions are as below (in the PS at the end of this message).
I also have an EAR with an EJB3.1 module in it.
When I choose to deploy the CommonLib.jar as a "Bundled Library" of the EAR, then I get the following error:
Error occurred during deployment: Exception while loading the app : WELD-001408 Unsatisfied dependencies for type [EntityManager] with qualifiers [#UserDatabase] at injection point [[field] #UserDatabase #Inject com.test.TestEJB.itemPersistenceEm]. Please see server.log for more details.
Same error as above I get also when I deploy the CommonLib.jar as a shared library (jar file copied under $glasshfish_installation_path/domains/domain1/lib)
BUT, if I choose to just have the two classes (UserDatabase and UserDatabaseEntityManager) in the EJB project (thus they are compiled within the EJB module), then the injection works fine.
Am I facing a classloader issue? Any ideas how I can get past this issue?
Just a guess, because I faced a very similar problem with Glassfish and CDI a few days ago: Do you have a beans.xml in every JAR, i.e. in the CommonLib.jar and the EJB JAR, so that CDI scans both of them?
My problem resulted from the fact that I thought placing a beans.xml into the EAR would be sufficient, which is not the case.
Sounds like you're running into some of the Glassfish CDI integration issues we've found while working on Seam 3. It could be a couple of them, so you'll have to take a look at see which one it may be. Try testing on JBoss AS7 or Apache TomEE and see if you still have problems.

How to solve "NullPointerException" with "Server.processing" error while we are using Flex Builder 3 and BlazeDS?

I am using Flex builder 3, BlazeDS, and Java with Spring and Hibernate framework. I using the remote object to load a string from spring's configuration files. But in testing, I found this fault event like this:
RPC Fault
faultString="java.lang.NullPointerException"
faultCode="Server.Processing"
faultDetail="null"
I have checked the configuration in remote-config.xml and services-config.xml. But it looks good. Some people have talked about this problem around the Internet and I think you can help me and them.
I am using these environment:
Flex Builder 3
BlazeDS 3.2.0
JBoss server
Full stacktrace:
[RPC Fault faultString="java.lang.NullPointerException" faultCode="Server.Processing" faultDetail="null"]
at mx.rpc::AbstractInvoker/http://www.adobe.com/2006/flex/mx/internal::faultHandler()[C:\autobuild\3.2.0\frameworks\projects\rpc\src\mx\rpc\AbstractInvoker.as:220]
at mx.rpc::Responder/fault()[C:\autobuild\3.2.0\frameworks\projects\rpc\src\mx\rpc\Responder.as:53]
at mx.rpc::AsyncRequest/fault()[C:\autobuild\3.2.0\frameworks\projects\rpc\src\mx\rpc\AsyncRequest.as:103]
at NetConnectionMessageResponder/statusHandler()[C:\autobuild\3.2.0\frameworks\projects\rpc\src\mx\messaging\channels\NetConnectionChannel.as:569]
at mx.messaging::MessageResponder/status()[C:\autobuild\3.2.0\frameworks\projects\rpc\src\mx\messaging\MessageResponder.as:222]
The java.lang.NullPointerException indicates an error being thrown on the server. To debug this, active debug logging on BlazeDS in the services-config.xml file. You should see detailed debug information in the server console.
When using the BlazeDS/Spring integration take care that you will need to use a custom exception translator in order to obtain meaningful exceptions. Please read this document http://static.springsource.org/spring-flex/docs/1.0.x/reference/html/ch02s08.html
In your case the error is not related to some configuration problems, it seems that is thrown inside your java method. Use a debugger in order to diagnose properly.

Resources