powered by Jive Software

Config developing enviroment with Intellij Idea


#1

Hello!

I have imported Openfire sources from Github using Intellij Idea.
When I try to build the sources I receive the following error:
Error:(16, 25) java: package sun.security.x509 does not exist
at row: import sun.security.x509.GeneralNameInterface;
within CertificateManagerTest.java file

I have tried to Invalidate caches/restart but it didn’t help(

How can I solve the problem?

Thanks


#2

You’ll need to compile against JDK8 - that sounds like you may be using 9 or later. Also note you can’t run Openfire from the IDE; it has to be done at the command line. See https://github.com/igniterealtime/Openfire#user-content-testing-your-changes

Greg


#3

The same error: I got latest Openfire zip (4.3.2), unzipped it, opened project in Intellij IDEA, hit Build (or Build module Xmppserver) and got

Error:(16, 25) java: package sun.security.x509 does not exist
at row: import sun.security.x509.GeneralNameInterface;
within CertificateManagerTest.java file

Java version installed is 8.

Please help.


#4

Are you using an /Oracle/ JDK? That class (on my platform) is found in C:\Program Files\jdk1.8.0_162\jre\lib\rt.jar

Greg


#5

Yes, I’m using Oracle JDK (on windows 10 machine). I found C:\Program Files\Java\jre1.8.0_201\lib\rt.jar
extracted its contents and found that class.
But how does it help, what should I do? Excuse me, I have close to zero Java experience.

On https://stackoverflow.com/questions/29060064/sun-security-x509-certandkeygen-and-sun-security-pkcs-pkcs10-missing-in-jdk8 and https://stackoverflow.com/questions/31353565/maven-cant-compile-using-rt-jar people suggest I need to add

<plugin>
  <groupId>org.apache.maven.plugins</groupId>
  <artifactId>maven-compiler-plugin</artifactId>
  <version>3.2</version>
  <configuration>
     <fork>true</fork>
     <compilerArgument>-XDignore.symbol.file</compilerArgument>
  </configuration>
</plugin>

to pom.xml. I tried to do that, it didn’t eliminate the error. Also, there are multiple pom.xml files, one global, one in xmppserver folder… which one should be modified?


#6

That will be the one in the root directory. Though I’m not sure why you’re seeing it and no-one else :confused:

Greg


#7

Got it.
Somehow on my machine there was JDK 11 installed besides JDK 1.8. How it got there I don’t remember… maybe team which initially prepared my laptop did it… I don’t know.
Then, in File->Project Structure -> Project Settings -> Project Project SDK was set to 11, not to 1.8. I don’t remember setting it… maybe IntelliJ IDEA chose maximum available when I first opened Openfire project?

And there was no need to add explicit dependency on rt.jar in and to add -XDignore.symbol.file in pom.xml


#8
  1. I downloaded latest Openfire 4.3.2. zip and unzipped it.
  2. I opened it in Inellij IDEA and made sure I can build project.

“Build” process did not produce JAR files. I googled and found I have to use “Build Artifacts”

  1. File -> Project Structure -> Project Settings --> Artifacts -&> Click plus sign -> Jar -> From modules with dependencies… Choose xmppserver module.
    Now, do I need to choose Main Class there? (I didn’t)
    Should I select to extract JAR file from libraries to the target JAR or to copy to the output directory and link? (I tried both options)
  2. Build -> Build Artifacts…
    I tried both options, one produced xmppserver.jar file of the size 2,658 KB, another produced xmppserver.jar file of the size 32,463 KB

Looking at existing xmppserver-4.3.0.jar file from our standard Openfire installation. It has size of 3,642 KB. Why is my file so smaller? Did I do something wrong?
Why the name of file I produced is xmppserver.jar not xmppserver-4.3.2.jar? Should I rename it if I want Openfire to work?


#9

I build Openfire by Maven task, point “Working directory” to the source root and “Command line” to “clean verify”.
After build you can find the distribution by path “/distribution/target/distribution-base”.
To debug Openfire you can start Openfire by command “/distribution/target/distribution-base/bin/openfire.sh -debug” and attach Intellij IDEA to the localhost:5005.


#10

Excuse my ignorance… Did you installed Maven and run from a command window “mvn verify -pl distribution -am” like https://github.com/igniterealtime/Openfire says? Or did you run Maven from inside IDEA environment?


#11

OK, I installed Maven and did run

mvn verify -pl distribution -am

from root folder of my OpenFire installation. It produced xmppserver-4.3.2.jar file of seemingly correct size of 3.662 KB in distribution\target\distribution-base\lib sub-folder.

Looks like it’s what I need. Then, what’s the role of IDEA in this case? It’s basically unnecessary and only confusing things…


#12

I thought that IDEs are to help write code mostly. Being able to run a project from IDE directly is a nice to have feature. It works for some things. Say i run Spark project from IDEA by running startup.java. I guess there should be a way or some plugin to better integrate with Maven. Most developers are so used to Linux/command line that they find it easier and more convenient to just run it via command than from the IDE itself.


#13

Yes, I understand. I’m not a Linux developer. Still, I would expect IDE at least not to make things more complicated. IntelliJ IDEA internally uses the same javac to compile code and build-in Maven to assemble JARs. It would be natural for it to use POM.xml and to perform the same mvn verify -pl distribution -am instead of inventing something.
Coming from C# / Visual Studio world I would also expect IDE easily and by default to allow running application in debug mode.


#14

I’m not a developer even, just bringing my 5c :slight_smile: Every time i have a question about running something in IDEA or say Eclipse i get suggestions from devs “just run this in cmd”…


#15

The IDE key word in IDE is Development. If you just want to compile the project, then Maven is the way to go. If you want to develop, then you’ll need an IDE.

Yes, the inability to run the project direct from the IDE is less than ideal, but as a result of the way the project is tied together is currently necessary. There’s probably a way around it, and of course PRs are always welcome!

Greg