Ljava.lang.String class cannot be resolved in persistence.xml
Asked Answered
T

1

9

I am using JBoss Developer Studio. I have a project with a persistence.xml file. The file is perfect to me, but I keep getting this error on the tab that lists all the Problems of my project.

Class "[Ljava.lang.String;@22ec7158" cannot be resolved

I include the picture for a better context.

enter image description here

When I click on the error, so that it takes me to the place where the error is happening, it takes me to the end of the file.

Persistence.xml

<?xml version="1.0" encoding="UTF-8"?>
<persistence version="2.1" xmlns="http://xmlns.jcp.org/xml/ns/persistence" 
        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
        xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/persistence http://xmlns.jcp.org/xml/ns/persistence/persistence_2_1.xsd">
<persistence-unit name="Persistence">
    <provider>org.hibernate.ejb.HibernatePersistence</provider>
    <jta-data-source>java:jboss/datasources/MemberOfferDS</jta-data-source>
    <class>com.bbb.memberoffer.model.SycsCoordinator</class>
    <class>com.bbb.aicweb.memberoffer.model.SycsCoordinatorPhoneNumber</class>
    <class>com.bbb.memberoffer.model.SycsCoordinatorClub</class>
    <class>com.bbb.memberoffer.model.SycsCoordinatorSecurityGroup</class>
    <class>com.bbb.memberoffer.model.SycsCoordinatorClubPk</class>
    <class>com.bbb.memberoffer.model.PhoneNumberType</class>
    <class>com.bbb.memberoffer.model.Club</class>
    <exclude-unlisted-classes>true</exclude-unlisted-classes>
    <properties>
        <!-- Not sure if this is the right one to use or not? -->
        <property name='hibernate.show_sql' value='true' />
        <property name='hibernate.format_sql' value='true' />
        <property name="hibernate.dialect" value="org.hibernate.dialect.SQLServerDialect"/>
    </properties>
</persistence-unit>
</persistence>
Tabathatabb answered 17/3, 2015 at 12:2 Comment(9)
Can you share the persistence.xml?Ephesians
We don't have any magic skills to look into your configuration remotely. Please post relevant code/config.Possessive
I have included the file.Tabathatabb
Does it help if you replace ' with " in properties?Charades
No, it did not help. Also, if I change something in the file (even a carriage return) and then save the file. The hexadecimal value after @ changes.Tabathatabb
Do you have </persistence> at the end of the file?Charades
I do, I need to post it.Tabathatabb
You may have solved this already, however, in my case the problem was caused by referencing a class in a <class> element that no longer existed.Lenoralenore
@DanSmith: Thanks!!! Please post your comment as an answer, I will upvote it. It helped me a lot and I could not be able to connect these two things together - String is a well-known type :)Sciatica
L
12

You may have solved this already, however, in my case the problem was caused by referencing a class in a element that no longer existed.

EDIT: The exact reason for this type of error message is that the error generator is trying to run a toString() on a String array when it generates the error message.

Lenoralenore answered 29/5, 2015 at 20:20 Comment(5)
Thanks. Dan. I had the same problem and your answer was the solution. However, have you figured out what such a strange error message has in common with the root cause?Sciatica
@HonzaZidek I think it's a peculiarity in the way it checks the types. I think that the String classes that "can't be resolved" are actually the .toString() of the instances of the strings in the XML file. The hex code and output looks like something that would typically be output when calling System.out.println on a custom type without a .toString() method. But that's all a guess. In order to more closely understand what it's doing there I'd have to look at the source.Lenoralenore
The reason for this is that it is trying to run a toString() on a String array when it generates the error message.Lenoralenore
Dan, add your new comment to your answer. It is educative :)Sciatica
Any way of finding the offending line in the xml?Lucila

© 2022 - 2024 — McMap. All rights reserved.