I have built a Play assembly in Maven using
<plugin>
<groupId>com.google.code.play2-maven-plugin</groupId>
<artifactId>play2-maven-plugin</artifactId>
<version>1.0.0-beta1</version>
</plugin>
via the maven-shade-plugin with entry point play.core.server.NettyServer. When I try to run it using
java -Dhttp-port=7000 -jar p3-users-1.0.0-SNAPSHOT-allinone.jar
I get
Play server process ID is 2924
Oops, cannot start the server.
java.lang.RuntimeException: Akka plugin is not registered.
at scala.sys.package$.error(package.scala:27)
at play.api.libs.concurrent.Akka$$anonfun$system$2.apply(Akka.scala:25)
at play.api.libs.concurrent.Akka$$anonfun$system$2.apply(Akka.scala:25)
at scala.Option.getOrElse(Option.scala:120)
at play.api.libs.concurrent.Akka$.system(Akka.scala:24)
at securesocial.core.UserServicePlugin.onStart(UserService.scala:129)
at play.api.Play$$anonfun$start$1$$anonfun$apply$mcV$sp$1.apply(Play.scala:88)
at play.api.Play$$anonfun$start$1$$anonfun$apply$mcV$sp$1.apply(Play.scala:88)
at scala.collection.immutable.List.foreach(List.scala:318)
at play.api.Play$$anonfun$start$1.apply$mcV$sp(Play.scala:88)
at play.api.Play$$anonfun$start$1.apply(Play.scala:88)
at play.api.Play$$anonfun$start$1.apply(Play.scala:88)
at play.utils.Threads$.withContextClassLoader(Threads.scala:18)
at play.api.Play$.start(Play.scala:87)
at play.core.StaticApplication.<init>(ApplicationProvider.scala:52)
at play.core.server.NettyServer$.createServer(NettyServer.scala:243)
at play.core.server.NettyServer$$anonfun$main$3.apply(NettyServer.scala:279)
at play.core.server.NettyServer$$anonfun$main$3.apply(NettyServer.scala:274)
at scala.Option.map(Option.scala:145)
at play.core.server.NettyServer$.main(NettyServer.scala:274)
at play.core.server.NettyServer.main(NettyServer.scala)
I am not sure what 'registered' is supposed to mean. Is this a missing dependency somewhere, or some other configuration problem?
As an aside, I previously built the assembly in SBT using the sbt-assembly-plugin, and it all seemed to work fine, so I know it's possible to build an uber-jar for a Play application. However, the sbt-assembly-plugin seems to have some serious algorithmic problems, causing it to take 20 times longer to build assemblies than the maven-shade-plugin.
OK, I seem to have manually fixed the problem.
According to https://www.playframework.com/documentation/2.4.x/ScalaPlugins plugins are registered in conf/play.plugins. I could see that Akka was missing from that, but was not sure why. Somehow the sbt-assembly-plugin did the right thing, but the maven-shade-plugin did not.
I searched my target directory for more play.plugins files, and found a couple under streams/... and one included a definition for
1000:play.api.libs.concurrent.AkkaPlugin
so I added that, and other definitions to my conf/play.plugins file. I am not sure if this is something that the play2-maven-plugin should be handling or not. Likely SBT has a built in awareness of Play projects, and handled the Play plugin registrations properly.
Anyway, this is more of a workaround than a solution.
There is no AkkaPlugin in Play! 2.4.x. I don't use 2.4.x, so I don't know if it was moved somewhere or just removed from play/api/libs/concurrent/Akka.scala file.
Could you provide simple test project, or a least your dependencies and plugins configuration in pom.xml file?
Related
I am trying to run my spring boot application (via Run As -> Spring Boot Application) in a tomcat8 container on STS and I am receiving these errors:
Caused by: java.lang.IllegalStateException: Expected method not found: java.lang.NoSuchMethodException: org.springframework.boot.context.embedded.tomcat.TomcatEmbeddedContext.addApplicationListener(org.apache.catalina.deploy.ApplicationListener)
at org.springframework.util.ClassUtils.getMethod(ClassUtils.java:627)
at org.springframework.boot.autoconfigure.websocket.TomcatWebSocketContainerCustomizer.addListener(TomcatWebSocketContainerCustomizer.java:85)
at org.springframework.boot.autoconfigure.websocket.TomcatWebSocketContainerCustomizer.access$100(TomcatWebSocketContainerCustomizer.java:36)
at org.springframework.boot.autoconfigure.websocket.TomcatWebSocketContainerCustomizer$1.customize(TomcatWebSocketContainerCustomizer.java:50)
at org.springframework.boot.context.embedded.tomcat.TomcatEmbeddedServletContainerFactory.configureContext(TomcatEmbeddedServletContainerFactory.java:355)
at org.springframework.boot.context.embedded.tomcat.TomcatEmbeddedServletContainerFactory.prepareContext(TomcatEmbeddedServletContainerFactory.java:184)
at org.springframework.boot.context.embedded.tomcat.TomcatEmbeddedServletContainerFactory.getEmbeddedServletContainer(TomcatEmbeddedServletContainerFactory.java:154)
at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.createEmbeddedServletContainer(EmbeddedWebApplicationContext.java:157)
at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.onRefresh(EmbeddedWebApplicationContext.java:130)
... 7 more
I have searched around for this quite a bit and have found little to guide me in figuring out what the problem is. After going through the spring boot code in the debugger I see that the object named "instance" referenced in the TomcatWebSocketContainerCustomizer.addListener() uses reflection to retrieve a handle to it. This object is associated with the tomcat 7.0.53 jar ($HOME/.m2/repository/org/apache/tomcat/tomcat-catalina/7.0.53/tomcat-catalina-7.0.53.jar). I do not see this in any of my maven dependencies and have tried several techniques to force it to tomcat 8.0.20, nothing seems to work.
After banging my head for a while I started looking at the run configuration for the project in STS (via Run As -> Run Configurations). I found that the Source tab shows tomcat 7.0.53 above version 8.0.20 along with several dependencies that aren't referenced in maven. I am at a loss on where these values come from and not sure how to edit it. For some reason when I try to manually delete these legacy jar files STS doesn't allow me to delete any of them.
Does anyone have an idea of where these dependencies may be coming from and how I can remove them?
They do reference my $HOME/.m2/path/to/tomcat-catalina/<version> dir, so I could simply remove them from my .m2 and theoretically it may work but I'd rather not do this if I don't have to.
I am using spring boot 1.2.x and all of them have this problem.
thanks.
I've got two ideas that you might try.
1) It is possible, that this may be manifestation of this bug in STS 3.6.4: https://issuetracker.springsource.com/browse/STS-4085
The depencies you aren't expecting to see may be coming from the maven 'test' scope. (The bug explicitly mentions 'srt/test' but the same happens with jar dependencies). You can verify whether this bug is the cause by using the regular "Run As Java Application" on your main class.
If that works, then it is almost certainly this bug. If it also fails with a similar error then its something else... then try:
2) You must be getting the unwanted tomcat version from somewhere, probably indirectly as dependency of something else.
Try using the m2e 'dependency hierarchy' to find where it came from like so:
open pom.xml
Click the 'Dependency Hierarchy' tab.
Type 'tomcat' in the 'Filter' box.
I finally figured it out.
In my $WORKSPACE/.metadata/.plugins/org.eclipse.m2e.core/workspacestate.properties it lists all poms, jars and wars from my workspace build with the maven plugin. I noticed that a pom in the file points to the exact version tomcat that is being loaded in my spring boot project. Once I deleted these projects from my STS I can successfully launch the spring boot app :-)
When I re-import the maven projects back to STS the error occurs again, then disappears when I remove them.
These projects have no connection to the project that I am trying to launch. Therefore I think the bug is in m2e.
I'll file a bug and update this post when it is complete.
thanks #Kris for working through it with me.
Im building an application based on Spring Boot v1.2. While my application boots successfully and executes well (so far.. ), I'm unable to test using the spring boot framework because of an AbstractMethodError.
The last few lines of the trace are as below
Caused by: java.lang.AbstractMethodError: org.springframework.data.jpa.repository.support.LockModeRepositoryPostProcessor.postProcess(Lorg/springframework/aop/framework/ProxyFactory;Lorg/springframework/data/repository/core/RepositoryInformation;)V
at org.springframework.data.repository.core.support.RepositoryFactorySupport.getRepository(RepositoryFactorySupport.java:185)
at org.springframework.data.repository.core.support.RepositoryFactoryBeanSupport.initAndReturn(RepositoryFactoryBeanSupport.java:239)
at org.springframework.data.repository.core.support.RepositoryFactoryBeanSupport.afterPropertiesSet(RepositoryFactoryBeanSupport.java:225)
at org.springframework.data.jpa.repository.support.JpaRepositoryFactoryBean.afterPropertiesSet(JpaRepositoryFactoryBean.java:84)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1627)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1564)
... 55 more
To analyze the above error, I checked the jar files from classpath involving the above classes. So the info is available as below
jar:file:/C:/rearch/intellij-workspace/springbootproj/lib/spring-aop-4.1.2.RELEASE.jar!/org/springframework/aop/framework/ProxyFactory.class
jar:file:/C:/rearch/mavenrepo/org/springframework/data/spring-data-commons/1.9.1.RELEASE/spring-data-commons-1.9.1.RELEASE.jar!/org/springframework/data/repository/core/RepositoryInformation.class
jar:file:/C:/rearch/intellij-workspace/springbootproj/lib/spring-data-jpa-1.3.3.jar!/org/springframework/data/jpa/repository/support/LockModeRepositoryPostProcessor.class
jar:file:/C:/rearch/intellij-workspace/springbootproj/lib/spring-test-4.1.2.RELEASE.jar!/org/springframework/test/context/support/DependencyInjectionTestExecutionListener.class
I'm not exactly sure on why spring-data-commons is coming up from maven repostory folder, while the others are being served from the project library.
While I debug that, I meanwhile need your help in figuring out the version compatibility between the above libraries.
I wasnt able to exactly pin point on what exactly is causing the error. Please help!
Thanks
The issue was with the intellij configuration of libraries which conflicts with Spring boot application. I manually replaced the required libraries from Maven repository and that worked out for me.
Per request from Elron..
Open the project folder in explorer and verify if the third party library versions in your project matches the ones you actually expect it to be. If something doesnt match, just replace the file with the one you expect it to be. In my case, since I use Maven, I didnt see a need for explicitly saving those libraries in a new lib folder under the project. So, I just deleted all of the files inside the lib folder and things started working again.
For fix this error, change the spring-data-jpa version to 1.5.0.RELEASE
I have faced this issue .
Get rid of spring-data-commons and change spring-data-jpa version to 1.9.0.RELEASE.
For more details , please follow this link :-
Spring Data Rest PagingAndSortingRepository AbstractMethodError (RepositoryFactorySupport)
I have a project with more than an hundred external library dependencies, here we use tomcat with this endorsed jar libs configured on a directory in the server (now is under $CATALINA_HOME/lib/endorsed), so the webapp can access those resources on runtime start.
I wanted to try jetty instead, because tomcat takes too much memory and crashes frequently. Now I'm wondering if there is a parameter to pass on maven-jetty-plugin to specify this jar's folder so as the webapp class loader find them in its classpath.
I've tried extraClasspath in configuration tag, but it seems to load only classes and ignore all jars in the directory I set into (if I pass the full name path of the jar, it is loaded, but I don't want to set every library that I need there).
Thanks in advance for the help
update:I know it's not a standard maven operation, i'm searching for an emergency workaround since this project is very huge and I can't refactor as I want.
But also I expected this feature was not as tricky as it seemed to me at first glance.
You need to pass them as absolute paths, or, alternatively, have them as dependencies of the plugin itself.
What you want to have done goes against Maven's portability principles, so don't expect it to support it.
I am currently working on a portlet that is using the commons-collections jar file and am getting a NoSuchMethodError. To resolve this issue I need to change the classloader of my WAR file from PARENT_FIRST to PARENT_LAST (in the application.xml file).
However, when I do this my portlet will not launch and when I log into the console it displays the message "The portlet is temporarily disabled". If I change the classloader back to PARENT_FIRST then it will launch again but then I get the NoSuchMethodError.
Does anybody have any suggestions on how to fix this issue ?
I am not sure how, but today I started getting error messages in the logs when I was getting "The portlet is temporarily disabled". I was getting a java.lang.LinkageError which was down to the fact that I had the servlet-api-2.5.jar and a jaxb jar which was conflicting with webshpere j2ee.jar. Once I removed these dependencies and set the classloader to PARENT_LAST, it seems to work properly. It seems that a lot of people face similar issues. The link below is also useful http://forum.springsource.org/showthread.php?33663-dispatcher-servlet-quot-not-a-servlet-class-quot-in-websphere
#MTH,
please try adding commons-collections as a shared library. See here for an example on how others have used shared library support [1]. That will give you the steps, just do it for the jars that you need to override/replace from WAS's classloader
[1] http://portals.apache.org/jetspeed-2/deployguide/deploying-jetspeed-to-websphere.html#section_4_2
thanks,
dims
You haven't provided any logs... but still, one of the most important things to look out for when setting your application to run PARENT_LAST is that your application isn't bundled with any system-level classes that may conflict with the ones provided by WebSphere Portal. For example, classes that pertain to the Portlet specification or the JavaEE specification.
I have a very large project with a ton of dependancies, and am getting the following exception when trying to send mail:
javax.mail.NoSuchProviderException: smtp
I know the code works because it is part of a library that is used in other projects. Does anyone know what would cause this exception to happen? I have looked through all of the jar's and the only one containing 'javax.mail' is 'mail-1.4.4-SNAPSHOT.jar'.
Is there some file/class that registeres the 'smtp' protocol, and it could be happening somewhere else in my classpath?
It's been a while since this question has been asked but it's still worth answering :
What's happening is that your mail service is using the SMTP (usually, it is even considered as the default protocol to use)protocol to send mail. No matter what concrete class you're using as mail service (might depend on whether you're working with Java EE, Spring or something else), it ends up using classes from the javamail API. In this API, in order to establish a connection to your mail server, an instance of javax.mail.Session will be created and this object will dynamically load classes that provide support for the protocol to use.
When loading the required class, in case it is not found, the ClassNotFoundException is caught and re-threw as javax.mail.NoSuchProviderException, with a message indicating the missing protocol support.
The solution in that case is to add the smtp.jar to your classpath.
With a Maven-based project, simply add the following dependency
<dependency>
<groupId>com.sun.mail</groupId>
<artifactId>smtp</artifactId>
<version>1.4.5</version>
</dependency>
I had this issue. Putting smtp.jar in classpath solved the issue.
The way I have fixed this was to remove the mail jar from the classpath. Somewhere in the classpath there exists another instance of mail.jar, and I have yet been able to find it. If anyone else runs into this problem, additional information on trouble shooting can be found here:
http://forum.springsource.org/showthread.php?t=90737
and
http://forums.sun.com/thread.jspa?threadID=5442371
I got same problem while we upgrade jboss from 4.x to 6.x.
Here Problem is setting classpath to the more number of mail.jar files(default server will take the mail.jar from its common/lib foler if it available there).
To confirm which jar file it is using, following statement is usefull.
System.out.println(getClass().getResource("/javax/mail/Address.class"));
if it is using the another jar file which you are not expecting.. set classpath to that instead which you are using. other wise remove that jar file from the above printed location.
This can also happen when you have an incorrect version of the "mailapi.jar" file in your classpath as well.
I'd recently upgraded a project to use PayPal's soap API, and PayPal's distribution contained a mailapi.jar file, which was different than the one I'd currently had in my project, and caused my app to fail when sending mail.
So for me, I just had to revert to my old mailapi.jar and I was fine.
I had this isssue right now. The problem was two javax.mail.jar in the same classpath.