When I want to create class in default package Eclipse shows this error:
Must Declare a Named Package Because This Compilation Unit is Associated to the Named Module
Then I have to delete module.info.java from \src to solve the problem but I don't know why?
As I said I searched in internet and I've got that I should the module.info.java in \src directory must be removed.
but I don't understand the reason of mentioned problem.
Related
I'm trying to install Marlin on an Ender 3. But Arduino IDE is giving me this error:
C:\Users\Michael.Heredia\Downloads\Marlin-2.0.x\Marlin-2.0.x\Marlin\src\lcd\dogm\HAL_LCD_class_defines.h: In member function 'void U8GLIB_SSD1309_128X64_HAL::init(pin_t, pin_t, pin_t)': C:\Users\Michael.Heredia\Downloads\Marlin-2.0.x\Marlin-2.0.x\Marlin\src\lcd\dogm\HAL_LCD_class_defines.h:134:5: error: 'init' is not a member of 'U8GLIB'
U8GLIB::init(&u8g_dev_ssd1309_hw_spi, (uint8_t)cs, (uint8_t)a0, (uint8_t)reset);
I've decided to try auto build Marlin on VSCode but cannot get past this error:
avr-g++.exe: error: device-specs/specs-avr2: No such file or directory
I've looked across many forums and the most common issue seems to be adding or deleting something in the path. Judging by the fact that it is a No such file or directory error, I need to add something to the path, but all the solutions I've found seem to have different things, and none of them seem to explain where I find the directory to add to the path.
How can I solve this?
Close VSC and go to C:\Users\yourname and delete the .platformio folder.
Restart VS Code and you should get a fresh install of Platformio.
This should get you going.
I was trying to override
<preference for="Magento\Customer\Model\CustomerRegistry" type="Mycustom\Mymodule\Model\CustomerRegistry" />
under etc/di.xml. But after running the
php bin/magento setup:upgrade
command will get the 'catalog rule indexing failed' error message. And under the system.log file it will show the below error message -
Type Error occurred when creating object:
Magento\Customer\Model\ResourceModel\AddressRepository,
Note: I have deleted the generated folder and run all required commands. Also, my magento version is 2.3.
I had a similar issue with a preference over a class that is injected into a plugin constructor.
The problem seems to be caused by the Magento developer mode that doesn't have all of the DI data generated at the time the plugin is executed, causing the error when executing the constructor and the DI fails.
Switching to default mode seems to fix the problem.
bin/magento deploy:mode:set default
Anyways, I finally changed the implementation on the classes that use the overridden class in order to use a custom interface that is overridden by the preference, and use the module dependency to make my new module load after the modified one (using sequence dependency).
This is not the best solution, but it worked and I could do this because both modules are from my company, and are implemented in the app/code folder.
You should use plugins instead of preference if you can.
I have had the same issue and after hours of searching I saw some of the classes can not be overridden. You can see more details about this issue here:
https://github.com/magento/magento2/issues/2674
I used magento "around" plugin instead of <preference/>.
I have an issue when trying to import in scala. The object Database exists under com.me.project.database but when I try to import it:
import com.me.project.database.Database
I get the error:
object Database is not a member of package com.me.project.controllers.com.me.project.database
Any ideas what the problem is?
Edit:
It is worth mentioning that the import is in the file Application.scala under the package com.me.project.controllers, I can't figure out why it would append the import to the current package though, weird...
Edit 2:
So using:
import _root_.com.me.project.database.Database
Does work as mentioned below. But should it work without the _root_? The comments so far seem to indicate that it should.
Answer:
So it turns out that I just needed to clean the project for the import to work properly, using both:
import _root_.com.me.project.database.Database
import com.me.project.database.Database
are valid solutions. Eclipse had just gotten confused.
imports can be relative. Is that the only import you have? be careful with other imports like
import com.me
ultimately, this should fix it, then you can try to find more about it:
import _root_.com.me.project.database.Database
In my case I also needed to check that object which is not found as a member of package is compiled successfully.
I realize this question already has an accepted answer, but since I experienced the same problem but with a different cause I figured I'd add an answer.
I had a bunch of interdependent projects which suddenly needed a root import in order to compile. It turned out that I had duplicated the package declaration in a single file. This caused some kind of chain reaction and made it very hard to find the source of the problem.
In summary I had
package foo.bar
package foo.bar
on the top of the file instead of just
package foo.bar
Hope this saves someone some really tedious error hunting.
In my case I had to run sbt clean.
I had faced similar issue where IntelliJ showed error on importing one file from the same project.
What did not resolve the issue in my case:
adding _root_ in import statement
sbt clean
restarting machine
What actually resolved the issue:
main menu => select File => click on Invalidate Caches / Restart => pop-up dailog => click on invalidate the caches and restart.
I was using IDEA (2019.2.2 Ultimate Edition) on macOs mojave 10.14.6
Java -> Scala conversion without cleaning
Don't forget to clean if you convert some file in a project from Java to Scala. I had a continuous integration build running where I couldn't get things to work, even though the build was working locally, after I had converted a Java class into a Scala object. Solution: add 'clean' to the build procedure on the CI server. The name of the generated .class file in Scala is slightly different than for a Java class, I believe, so this is very likely what was causing the issue.
If you are using gradle as your build tool, then ensure that jar task is not disabled.
I had multiple modules in my project, where one module was dependent on a few other modules. However, I had disabled jar task in build.gradle:
jar {
enabled = false
}
That caused it to fail to resolve classes in the dependent modules and fail with the above error.
I will share my story, just in case it may help someone.
Scenario: intellij compilation succeeds, but gradle build fails on import com.foo.Bar, where Bar is a scala class.
TLDR reason: Bar was located under src/main/java/... as opposed to src/main/scala/...
Actual reason: Bar was not being compiled by compileScala gradle task (from gradle scala plugin) because it looks for scala sources only under src/<sourceSet>/scala.
From docs.gradle.org:
All the Scala source directories can contain Scala and Java code. The
Java source directories may only contain Java source code.
Hope this helps
I had a similar problem but none of the solutions here worked for me. What did work however was a simple restart of my machine.
Perhaps it was something with my Intellij but after a quick restart, everything seems to be working fine.
I had a similar situation, which was failing in both IntelliJ and maven on the command line. I went to apply the suggested temp fix (adding _root_) but intellij was glitching so bad that wasn't even possible.
Eventually I noticed that I had mis-created a package so that it repeated the whole path of the package. That meant that the directory my class was in had a subfolder called "com", and the start of my file looked like:
package com.mycompany.mydept.myproject.myfunctionality.sub1
import com.holdenkarau.spark.testing.DataFrameSuiteBase
where I had another package called
com.mycompany.mydept.myproject.myfunctionality.sub1.com.mycompany.mydept.myproject.myfunctionality.sub2
And the compiler was looking for "holdenkarau" under com.mycompany.mydept.myproject.myfunctionality.com and failing.
I had this issue while using Intellij and the built-in sbt shell (precisely, I was trying to run the command console, which invokes a compiler check of the code).
In my case, after trying the other suggested solutions on this thread, I found that I could restart the sbt shell and it would go away. There's a button on the left-hand side of a looped green arrow and a small grey square which does this in one click (obviously, this is subject to Jet Brains not changing the design of the IDE!!!).
I hope this helps some people get past this issue quickly.
In my case, In Intellij, Just renaming the package file to something else >> see if it updates the import statements >> run the code >> then renaming back to the original name worked.
On several different packages like SquishIt and DotNetOpenAuth i get an error saying:
Failed to generate binding redirects for 'MyProject'. Object reference not set to an instance of an object.
I've seen a lot of post about other people having problems with "binding redirects" but not found a single reference to this problem combined with "Object reference not set to an instance of an object.".
What exactly is NuGet trying to do at this stage? Does it try to update the binding redirects in Web.Config? Could i have some issue with my Web.Config? How can i go about debugging this?
I shall say that this does not happen in a "clean" project.
I had the same issue mucking around with MVC versions in one project. I think it could happen for any NuGet package that tries to add Binding Redirects to your config file.
I ended up renaming "Web.config" to "Web.Temp.Config", then installing the package.
I then I manually merged the changes that the package put into my config file into the temp one, then deleted it and renamed my original back to web.config.
This resolved the issue for me - hopefully it helps you.
In my case, update NuGet Package Manager solves the problem.
I'm just getting started with Groovy/Grails.
I added a new domain controller to my project, and generate-controller doesn't like it.
There are other indications something's wrong: If I run the app no table is actually created in the database for this.
I've reduced the DomainController to one String field and no constraints, just to make sure there wasn't something wrong with my specification. I also tried renaming it, just in case there was something about the original name (Privacy) that conflicted with something.
I'm sure I have the correct name, and that the file is called PrivacyOptions.groovy and inside the class is also called PrivacyOptions.
Here's the error:
Running script /opt/local/grails/scripts/GenerateController.groovy
Environment set to development
Domain class not found in grails-app/domain, trying hibernate mapped classes...
No domain class found for name PrivacyOptions. Please try again and enter a valid domain class name
Add the project name (aka the package name from the first line of the model file) before the model name.
grails generate-all projectname.Class
This is the one that finally worked for me, after an hour of head scratching and googling.
ref: http://grails.1312388.n4.nabble.com/Generate-Scaffold-Scripts-Don-t-Work-Getting-No-domain-class-found-Error-td2017858.html#a2017880
As of 1.2.2 Grails creates artifacts in packages that default to your
project name - see http://jira.codehaus.org/browse/GRAILS-5713
So you'd need to run grails generate-all srapp.Srmodel
- Burt
it's not projectname.Class , it must be dirname.classname .
eg: your projectname is Helloworld, the directory is "grails-app/domain/helloworld/User.groovy" . so , the command is "grails generate-all helloworld.User" ,but not "Helloworld.User"
Run:
grails clean
and then re-run the generate-all command.
ref: http://parasjain.net/2009/06/23/grails-no-domain-class-found-for-name-please-try-again-and-enter-a-valid-domain-class-name/
Great help. I faced the same problem following this tutorial that names the project as "trip-planner" and Grails generates the domain directories as '~/trip/planner/' instead of '~/trip-planner/'. Then the generate-all command for a Trip class should be 'grails generate-all trip.planner.Trip'
Just in case someone adds a '-' character to the project name.
Yep... worked for me too. I just prefixed the package name to the class I was trying to generate-all for and it worked. So ...
generate-all racetrack.User
Bit of a pants bug really since all other grails commands do not require a package name to be included :-))
I don't know how you got to this point, but maybe this will help you get over the hump.
Am I correct to assume that you used "grails create-domain-class" to create PrivacyOptions domain object, and the Groovy script showed up in your grails-app/domain directory? Did you get a PrivacyOptionsTests in test/unit? Did that pass? Did you add a package?
related issue about stack trace not being clear for missing properties:
http://jira.codehaus.org/browse/GRAILS-1607
generate-all Domainname will not work as the full package name is needed.
I tent to do add an * for the first time and then you will see what the domain class should look like for the other calls.
generate-all *
http://grails.org/doc/latest/ref/Command%20Line/generate-all.html
It must be dirname.classname.
If you have a domain class created Book, like this 'grails-app/domain/book/Book.groovy'
The it should be: grails generate-app book.Book
If you are working on Groovy/Grails Tool Suite, you can simply see the domain name by right clicking on the controller that you created, notice the exact case for domain name, then right click on views and generate views and type in domainname.viewname
Example, your controller name is RegistrationController and domain name is helloworld, you can right click on views and in generate views dialog, enter the value as helloworld.Registration