I cloned the project here https://github.com/OhadR/oAuth2-sample
Set appropriate version for parent in pom.xml of all 3 projects oauth2-client, oauth2-auth-server, resource-sercer to
<version>1.6.2-SNAPSHOT</version>
I added the 3 projects to modules section in auth-parent. I built war files using mvn install.
<modules>
<module>auth-common</module>
<module>common-crypto</module>
<module>authentication-flows</module>
<module>oauth2-auth-server</module>
<module>oauth2-client</module>
<module>oauth2-resource-server</module>
</modules>
I put the 3 generate war file in jetty/webapps. Client and Resource-server seem to load fine but oauth2-auth-server doesnt. At localhost:8080 I get UNAVAILABLE for oauth2-auth-server.
I tried debugging by adding maven-jetty plugin and mvn jetty:run for oauth2-auth-server. But I get
org.springframework.beans.factory.BeanDefinitionStoreException: Unexpected exception parsing XML document from ServletContext resource [/WEB-INF/spring-servlet.xml]; nested exception is org.springframework.context.annotation.ConflictingBeanDefinitionException: Annotation-specified bean name 'authenticationSuccessHandler' for bean class [com.ohadr.auth_flows.core.AuthenticationSuccessHandler] conflicts with existing, non-compatible bean definition of same name and class [com.ohadr.oauth_srv.web.OhadAuthenticationSuccessHandler]
Not sure I see the problem - did you try build it from the main directory, by using maven command "mvn clean install"?
Maven will then build all sub-modules, which are common-crypto and authentication-flows.
My oAuth-Sample project is in use as an oAuth example as well as "authentication-flows" logic.
Do you build this oAuth-sample for oAuth-sample, or for "authentication-flows"?
Hope that helps (and sorry about the delay)
Related
I have a web project with following structure:
app
pom.xml
–modules:
app-api (contains only OpenAPI documentation used to generate REST endpoints)
pom.xml
app-service (contains the actual business logic with services/controllers/etc)
pom.xml
I am trying to manually run SonarCloud.
I put the following settings in the parent pom.xml
<sonar.organization>company-account</sonar.organization>
<sonar.host.url>https://sonarcloud.io</sonar.host.url>
<sonar.projectKey>project-name</sonar.projectKey>
All of the above are taken according to what the Sonar web portal is recommending.
I added the SONAR_TOKEN variable as well.
At the moment I am getting:
"Project ‘…’ can’t have 2 modules with the following key: …
I tried a bunch of other combinations, like putting the maven properties in the service submodule.
It either does not recognize the project or gives me a stackoverflow error.
I tried passing the project key as a parameter:
mvn verify org.sonarsource.scanner.maven:sonar-maven-plugin:sonar -Dsonar.projectKey=the-project-key
It just gives another error:
Project not found. Please check the ‘sonar.projectKey’ and ‘sonar.organization’ properties, the ‘SONAR_TOKEN’ environment variable, or contact the project administrator
Do you have any idea what am I doing wrong?
I am including security definitions in pom.xml file. When I run a goal mvn compile, it throws an exception:
org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal com.github.kongchen:swagger-maven-plugin:3.1.2:generate (default) on project test: com.fasterxml.jackson.databind.JsonMappingException: No content to map due to end-of-input
I have included security definitions in Swagger Maven plugin as below
<securityDefinitions>
<securityDefinition>
<json>src/main/resources/securityDefinition.json</json>
</securityDefinition>
</securityDefinitions>
I have tried with ${basedir} but still get the above exception. How can this be resolved also as the spec says?
The file will be read by getClass().getResourceAsStream, so please note the path you configured. How can I fullfil this condition?
You need to wait to next plugin release (3.1.6). They just merged the changes to the master branch with the solution to the classpath file loading problem that you are facing. The classloader used when the plugin executes has no access to the project's files, be it resources or Java source files.
Next release will have a <jsonPath> tag to allow access to file location and <json> tag for classpath file loading (solving the problem).
Update (tested):
If you don't mind about it you can use the 3.1.6-SNAPSHOT version.
Then, in your POM:
<securityDefinitions>
<securityDefinition>
<jsonPath>${project.basedir}/securityDefinition.json</jsonPath>
</securityDefinition>
</securityDefinitions>
And in the JSON file follow the author's intructions:
https://github.com/kongchen/swagger-maven-plugin
I have a LinkageError in my EAR Project on Wildfly 10.1.
The project contains an ejb and a web subproject. Dependency Management by Maven. Gson Package is added in parent prom and in proms of both subprojects.
Can't figure out where the second gson class gets loaded. Any suggestions on how to solve this?
15:02:14,242 ERROR [io.undertow.request] (default task-2) UT005023:
Exception handling request to /Trigger-Server-web/event/quote:
java.lang.LinkageError: loader constraint violation: when resolving
interface method "de.company.triggerserver.ejb.EventProcessingLocal.processEvent(Ljava/lang/String;Lcom/google/gson/JsonObject;)Z" the class loader (instance of org/jboss/modules/ModuleClassLoader) of the current class, de/company/triggerserver/web/EventServlet, and the class loader (instance of org/jboss
/modules/ModuleClassLoader) for the method's defining class, de/company
/triggerserver/ejb/EventProcessingLocal, have different Class objects for the type com/google/gson/JsonObject used in the signature
This problem is caused by having a copy of the Gson jar in both the EAR/lib directory and the WEB-INF/lib directory of your WAR file.
Therefore the trick is to get rid of the one in the WAR file.
The simple solution is to mark it's dependency as <scope>provided</scope> in the web module's pom.xml file.
A more sophisticated approach is to make use of the maven-ear-plugin's ability to build EAR files with "skinny WARS" as described in Creating Skinny WARs. This essentially removes duplicate jar from your web module's WEB-INF/lib directory during the EAR assembly process.
You may find the second approach better because it's possible that you have multiple copies of other jars in your EAR file build, and you will be discovering these one at a time with the first approach.
Newbie question: I have different projects that im doing in STS, all opened. For example i have myproject_mvc and myproject_datamodel.
In myproject_mvc are the views and controllers.
In myproject_datamodel are the class of the Model like: Person, Car, etc.
the project_datamodel is used in other projects too. So i want to add a reference and use it like if that class where in myproject_mvc.
I added doing right click over myproject_mvc Build Path/Configure Build Path/Projects and i added the porject there, but when i run the application i recieve this error message:
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerMapping#0': Initialization of bean failed; nested exception is java.lang.NoClassDefFoundError: solvian_datamodel/Vehicle
Maybe i have to register that dependency in pom.xml or other file that i dont know.
You need to configure Web Deployment Assembly in STS.
Try following:
Go to myproject_mvc's properties -> Deployment Assembly.
Click Add button.
Add dependency projects.
Hope this helps.
I'm working on a java project with spring on eclipse using Maven, and running on a Tomcat server v6.0. Everything was working fine since yesterday morning.
Here his my problem : I'm building my project, I got a build success. Then I start my Tomcat server and got this error :
org.springframework.beans.factory.parsing.BeanDefinitionParsingException: Configuration problem: Failed to import bean definitions from URL location [classpath:applicationContext- core.xml]
Offending resource: ServletContext resource [/WEB-INF/applicationContext.xml]; nested exception is org.springframework.beans.factory.BeanDefinitionStoreException: IOException parsing XML document from class path resource [applicationContext-core.xml]; nested exception is java.io.FileNotFoundException: class path resource [applicationContext-core.xml] cannot be opened because it does not exist
I found out similar problem on some website but none of them give me a solution that worked for me.
It seems that eclipse isn't able to find applicationContext-core.xml when I'm doing this :
<import resource="classpath:applicationContext-core.xml" />
However, I do have the needed jar file nad-core-0.0.1-SNAPSHOT.jar in WEB-INF/lib containing applicationContext-core.xml.
I even tried to add it manually to the classpath but I was still having the same problem.
I keep on looking for a solution, when suddendly it work again once after restarting Eclipse and building while Eclipse was still updating indexes and my project was having this strange status Hg status pending instead of default. Surprised by this result I decide to build again my project after restarting Eclipse and I got the error again and I enable to make it work again. It's quite annoying...
This looks to be a really random problem.
Thanks a lot for your help :)
As you've not specified you web application structure. I assume you've a simple web application at hand with the following structures
webapp
WEB-INF/classes/applicationContext.xml
WEB-INF/lib/nad-core-0.0.1-SNAPSHOT.jar/applicationContext-core.xml
Application context.xml refers to the applicationContext-core.xml file using the import tag. I did encounter a similar situation in my web application, here're the check lists that you should go through and may be one of them can apply to your situation.
Check the generated snapshot jar file for the applicationContext-core.xml file and make sure it is in the root directory of the jar. As silly as it sounds, this was the root cause of the issue I faced in my deployment.
Make sure your Maven Pom.xml file is configured to include this XML file from the resources folder. You can use the resource tags in the build phase of Maven to package them within the jar file itself.
You can try removing the import tag from application context.xml file and instead load both of them from Spring's webapplication context itself.
Add a context loader listener class from spring org.springframework.web.context.ContextLoaderListener
Add context-param contextConfigLocation with value classpath:applicationContext-core.xml,classpath:applicationContext.xml. Spring has the ability to dynamically sort out the dependencies before initiating the bean factory.
Hope this check list helps.
I get pretty much the same config, six years later, I got the same error.
I also restart Eclipse, and it solved the issue.