Package not found, Gradle build - java

I have the following problem. In my ORMConfiguration file I am setting up some of the basic properties that I need to implement JPA. Inside this ORMConfig.java file, I also have a main class.
The class imports look like this
package io.good.asset.ams.dao.configuration;
import io.good.asset.ams.model.domain.Category;
import io.good.asset.ams.model.domain.Company;
import org.hibernate.HibernateException;
import org.hibernate.Session;
import org.hibernate.SessionFactory;
import org.hibernate.Transaction;
import org.hibernate.boot.registry.StandardServiceRegistryBuilder;
import org.hibernate.cfg.Configuration;
import org.hibernate.service.ServiceRegistry;
import java.util.Map;
The project is built using gradle and depencies are set in the following manner:
project(':AMSRepository'){
dependencies {
compile project(':AMSModel')
compile("org.springframework.boot:spring-boot-starter-jdbc:${springBootVersion}")
compile("org.hibernate:hibernate-core:5.2.10.Final")
compile("com.h2database:h2:${h2Ver}")
testCompile("org.liquibase:liquibase-core:${liquibaseSpringVer}")
}
}
Since this is a multi-modular project the first two imports in my class are pointing to the different module, and when I try to build that complete project from root, or individual AMSRepository module i get error that
error: package io.good.asset.ams.model.domain does not exist
import io.good.asset.ams.model.domain.Category;
^
error: package io.good.asset.ams.model.domain does not exist
import io.good.asset.ams.model.domain.Company;
My settings.gradle looks like this
rootProject.name = 'AMS'
include 'AMSRepository'
include 'AMSService'
include 'AMSWeb'
include 'AMSModel'
I have also used IntelliJ module settings panel and tried to add manually decencies to this module troublesome module, and the most weird this is that nothing is underlined as wrong and that when I run the main class in ORMConfig.java and instantiate objects from these modules, everything works fine.

Like a war file, a Spring Boot application is not intended to be used
as a dependency. If your application contains classes that you want to
share with other projects, the recommended approach is to move that
code into a separate module. The separate module can then be depended
upon by your application and other projects.
Spring Boot Doc

Related

How to import com.sun.mdm.index.query.QueryObject

In my java project I want to use the com.sun.mdm.index.query.QueryObject class. I tried
import com.sun.mdm.index.query.QueryObject;
But I got compile error
package com.sun.mdm.index.query does not exist
What dependencies do I need to include in gradle to be able to use this class.

'classpath resource does not exist' for .class file

I'm having an issue with a Spring Boot application I'm developing, building using Maven. I'm pretty new to Java coming from C++ & Go I hope this is down to a lack of knowledge than something fundamentally wrong.
I am developing a suite of applications, which all rely on a set of common classes. I have set up 'common' as its own Maven project, albeit without a 'main' class. I am using VS Code and I am able to successfully import, and run in debug, classes from the 'common' project in my application. I have included a Maven dependency in my pom.xml for the 'common' project and in VS Code debug, everything runs fine. I've then run 'mvn package' in both the application and 'common' directories, building a .jar for each under the /target directory (however building 'common' does complain about the lack of a 'main' class but still outputs a .jar - can I specify it as a library rather than an application?)
However when I run the application .jar with the command 'java -jar configservice-0.0.0.1.jar', I'm given the error:
org.springframework.beans.factory.BeanDefinitionStoreException: Failed
to parse configuration class
[logsystem.configservice.ConfigServiceApplication]; nested exception
is java.io.FileNotFoundException: class path resource
[logsystem/common/lsrestcontroller/LSRestController.class] cannot be
opened because it does not exist
Would someone be able to point me in the right direction on how I could resolve this issue?
Many thanks.
EDIT: Here is the content of ConfigServiceApplication as requested, although quite why this is flagging an issue i'm not sure as the .class isn't referenced in here...
package logsystem.configservice;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.boot.autoconfigure.SpringBootApplication;
#SpringBootApplication
#EnableAutoConfiguration
public class ConfigServiceApplication {
//ConfigServiceApplication constructor, called when starting the Spring Boot service
public ConfigServiceApplication( String[] args ) {
System.out.println( "Application Loaded" );
}
}
EDIT2:
package logsystem.configservice;
import logsystem.common.lsrestcontroller.LSRestController;
import logsystem.common.connection.HTTPConnection;
import logsystem.configservice.Config;
import java.util.Map;
import java.util.HashMap;
import javax.servlet.http.HttpServletRequest;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
#RestController
#EnableAutoConfiguration
public class ConfigServiceController extends LSRestController {
private Config config;
//Constructor - initialise storage and create cleanup process for it
ConfigServiceController( ) {
super( );
//some more logic specific to this instance
}

unable to view akka http package in IntelliJ

I am trying to use akka http v10.0.2. I added akka-http in my build.gradle file (just akka-http, not http-core or any other akka http related dependency). I tried using the imports below but the 'akka.http.javadsl.server' does not seem available (even though I can see the package when I download the jar file and extract it). The other packages are visible. I have tried clearing the IntelliJ cache. Barring clearing my ivy cache, are there any other steps I can take to troubleshoot this further?
import akka.NotUsed;
import akka.actor.ActorSystem;
import akka.http.javadsl.ConnectHttp;
import akka.http.javadsl.Http;
import akka.http.javadsl.ServerBinding;
import akka.http.javadsl.model.HttpRequest;
import akka.http.javadsl.model.HttpResponse;
import akka.http.javadsl.server.AllDirectives;
import akka.http.javadsl.server.Route;
import akka.stream.ActorMaterializer;
import akka.stream.javadsl.Flow;
import java.util.concurrent.CompletionStage;
the issue was resolved by adding all the other akka http dependencies in my gradle build file. I will try to post the build file here when possible.

Can't Import packaged class files from a jar in jython when it contains classes in the default package

I am working on a program that needs to import a jar that has classes both in the default package (root of the jar) and in packages.
So far I have this code and it works so i can import the ones in default but it fails when trying to import ones on packages.
import sys
import os
sys.path.append(os.getcwd() + "/versions/1.7.2.jar")
If I run import a (a is a class as this is a Obfuscated jar.)
it imports but if I run import net.minecraft.server.MinecraftServer it does not work it says No Module named net.
Which I know the class and all packages around it is there so any help?
The problem is that Jython does not correctly find the code.
The source code is based on files like a.class wich you can import but not net.minecraft.server.MinecraftServer.

Unable to import my own Java package into another package of the same project

I am facing a strange problem related to accessing packages. Recently I merged code of multiple projects into a single one. I reorganized class references, import statements and everything is fine and its working perfectly. But one problem occurred where I am not able to import any package into a specific package.
I try to explain with a simple example:
I had 3 projects
Draw
Record
Capture
and there packages as given below:
package com.company.draw;
package com.company.record;
package com.company.capture;
Now after merging into single project I am unable to import com.company.record or com.company.capture into com.company.draw, whereas the other packages com.company.record and com.company.capture can import any of the mentioned packages.
What could be the problem in a specific package which prevents it from accessing other packages?

Categories

Resources